mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-05-04 14:39:31 +03:00
add option to build with thread sanitizer
This commit is contained in:
parent
8769082d63
commit
01da026314
1 changed files with 11 additions and 0 deletions
|
@ -19,6 +19,7 @@ option(MI_BUILD_SHARED "Build shared library" ON)
|
||||||
option(MI_BUILD_STATIC "Build static library" ON)
|
option(MI_BUILD_STATIC "Build static library" ON)
|
||||||
option(MI_BUILD_OBJECT "Build object library" ON)
|
option(MI_BUILD_OBJECT "Build object library" ON)
|
||||||
option(MI_BUILD_TESTS "Build test executables" ON)
|
option(MI_BUILD_TESTS "Build test executables" ON)
|
||||||
|
option(MI_DEBUG_TSAN "Build with thread sanitizer (needs clang)" OFF)
|
||||||
option(MI_CHECK_FULL "Use full internal invariant checking in DEBUG mode (deprecated, use MI_DEBUG_FULL instead)" OFF)
|
option(MI_CHECK_FULL "Use full internal invariant checking in DEBUG mode (deprecated, use MI_DEBUG_FULL instead)" OFF)
|
||||||
|
|
||||||
include("cmake/mimalloc-config-version.cmake")
|
include("cmake/mimalloc-config-version.cmake")
|
||||||
|
@ -133,6 +134,16 @@ if(MI_USE_CXX MATCHES "ON")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(MI_DEBUG_TSAN MATCHES "ON")
|
||||||
|
if(CMAKE_C_COMPILER_ID MATCHES "Clang")
|
||||||
|
message(STATUS "Build with thread sanitizer (MI_DEBUG_TSAN=ON)")
|
||||||
|
list(APPEND mi_cflags -fsanitize=thread -g)
|
||||||
|
list(APPEND CMAKE_EXE_LINKER_FLAGS -fsanitize=thread)
|
||||||
|
else()
|
||||||
|
message(WARNING "Can only use thread sanitizer with clang (MI_DEBUG_TSAN=ON but ignored)")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
# Compiler flags
|
# Compiler flags
|
||||||
if(CMAKE_C_COMPILER_ID MATCHES "AppleClang|Clang|GNU")
|
if(CMAKE_C_COMPILER_ID MATCHES "AppleClang|Clang|GNU")
|
||||||
list(APPEND mi_cflags -Wall -Wextra -Wno-unknown-pragmas -fvisibility=hidden)
|
list(APPEND mi_cflags -Wall -Wextra -Wno-unknown-pragmas -fvisibility=hidden)
|
||||||
|
|
Loading…
Add table
Reference in a new issue