From 06e423d0647c4a3915f8600c8ec7c8825f8f1e97 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Wed, 12 Feb 2020 10:56:13 +0100 Subject: cmake: Add ThreadSanitizer compile flags Signed-off-by: Andreas Schneider Reviewed-by: Stefan Metzmacher --- cmake/Modules/DefineCompilerFlags.cmake | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cmake/Modules/DefineCompilerFlags.cmake b/cmake/Modules/DefineCompilerFlags.cmake index 3277b99..c92182d 100644 --- a/cmake/Modules/DefineCompilerFlags.cmake +++ b/cmake/Modules/DefineCompilerFlags.cmake @@ -34,4 +34,16 @@ if (UNIX AND NOT WIN32) CACHE STRING "Flags used by the linker during the creation of shared libraries during UNDEFINEDSANITIZER builds.") set(CMAKE_EXEC_LINKER_FLAGS_UNDEFINEDSANITIZER "-fsanitize=undefined" CACHE STRING "Flags used by the linker during UNDEFINEDSANITIZER builds.") + + # Activate with: -DCMAKE_BUILD_TYPE=ThreadSanitizer + set(CMAKE_C_FLAGS_THREADSANITIZER "-g -O1 -fsanitize=thread" + CACHE STRING "Flags used by the C compiler during THREADSANITIZER builds.") + set(CMAKE_CXX_FLAGS_THREADSANITIZER "-g -O1 -fsanitize=thread" + CACHE STRING "Flags used by the CXX compiler during THREADSANITIZER builds.") + set(CMAKE_SHARED_LINKER_FLAGS_THREADSANITIZER "-fsanitize=thread" + CACHE STRING "Flags used by the linker during the creation of shared libraries during THREADSANITIZER builds.") + set(CMAKE_MODULE_LINKER_FLAGS_THREADSANITIZER "-fsanitize=thread" + CACHE STRING "Flags used by the linker during the creation of shared libraries during THREADSANITIZER builds.") + set(CMAKE_EXEC_LINKER_FLAGS_THREADSANITIZER "-fsanitize=thread" + CACHE STRING "Flags used by the linker during THREADSANITIZER builds.") endif() -- cgit