diff options
author | Gerald Combs <gerald@wireshark.org> | 2017-11-20 12:44:17 -0800 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2017-11-21 16:55:18 +0000 |
commit | 0b2ecccd863b577335c1c87a902783d3de158839 (patch) | |
tree | af12ca156f988ca2deff794843d8e67125116735 /CMakeLists.txt | |
parent | 8cbde93146bfd72e98b942fe81d69300f9488dac (diff) |
Add ThreadSanitizer configure-time options.
Add ENABLE_TSAN and enable-tsan options to CMake and Autotools
respectively which enable ThreadSanitizer, similar to AddressSanitizer
and UndefinedBehaviorSanitizer.
Change-Id: I79adf5c1516b0938f140bbf501c181bf14d7619b
Reviewed-on: https://code.wireshark.org/review/24515
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index eddd909914..de47807b3c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -472,9 +472,9 @@ else() # # Code that may be worth looking into (coding practices) # - if((NOT ENABLE_ASAN) AND (NOT ENABLE_UBSAN) AND (NOT DISABLE_FRAME_LARGER_THAN_WARNING)) + if((NOT ENABLE_ASAN) AND (NOT ENABLE_TSAN) AND (NOT ENABLE_UBSAN) AND (NOT DISABLE_FRAME_LARGER_THAN_WARNING)) # - # Only do this if neither ASan nor UBSan are + # Only do this if none of ASan, TSan, and UBSan are # enabled; the instrumentation they add increases # the stack usage - we only care about stack # usage in normal operation. @@ -712,7 +712,23 @@ if(ENABLE_ASAN) endif() endif() +if(ENABLE_TSAN) + # Available since Clang >= 3.2 and GCC >= 4.8 + cmake_push_check_state() + set(CMAKE_REQUIRED_LIBRARIES "-fsanitize=thread") + check_c_compiler_flag(-fsanitize=thread C__fsanitize_thread_VALID) + check_cxx_compiler_flag(-fsanitize=thread CXX__fsanitize_thread_VALID) + cmake_pop_check_state() + if(NOT C__fsanitize_thread_VALID OR NOT CXX__fsanitize_thread_VALID) + message(FATAL_ERROR "ENABLE_TSAN was requested, but not supported!") + endif() + set(CMAKE_C_FLAGS "-fsanitize=thread ${CMAKE_C_FLAGS}") + set(CMAKE_CXX_FLAGS "-fsanitize=thread ${CMAKE_CXX_FLAGS}") + set(WS_LINK_FLAGS "-fsanitize=thread ${WS_LINK_FLAGS}") +endif() + if(ENABLE_UBSAN) + # Available since Clang >= 3.3 and GCC >= 4.9 cmake_push_check_state() set(CMAKE_REQUIRED_LIBRARIES "-fsanitize=undefined") check_c_compiler_flag(-fsanitize=undefined C__fsanitize_undefined_VALID) |