mirror of
https://github.com/saymrwulf/pytorch.git
synced 2026-05-14 20:57:59 +00:00
Add USE_TSAN option (#35197)
Summary: Sometimes it is important to run code with thread sanitizer. Pull Request resolved: https://github.com/pytorch/pytorch/pull/35197 Test Plan: CI Differential Revision: D20605005 Pulled By: malfet fbshipit-source-id: bcd1a5191b5f859e12b6df6737c980099b1edc36
This commit is contained in:
parent
a00e12e755
commit
93983c7d00
2 changed files with 10 additions and 0 deletions
|
|
@ -136,6 +136,7 @@ cmake_dependent_option(
|
|||
"BUILD_TEST" OFF)
|
||||
option(COLORIZE_OUTPUT "Colorize output during compilation" ON)
|
||||
option(USE_ASAN "Use Address Sanitizer" OFF)
|
||||
option(USE_TSAN "Use Thread Sanitizer" OFF)
|
||||
option(USE_CUDA "Use CUDA" ON)
|
||||
option(USE_ROCM "Use ROCm" ON)
|
||||
option(CAFFE2_STATIC_LINK_CUDA "Statically link CUDA libraries" OFF)
|
||||
|
|
|
|||
|
|
@ -323,6 +323,15 @@ if (USE_ASAN)
|
|||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${CAFFE2_ASAN_FLAG}")
|
||||
endif()
|
||||
|
||||
if (USE_TSAN)
|
||||
set(CAFFE2_TSAN_FLAG "-fsanitize=thread -fPIE -pie")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CAFFE2_TSAN_FLAG}")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CAFFE2_TSAN_FLAG}")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CAFFE2_TSAN_FLAG}")
|
||||
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${CAFFE2_TSAN_FLAG}")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${CAFFE2_TSAN_FLAG}")
|
||||
endif()
|
||||
|
||||
# ---[ Create CAFFE2_BUILD_SHARED_LIBS for macros.h.in usage.
|
||||
set(CAFFE2_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue