diff options
-rw-r--r-- | CMakeLists.txt | 6 | ||||
-rw-r--r-- | cmake/StaticBuild.cmake | 7 |
2 files changed, 13 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 7fb7b1e6..f2e7d50e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -80,6 +80,12 @@ if(ENABLE_ASAN AND NOT WIN32 AND NOT APPLE) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address") endif() +option(ENABLE_TSAN "Enable thread sanitizer support" OFF) +if(ENABLE_TSAN AND NOT WIN32 AND NOT APPLE AND CMAKE_SIZEOF_VOID_P MATCHES 8) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=thread") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread") +endif() + if(NOT DEFINED BUILD_WINVNC) set(BUILD_WINVNC 1) endif() diff --git a/cmake/StaticBuild.cmake b/cmake/StaticBuild.cmake index 5a3d9987..6db0e14b 100644 --- a/cmake/StaticBuild.cmake +++ b/cmake/StaticBuild.cmake @@ -119,6 +119,13 @@ if(BUILD_STATIC_GCC) if(ENABLE_ASAN AND NOT WIN32 AND NOT APPLE) set(STATIC_BASE_LIBRARIES "${STATIC_BASE_LIBRARIES} -Wl,-Bstatic -lasan -Wl,-Bdynamic -ldl -lm -lpthread") endif() + if(ENABLE_TSAN AND NOT WIN32 AND NOT APPLE AND CMAKE_SIZEOF_VOID_P MATCHES 8) + # libtsan redefines some C++ symbols which then conflict with a + # statically linked libstdc++. Work around this by allowing multiple + # definitions. The linker will pick the first one (i.e. the one + # from libtsan). + set(STATIC_BASE_LIBRARIES "${STATIC_BASE_LIBRARIES} -Wl,-z -Wl,muldefs -Wl,-Bstatic -ltsan -Wl,-Bdynamic -ldl -lm") + endif() if(WIN32) set(STATIC_BASE_LIBRARIES "${STATIC_BASE_LIBRARIES} -lmingw32 -lgcc_eh -lgcc -lmoldname -lmingwex -lmsvcrt") set(STATIC_BASE_LIBRARIES "${STATIC_BASE_LIBRARIES} -luser32 -lkernel32 -ladvapi32 -lshell32") |