mirror of
https://github.com/gabime/spdlog.git
synced 2025-09-28 09:09:35 +08:00
Gabime/tsan (#3237)
* Fixed race condition in tests * Support for thread sanitizer
This commit is contained in:
@@ -49,7 +49,7 @@ function(spdlog_enable_warnings target_name)
|
||||
endfunction()
|
||||
|
||||
# Enable address sanitizer (gcc/clang only)
|
||||
function(spdlog_enable_sanitizer target_name)
|
||||
function(spdlog_enable_addr_sanitizer target_name)
|
||||
if(NOT CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
|
||||
message(FATAL_ERROR "Sanitizer supported only for gcc/clang")
|
||||
endif()
|
||||
@@ -60,3 +60,14 @@ function(spdlog_enable_sanitizer target_name)
|
||||
target_compile_options(${target_name} PRIVATE -fno-omit-frame-pointer)
|
||||
target_link_libraries(${target_name} PRIVATE -fsanitize=address,undefined -fuse-ld=gold)
|
||||
endfunction()
|
||||
|
||||
# Enable thread sanitizer (gcc/clang only)
|
||||
function(spdlog_enable_thread_sanitizer target_name)
|
||||
if(NOT CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
|
||||
message(FATAL_ERROR "Sanitizer supported only for gcc/clang")
|
||||
endif()
|
||||
message(STATUS "Thread sanitizer enabled")
|
||||
target_compile_options(${target_name} PRIVATE -fsanitize=thread)
|
||||
target_compile_options(${target_name} PRIVATE -fno-omit-frame-pointer)
|
||||
target_link_libraries(${target_name} PRIVATE -fsanitize=thread -fuse-ld=gold)
|
||||
endfunction()
|
||||
|
Reference in New Issue
Block a user