summaryrefslogtreecommitdiff
path: root/lib/CMakeLists.txt
diff options
context:
space:
mode:
authorSaleem Abdulrasool <compnerd@compnerd.org>2016-08-19 15:13:21 +0000
committerSaleem Abdulrasool <compnerd@compnerd.org>2016-08-19 15:13:21 +0000
commit2b23fdcc97d60b5fa2f6d1280a7132a82e35c815 (patch)
tree079536090daa51e8f1d0c79682ee0df6beb6ece3 /lib/CMakeLists.txt
parent9f3462bee804f1ee1c17509c9e5adb8255b548d2 (diff)
build: allow building a specific set of sanitizers
Introduce a new CMake option `COMPILER_RT_SANITIZERS_TO_BUILD` which takes either a special token `all` (default) which will preserve the current behaviour or a CMake list of sanitizers to build. It will still perform the normal checks if the sanitizer is requested. It only permits a further means to exclude a particular sanitizer. This gives finer grained control than `COMPILER_RT_BUILD_SANITIZERS` which only gives an all or nothing control. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@279253 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CMakeLists.txt')
-rw-r--r--lib/CMakeLists.txt71
1 files changed, 31 insertions, 40 deletions
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
index ce96fe484..4ab1e933a 100644
--- a/lib/CMakeLists.txt
+++ b/lib/CMakeLists.txt
@@ -17,10 +17,27 @@ if(COMPILER_RT_BUILD_BUILTINS)
add_subdirectory(builtins)
endif()
-if(COMPILER_RT_BUILD_SANITIZERS)
- if(COMPILER_RT_HAS_INTERCEPTION)
- add_subdirectory(interception)
+function(compiler_rt_build_runtime runtime)
+ string(TOUPPER ${runtime} runtime_uppercase)
+ if(COMPILER_RT_HAS_${runtime_uppercase})
+ add_subdirectory(${runtime})
+ foreach(directory ${ARGN})
+ add_subdirectory(${directory})
+ endforeach()
+ endif()
+endfunction()
+
+function(compiler_rt_build_sanitizer sanitizer)
+ string(TOUPPER ${sanitizer} sanitizer_uppercase)
+ string(TOLOWER ${sanitizer} sanitizer_lowercase)
+ list(FIND COMPILER_RT_SANITIZERS_TO_BUILD ${sanitizer_lowercase} result)
+ if(NOT ${result} EQUAL -1)
+ compiler_rt_build_runtime(${sanitizer} ${ARGN})
endif()
+endfunction()
+
+if(COMPILER_RT_BUILD_SANITIZERS)
+ compiler_rt_build_runtime(interception)
if(COMPILER_RT_HAS_SANITIZER_COMMON)
add_subdirectory(stats)
@@ -28,44 +45,18 @@ if(COMPILER_RT_BUILD_SANITIZERS)
add_subdirectory(ubsan)
endif()
- if(COMPILER_RT_HAS_ASAN)
- add_subdirectory(asan)
- endif()
+ compiler_rt_build_sanitizer(asan)
+ compiler_rt_build_sanitizer(dfsan)
+ compiler_rt_build_sanitizer(msan)
+ compiler_rt_build_sanitizer(tsan tsan/dd)
+ compiler_rt_build_sanitizer(safestack)
+ compiler_rt_build_sanitizer(cfi)
+ compiler_rt_build_sanitizer(esan)
+ compiler_rt_build_sanitizer(scudo)
- if(COMPILER_RT_HAS_DFSAN)
- add_subdirectory(dfsan)
- endif()
-
- if(COMPILER_RT_HAS_MSAN)
- add_subdirectory(msan)
- 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_SAFESTACK)
- add_subdirectory(safestack)
- endif()
-
- if(COMPILER_RT_HAS_CFI)
- add_subdirectory(cfi)
- endif()
-
- if(COMPILER_RT_HAS_ESAN)
- add_subdirectory(esan)
- endif()
-
- if(COMPILER_RT_HAS_SCUDO)
- add_subdirectory(scudo)
- endif()
+ compiler_rt_build_runtime(profile)
endif()
-if(COMPILER_RT_BUILD_XRAY AND COMPILER_RT_HAS_XRAY)
- add_subdirectory(xray)
+if(COMPILER_RT_BUILD_XRAY)
+ compiler_rt_build_runtime(xray)
endif()