Skip to content

Commit

Permalink
Add thread sanitizer option to cmake
Browse files Browse the repository at this point in the history
----------------------------------------------

Thread sanitizer (TSAN) is a tool that detect data races, deadlocks  between threads. (it also sometimes report heap-use-after-free in same thread check #71 for issues reported in current repo)

For more information, checkout https://clang.llvm.org/docs/ThreadSanitizer.html
  • Loading branch information
sherry-yuan committed Feb 8, 2022
1 parent ef694d7 commit 4b3aa08
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,18 @@ if(ACL_CODE_COVERAGE)
endif()
endif()

# Flag for tsan scans
option(ACL_TSAN "Build with tsan" OFF)
message(STATUS "Build with tsan: ${ACL_TSAN}")
if(ACL_TSAN)
if(CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread -fno-omit-frame-pointer")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=thread -fno-omit-frame-pointer")
else()
message(FATAL_ERROR "cannot build with tsan tools due to unsupported CXX compiler")
endif()
endif()

################################################################################
### Modified Debug flags
################################################################################
Expand Down

0 comments on commit 4b3aa08

Please sign in to comment.