diff options
author | Alexey Samsonov <samsonov@google.com> | 2012-09-13 12:18:41 +0000 |
---|---|---|
committer | Alexey Samsonov <samsonov@google.com> | 2012-09-13 12:18:41 +0000 |
commit | 255f6a5f1a99afbf6110d67119754febb8016e88 (patch) | |
tree | 8197338e9af1b7f00f24e03d69d0f09830fdad2c /compiler-rt/lib | |
parent | 046248c50948c7e5c660fef51740f423a6d0d55c (diff) | |
download | bcm5719-llvm-255f6a5f1a99afbf6110d67119754febb8016e88.tar.gz bcm5719-llvm-255f6a5f1a99afbf6110d67119754febb8016e88.zip |
[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
Diffstat (limited to 'compiler-rt/lib')
-rw-r--r-- | compiler-rt/lib/CMakeLists.txt | 2 | ||||
-rw-r--r-- | compiler-rt/lib/tsan/CMakeLists.txt | 20 | ||||
-rw-r--r-- | compiler-rt/lib/tsan/rtl/CMakeLists.txt | 56 |
3 files changed, 72 insertions, 6 deletions
diff --git a/compiler-rt/lib/CMakeLists.txt b/compiler-rt/lib/CMakeLists.txt index 1249aa00e7e..02d58de0af5 100644 --- a/compiler-rt/lib/CMakeLists.txt +++ b/compiler-rt/lib/CMakeLists.txt @@ -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 diff --git a/compiler-rt/lib/tsan/CMakeLists.txt b/compiler-rt/lib/tsan/CMakeLists.txt index acfb854d260..fc20cd88b0d 100644 --- a/compiler-rt/lib/tsan/CMakeLists.txt +++ b/compiler-rt/lib/tsan/CMakeLists.txt @@ -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. diff --git a/compiler-rt/lib/tsan/rtl/CMakeLists.txt b/compiler-rt/lib/tsan/rtl/CMakeLists.txt new file mode 100644 index 00000000000..267c02a4239 --- /dev/null +++ b/compiler-rt/lib/tsan/rtl/CMakeLists.txt @@ -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() |