From: Andres Noetzli Date: Sun, 17 Nov 2019 06:38:34 +0000 (-0800) Subject: Add support for ThreadSanitizer instrumentation (#3467) X-Git-Tag: cvc5-1.0.0~3835 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=990ff24487fd0b6998231894825eb9cd4610494e;p=cvc5.git Add support for ThreadSanitizer instrumentation (#3467) This commit adds support for compiling CVC4 with ThreadSanitizer instrumentation. This is useful for debugging issues when CVC4 is used in a multi-threaded context (e.g. #3292). --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 294286e30..fbdd05c95 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -68,6 +68,7 @@ option(ENABLE_GPL "Enable GPL dependencies") # > only necessary for options set for build types cvc4_option(ENABLE_ASAN "Enable ASAN build") cvc4_option(ENABLE_UBSAN "Enable UBSan build") +cvc4_option(ENABLE_TSAN "Enable TSan build") cvc4_option(ENABLE_ASSERTIONS "Enable assertions") cvc4_option(ENABLE_COMP_INC_TRACK "Enable optimizations for incremental SMT-COMP tracks") @@ -156,7 +157,7 @@ endif() # to cmake standards (first letter uppercase). set(BUILD_TYPES Production Debug Testing Competition) -if(ENABLE_ASAN OR ENABLE_UBSAN) +if(ENABLE_ASAN OR ENABLE_UBSAN OR ENABLE_TSAN) set(CMAKE_BUILD_TYPE Debug) endif() @@ -302,6 +303,14 @@ if(ENABLE_UBSAN) add_definitions(-DCVC4_USE_UBSAN) endif() +if(ENABLE_TSAN) + # -fsanitize=thread requires CMAKE_REQUIRED_FLAGS to be explicitely set, + # otherwise the -fsanitize=thread check will fail while linking. + set(CMAKE_REQUIRED_FLAGS -fsanitize=thread) + add_required_c_cxx_flag("-fsanitize=thread") + unset(CMAKE_REQUIRED_FLAGS) +endif() + if(ENABLE_ASSERTIONS) add_definitions(-DCVC4_ASSERTIONS) else() @@ -542,7 +551,9 @@ print_config("Replay :" ENABLE_REPLAY) print_config("Statistics :" ENABLE_STATISTICS) print_config("Tracing :" ENABLE_TRACING) message("") -print_config("Asan :" ENABLE_ASAN) +print_config("ASan :" ENABLE_ASAN) +print_config("UBSan :" ENABLE_UBSAN) +print_config("TSan :" ENABLE_TSAN) print_config("Coverage (gcov) :" ENABLE_COVERAGE) print_config("Profiling (gprof) :" ENABLE_PROFILING) print_config("Unit tests :" ENABLE_UNIT_TESTING) diff --git a/configure.sh b/configure.sh index 701744570..5763fa7ce 100755 --- a/configure.sh +++ b/configure.sh @@ -46,6 +46,7 @@ The following flags enable optional features (disable with --no-