add thread sanitizer cmake flag

master
Francisco 4 years ago committed by Francisco Paisana
parent 49731ab5a1
commit 89628b691f

@ -71,6 +71,7 @@ option(RPATH "Enable RPATH" OFF)
option(ENABLE_ASAN "Enable gcc/clang address sanitizer" OFF) option(ENABLE_ASAN "Enable gcc/clang address sanitizer" OFF)
option(ENABLE_GCOV "Enable gcc/clang address sanitizer" OFF) option(ENABLE_GCOV "Enable gcc/clang address sanitizer" OFF)
option(ENABLE_MSAN "Enable clang memory sanitizer" OFF) option(ENABLE_MSAN "Enable clang memory sanitizer" OFF)
option(ENABLE_TSAN "Enable clang thread sanitizer" OFF)
option(ENABLE_TIDY "Enable clang tidy" OFF) option(ENABLE_TIDY "Enable clang tidy" OFF)
option(USE_LTE_RATES "Use standard LTE sampling rates" OFF) option(USE_LTE_RATES "Use standard LTE sampling rates" OFF)
@ -467,15 +468,20 @@ if(CMAKE_C_COMPILER_ID MATCHES "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Clang")
endif(NOT WIN32) endif(NOT WIN32)
endif(NOT ${CMAKE_BUILD_TYPE} STREQUAL "Debug") endif(NOT ${CMAKE_BUILD_TYPE} STREQUAL "Debug")
if (ENABLE_ASAN AND ENABLE_MSAN) if ((ENABLE_ASAN AND ENABLE_MSAN) OR (ENABLE_ASAN AND ENABLE_TSAN) OR (ENABLE_MSAN AND ENABLE_TSAN))
message(FATAL_ERROR "ASAN and MSAN cannot be enabled at the same time.") message(FATAL_ERROR "ASAN, MSAN and TSAN cannot be enabled at the same time.")
endif (ENABLE_ASAN AND ENABLE_MSAN) endif ()
if (ENABLE_ASAN) if (ENABLE_ASAN)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fno-omit-frame-pointer") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fno-omit-frame-pointer")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer")
endif (ENABLE_ASAN) endif (ENABLE_ASAN)
if (ENABLE_TSAN)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=thread")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread")
endif (ENABLE_TSAN)
if (ENABLE_MSAN AND CMAKE_C_COMPILER_ID MATCHES "Clang") if (ENABLE_MSAN AND CMAKE_C_COMPILER_ID MATCHES "Clang")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=memory -fno-omit-frame-pointer -fPIE -pie") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=memory -fno-omit-frame-pointer -fPIE -pie")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=memory -fno-omit-frame-pointer -fPIE -pie") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=memory -fno-omit-frame-pointer -fPIE -pie")

Loading…
Cancel
Save