From 679ab85a7cf98247e0c82dae88b99c301a62c92f Mon Sep 17 00:00:00 2001 From: Chris Bieneman Date: Mon, 14 Sep 2015 19:59:24 +0000 Subject: [PATCH] [CMake] Add options to control building sanitizers and builtins. There are situations where a user may want to build only the compiler-rt builtins, or only the sanitizer runtimes. This exposes options to do that. Both default to On, so there should be no implicit change in behavior. llvm-svn: 247607 --- compiler-rt/CMakeLists.txt | 5 +++ compiler-rt/lib/CMakeLists.txt | 58 ++++++++++++++++++---------------- 2 files changed, 36 insertions(+), 27 deletions(-) diff --git a/compiler-rt/CMakeLists.txt b/compiler-rt/CMakeLists.txt index a805601eb126..6f0b8674631b 100644 --- a/compiler-rt/CMakeLists.txt +++ b/compiler-rt/CMakeLists.txt @@ -43,6 +43,11 @@ endif() # Top level target used to build all compiler-rt libraries. add_custom_target(compiler-rt ALL) +option(COMPILER_RT_BUILD_BUILTINS "Build builtins" ON) +mark_as_advanced(COMPILER_RT_BUILD_BUILTINS) +option(COMPILER_RT_BUILD_SANITIZERS "Build sanitizers" ON) +mark_as_advanced(COMPILER_RT_BUILD_SANITIZERS) + if (NOT COMPILER_RT_STANDALONE_BUILD) # Compute the Clang version from the LLVM version. # FIXME: We should be able to reuse CLANG_VERSION variable calculated diff --git a/compiler-rt/lib/CMakeLists.txt b/compiler-rt/lib/CMakeLists.txt index df0d9f4839f3..fb5851aae876 100644 --- a/compiler-rt/lib/CMakeLists.txt +++ b/compiler-rt/lib/CMakeLists.txt @@ -4,40 +4,44 @@ include(AddCompilerRT) include(SanitizerUtils) -if(COMPILER_RT_HAS_INTERCEPTION) - add_subdirectory(interception) +if(COMPILER_RT_BUILD_BUILTINS) + add_subdirectory(builtins) endif() -if(COMPILER_RT_HAS_SANITIZER_COMMON) - add_subdirectory(sanitizer_common) - add_subdirectory(cfi) - add_subdirectory(lsan) - add_subdirectory(ubsan) -endif() +if(COMPILER_RT_BUILD_SANITIZERS) + if(COMPILER_RT_HAS_INTERCEPTION) + add_subdirectory(interception) + endif() -if(COMPILER_RT_HAS_ASAN) - add_subdirectory(asan) -endif() + if(COMPILER_RT_HAS_SANITIZER_COMMON) + add_subdirectory(sanitizer_common) + add_subdirectory(cfi) + add_subdirectory(lsan) + add_subdirectory(ubsan) + endif() -add_subdirectory(builtins) + if(COMPILER_RT_HAS_ASAN) + add_subdirectory(asan) + endif() -if(COMPILER_RT_HAS_DFSAN) - add_subdirectory(dfsan) -endif() + if(COMPILER_RT_HAS_DFSAN) + add_subdirectory(dfsan) + endif() -if(COMPILER_RT_HAS_MSAN) - add_subdirectory(msan) -endif() + if(COMPILER_RT_HAS_MSAN) + add_subdirectory(msan) + endif() -if(COMPILER_RT_HAS_PROFILE) - add_subdirectory(profile) -endif() + if(COMPILER_RT_HAS_PROFILE) + add_subdirectory(profile) + endif() -if(COMPILER_RT_HAS_TSAN) - add_subdirectory(tsan) - add_subdirectory(tsan/dd) -endif() + if(COMPILER_RT_HAS_TSAN) + add_subdirectory(tsan) + add_subdirectory(tsan/dd) + endif() -if(COMPILER_RT_HAS_SAFESTACK) - add_subdirectory(safestack) + if(COMPILER_RT_HAS_SAFESTACK) + add_subdirectory(safestack) + endif() endif()