mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-12-13 02:21:45 +00:00
[cmake] Add LLVM_UBSAN_FLAGS, to allow overriding UBSan flags
Allow overriding the default set of flags used to enable UBSan when building llvm. This can be used to test new checks or opt out of certain checks. Differential Revision: https://reviews.llvm.org/D89439
This commit is contained in:
parent
b2b7cf39d5
commit
905f874c44
@ -487,6 +487,10 @@ endif( LLVM_USE_PERF )
|
||||
set(LLVM_USE_SANITIZER "" CACHE STRING
|
||||
"Define the sanitizer used to build binaries and tests.")
|
||||
option(LLVM_OPTIMIZE_SANITIZED_BUILDS "Pass -O1 on debug sanitizer builds" ON)
|
||||
set(LLVM_UBSAN_FLAGS
|
||||
"-fsanitize=undefined -fno-sanitize=vptr,function -fno-sanitize-recover=all"
|
||||
CACHE STRING
|
||||
"Compile flags set to enable UBSan. Only used if LLVM_USE_SANITIZER contains 'Undefined'.")
|
||||
set(LLVM_LIB_FUZZING_ENGINE "" CACHE PATH
|
||||
"Path to fuzzing library for linking with fuzz targets")
|
||||
|
||||
|
@ -776,8 +776,7 @@ if(LLVM_USE_SANITIZER)
|
||||
endif()
|
||||
elseif (LLVM_USE_SANITIZER STREQUAL "Undefined")
|
||||
append_common_sanitizer_flags()
|
||||
append("-fsanitize=undefined -fno-sanitize=vptr,function -fno-sanitize-recover=all"
|
||||
CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
|
||||
append("${LLVM_UBSAN_FLAGS}" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
|
||||
elseif (LLVM_USE_SANITIZER STREQUAL "Thread")
|
||||
append_common_sanitizer_flags()
|
||||
append("-fsanitize=thread" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
|
||||
@ -786,8 +785,8 @@ if(LLVM_USE_SANITIZER)
|
||||
elseif (LLVM_USE_SANITIZER STREQUAL "Address;Undefined" OR
|
||||
LLVM_USE_SANITIZER STREQUAL "Undefined;Address")
|
||||
append_common_sanitizer_flags()
|
||||
append("-fsanitize=address,undefined -fno-sanitize=vptr,function -fno-sanitize-recover=all"
|
||||
CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
|
||||
append("-fsanitize=address" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
|
||||
append("${LLVM_UBSAN_FLAGS}" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
|
||||
elseif (LLVM_USE_SANITIZER STREQUAL "Leaks")
|
||||
append_common_sanitizer_flags()
|
||||
append("-fsanitize=leak" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
|
||||
|
@ -428,6 +428,11 @@ LLVM-specific variables
|
||||
are ``Address``, ``Memory``, ``MemoryWithOrigins``, ``Undefined``, ``Thread``,
|
||||
``DataFlow``, and ``Address;Undefined``. Defaults to empty string.
|
||||
|
||||
**LLVM_UBSAN_FLAGS**:STRING
|
||||
Defines the set of compile flags used to enable UBSan. Only used if
|
||||
``LLVM_USE_SANITIZER`` contains ``Undefined``. This can be used to override
|
||||
the default set of UBSan flags.
|
||||
|
||||
**LLVM_ENABLE_LTO**:STRING
|
||||
Add ``-flto`` or ``-flto=`` flags to the compile and link command
|
||||
lines, enabling link-time optimization. Possible values are ``Off``,
|
||||
|
Loading…
Reference in New Issue
Block a user