mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-01-28 12:30:22 +00:00
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. llvm-svn: 279253
This commit is contained in:
parent
7d200668e4
commit
b6ced621e8
@ -76,6 +76,18 @@ macro(list_intersect output input1 input2)
|
||||
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}})
|
||||
|
@ -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)))
|
||||
|
@ -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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user