Greg Bedwell | d6b0ecb | 2017-11-13 12:57:54 | [diff] [blame] | 1 | # Needed for lit support in standalone builds. |
Chris Bieneman | a58d065 | 2016-02-17 16:38:54 | [diff] [blame] | 2 | include(AddLLVM) |
| 3 | |
Dan Liew | ad7e122 | 2021-04-30 23:24:33 | [diff] [blame] | 4 | pythonize_bool(COMPILER_RT_TEST_STANDALONE_BUILD_LIBS) |
| 5 | |
Alex Lorenz | ad871e4 | 2019-12-03 22:34:02 | [diff] [blame] | 6 | pythonize_bool(LLVM_ENABLE_EXPENSIVE_CHECKS) |
Alex Brachet | fe2f0ab | 2023-05-25 18:55:47 | [diff] [blame] | 7 | |
| 8 | pythonize_bool(ZLIB_FOUND) |
Alex Brachet | 445978e | 2023-08-29 21:37:49 | [diff] [blame] | 9 | pythonize_bool(COMPILER_RT_BUILD_STANDALONE_LIBATOMIC) |
Alex Brachet | fe2f0ab | 2023-05-25 18:55:47 | [diff] [blame] | 10 | |
Vitaly Buka | 23d1b65 | 2023-08-15 00:56:22 | [diff] [blame] | 11 | pythonize_bool(COMPILER_RT_ENABLE_INTERNAL_SYMBOLIZER) |
| 12 | |
Midhunesh | d75a40a | 2025-03-25 23:29:35 | [diff] [blame] | 13 | pythonize_bool(SANITIZER_DISABLE_SYMBOLIZER_PATH_SEARCH) |
| 14 | |
Dinar Temirbulatov | 3112578 | 2024-01-23 11:19:44 | [diff] [blame] | 15 | pythonize_bool(COMPILER_RT_HAS_AARCH64_SME) |
| 16 | |
Martin Storsjö | a14a83d | 2024-10-24 20:45:14 | [diff] [blame] | 17 | pythonize_bool(COMPILER_RT_HAS_NO_DEFAULT_CONFIG_FLAG) |
| 18 | |
Greg Bedwell | d6b0ecb | 2017-11-13 12:57:54 | [diff] [blame] | 19 | configure_compiler_rt_lit_site_cfg( |
Alexey Samsonov | 81a2b46 | 2014-02-14 11:00:07 | [diff] [blame] | 20 | ${CMAKE_CURRENT_SOURCE_DIR}/lit.common.configured.in |
| 21 | ${CMAKE_CURRENT_BINARY_DIR}/lit.common.configured) |
| 22 | |
Erik Pilkington | 0490e1c5 | 2017-03-09 17:02:16 | [diff] [blame] | 23 | # BlocksRuntime (and most of builtins) testsuites are not yet ported to lit. |
Alexey Samsonov | 81a2b46 | 2014-02-14 11:00:07 | [diff] [blame] | 24 | # add_subdirectory(BlocksRuntime) |
Alexey Samsonov | ba869e7 | 2014-02-14 11:42:22 | [diff] [blame] | 25 | |
Alexey Samsonov | aa980c7 | 2014-02-19 10:04:29 | [diff] [blame] | 26 | set(SANITIZER_COMMON_LIT_TEST_DEPS) |
Vitaly Buka | 581fbc6 | 2017-09-16 03:26:03 | [diff] [blame] | 27 | |
Michal Gorny | 806b8d5 | 2017-10-02 05:03:55 | [diff] [blame] | 28 | if(COMPILER_RT_BUILD_PROFILE AND COMPILER_RT_HAS_PROFILE) |
Vitaly Buka | 581fbc6 | 2017-09-16 03:26:03 | [diff] [blame] | 29 | list(APPEND SANITIZER_COMMON_LIT_TEST_DEPS profile) |
| 30 | endif() |
| 31 | |
Alexey Samsonov | b73db72 | 2014-02-18 07:52:40 | [diff] [blame] | 32 | # 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 Samsonov | aa980c7 | 2014-02-19 10:04:29 | [diff] [blame] | 34 | if(NOT ANDROID) |
Petr Hosek | 61a792b | 2021-03-03 08:39:50 | [diff] [blame] | 35 | if(NOT COMPILER_RT_STANDALONE_BUILD AND NOT LLVM_RUNTIMES_BUILD) |
Alexey Samsonov | aa980c7 | 2014-02-19 10:04:29 | [diff] [blame] | 36 | # Use LLVM utils and Clang from the same build tree. |
| 37 | list(APPEND SANITIZER_COMMON_LIT_TEST_DEPS |
Zequan Wu | ab3430f | 2023-12-14 19:16:38 | [diff] [blame] | 38 | 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 Collingbourne | a68d90f | 2015-07-02 22:08:38 | [diff] [blame] | 41 | if (WIN32) |
| 42 | list(APPEND SANITIZER_COMMON_LIT_TEST_DEPS KillTheDoctor) |
| 43 | endif() |
Alexey Samsonov | aa980c7 | 2014-02-19 10:04:29 | [diff] [blame] | 44 | endif() |
Petr Hosek | 775e554 | 2021-04-01 06:23:20 | [diff] [blame] | 45 | # Tests use C++ standard library headers. |
| 46 | if (TARGET cxx-headers OR HAVE_LIBCXX) |
Petr Hosek | b0d286b | 2021-04-02 03:30:49 | [diff] [blame] | 47 | list(APPEND SANITIZER_COMMON_LIT_TEST_DEPS cxx-headers) |
Petr Hosek | 775e554 | 2021-04-01 06:23:20 | [diff] [blame] | 48 | endif() |
Alexey Samsonov | b73db72 | 2014-02-18 07:52:40 | [diff] [blame] | 49 | endif() |
| 50 | |
Martin Storsjö | 002897b | 2023-03-30 09:35:08 | [diff] [blame] | 51 | umbrella_lit_testsuite_begin(check-compiler-rt) |
Sam McCall | 7cc8377 | 2022-03-16 18:46:28 | [diff] [blame] | 52 | |
Francis Ricci | 57a3f45 | 2017-06-27 19:18:01 | [diff] [blame] | 53 | function(compiler_rt_test_runtime runtime) |
| 54 | string(TOUPPER ${runtime} runtime_uppercase) |
Vitaly Buka | d4b28fb | 2024-07-19 01:33:24 | [diff] [blame] | 55 | if(COMPILER_RT_HAS_${runtime_uppercase} AND COMPILER_RT_INCLUDE_TESTS) |
Vitaly Buka | 502a40a | 2024-07-11 03:11:49 | [diff] [blame] | 56 | 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 Phillips | c414bbe | 2022-12-01 23:35:04 | [diff] [blame] | 59 | add_subdirectory(scudo/standalone) |
| 60 | else() |
| 61 | add_subdirectory(${runtime}) |
| 62 | endif() |
Francis Ricci | 57a3f45 | 2017-06-27 19:18:01 | [diff] [blame] | 63 | endif() |
| 64 | endfunction() |
| 65 | |
Alexey Samsonov | ba869e7 | 2014-02-14 11:42:22 | [diff] [blame] | 66 | # Run sanitizer tests only if we're sure that clang would produce |
| 67 | # working binaries. |
| 68 | if(COMPILER_RT_CAN_EXECUTE_TESTS) |
Erik Pilkington | 0490e1c5 | 2017-03-09 17:02:16 | [diff] [blame] | 69 | if(COMPILER_RT_BUILD_BUILTINS) |
| 70 | add_subdirectory(builtins) |
| 71 | endif() |
Michal Gorny | 2bcd94f | 2017-04-26 07:35:36 | [diff] [blame] | 72 | if(COMPILER_RT_BUILD_SANITIZERS) |
Francis Ricci | 57a3f45 | 2017-06-27 19:18:01 | [diff] [blame] | 73 | compiler_rt_test_runtime(interception) |
| 74 | |
| 75 | compiler_rt_test_runtime(lsan) |
Vitaly Buka | 502a40a | 2024-07-11 03:11:49 | [diff] [blame] | 76 | compiler_rt_test_runtime(ubsan) |
Francis Ricci | 57a3f45 | 2017-06-27 19:18:01 | [diff] [blame] | 77 | compiler_rt_test_runtime(sanitizer_common) |
Vedant Kumar | 637e321 | 2017-08-30 19:29:11 | [diff] [blame] | 78 | |
Vitaly Buka | 9802089 | 2018-04-09 22:38:26 | [diff] [blame] | 79 | # OpenBSD not supporting asan, cannot run the tests |
Matt Morehouse | 2456878 | 2018-09-04 17:08:47 | [diff] [blame] | 80 | if(COMPILER_RT_BUILD_LIBFUZZER AND NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "OpenBSD" AND NOT ANDROID) |
Vedant Kumar | 637e321 | 2017-08-30 19:29:11 | [diff] [blame] | 81 | compiler_rt_test_runtime(fuzzer) |
Dmitry Vyukov | f7f0159 | 2023-01-20 09:26:20 | [diff] [blame] | 82 | |
| 83 | # These tests don't need an additional runtime but use asan runtime. |
| 84 | add_subdirectory(metadata) |
Vedant Kumar | 637e321 | 2017-08-30 19:29:11 | [diff] [blame] | 85 | endif() |
Francis Ricci | 57a3f45 | 2017-06-27 19:18:01 | [diff] [blame] | 86 | |
Francis Ricci | d379d1c | 2017-06-27 19:32:39 | [diff] [blame] | 87 | foreach(sanitizer ${COMPILER_RT_SANITIZERS_TO_BUILD}) |
Vitaly Buka | 502a40a | 2024-07-11 03:11:49 | [diff] [blame] | 88 | compiler_rt_test_runtime(${sanitizer}) |
Francis Ricci | d379d1c | 2017-06-27 19:32:39 | [diff] [blame] | 89 | endforeach() |
Vedant Kumar | 4a10504 | 2017-09-18 18:13:47 | [diff] [blame] | 90 | endif() |
Michal Gorny | 806b8d5 | 2017-10-02 05:03:55 | [diff] [blame] | 91 | if(COMPILER_RT_BUILD_PROFILE AND COMPILER_RT_HAS_PROFILE) |
Francis Ricci | 57a3f45 | 2017-06-27 19:18:01 | [diff] [blame] | 92 | compiler_rt_test_runtime(profile) |
Chris Bieneman | 5c64ddf | 2015-12-10 00:40:58 | [diff] [blame] | 93 | endif() |
Mircea Trofin | 7b06ec0 | 2024-04-24 20:31:55 | [diff] [blame] | 94 | if(COMPILER_RT_BUILD_CTX_PROFILE) |
| 95 | compiler_rt_test_runtime(ctx_profile) |
| 96 | endif() |
Teresa Johnson | 3d4bba3 | 2020-09-03 22:21:20 | [diff] [blame] | 97 | if(COMPILER_RT_BUILD_MEMPROF) |
| 98 | compiler_rt_test_runtime(memprof) |
| 99 | endif() |
Francis Ricci | 57a3f45 | 2017-06-27 19:18:01 | [diff] [blame] | 100 | if(COMPILER_RT_BUILD_XRAY) |
| 101 | compiler_rt_test_runtime(xray) |
Dean Michael Berris | 68e7484 | 2016-08-08 03:10:22 | [diff] [blame] | 102 | endif() |
Lang Hames | 5e537ea | 2021-04-24 04:14:56 | [diff] [blame] | 103 | if(COMPILER_RT_BUILD_ORC) |
Qinkun Bao | bed2bdf | 2025-03-28 05:20:14 | [diff] [blame^] | 104 | compiler_rt_test_runtime(orc) |
Lang Hames | 5e537ea | 2021-04-24 04:14:56 | [diff] [blame] | 105 | endif() |
Vlad Tsyrklevich | 1781d10 | 2018-04-04 17:53:33 | [diff] [blame] | 106 | # ShadowCallStack does not yet provide a runtime with compiler-rt, the tests |
| 107 | # include their own minimal runtime |
| 108 | add_subdirectory(shadowcallstack) |
Alexey Samsonov | ba869e7 | 2014-02-14 11:42:22 | [diff] [blame] | 109 | endif() |
Alexey Samsonov | 04e7ad2 | 2014-02-20 12:36:26 | [diff] [blame] | 110 | |
Martin Storsjö | 002897b | 2023-03-30 09:35:08 | [diff] [blame] | 111 | # 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ño | 4eb092d | 2024-02-14 23:49:09 | [diff] [blame] | 113 | get_property(LLVM_COMPILER_RT_LIT_DEPENDS GLOBAL PROPERTY LLVM_COMPILER_RT_LIT_DEPENDS) |
| 114 | add_custom_target(compiler-rt-test-depends) |
Michael Kruse | a35ac42 | 2024-06-04 07:26:45 | [diff] [blame] | 115 | set_target_properties(compiler-rt-test-depends PROPERTIES FOLDER "Compiler-RT/Tests") |
Daniel Rodríguez Troitiño | 4eb092d | 2024-02-14 23:49:09 | [diff] [blame] | 116 | if(LLVM_COMPILER_RT_LIT_DEPENDS) |
| 117 | add_dependencies(compiler-rt-test-depends ${LLVM_COMPILER_RT_LIT_DEPENDS}) |
| 118 | endif() |
Martin Storsjö | 002897b | 2023-03-30 09:35:08 | [diff] [blame] | 119 | umbrella_lit_testsuite_end(check-compiler-rt) |
Sam McCall | 7cc8377 | 2022-03-16 18:46:28 | [diff] [blame] | 120 | |
Martin Storsjö | 002897b | 2023-03-30 09:35:08 | [diff] [blame] | 121 | if(COMPILER_RT_STANDALONE_BUILD) |
Chris Bieneman | 5968c3a | 2016-08-19 22:17:48 | [diff] [blame] | 122 | if(NOT TARGET check-all) |
| 123 | add_custom_target(check-all) |
| 124 | endif() |
Chris Bieneman | 5968c3a | 2016-08-19 22:17:48 | [diff] [blame] | 125 | add_dependencies(check-all check-compiler-rt) |
Alexey Samsonov | 04e7ad2 | 2014-02-20 12:36:26 | [diff] [blame] | 126 | endif() |