diff --git a/CMakeLists.txt b/CMakeLists.txt index a16748630b..4c32f04db5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -64,6 +64,7 @@ option(BUILD_SHARED_LIBS "Build libscap and libsinsp as shared libraries" OFF) option(ENABLE_VM_TESTS "Enable driver sanity tests" OFF) option(USE_ASAN "Build with AddressSanitizer" OFF) option(USE_UBSAN "Build with UndefinedBehaviorSanitizer" OFF) +option(USE_TSAN "Build with ThreadSanitizer" OFF) option(ENABLE_COVERAGE "Build with code coverage" OFF) option(UBSAN_HALT_ON_ERROR "Halt on error when building with UBSan" ON) diff --git a/cmake/modules/CompilerFlags.cmake b/cmake/modules/CompilerFlags.cmake index 7eccbc0d70..9a1cdb9289 100644 --- a/cmake/modules/CompilerFlags.cmake +++ b/cmake/modules/CompilerFlags.cmake @@ -67,6 +67,11 @@ if(NOT MSVC) endif() endif() + if(USE_TSAN) + set(FALCOSECURITY_LIBS_USERSPACE_COMPILE_FLAGS "${FALCOSECURITY_LIBS_USERSPACE_COMPILE_FLAGS};-fsanitize=thread") + set(FALCOSECURITY_LIBS_USERSPACE_LINK_FLAGS "${FALCOSECURITY_LIBS_USERSPACE_LINK_FLAGS};-fsanitize=thread") + endif() + if(ENABLE_COVERAGE) set(FALCOSECURITY_LIBS_USERSPACE_COMPILE_FLAGS "${FALCOSECURITY_LIBS_USERSPACE_COMPILE_FLAGS};--coverage") set(FALCOSECURITY_LIBS_USERSPACE_LINK_FLAGS "${FALCOSECURITY_LIBS_USERSPACE_COMPILE_FLAGS};--coverage")