[compiler-rt] r279253 - build: allow building a specific set of sanitizers
Saleem Abdulrasool via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 19 08:13:21 PDT 2016
Author: compnerd
Date: Fri Aug 19 10:13:21 2016
New Revision: 279253
URL: http://llvm.org/viewvc/llvm-project?rev=279253&view=rev
Log:
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.
Modified:
compiler-rt/trunk/cmake/Modules/CompilerRTUtils.cmake
compiler-rt/trunk/cmake/config-ix.cmake
compiler-rt/trunk/lib/CMakeLists.txt
Modified: compiler-rt/trunk/cmake/Modules/CompilerRTUtils.cmake
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/cmake/Modules/CompilerRTUtils.cmake?rev=279253&r1=279252&r2=279253&view=diff
==============================================================================
--- compiler-rt/trunk/cmake/Modules/CompilerRTUtils.cmake (original)
+++ compiler-rt/trunk/cmake/Modules/CompilerRTUtils.cmake Fri Aug 19 10:13:21 2016
@@ -76,6 +76,18 @@ macro(list_intersect output input1 input
endforeach()
endmacro()
+function(list_replace input_list old new)
+ set(replaced_list)
+ foreach(item ${${input_list}})
+ if(${item} STREQUAL ${old})
+ list(APPEND replaced_list ${new})
+ else()
+ list(APPEND replaced_list ${item})
+ endif()
+ endforeach()
+ set(${input_list} "${replaced_list}" PARENT_SCOPE)
+endfunction()
+
# Takes ${ARGN} and puts only supported architectures in @out_var list.
function(filter_available_targets out_var)
set(archs ${${out_var}})
Modified: compiler-rt/trunk/cmake/config-ix.cmake
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/cmake/config-ix.cmake?rev=279253&r1=279252&r2=279253&view=diff
==============================================================================
--- compiler-rt/trunk/cmake/config-ix.cmake (original)
+++ compiler-rt/trunk/cmake/config-ix.cmake Fri Aug 19 10:13:21 2016
@@ -400,6 +400,11 @@ else()
set(OS_NAME "${CMAKE_SYSTEM_NAME}")
endif()
+set(ALL_SANITIZERS asan;dfsan;msan;profile;tsan;safestack;cfi;esan;scudo)
+set(COMPILER_RT_SANITIZERS_TO_BUILD ${ALL_SANITIZERS} CACHE STRING
+ "sanitizers to build if supported on the target (all;${ALL_SANITIZERS})")
+list_replace(COMPILER_RT_SANITIZERS_TO_BUILD all "${ALL_SANITIZERS}")
+
if (SANITIZER_COMMON_SUPPORTED_ARCH AND NOT LLVM_USE_SANITIZER AND
(OS_NAME MATCHES "Android|Darwin|Linux|FreeBSD" OR
(OS_NAME MATCHES "Windows" AND MSVC)))
Modified: compiler-rt/trunk/lib/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/CMakeLists.txt?rev=279253&r1=279252&r2=279253&view=diff
==============================================================================
--- compiler-rt/trunk/lib/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/CMakeLists.txt Fri Aug 19 10:13:21 2016
@@ -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()
-
- 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()
+ 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_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()
More information about the llvm-commits
mailing list