Index: compiler-rt/cmake/Modules/AddCompilerRT.cmake =================================================================== --- compiler-rt/cmake/Modules/AddCompilerRT.cmake +++ compiler-rt/cmake/Modules/AddCompilerRT.cmake @@ -474,11 +474,6 @@ endif() cmake_parse_arguments(LIBCXX "USE_TOOLCHAIN" "" "DEPS;CFLAGS;CMAKE_ARGS" ${ARGN}) - foreach(flag ${LIBCXX_CFLAGS}) - set(flagstr "${flagstr} ${flag}") - endforeach() - set(LIBCXX_C_FLAGS ${flagstr}) - set(LIBCXX_CXX_FLAGS ${flagstr}) if(LIBCXX_USE_TOOLCHAIN) set(compiler_args -DCMAKE_C_COMPILER=${COMPILER_RT_TEST_COMPILER} @@ -492,6 +487,43 @@ -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}) endif() + set(PASSTHROUGH_VARIABLES + CMAKE_C_COMPILER_TARGET + CMAKE_CXX_COMPILER_TARGET + CMAKE_SHARED_LINKER_FLAGS + CMAKE_MODULE_LINKER_FLAGS + CMAKE_EXE_LINKER_FLAGS + CMAKE_INSTALL_PREFIX + CMAKE_MAKE_PROGRAM + CMAKE_LINKER + CMAKE_AR + CMAKE_RANLIB + CMAKE_NM + CMAKE_OBJCOPY + CMAKE_OBJDUMP + CMAKE_STRIP + CMAKE_SYSROOT + CMAKE_SYSTEM_NAME) + foreach(variable ${PASSTHROUGH_VARIABLES}) + if(${variable}) + list(APPEND CMAKE_PASSTHROUGH_VARIABLES -D${variable}=${${variable}}) + endif() + endforeach() + + set(PASSTHROUGH_PREFIXES CLANG_DEFAULT_) + get_cmake_property(variable_names VARIABLES) + foreach(passthrough ${PASSTHROUGH_PREFIXES}) + foreach(variable ${variable_names}) + if(variable MATCHES "^${passthrough}") + string(REPLACE ";" "|" value "${${variable}}") + list(APPEND CMAKE_PASSTHROUGH_VARIABLES -D${variable}=${value}) + endif() + endforeach() + endforeach() + + set(LIBCXX_C_FLAGS "${CMAKE_C_FLAGS} ${LIBCXX_CFLAGS}") + set(LIBCXX_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LIBCXX_CFLAGS}") + set(STAMP_DIR ${prefix}-stamps/) set(BINARY_DIR ${prefix}-bins/) @@ -514,23 +546,17 @@ add_custom_target(${name}-clobber DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${name}-clobber-stamp) - if(CMAKE_SYSROOT) - set(sysroot_arg -DCMAKE_SYSROOT=${CMAKE_SYSROOT}) - endif() - ExternalProject_Add(${name} DEPENDS ${name}-clobber ${LIBCXX_DEPS} PREFIX ${prefix} SOURCE_DIR ${COMPILER_RT_LIBCXX_PATH} STAMP_DIR ${STAMP_DIR} BINARY_DIR ${BINARY_DIR} - CMAKE_ARGS -DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM} + CMAKE_ARGS ${CMAKE_PASSTHROUGH_VARIABLES} ${compiler_args} - ${sysroot_arg} - -DCMAKE_C_FLAGS=${LIBCXX_C_FLAGS} - -DCMAKE_CXX_FLAGS=${LIBCXX_CXX_FLAGS} + -DCMAKE_C_FLAGS=${LIBCXX_C_CFLAGS} + -DCMAKE_CXX_FLAGS=${LIBCXX_CXX_CFLAGS} -DCMAKE_BUILD_TYPE=Release - -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} -DLLVM_PATH=${LLVM_MAIN_SRC_DIR} -DLLVM_BINARY_DIR=${prefix} -DLLVM_LIBRARY_OUTPUT_INTDIR=${prefix}/lib @@ -543,6 +569,7 @@ USES_TERMINAL_BUILD 1 USES_TERMINAL_INSTALL 1 EXCLUDE_FROM_ALL TRUE + LIST_SEPARATOR | ) if (CMAKE_GENERATOR MATCHES "Make")