[llvm-commits] [compiler-rt] r163789 - in /compiler-rt/trunk/lib: CMakeLists.txt tsan/CMakeLists.txt tsan/rtl/CMakeLists.txt
Alexey Samsonov
samsonov at google.com
Thu Sep 13 05:18:41 PDT 2012
Author: samsonov
Date: Thu Sep 13 07:18:41 2012
New Revision: 163789
URL: http://llvm.org/viewvc/llvm-project?rev=163789&view=rev
Log:
[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
Added:
compiler-rt/trunk/lib/tsan/rtl/CMakeLists.txt
Modified:
compiler-rt/trunk/lib/CMakeLists.txt
compiler-rt/trunk/lib/tsan/CMakeLists.txt
Modified: compiler-rt/trunk/lib/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/CMakeLists.txt?rev=163789&r1=163788&r2=163789&view=diff
==============================================================================
--- compiler-rt/trunk/lib/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/CMakeLists.txt Thu Sep 13 07:18:41 2012
@@ -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
Modified: compiler-rt/trunk/lib/tsan/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/CMakeLists.txt?rev=163789&r1=163788&r2=163789&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/tsan/CMakeLists.txt Thu Sep 13 07:18:41 2012
@@ -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.
Added: compiler-rt/trunk/lib/tsan/rtl/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/CMakeLists.txt?rev=163789&view=auto
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/CMakeLists.txt (added)
+++ compiler-rt/trunk/lib/tsan/rtl/CMakeLists.txt Thu Sep 13 07:18:41 2012
@@ -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()
More information about the llvm-commits
mailing list