Chandler Carruth | c78ad00 | 2012-06-25 08:40:10 | [diff] [blame] | 1 | # First, add the subdirectories which contain feature-based runtime libraries |
| 2 | # and several convenience helper libraries. |
Alexey Samsonov | d951290 | 2013-09-02 08:57:23 | [diff] [blame] | 3 | |
Alexey Samsonov | 9a1ffce | 2014-02-18 07:26:58 | [diff] [blame] | 4 | include(AddCompilerRT) |
| 5 | include(SanitizerUtils) |
Alexey Samsonov | 68b9e74 | 2014-08-08 22:01:20 | [diff] [blame] | 6 | |
Dean Michael Berris | 938c503 | 2016-07-21 07:39:55 | [diff] [blame] | 7 | # Hoist the building of sanitizer_common on whether we're building either the |
| 8 | # sanitizers or xray (or both). |
| 9 | # |
| 10 | #TODO: Refactor sanitizer_common into smaller pieces (e.g. flag parsing, utils). |
| 11 | if (COMPILER_RT_HAS_SANITIZER_COMMON AND |
Nikita Popov | e338936 | 2024-08-22 07:48:05 | [diff] [blame] | 12 | (COMPILER_RT_BUILD_SANITIZERS OR COMPILER_RT_BUILD_XRAY OR COMPILER_RT_BUILD_MEMPROF OR COMPILER_RT_BUILD_CTX_PROFILE)) |
Dean Michael Berris | 938c503 | 2016-07-21 07:39:55 | [diff] [blame] | 13 | add_subdirectory(sanitizer_common) |
| 14 | endif() |
| 15 | |
Chris Bieneman | 679ab85 | 2015-09-14 19:59:24 | [diff] [blame] | 16 | if(COMPILER_RT_BUILD_BUILTINS) |
| 17 | add_subdirectory(builtins) |
Peter Collingbourne | d3b9917 | 2015-07-02 01:44:34 | [diff] [blame] | 18 | endif() |
| 19 | |
Saleem Abdulrasool | b6ced62 | 2016-08-19 15:13:21 | [diff] [blame] | 20 | function(compiler_rt_build_runtime runtime) |
| 21 | string(TOUPPER ${runtime} runtime_uppercase) |
| 22 | if(COMPILER_RT_HAS_${runtime_uppercase}) |
Francis Ricci | fa0e536 | 2017-06-27 21:10:46 | [diff] [blame] | 23 | if(${runtime} STREQUAL tsan) |
| 24 | add_subdirectory(tsan/dd) |
| 25 | endif() |
Mitch Phillips | c414bbe | 2022-12-01 23:35:04 | [diff] [blame] | 26 | if(${runtime} STREQUAL scudo_standalone) |
Kostya Kortchinsky | 47f0d13 | 2019-02-04 16:25:40 | [diff] [blame] | 27 | add_subdirectory(scudo/standalone) |
Mitch Phillips | c414bbe | 2022-12-01 23:35:04 | [diff] [blame] | 28 | else() |
| 29 | add_subdirectory(${runtime}) |
Kostya Kortchinsky | 47f0d13 | 2019-02-04 16:25:40 | [diff] [blame] | 30 | endif() |
Saleem Abdulrasool | b6ced62 | 2016-08-19 15:13:21 | [diff] [blame] | 31 | endif() |
| 32 | endfunction() |
| 33 | |
Teresa Johnson | ba71a07 | 2020-10-26 20:36:01 | [diff] [blame] | 34 | if(COMPILER_RT_BUILD_SANITIZERS OR COMPILER_RT_BUILD_MEMPROF) |
Saleem Abdulrasool | b6ced62 | 2016-08-19 15:13:21 | [diff] [blame] | 35 | compiler_rt_build_runtime(interception) |
Teresa Johnson | ba71a07 | 2020-10-26 20:36:01 | [diff] [blame] | 36 | endif() |
Chris Bieneman | 5c64ddf | 2015-12-10 00:40:58 | [diff] [blame] | 37 | |
Teresa Johnson | ba71a07 | 2020-10-26 20:36:01 | [diff] [blame] | 38 | if(COMPILER_RT_BUILD_SANITIZERS) |
Chris Bieneman | 5c64ddf | 2015-12-10 00:40:58 | [diff] [blame] | 39 | if(COMPILER_RT_HAS_SANITIZER_COMMON) |
Peter Collingbourne | 5788e12 | 2016-01-16 00:31:29 | [diff] [blame] | 40 | add_subdirectory(stats) |
Vitaly Buka | d38a8e9 | 2024-07-10 23:34:55 | [diff] [blame] | 41 | # Contains RTLSanCommon used even without COMPILER_RT_HAS_LSAN. |
| 42 | add_subdirectory(lsan) |
| 43 | # Contains RTUbsan used even without COMPILER_RT_HAS_UBSAN. |
Vitaly Buka | a75322c | 2024-07-11 00:58:13 | [diff] [blame] | 44 | add_subdirectory(ubsan) |
Chris Bieneman | 5c64ddf | 2015-12-10 00:40:58 | [diff] [blame] | 45 | endif() |
| 46 | |
Francis Ricci | d379d1c | 2017-06-27 19:32:39 | [diff] [blame] | 47 | foreach(sanitizer ${COMPILER_RT_SANITIZERS_TO_BUILD}) |
| 48 | compiler_rt_build_runtime(${sanitizer}) |
Francis Ricci | d379d1c | 2017-06-27 19:32:39 | [diff] [blame] | 49 | endforeach() |
Vedant Kumar | 4a10504 | 2017-09-18 18:13:47 | [diff] [blame] | 50 | endif() |
Chris Bieneman | 5c64ddf | 2015-12-10 00:40:58 | [diff] [blame] | 51 | |
Vitaly Buka | b96eb76 | 2024-07-10 21:35:45 | [diff] [blame] | 52 | if(COMPILER_RT_BUILD_PROFILE) |
Saleem Abdulrasool | b6ced62 | 2016-08-19 15:13:21 | [diff] [blame] | 53 | compiler_rt_build_runtime(profile) |
Dean Michael Berris | e1c81d1 | 2016-07-20 14:14:50 | [diff] [blame] | 54 | endif() |
Dean Michael Berris | 938c503 | 2016-07-21 07:39:55 | [diff] [blame] | 55 | |
Vitaly Buka | b96eb76 | 2024-07-10 21:35:45 | [diff] [blame] | 56 | if(COMPILER_RT_BUILD_CTX_PROFILE) |
Mircea Trofin | a3e7a12 | 2024-04-22 17:30:20 | [diff] [blame] | 57 | compiler_rt_build_runtime(ctx_profile) |
| 58 | endif() |
| 59 | |
Saleem Abdulrasool | b6ced62 | 2016-08-19 15:13:21 | [diff] [blame] | 60 | if(COMPILER_RT_BUILD_XRAY) |
| 61 | compiler_rt_build_runtime(xray) |
Dean Michael Berris | 938c503 | 2016-07-21 07:39:55 | [diff] [blame] | 62 | endif() |
George Karpenkov | 10ab2ac | 2017-08-21 23:25:50 | [diff] [blame] | 63 | |
| 64 | if(COMPILER_RT_BUILD_LIBFUZZER) |
| 65 | compiler_rt_build_runtime(fuzzer) |
| 66 | endif() |
Peter Collingbourne | 21d5001 | 2020-01-28 02:43:46 | [diff] [blame] | 67 | |
Teresa Johnson | ba71a07 | 2020-10-26 20:36:01 | [diff] [blame] | 68 | if(COMPILER_RT_BUILD_MEMPROF AND COMPILER_RT_HAS_SANITIZER_COMMON) |
Teresa Johnson | 3d4bba3 | 2020-09-03 22:21:20 | [diff] [blame] | 69 | compiler_rt_build_runtime(memprof) |
| 70 | endif() |
| 71 | |
Lang Hames | 5e537ea | 2021-04-24 04:14:56 | [diff] [blame] | 72 | if(COMPILER_RT_BUILD_ORC) |
| 73 | compiler_rt_build_runtime(orc) |
| 74 | endif() |
| 75 | |
Peter Collingbourne | 21d5001 | 2020-01-28 02:43:46 | [diff] [blame] | 76 | # It doesn't normally make sense to build runtimes when a sanitizer is enabled, |
| 77 | # so we don't add_subdirectory the runtimes in that case. However, the opposite |
| 78 | # is true for fuzzers that exercise parts of the runtime. So we add the fuzzer |
| 79 | # directories explicitly here. |
| 80 | add_subdirectory(scudo/standalone/fuzz) |