CMake: expand sanitizer support to include TSan.
parent
47e82798da
commit
74103eee81
|
@ -113,12 +113,34 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
|
|||
endif()
|
||||
|
||||
if(ENABLE_SANITIZERS)
|
||||
list(APPEND SANITIZERS address alignment bounds)
|
||||
list(APPEND SANITIZERS shift signed-integer-overflow integer-divide-by-zero)
|
||||
list(APPEND SANITIZERS null bool enum)
|
||||
list(APPEND SANITIZERS return)
|
||||
string(REPLACE ";" "," SANITIZERS "${SANITIZERS}")
|
||||
set(SANITIZE_FLAGS "-O1 -fsanitize=${SANITIZERS} -fno-sanitize-recover=address,undefined")
|
||||
if(NOT SANITIZERS)
|
||||
set(SANITIZERS "address;undefined")
|
||||
endif()
|
||||
|
||||
if("thread" IN_LIST SANITIZERS)
|
||||
list(REMOVE_ITEM SANITIZERS "thread")
|
||||
list(APPEND SANITIZE_OPTIONS thread)
|
||||
endif()
|
||||
if("address" IN_LIST SANITIZERS)
|
||||
list(REMOVE_ITEM SANITIZERS "address")
|
||||
list(APPEND SANITIZE_OPTIONS address)
|
||||
endif()
|
||||
if("undefined" IN_LIST SANITIZERS)
|
||||
list(REMOVE_ITEM SANITIZERS "undefined")
|
||||
list(APPEND SANITIZE_OPTIONS alignment bounds)
|
||||
list(APPEND SANITIZE_OPTIONS shift signed-integer-overflow integer-divide-by-zero)
|
||||
list(APPEND SANITIZE_OPTIONS null bool enum)
|
||||
list(APPEND SANITIZE_OPTIONS return)
|
||||
endif()
|
||||
if(SANITIZERS)
|
||||
message(FATAL_ERROR "Unknown sanitizer(s) ${SANITIZERS}")
|
||||
else()
|
||||
message(STATUS "Using sanitizer options ${SANITIZE_OPTIONS}")
|
||||
endif()
|
||||
|
||||
string(REPLACE ";" "," SANITIZE_OPTIONS "${SANITIZE_OPTIONS}")
|
||||
set(SANITIZE_FLAGS "-O1 -fsanitize=${SANITIZE_OPTIONS}")
|
||||
set(SANITIZE_FLAGS "${SANITIZE_FLAGS} -fno-sanitize-recover=address,undefined")
|
||||
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
set(SANITIZE_FLAGS "${SANITIZE_FLAGS} -fno-omit-frame-pointer -fno-optimize-sibling-calls")
|
||||
|
|
Loading…
Reference in New Issue