forked from OSchip/llvm-project
[TSan] Add initial support for buidling ThreadSanitizer runtime library with CMake (currently the only supported platfrom is 64-bit Linux). This patch makes 'clang++ -fthread-sanitizer' work for both clang in the build tree and installed clang
llvm-svn: 163789
This commit is contained in:
parent
046248c509
commit
255f6a5f1a
|
@ -3,8 +3,8 @@
|
|||
add_subdirectory(asan)
|
||||
add_subdirectory(interception)
|
||||
add_subdirectory(sanitizer_common)
|
||||
add_subdirectory(tsan)
|
||||
|
||||
# FIXME: Add support for tsan library.
|
||||
# FIXME: Add support for the profile library.
|
||||
|
||||
# The top-level lib directory contains a large amount of C code which provides
|
||||
|
|
|
@ -1,8 +1,18 @@
|
|||
# Build for the AddressSanitizer runtime support library.
|
||||
# Build for the ThreadSanitizer runtime support library.
|
||||
|
||||
file(GLOB TSAN_SOURCES "*.cc")
|
||||
include_directories(..)
|
||||
|
||||
if(CAN_TARGET_X86_64)
|
||||
add_library(clang_rt.tsan-x86_64 STATIC ${TSAN_SOURCES})
|
||||
set_target_properties(clang_rt.tsan-x86_64 PROPERTIES COMPILE_FLAGS "${TARGET_X86_64_CFLAGS}")
|
||||
set(TSAN_CFLAGS ${SANITIZER_COMMON_CFLAGS})
|
||||
# FIXME: Add support for compile flags:
|
||||
# -Wframe-larger-than=512,
|
||||
# -Wglobal-constructors,
|
||||
# --sysroot=.
|
||||
|
||||
if("${CMAKE_BUILD_TYPE}" EQUAL "Release")
|
||||
set(TSAN_COMMON_DEFINITIONS DEBUG=0)
|
||||
else()
|
||||
set(TSAN_COMMON_DEFINITIONS DEBUG=1)
|
||||
endif()
|
||||
|
||||
add_subdirectory(rtl)
|
||||
# FIXME: Support TSan runtime tests, unit tests and output tests.
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
set(TSAN_SOURCES
|
||||
tsan_clock.cc
|
||||
tsan_flags.cc
|
||||
tsan_interceptors.cc
|
||||
tsan_interface_ann.cc
|
||||
tsan_interface_atomic.cc
|
||||
tsan_interface.cc
|
||||
tsan_md5.cc
|
||||
tsan_mman.cc
|
||||
tsan_mutex.cc
|
||||
tsan_printf.cc
|
||||
tsan_report.cc
|
||||
tsan_rtl.cc
|
||||
tsan_rtl_mutex.cc
|
||||
tsan_rtl_report.cc
|
||||
tsan_rtl_thread.cc
|
||||
tsan_stat.cc
|
||||
tsan_suppressions.cc
|
||||
tsan_symbolize.cc
|
||||
tsan_sync.cc
|
||||
)
|
||||
|
||||
if(APPLE)
|
||||
list(APPEND TSAN_SOURCES tsan_platform_mac.cc)
|
||||
elseif(UNIX)
|
||||
# Assume Linux
|
||||
list(APPEND TSAN_SOURCES
|
||||
tsan_platform_linux.cc
|
||||
tsan_symbolize_addr2line_linux.cc)
|
||||
endif()
|
||||
|
||||
set(TSAN_RUNTIME_LIBRARIES)
|
||||
# TSan is currently supported on 64-bit Linux only.
|
||||
if(CAN_TARGET_X86_64 AND UNIX AND NOT APPLE)
|
||||
set(TSAN_ASM_SOURCES tsan_rtl_amd64.S)
|
||||
# Pass ASM file directly to the C++ compiler.
|
||||
set_source_files_properties(${TSAN_ASM_SOURCES} PROPERTIES
|
||||
LANGUAGE CXX
|
||||
)
|
||||
add_library(clang_rt.tsan-x86_64 STATIC
|
||||
${TSAN_SOURCES}
|
||||
${TSAN_ASM_SOURCES}
|
||||
$<TARGET_OBJECTS:RTInterception.x86_64>
|
||||
$<TARGET_OBJECTS:RTSanitizerCommon.x86_64>
|
||||
)
|
||||
set_target_compile_flags(clang_rt.tsan-x86_64
|
||||
${TSAN_CFLAGS} ${TARGET_X864_64_CFLAGS}
|
||||
)
|
||||
list(APPEND TSAN_RUNTIME_LIBRARIES clang_rt.tsan-x86_64)
|
||||
endif()
|
||||
|
||||
if(TSAN_RUNTIME_LIBRARIES)
|
||||
set_property(TARGET ${TSAN_RUNTIME_LIBRARIES} APPEND PROPERTY
|
||||
COMPILE_DEFINITIONS ${TSAN_COMMON_DEFINITIONS})
|
||||
add_clang_compiler_rt_libraries(${TSAN_RUNTIME_LIBRARIES})
|
||||
endif()
|
Loading…
Reference in New Issue