1 # Needed for lit support in standalone builds.
4 option(COMPILER_RT_TEST_STANDALONE_BUILD_LIBS
5 "When set to ON and testing in a standalone build, test the runtime \
6 libraries built by this standalone build rather than the runtime libraries \
7 shipped with the compiler (used for testing). When set to OFF and testing \
8 in a standalone build, test the runtime libraries shipped with the compiler \
9 (used for testing). This option has no effect if the compiler and this \
10 build are configured to use the same runtime library path."
12 pythonize_bool(COMPILER_RT_TEST_STANDALONE_BUILD_LIBS)
14 pythonize_bool(LLVM_ENABLE_EXPENSIVE_CHECKS)
15 configure_compiler_rt_lit_site_cfg(
16 ${CMAKE_CURRENT_SOURCE_DIR}/lit.common.configured.in
17 ${CMAKE_CURRENT_BINARY_DIR}/lit.common.configured)
19 # BlocksRuntime (and most of builtins) testsuites are not yet ported to lit.
20 # add_subdirectory(BlocksRuntime)
22 set(SANITIZER_COMMON_LIT_TEST_DEPS)
24 if(COMPILER_RT_BUILD_PROFILE AND COMPILER_RT_HAS_PROFILE)
25 list(APPEND SANITIZER_COMMON_LIT_TEST_DEPS profile)
28 # When ANDROID, we build tests with the host compiler (i.e. CMAKE_C_COMPILER),
29 # and run tests with tools from the host toolchain.
31 if(NOT COMPILER_RT_STANDALONE_BUILD AND NOT LLVM_RUNTIMES_BUILD)
32 # Use LLVM utils and Clang from the same build tree.
33 list(APPEND SANITIZER_COMMON_LIT_TEST_DEPS
34 clang clang-resource-headers FileCheck count not llvm-config llvm-nm llvm-objdump
35 llvm-readelf llvm-readobj llvm-size llvm-symbolizer compiler-rt-headers sancov)
37 list(APPEND SANITIZER_COMMON_LIT_TEST_DEPS KillTheDoctor)
40 # Tests use C++ standard library headers.
41 if (TARGET cxx-headers OR HAVE_LIBCXX)
42 list(APPEND SANITIZER_COMMON_LIT_TEST_DEPS cxx-headers)
46 if(COMPILER_RT_STANDALONE_BUILD)
47 umbrella_lit_testsuite_begin(check-compiler-rt)
50 function(compiler_rt_test_runtime runtime)
51 string(TOUPPER ${runtime} runtime_uppercase)
52 if(COMPILER_RT_HAS_${runtime_uppercase})
53 add_subdirectory(${runtime})
54 foreach(directory ${ARGN})
55 add_subdirectory(${directory})
60 # Run sanitizer tests only if we're sure that clang would produce
62 if(COMPILER_RT_CAN_EXECUTE_TESTS)
63 if(COMPILER_RT_BUILD_BUILTINS)
64 add_subdirectory(builtins)
66 if(COMPILER_RT_BUILD_SANITIZERS)
67 compiler_rt_test_runtime(interception)
69 compiler_rt_test_runtime(lsan)
70 # CFI tests require diagnostic mode, which is implemented in UBSan.
71 compiler_rt_test_runtime(ubsan cfi)
72 compiler_rt_test_runtime(sanitizer_common)
74 # OpenBSD not supporting asan, cannot run the tests
75 if(COMPILER_RT_BUILD_LIBFUZZER AND NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "OpenBSD" AND NOT ANDROID)
76 compiler_rt_test_runtime(fuzzer)
79 foreach(sanitizer ${COMPILER_RT_SANITIZERS_TO_BUILD})
80 # cfi testing is gated on ubsan
81 if(NOT ${sanitizer} STREQUAL cfi)
82 compiler_rt_test_runtime(${sanitizer})
86 if(COMPILER_RT_BUILD_PROFILE AND COMPILER_RT_HAS_PROFILE)
87 compiler_rt_test_runtime(profile)
89 if(COMPILER_RT_BUILD_MEMPROF)
90 compiler_rt_test_runtime(memprof)
92 if(COMPILER_RT_BUILD_XRAY)
93 compiler_rt_test_runtime(xray)
95 if(COMPILER_RT_BUILD_ORC)
96 compiler_rt_Test_runtime(orc)
98 if(COMPILER_RT_BUILD_CRT)
101 # ShadowCallStack does not yet provide a runtime with compiler-rt, the tests
102 # include their own minimal runtime
103 add_subdirectory(shadowcallstack)
106 if(COMPILER_RT_STANDALONE_BUILD)
107 # Now that we've traversed all the directories and know all the lit testsuites,
108 # introduce a rule to run to run all of them.
109 add_custom_target(compiler-rt-test-depends DEPENDS ${LLVM_COMPILER_RT_LIT_DEPENDS})
110 umbrella_lit_testsuite_end(check-compiler-rt)
112 if(NOT TARGET check-all)
113 add_custom_target(check-all)
115 add_dependencies(check-all check-compiler-rt)