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 OR COMPILER_RT_BUILD_MEMPROF)) 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 OR COMPILER_RT_BUILD_MEMPROF) 38 compiler_rt_build_runtime(interception) 39endif() 40 41if(COMPILER_RT_BUILD_SANITIZERS) 42 if(COMPILER_RT_HAS_SANITIZER_COMMON) 43 add_subdirectory(stats) 44 add_subdirectory(lsan) 45 add_subdirectory(ubsan) 46 endif() 47 48 foreach(sanitizer ${COMPILER_RT_SANITIZERS_TO_BUILD}) 49 compiler_rt_build_runtime(${sanitizer}) 50 endforeach() 51endif() 52 53if(COMPILER_RT_BUILD_PROFILE AND COMPILER_RT_HAS_PROFILE) 54 compiler_rt_build_runtime(profile) 55endif() 56 57if(COMPILER_RT_BUILD_XRAY) 58 compiler_rt_build_runtime(xray) 59endif() 60 61if(COMPILER_RT_BUILD_LIBFUZZER) 62 compiler_rt_build_runtime(fuzzer) 63endif() 64 65if(COMPILER_RT_BUILD_MEMPROF AND COMPILER_RT_HAS_SANITIZER_COMMON) 66 compiler_rt_build_runtime(memprof) 67endif() 68 69# It doesn't normally make sense to build runtimes when a sanitizer is enabled, 70# so we don't add_subdirectory the runtimes in that case. However, the opposite 71# is true for fuzzers that exercise parts of the runtime. So we add the fuzzer 72# directories explicitly here. 73add_subdirectory(scudo/standalone/fuzz) 74