From 089d130568e138a1f9392bef297de002aa5fb5ab Mon Sep 17 00:00:00 2001 From: Alexey Samsonov Date: Fri, 21 Mar 2014 13:09:25 +0000 Subject: [CMake] Propagate top-level targets for compiler-rt runtimes and test-suites from (external) compiler-rt build tree into LLVM/Clang build tree in LLVM_BUILD_EXTERNAL_COMPILER_RT mode. For instance, running make asan -j12 in LLVM/Clang build tree will now build Clang, use it to configure compiler-rt build tree, and invoke "make asan -j12" there. ASan runtime will be built in the proper location, where Clang driver expects to find it. Running make check-asan will build Clang, use it to configure compiler-rt build tree, build everything there, and then run "make check-asan" in compiler-rt build tree using just-built Clang and ASan runtime. llvm-svn: 204463 --- clang/runtime/CMakeLists.txt | 60 +++++++++++++++++++++++++++++++++----------- 1 file changed, 46 insertions(+), 14 deletions(-) (limited to 'clang/runtime/CMakeLists.txt') diff --git a/clang/runtime/CMakeLists.txt b/clang/runtime/CMakeLists.txt index 42aa378b934..dc14541323a 100644 --- a/clang/runtime/CMakeLists.txt +++ b/clang/runtime/CMakeLists.txt @@ -12,6 +12,16 @@ foreach (dir ${known_subdirs}) endif() endforeach() +function(get_ext_project_build_command out_var target) + if (CMAKE_GENERATOR MATCHES "Make") + # Use special command for Makefiles to support parallelism. + set(${out_var} "$(MAKE)" "${target}" PARENT_SCOPE) + else() + set(${out_var} ${CMAKE_COMMAND} --build . --target ${target} + --config $ PARENT_SCOPE) + endif() +endfunction() + set(COMPILER_RT_SRC_ROOT ${LLVM_MAIN_SRC_DIR}/projects/compiler-rt) if(LLVM_BUILD_EXTERNAL_COMPILER_RT AND EXISTS ${COMPILER_RT_SRC_ROOT}/) if(CMAKE_GENERATOR MATCHES "Ninja") @@ -37,6 +47,7 @@ if(LLVM_BUILD_EXTERNAL_COMPILER_RT AND EXISTS ${COMPILER_RT_SRC_ROOT}/) -DCOMPILER_RT_INCLUDE_TESTS=${LLVM_INCLUDE_TESTS} -DCOMPILER_RT_ENABLE_WERROR=ON INSTALL_COMMAND "" + STEP_TARGETS configure build ) # Due to a bug, DEPENDS in ExternalProject_Add doesn't work # in CMake 2.8.9 and 2.8.10. @@ -57,20 +68,41 @@ if(LLVM_BUILD_EXTERNAL_COMPILER_RT AND EXISTS ${COMPILER_RT_SRC_ROOT}/) DEPENDS ${LLVM_RUNTIME_OUTPUT_INTDIR}/clang ) - if (CMAKE_GENERATOR MATCHES "Make") - # Use special command for Makefiles to support parallelism. - set(check_command "$(MAKE)" "check-all") - else() - set(check_command ${CMAKE_COMMAND} --build . --target check-all - --config $) - endif() ExternalProject_Get_Property(compiler-rt BINARY_DIR) - add_custom_target(check-compiler-rt - COMMAND ${check_command} - DEPENDS compiler-rt - WORKING_DIRECTORY ${BINARY_DIR} - VERBATIM) + set(COMPILER_RT_BINARY_DIR ${BINARY_DIR}) + + # Add top-level targets that build specific compiler-rt runtimes. + set(COMPILER_RT_RUNTIMES asan builtins dfsan lsan msan profile tsan ubsan) + foreach(runtime ${COMPILER_RT_RUNTIMES}) + get_ext_project_build_command(build_runtime_cmd ${runtime}) + add_custom_target(${runtime} + COMMAND ${build_runtime_cmd} + DEPENDS compiler-rt-configure + WORKING_DIRECTORY ${COMPILER_RT_BINARY_DIR} + VERBATIM) + endforeach() + # Add binaries that compiler-rt tests depend on. - add_dependencies(check-compiler-rt FileCheck count - not llvm-nm llvm-symbolizer) + set(COMPILER_RT_TEST_DEPENDENCIES + FileCheck count not llvm-nm llvm-symbolizer) + + # Add top-level targets for various compiler-rt test suites. + set(COMPILER_RT_TEST_SUITES check-asan check-dfsan check-lsan check-msan + check-sanitizer check-tsan check-ubsan) + foreach(test_suite ${COMPILER_RT_TEST_SUITES}) + get_ext_project_build_command(run_test_suite ${test_suite}) + add_custom_target(${test_suite} + COMMAND ${run_test_suite} + DEPENDS compiler-rt-build ${COMPILER_RT_TEST_DEPENDENCIES} + WORKING_DIRECTORY ${COMPILER_RT_BINARY_DIR} + VERBATIM) + endforeach() + + # Add special target to run all compiler-rt test suites. + get_ext_project_build_command(run_check_compiler_rt check-all) + add_custom_target(check-compiler-rt + COMMAND ${run_check_compiler_rt} + DEPENDS compiler-rt-build ${COMPILER_RT_TEST_DEPENDENCIES} + WORKING_DIRECTORY ${COMPILER_RT_BINARY_DIR} + VERBATIM) endif() -- cgit v1.2.1