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)
16 pythonize_bool(ZLIB_FOUND)
17 pythonize_bool(COMPILER_RT_BUILD_STANDALONE_LIBATOMIC)
19 pythonize_bool(COMPILER_RT_ENABLE_INTERNAL_SYMBOLIZER)
21 configure_compiler_rt_lit_site_cfg(
22 ${CMAKE_CURRENT_SOURCE_DIR}/lit.common.configured.in
23 ${CMAKE_CURRENT_BINARY_DIR}/lit.common.configured)
25 # BlocksRuntime (and most of builtins) testsuites are not yet ported to lit.
26 # add_subdirectory(BlocksRuntime)
28 set(SANITIZER_COMMON_LIT_TEST_DEPS)
30 if(COMPILER_RT_BUILD_PROFILE AND COMPILER_RT_HAS_PROFILE)
31 list(APPEND SANITIZER_COMMON_LIT_TEST_DEPS profile)
34 # When ANDROID, we build tests with the host compiler (i.e. CMAKE_C_COMPILER),
35 # and run tests with tools from the host toolchain.
37 if(NOT COMPILER_RT_STANDALONE_BUILD AND NOT LLVM_RUNTIMES_BUILD)
38 # Use LLVM utils and Clang from the same build tree.
39 list(APPEND SANITIZER_COMMON_LIT_TEST_DEPS
40 clang clang-resource-headers FileCheck count not llvm-config llvm-nm llvm-objdump
41 llvm-readelf llvm-readobj llvm-size llvm-symbolizer compiler-rt-headers sancov split-file)
43 list(APPEND SANITIZER_COMMON_LIT_TEST_DEPS KillTheDoctor)
46 # Tests use C++ standard library headers.
47 if (TARGET cxx-headers OR HAVE_LIBCXX)
48 list(APPEND SANITIZER_COMMON_LIT_TEST_DEPS cxx-headers)
52 umbrella_lit_testsuite_begin(check-compiler-rt)
54 function(compiler_rt_test_runtime runtime)
55 string(TOUPPER ${runtime} runtime_uppercase)
56 if(COMPILER_RT_HAS_${runtime_uppercase})
57 if (${runtime} STREQUAL scudo_standalone)
58 add_subdirectory(scudo/standalone)
60 add_subdirectory(${runtime})
62 foreach(directory ${ARGN})
63 add_subdirectory(${directory})
68 # Run sanitizer tests only if we're sure that clang would produce
70 if(COMPILER_RT_CAN_EXECUTE_TESTS)
71 if(COMPILER_RT_BUILD_BUILTINS)
72 add_subdirectory(builtins)
74 if(COMPILER_RT_BUILD_SANITIZERS)
75 compiler_rt_test_runtime(interception)
77 compiler_rt_test_runtime(lsan)
78 # CFI tests require diagnostic mode, which is implemented in UBSan.
79 compiler_rt_test_runtime(ubsan cfi)
80 compiler_rt_test_runtime(sanitizer_common)
82 # OpenBSD not supporting asan, cannot run the tests
83 if(COMPILER_RT_BUILD_LIBFUZZER AND NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "OpenBSD" AND NOT ANDROID)
84 compiler_rt_test_runtime(fuzzer)
86 # These tests don't need an additional runtime but use asan runtime.
87 add_subdirectory(metadata)
90 foreach(sanitizer ${COMPILER_RT_SANITIZERS_TO_BUILD})
91 # cfi testing is gated on ubsan
92 if(NOT ${sanitizer} STREQUAL cfi)
93 compiler_rt_test_runtime(${sanitizer})
97 if(COMPILER_RT_BUILD_PROFILE AND COMPILER_RT_HAS_PROFILE)
98 compiler_rt_test_runtime(profile)
100 if(COMPILER_RT_BUILD_MEMPROF)
101 compiler_rt_test_runtime(memprof)
103 if(COMPILER_RT_BUILD_XRAY)
104 compiler_rt_test_runtime(xray)
106 if(COMPILER_RT_BUILD_ORC)
107 compiler_rt_Test_runtime(orc)
109 # ShadowCallStack does not yet provide a runtime with compiler-rt, the tests
110 # include their own minimal runtime
111 add_subdirectory(shadowcallstack)
114 # Now that we've traversed all the directories and know all the lit testsuites,
115 # introduce a rule to run to run all of them.
116 add_custom_target(compiler-rt-test-depends DEPENDS ${LLVM_COMPILER_RT_LIT_DEPENDS})
117 umbrella_lit_testsuite_end(check-compiler-rt)
119 if(COMPILER_RT_STANDALONE_BUILD)
120 if(NOT TARGET check-all)
121 add_custom_target(check-all)
123 add_dependencies(check-all check-compiler-rt)