Index: cmake/Modules/AddCompilerRT.cmake =================================================================== --- cmake/Modules/AddCompilerRT.cmake +++ cmake/Modules/AddCompilerRT.cmake @@ -469,32 +469,35 @@ message(FATAL_ERROR "libcxx not found!") endif() - cmake_parse_arguments(LIBCXX "" "" "DEPS;CFLAGS;CMAKE_ARGS" ${ARGN}) + cmake_parse_arguments(LIBCXX "USE_TOOLCHAIN;NO_INSTALL" "" "DEPS;CFLAGS;CMAKE_ARGS" ${ARGN}) foreach(flag ${LIBCXX_CFLAGS}) set(flagstr "${flagstr} ${flag}") endforeach() set(LIBCXX_CFLAGS ${flagstr}) - if(NOT COMPILER_RT_STANDALONE_BUILD) - list(APPEND LIBCXX_DEPS clang) + if(LIBCXX_USE_TOOLCHAIN) + set(compiler_args -DCMAKE_C_COMPILER=${COMPILER_RT_TEST_COMPILER} + -DCMAKE_CXX_COMPILER=${COMPILER_RT_TEST_CXX_COMPILER}) + if(NOT COMPILER_RT_STANDALONE_BUILD) + set(force_deps DEPENDS clang) + endif() endif() ExternalProject_Add(${name} + DEPENDS ${LIBCXX_DEPS} PREFIX ${prefix} SOURCE_DIR ${COMPILER_RT_LIBCXX_PATH} CMAKE_ARGS -DCMAKE_MAKE_PROGRAM:STRING=${CMAKE_MAKE_PROGRAM} - -DCMAKE_C_COMPILER=${COMPILER_RT_TEST_COMPILER} - -DCMAKE_CXX_COMPILER=${COMPILER_RT_TEST_CXX_COMPILER} + ${compiler_args} -DCMAKE_C_FLAGS=${LIBCXX_CFLAGS} -DCMAKE_CXX_FLAGS=${LIBCXX_CFLAGS} -DCMAKE_BUILD_TYPE=Release - -DCMAKE_INSTALL_PREFIX:PATH= -DLLVM_PATH=${LLVM_MAIN_SRC_DIR} -DLIBCXX_STANDALONE_BUILD=On ${LIBCXX_CMAKE_ARGS} + INSTALL_COMMAND "" LOG_BUILD 1 LOG_CONFIGURE 1 - LOG_INSTALL 1 ) set_target_properties(${name} PROPERTIES EXCLUDE_FROM_ALL TRUE) @@ -508,8 +511,19 @@ COMMAND ${CMAKE_COMMAND} -E make_directory COMMENT "Clobberring ${name} build directory..." DEPENDERS configure - DEPENDS ${LIBCXX_DEPS} + ${force_deps} ) + + if(NOT LIBCXX_NO_INSTALL) + install(CODE "execute_process\(COMMAND \${CMAKE_COMMAND} -DCMAKE_INSTALL_PREFIX=\${CMAKE_INSTALL_PREFIX} -P ${BINARY_DIR}/cmake_install.cmake \)" + COMPONENT ${name}) + add_custom_target(install-${name} + DEPENDS ${name} + COMMAND "${CMAKE_COMMAND}" + -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} + -P "${CMAKE_BINARY_DIR}/cmake_install.cmake" + USES_TERMINAL) + endif() endmacro() function(rt_externalize_debuginfo name) Index: lib/fuzzer/CMakeLists.txt =================================================================== --- lib/fuzzer/CMakeLists.txt +++ lib/fuzzer/CMakeLists.txt @@ -97,11 +97,12 @@ set(LIBCXX_${arch}_PREFIX ${CMAKE_CURRENT_BINARY_DIR}/libcxx_fuzzer_${arch}) add_custom_libcxx(libcxx_fuzzer_${arch} ${LIBCXX_${arch}_PREFIX} CFLAGS ${TARGET_CFLAGS} - -D_LIBCPP_ABI_VERSION=__Fuzzer + -D_LIBCPP_ABI_VERSION=Fuzzer -D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS=1 -fvisibility=hidden CMAKE_ARGS -DLIBCXX_ENABLE_EXCEPTIONS=OFF - -DLIBCXX_CXX_ABI=none) + -DLIBCXX_CXX_ABI=none + NO_INSTALL) target_compile_options(RTfuzzer.${arch} PRIVATE -isystem ${LIBCXX_${arch}_PREFIX}/include/c++/v1) add_dependencies(RTfuzzer.${arch} libcxx_fuzzer_${arch}) target_compile_options(RTfuzzer_main.${arch} PRIVATE -isystem ${LIBCXX_${arch}_PREFIX}/include/c++/v1) Index: lib/msan/tests/CMakeLists.txt =================================================================== --- lib/msan/tests/CMakeLists.txt +++ lib/msan/tests/CMakeLists.txt @@ -128,7 +128,8 @@ set(LIBCXX_PREFIX ${CMAKE_CURRENT_BINARY_DIR}/../libcxx_msan_${arch}) add_custom_libcxx(libcxx_msan_${arch} ${LIBCXX_PREFIX} DEPS ${MSAN_RUNTIME_LIBRARIES} - CFLAGS ${MSAN_LIBCXX_CFLAGS} ${TARGET_CFLAGS}) + CFLAGS ${MSAN_LIBCXX_CFLAGS} ${TARGET_CFLAGS} + USE_TOOLCHAIN) set(MSAN_LIBCXX_SO ${LIBCXX_PREFIX}/lib/libc++.so) add_msan_tests_for_arch(${arch} "" "") Index: lib/tsan/CMakeLists.txt =================================================================== --- lib/tsan/CMakeLists.txt +++ lib/tsan/CMakeLists.txt @@ -212,7 +212,8 @@ set(LIBCXX_PREFIX ${CMAKE_CURRENT_BINARY_DIR}/libcxx_tsan_${arch}) add_custom_libcxx(libcxx_tsan_${arch} ${LIBCXX_PREFIX} DEPS ${TSAN_RUNTIME_LIBRARIES} - CFLAGS ${TARGET_CFLAGS} -fsanitize=thread) + CFLAGS ${TARGET_CFLAGS} -fsanitize=thread + USE_TOOLCHAIN) list(APPEND libcxx_tsan_deps libcxx_tsan_${arch}) endforeach()