blob: a2e4c8cbf56851dc67499b347a6941682a3728b2 [file] [log] [blame]
Greg Bedwelld6b0ecb2017-11-13 12:57:541# Needed for lit support in standalone builds.
Chris Bienemana58d0652016-02-17 16:38:542include(AddLLVM)
3
Dan Liewad7e1222021-04-30 23:24:334pythonize_bool(COMPILER_RT_TEST_STANDALONE_BUILD_LIBS)
5
Alex Lorenzad871e42019-12-03 22:34:026pythonize_bool(LLVM_ENABLE_EXPENSIVE_CHECKS)
Alex Brachetfe2f0ab2023-05-25 18:55:477
8pythonize_bool(ZLIB_FOUND)
Alex Brachet445978e2023-08-29 21:37:499pythonize_bool(COMPILER_RT_BUILD_STANDALONE_LIBATOMIC)
Alex Brachetfe2f0ab2023-05-25 18:55:4710
Vitaly Buka23d1b652023-08-15 00:56:2211pythonize_bool(COMPILER_RT_ENABLE_INTERNAL_SYMBOLIZER)
12
Midhuneshd75a40a2025-03-25 23:29:3513pythonize_bool(SANITIZER_DISABLE_SYMBOLIZER_PATH_SEARCH)
14
Dinar Temirbulatov31125782024-01-23 11:19:4415pythonize_bool(COMPILER_RT_HAS_AARCH64_SME)
16
Martin Storsjöa14a83d2024-10-24 20:45:1417pythonize_bool(COMPILER_RT_HAS_NO_DEFAULT_CONFIG_FLAG)
18
Greg Bedwelld6b0ecb2017-11-13 12:57:5419configure_compiler_rt_lit_site_cfg(
Alexey Samsonov81a2b462014-02-14 11:00:0720 ${CMAKE_CURRENT_SOURCE_DIR}/lit.common.configured.in
21 ${CMAKE_CURRENT_BINARY_DIR}/lit.common.configured)
22
Erik Pilkington0490e1c52017-03-09 17:02:1623# BlocksRuntime (and most of builtins) testsuites are not yet ported to lit.
Alexey Samsonov81a2b462014-02-14 11:00:0724# add_subdirectory(BlocksRuntime)
Alexey Samsonovba869e72014-02-14 11:42:2225
Alexey Samsonovaa980c72014-02-19 10:04:2926set(SANITIZER_COMMON_LIT_TEST_DEPS)
Vitaly Buka581fbc62017-09-16 03:26:0327
Michal Gorny806b8d52017-10-02 05:03:5528if(COMPILER_RT_BUILD_PROFILE AND COMPILER_RT_HAS_PROFILE)
Vitaly Buka581fbc62017-09-16 03:26:0329 list(APPEND SANITIZER_COMMON_LIT_TEST_DEPS profile)
30endif()
31
Alexey Samsonovb73db722014-02-18 07:52:4032# When ANDROID, we build tests with the host compiler (i.e. CMAKE_C_COMPILER),
33# and run tests with tools from the host toolchain.
Alexey Samsonovaa980c72014-02-19 10:04:2934if(NOT ANDROID)
Petr Hosek61a792b2021-03-03 08:39:5035 if(NOT COMPILER_RT_STANDALONE_BUILD AND NOT LLVM_RUNTIMES_BUILD)
Alexey Samsonovaa980c72014-02-19 10:04:2936 # Use LLVM utils and Clang from the same build tree.
37 list(APPEND SANITIZER_COMMON_LIT_TEST_DEPS
Zequan Wuab3430f2023-12-14 19:16:3838 clang clang-resource-headers FileCheck count not llvm-config llvm-nm
39 llvm-objdump llvm-readelf llvm-readobj llvm-size llvm-symbolizer
40 compiler-rt-headers sancov split-file llvm-strip)
Peter Collingbournea68d90f2015-07-02 22:08:3841 if (WIN32)
42 list(APPEND SANITIZER_COMMON_LIT_TEST_DEPS KillTheDoctor)
43 endif()
Alexey Samsonovaa980c72014-02-19 10:04:2944 endif()
Petr Hosek775e5542021-04-01 06:23:2045 # Tests use C++ standard library headers.
46 if (TARGET cxx-headers OR HAVE_LIBCXX)
Petr Hosekb0d286b2021-04-02 03:30:4947 list(APPEND SANITIZER_COMMON_LIT_TEST_DEPS cxx-headers)
Petr Hosek775e5542021-04-01 06:23:2048 endif()
Alexey Samsonovb73db722014-02-18 07:52:4049endif()
50
Martin Storsjö002897b2023-03-30 09:35:0851umbrella_lit_testsuite_begin(check-compiler-rt)
Sam McCall7cc83772022-03-16 18:46:2852
Francis Ricci57a3f452017-06-27 19:18:0153function(compiler_rt_test_runtime runtime)
54 string(TOUPPER ${runtime} runtime_uppercase)
Vitaly Bukad4b28fb2024-07-19 01:33:2455 if(COMPILER_RT_HAS_${runtime_uppercase} AND COMPILER_RT_INCLUDE_TESTS)
Vitaly Buka502a40a2024-07-11 03:11:4956 if (${runtime} STREQUAL cfi AND NOT COMPILER_RT_HAS_UBSAN)
57 # CFI tests require diagnostic mode, which is implemented in UBSan.
58 elseif (${runtime} STREQUAL scudo_standalone)
Mitch Phillipsc414bbe2022-12-01 23:35:0459 add_subdirectory(scudo/standalone)
60 else()
61 add_subdirectory(${runtime})
62 endif()
Francis Ricci57a3f452017-06-27 19:18:0163 endif()
64endfunction()
65
Alexey Samsonovba869e72014-02-14 11:42:2266# Run sanitizer tests only if we're sure that clang would produce
67# working binaries.
68if(COMPILER_RT_CAN_EXECUTE_TESTS)
Erik Pilkington0490e1c52017-03-09 17:02:1669 if(COMPILER_RT_BUILD_BUILTINS)
70 add_subdirectory(builtins)
71 endif()
Michal Gorny2bcd94f2017-04-26 07:35:3672 if(COMPILER_RT_BUILD_SANITIZERS)
Francis Ricci57a3f452017-06-27 19:18:0173 compiler_rt_test_runtime(interception)
74
75 compiler_rt_test_runtime(lsan)
Vitaly Buka502a40a2024-07-11 03:11:4976 compiler_rt_test_runtime(ubsan)
Francis Ricci57a3f452017-06-27 19:18:0177 compiler_rt_test_runtime(sanitizer_common)
Vedant Kumar637e3212017-08-30 19:29:1178
Vitaly Buka98020892018-04-09 22:38:2679 # OpenBSD not supporting asan, cannot run the tests
Matt Morehouse24568782018-09-04 17:08:4780 if(COMPILER_RT_BUILD_LIBFUZZER AND NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "OpenBSD" AND NOT ANDROID)
Vedant Kumar637e3212017-08-30 19:29:1181 compiler_rt_test_runtime(fuzzer)
Dmitry Vyukovf7f01592023-01-20 09:26:2082
83 # These tests don't need an additional runtime but use asan runtime.
84 add_subdirectory(metadata)
Vedant Kumar637e3212017-08-30 19:29:1185 endif()
Francis Ricci57a3f452017-06-27 19:18:0186
Francis Riccid379d1c2017-06-27 19:32:3987 foreach(sanitizer ${COMPILER_RT_SANITIZERS_TO_BUILD})
Vitaly Buka502a40a2024-07-11 03:11:4988 compiler_rt_test_runtime(${sanitizer})
Francis Riccid379d1c2017-06-27 19:32:3989 endforeach()
Vedant Kumar4a105042017-09-18 18:13:4790 endif()
Michal Gorny806b8d52017-10-02 05:03:5591 if(COMPILER_RT_BUILD_PROFILE AND COMPILER_RT_HAS_PROFILE)
Francis Ricci57a3f452017-06-27 19:18:0192 compiler_rt_test_runtime(profile)
Chris Bieneman5c64ddf2015-12-10 00:40:5893 endif()
Mircea Trofin7b06ec02024-04-24 20:31:5594 if(COMPILER_RT_BUILD_CTX_PROFILE)
95 compiler_rt_test_runtime(ctx_profile)
96 endif()
Teresa Johnson3d4bba32020-09-03 22:21:2097 if(COMPILER_RT_BUILD_MEMPROF)
98 compiler_rt_test_runtime(memprof)
99 endif()
Francis Ricci57a3f452017-06-27 19:18:01100 if(COMPILER_RT_BUILD_XRAY)
101 compiler_rt_test_runtime(xray)
Dean Michael Berris68e74842016-08-08 03:10:22102 endif()
Lang Hames5e537ea2021-04-24 04:14:56103 if(COMPILER_RT_BUILD_ORC)
Qinkun Baobed2bdf2025-03-28 05:20:14104 compiler_rt_test_runtime(orc)
Lang Hames5e537ea2021-04-24 04:14:56105 endif()
Vlad Tsyrklevich1781d102018-04-04 17:53:33106 # ShadowCallStack does not yet provide a runtime with compiler-rt, the tests
107 # include their own minimal runtime
108 add_subdirectory(shadowcallstack)
Alexey Samsonovba869e72014-02-14 11:42:22109endif()
Alexey Samsonov04e7ad22014-02-20 12:36:26110
Martin Storsjö002897b2023-03-30 09:35:08111# Now that we've traversed all the directories and know all the lit testsuites,
112# introduce a rule to run to run all of them.
Daniel Rodríguez Troitiño4eb092d2024-02-14 23:49:09113get_property(LLVM_COMPILER_RT_LIT_DEPENDS GLOBAL PROPERTY LLVM_COMPILER_RT_LIT_DEPENDS)
114add_custom_target(compiler-rt-test-depends)
Michael Krusea35ac422024-06-04 07:26:45115set_target_properties(compiler-rt-test-depends PROPERTIES FOLDER "Compiler-RT/Tests")
Daniel Rodríguez Troitiño4eb092d2024-02-14 23:49:09116if(LLVM_COMPILER_RT_LIT_DEPENDS)
117 add_dependencies(compiler-rt-test-depends ${LLVM_COMPILER_RT_LIT_DEPENDS})
118endif()
Martin Storsjö002897b2023-03-30 09:35:08119umbrella_lit_testsuite_end(check-compiler-rt)
Sam McCall7cc83772022-03-16 18:46:28120
Martin Storsjö002897b2023-03-30 09:35:08121if(COMPILER_RT_STANDALONE_BUILD)
Chris Bieneman5968c3a2016-08-19 22:17:48122 if(NOT TARGET check-all)
123 add_custom_target(check-all)
124 endif()
Chris Bieneman5968c3a2016-08-19 22:17:48125 add_dependencies(check-all check-compiler-rt)
Alexey Samsonov04e7ad22014-02-20 12:36:26126endif()