Add cmake compile options for enabling address/thread sanitizer

* Currently tsan doesn't work well in Qt because it doesn't recognise QMutex
This commit is contained in:
baldurk
2019-02-28 17:39:04 +00:00
parent bbdf2c1f80
commit 7541dc6bc7
3 changed files with 31 additions and 1 deletions
+14
View File
@@ -148,6 +148,20 @@ option(ENABLE_PYRENDERDOC "Enable renderdoc python modules" ON)
option(ENABLE_XLIB "Enable xlib windowing support" ON)
option(ENABLE_XCB "Enable xcb windowing support" ON)
option(ENABLE_ASAN "Enable address sanitizer" OFF)
option(ENABLE_TSAN "Enable thread sanitizer" OFF)
option(ENABLE_MSAN "Enable memory sanitizer" OFF)
if(ENABLE_ASAN)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer")
message(STATUS "Enabling address sanitizer - may cause issues if capturing, only recommended for use with replay only")
endif()
if(ENABLE_TSAN)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread -fno-omit-frame-pointer")
message(STATUS "Enabling thread sanitizer - may cause issues if capturing, only recommended for use with replay only")
endif()
if(WIN32)
message(FATAL_ERROR "CMake is not needed on Windows, just open and build renderdoc.sln")
endif()
+10
View File
@@ -9,6 +9,16 @@ set(QMAKE_LDFLAGS "")
set(QMAKE_CXXFLAGS "")
set(SWIG_FLAGS "")
if(ENABLE_ASAN)
set (QMAKE_CXXFLAGS "-fsanitize=address -fno-omit-frame-pointer")
set (QMAKE_LDFLAGS "-fsanitize=address")
endif()
if(ENABLE_TSAN)
set (QMAKE_CXXFLAGS "-fsanitize=thread -fno-omit-frame-pointer")
set (QMAKE_LDFLAGS "-fsanitize=thread")
endif()
if(STATIC_QRENDERDOC)
set(QMAKE_CXXFLAGS "-DSTATIC_QRENDERDOC=1")
set(QMAKE_CONFIG "debug static")
+7 -1
View File
@@ -470,7 +470,13 @@ target_link_libraries(renderdoc ${RDOC_LIBRARIES})
add_dependencies(renderdoc renderdoc_libentry)
if(UNIX AND NOT ANDROID AND NOT APPLE)
set_target_properties(renderdoc PROPERTIES LINK_FLAGS "-Wl,--undefined,force_include_libentry -Wl,--version-script,${CMAKE_CURRENT_SOURCE_DIR}/renderdoc.version -Wl,--no-undefined")
set(RDOC_LINK_FLAGS "-Wl,--undefined,force_include_libentry -Wl,--version-script,${CMAKE_CURRENT_SOURCE_DIR}/renderdoc.version")
if(NOT ENABLE_ASAN AND NOT ENABLE_TSAN)
set(RDOC_LINK_FLAGS "${RDOC_LINK_FLAGS} -Wl,--no-undefined")
endif()
set_target_properties(renderdoc PROPERTIES LINK_FLAGS "${RDOC_LINK_FLAGS}")
endif()
# On macOS set the rpath so that linked libraries are relative to the executable, not absolute