blob: e6158ec4088951f8a4188f2771fe02b8228ff89d [file] [log] [blame]
Chandler Carruthc78ad002012-06-25 08:40:101# First, add the subdirectories which contain feature-based runtime libraries
2# and several convenience helper libraries.
Alexey Samsonovd9512902013-09-02 08:57:233
Alexey Samsonov9a1ffce2014-02-18 07:26:584include(AddCompilerRT)
5include(SanitizerUtils)
Alexey Samsonov68b9e742014-08-08 22:01:206
Dean Michael Berris938c5032016-07-21 07:39:557# 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).
11if (COMPILER_RT_HAS_SANITIZER_COMMON AND
Nikita Popove3389362024-08-22 07:48:0512 (COMPILER_RT_BUILD_SANITIZERS OR COMPILER_RT_BUILD_XRAY OR COMPILER_RT_BUILD_MEMPROF OR COMPILER_RT_BUILD_CTX_PROFILE))
Dean Michael Berris938c5032016-07-21 07:39:5513 add_subdirectory(sanitizer_common)
14endif()
15
Chris Bieneman679ab852015-09-14 19:59:2416if(COMPILER_RT_BUILD_BUILTINS)
17 add_subdirectory(builtins)
Peter Collingbourned3b99172015-07-02 01:44:3418endif()
19
Saleem Abdulrasoolb6ced622016-08-19 15:13:2120function(compiler_rt_build_runtime runtime)
21 string(TOUPPER ${runtime} runtime_uppercase)
22 if(COMPILER_RT_HAS_${runtime_uppercase})
Francis Riccifa0e5362017-06-27 21:10:4623 if(${runtime} STREQUAL tsan)
24 add_subdirectory(tsan/dd)
25 endif()
Mitch Phillipsc414bbe2022-12-01 23:35:0426 if(${runtime} STREQUAL scudo_standalone)
Kostya Kortchinsky47f0d132019-02-04 16:25:4027 add_subdirectory(scudo/standalone)
Mitch Phillipsc414bbe2022-12-01 23:35:0428 else()
29 add_subdirectory(${runtime})
Kostya Kortchinsky47f0d132019-02-04 16:25:4030 endif()
Saleem Abdulrasoolb6ced622016-08-19 15:13:2131 endif()
32endfunction()
33
Teresa Johnsonba71a072020-10-26 20:36:0134if(COMPILER_RT_BUILD_SANITIZERS OR COMPILER_RT_BUILD_MEMPROF)
Saleem Abdulrasoolb6ced622016-08-19 15:13:2135 compiler_rt_build_runtime(interception)
Teresa Johnsonba71a072020-10-26 20:36:0136endif()
Chris Bieneman5c64ddf2015-12-10 00:40:5837
Teresa Johnsonba71a072020-10-26 20:36:0138if(COMPILER_RT_BUILD_SANITIZERS)
Chris Bieneman5c64ddf2015-12-10 00:40:5839 if(COMPILER_RT_HAS_SANITIZER_COMMON)
Peter Collingbourne5788e122016-01-16 00:31:2940 add_subdirectory(stats)
Vitaly Bukad38a8e92024-07-10 23:34:5541 # Contains RTLSanCommon used even without COMPILER_RT_HAS_LSAN.
42 add_subdirectory(lsan)
43 # Contains RTUbsan used even without COMPILER_RT_HAS_UBSAN.
Vitaly Bukaa75322c2024-07-11 00:58:1344 add_subdirectory(ubsan)
Chris Bieneman5c64ddf2015-12-10 00:40:5845 endif()
46
Francis Riccid379d1c2017-06-27 19:32:3947 foreach(sanitizer ${COMPILER_RT_SANITIZERS_TO_BUILD})
48 compiler_rt_build_runtime(${sanitizer})
Francis Riccid379d1c2017-06-27 19:32:3949 endforeach()
Vedant Kumar4a105042017-09-18 18:13:4750endif()
Chris Bieneman5c64ddf2015-12-10 00:40:5851
Vitaly Bukab96eb762024-07-10 21:35:4552if(COMPILER_RT_BUILD_PROFILE)
Saleem Abdulrasoolb6ced622016-08-19 15:13:2153 compiler_rt_build_runtime(profile)
Dean Michael Berrise1c81d12016-07-20 14:14:5054endif()
Dean Michael Berris938c5032016-07-21 07:39:5555
Vitaly Bukab96eb762024-07-10 21:35:4556if(COMPILER_RT_BUILD_CTX_PROFILE)
Mircea Trofina3e7a122024-04-22 17:30:2057 compiler_rt_build_runtime(ctx_profile)
58endif()
59
Saleem Abdulrasoolb6ced622016-08-19 15:13:2160if(COMPILER_RT_BUILD_XRAY)
61 compiler_rt_build_runtime(xray)
Dean Michael Berris938c5032016-07-21 07:39:5562endif()
George Karpenkov10ab2ac2017-08-21 23:25:5063
64if(COMPILER_RT_BUILD_LIBFUZZER)
65 compiler_rt_build_runtime(fuzzer)
66endif()
Peter Collingbourne21d50012020-01-28 02:43:4667
Teresa Johnsonba71a072020-10-26 20:36:0168if(COMPILER_RT_BUILD_MEMPROF AND COMPILER_RT_HAS_SANITIZER_COMMON)
Teresa Johnson3d4bba32020-09-03 22:21:2069 compiler_rt_build_runtime(memprof)
70endif()
71
Lang Hames5e537ea2021-04-24 04:14:5672if(COMPILER_RT_BUILD_ORC)
73 compiler_rt_build_runtime(orc)
74endif()
75
Peter Collingbourne21d50012020-01-28 02:43:4676# 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.
80add_subdirectory(scudo/standalone/fuzz)