1# First, add the subdirectories which contain feature-based runtime libraries 2# and several convenience helper libraries. 3 4include(AddCompilerRT) 5include(SanitizerUtils) 6 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). 11if (COMPILER_RT_HAS_SANITIZER_COMMON AND 12 (COMPILER_RT_BUILD_SANITIZERS OR COMPILER_RT_BUILD_XRAY)) 13 add_subdirectory(sanitizer_common) 14endif() 15 16if(COMPILER_RT_BUILD_BUILTINS) 17 add_subdirectory(builtins) 18endif() 19 20if(COMPILER_RT_BUILD_CRT AND COMPILER_RT_HAS_CRT) 21 add_subdirectory(crt) 22endif() 23 24function(compiler_rt_build_runtime runtime) 25 string(TOUPPER ${runtime} runtime_uppercase) 26 if(COMPILER_RT_HAS_${runtime_uppercase}) 27 add_subdirectory(${runtime}) 28 if(${runtime} STREQUAL tsan) 29 add_subdirectory(tsan/dd) 30 endif() 31 if(${runtime} STREQUAL scudo) 32 add_subdirectory(scudo/standalone) 33 endif() 34 endif() 35endfunction() 36 37if(COMPILER_RT_BUILD_SANITIZERS) 38 compiler_rt_build_runtime(interception) 39 40 if(COMPILER_RT_HAS_SANITIZER_COMMON) 41 add_subdirectory(stats) 42 add_subdirectory(lsan) 43 add_subdirectory(ubsan) 44 endif() 45 46 foreach(sanitizer ${COMPILER_RT_SANITIZERS_TO_BUILD}) 47 compiler_rt_build_runtime(${sanitizer}) 48 endforeach() 49endif() 50 51if(COMPILER_RT_BUILD_PROFILE AND COMPILER_RT_HAS_PROFILE) 52 compiler_rt_build_runtime(profile) 53endif() 54 55if(COMPILER_RT_BUILD_XRAY) 56 compiler_rt_build_runtime(xray) 57endif() 58 59if(COMPILER_RT_BUILD_LIBFUZZER) 60 compiler_rt_build_runtime(fuzzer) 61endif() 62 63# It doesn't normally make sense to build runtimes when a sanitizer is enabled, 64# so we don't add_subdirectory the runtimes in that case. However, the opposite 65# is true for fuzzers that exercise parts of the runtime. So we add the fuzzer 66# directories explicitly here. 67add_subdirectory(scudo/standalone/fuzz) 68