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