aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2017-11-20 12:44:17 -0800
committerGerald Combs <gerald@wireshark.org>2017-11-21 16:55:18 +0000
commit0b2ecccd863b577335c1c87a902783d3de158839 (patch)
treeaf12ca156f988ca2deff794843d8e67125116735
parent8cbde93146bfd72e98b942fe81d69300f9488dac (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>
-rw-r--r--CMakeLists.txt20
-rw-r--r--CMakeOptions.txt1
-rw-r--r--configure.ac14
3 files changed, 33 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index eddd909..de47807 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)
diff --git a/CMakeOptions.txt b/CMakeOptions.txt
index 388f9c4..e66cbed 100644
--- a/CMakeOptions.txt
+++ b/CMakeOptions.txt
@@ -30,6 +30,7 @@ option(EXTCAP_ANDROIDDUMP_LIBPCAP "Build androiddump using libpcap" OFF)
option(ENABLE_EXTRA_COMPILER_WARNINGS "Do additional compiler warnings (disables -Werror)" OFF)
option(ENABLE_CODE_ANALYSIS "Enable the compiler's static analyzer if possible" OFF)
option(ENABLE_ASAN "Enable AddressSanitizer (ASAN) for debugging (degrades performance)" OFF)
+option(ENABLE_TSAN "Enable ThreadSanitizer (TSan) for debugging" OFF)
option(ENABLE_UBSAN "Enable UndefinedBehaviorSanitizer (UBSan) for debugging" OFF)
option(ENABLE_CHECKHF_CONFLICT "Enable hf conflict check for debugging (start-up may be slower)" OFF)
option(ENABLE_CCACHE "Speed up compiling and linking using ccache if possible" OFF)
diff --git a/configure.ac b/configure.ac
index 8abddaf..3fcc038 100644
--- a/configure.ac
+++ b/configure.ac
@@ -759,6 +759,20 @@ AC_ARG_ENABLE(asan,
AC_SUBST(NO_SANITIZE_CFLAGS)
AC_SUBST(NO_SANITIZE_LDFLAGS)
+# Try to enable ThreadSanitizer.
+#
+AC_ARG_ENABLE(tsan,
+ AC_HELP_STRING( [--enable-tsan],
+ [Enable ThreadSanitizer (TSan) for debugging@<:@default=no@:>@]),
+[
+ #
+ # Available since Clang >= 3.2 and GCC >= 4.8
+ #
+ AC_WIRESHARK_COMPILER_FLAGS_CHECK(-fsanitize=thread)
+ AC_WIRESHARK_LDFLAGS_CHECK(-fsanitize=thread)
+
+])
+
# Try to enable UndefinedBehaviorSanitizer.
#
AC_ARG_ENABLE(ubsan,