Build: Add ThreadSanitizer (TSan) support

Enable it by setting -DTSAN=1
This setting is mutually exclusive with -DASAN
This commit is contained in:
Peter Keresztes Schmidt 2021-02-11 00:38:31 +01:00
parent 393e8b582a
commit 4c07bf5aae
3 changed files with 29 additions and 0 deletions

View File

@ -93,6 +93,11 @@ mark_as_advanced(
option(BUILD_TEST_SUITE "Build the test suite" 0) option(BUILD_TEST_SUITE "Build the test suite" 0)
option(BUILD_MAN "Build man pages" 1) option(BUILD_MAN "Build man pages" 1)
option(ASAN "DEBUGGING: Build with AddressSanitizer (ASan) support" 0) option(ASAN "DEBUGGING: Build with AddressSanitizer (ASan) support" 0)
option(TSAN "DEBUGGING: Build with ThreadSanitizer (TSan) support" 0)
if(ASAN AND TSAN)
message(FATAL_ERROR "ASAN and TSAN options are mutually exclusive")
endif()
set(ZM_RUNDIR "/var/run/zm" CACHE PATH set(ZM_RUNDIR "/var/run/zm" CACHE PATH
"Location of transient process files, default: /var/run/zm") "Location of transient process files, default: /var/run/zm")

View File

@ -19,3 +19,15 @@ if(ASAN)
message(STATUS "Clang: Enabled AddressSanitizer (ASan)") message(STATUS "Clang: Enabled AddressSanitizer (ASan)")
endif() endif()
if(TSAN)
target_compile_options(zm-compile-option-interface
INTERFACE
-fsanitize=thread)
target_link_options(zm-compile-option-interface
INTERFACE
-fsanitize=thread)
message(STATUS "Clang: Enabled ThreadSanitizer (TSan)")
endif()

View File

@ -19,3 +19,15 @@ if(ASAN)
message(STATUS "GCC: Enabled AddressSanitizer (ASan)") message(STATUS "GCC: Enabled AddressSanitizer (ASan)")
endif() endif()
if(TSAN)
target_compile_options(zm-compile-option-interface
INTERFACE
-fsanitize=thread)
target_link_options(zm-compile-option-interface
INTERFACE
-fsanitize=thread)
message(STATUS "GCC: Enabled ThreadSanitizer (TSan)")
endif()