From 6b1a47b85177c0f14e9c3adbbf8a3ba02f7c0e54 Mon Sep 17 00:00:00 2001 From: Tim Wojtulewicz Date: Mon, 9 Aug 2021 20:35:59 +0000 Subject: [PATCH] Added support for TSan to CMake, added CI run --- .travis.yml | 2 +- CMakeLists.txt | 10 ++++++++++ scripts/travis/build.sh | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 4dd5d25d..f42311ab 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,6 +12,7 @@ env: matrix: - BUILD_TYPE=Release - BUILD_TYPE=Debug ENABLE_ASAN=YES ENABLE_LSAN=YES ENABLE_UBSAN=YES ASAN_OPTIONS="symbolize=1 detect_leaks=1 detect_stack_use_after_return=1" LSAN_OPTIONS="fast_unwind_on_malloc=0:malloc_context_size=50" + - BUILD_TYPE=Debug ENABLE_TSAN=YES addons: apt: config: @@ -42,4 +43,3 @@ before_script: - ./scripts/travis/build.sh script: - make ARGS="-V" test - diff --git a/CMakeLists.txt b/CMakeLists.txt index d7cb70a7..04aa5df5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -84,6 +84,16 @@ if(ENABLE_UBSAN) list(APPEND DEBUG_FSANITIZERFLAGS "undefined") endif() +# +# ThreadSanitizer +# +if(ENABLE_TSAN) + # + # -fsanitize=thread - Build with tsan support + # + list(APPEND DEBUG_FSANITIZERFLAGS "thread") +endif() + if(DEBUG_FSANITIZERFLAGS) string (REPLACE ";" "," DEBUG_FSANITIZERFLAGS "${DEBUG_FSANITIZERFLAGS}") set(CMAKE_C_FLAGS_DEBUG "-fsanitize=${DEBUG_FSANITIZERFLAGS} ${CMAKE_C_FLAGS_DEBUG}") diff --git a/scripts/travis/build.sh b/scripts/travis/build.sh index 612caa25..4833469e 100755 --- a/scripts/travis/build.sh +++ b/scripts/travis/build.sh @@ -19,6 +19,7 @@ if ! cmake . -G "Unix Makefiles" \ -DENABLE_ASAN="${ENABLE_ASAN:-NO}" \ -DENABLE_LSAN="${ENABLE_LSAN:-NO}" \ -DENABLE_UBSAN="${ENABLE_UBSAN:-NO}" \ + -DENABLE_TSAN="${ENABLE_TSAN:-NO}" \ -DCMAKE_BUILD_TYPE="${BUILD_TYPE}"; then fatal "Failed during cmake build configuration" fi