[compiler-rt] 63d518f - [tsan] Move tsan/rtl build rules into tsan/rtl/CMakeLists.txt
Nico Weber via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 6 16:59:07 PST 2021
Author: Nico Weber
Date: 2021-12-06T19:58:30-05:00
New Revision: 63d518f31ac0d4e2cc3314953659c6cddc0c43cc
URL: https://github.com/llvm/llvm-project/commit/63d518f31ac0d4e2cc3314953659c6cddc0c43cc
DIFF: https://github.com/llvm/llvm-project/commit/63d518f31ac0d4e2cc3314953659c6cddc0c43cc.diff
LOG: [tsan] Move tsan/rtl build rules into tsan/rtl/CMakeLists.txt
That way, the build rules are closer to the source files they describe.
No intended behavior change.
Differential Revision: https://reviews.llvm.org/D115155
Added:
compiler-rt/lib/tsan/rtl/CMakeLists.txt
llvm/utils/gn/secondary/compiler-rt/lib/tsan/rtl/BUILD.gn
Modified:
compiler-rt/lib/tsan/CMakeLists.txt
llvm/utils/gn/secondary/compiler-rt/lib/BUILD.gn
Removed:
llvm/utils/gn/secondary/compiler-rt/lib/tsan/BUILD.gn
################################################################################
diff --git a/compiler-rt/lib/tsan/CMakeLists.txt b/compiler-rt/lib/tsan/CMakeLists.txt
index c3284a5dc4220..c5ec6b0ddfd22 100644
--- a/compiler-rt/lib/tsan/CMakeLists.txt
+++ b/compiler-rt/lib/tsan/CMakeLists.txt
@@ -1,7 +1,5 @@
# Build for the ThreadSanitizer runtime support library.
-include_directories(..)
-
set(TSAN_CFLAGS ${SANITIZER_COMMON_CFLAGS})
# SANITIZER_COMMON_CFLAGS contains -fPIC, but it's performance-critical for
# TSan runtime to be built with -fPIE to reduce the number of register spills.
@@ -17,287 +15,8 @@ if(COMPILER_RT_TSAN_DEBUG_OUTPUT)
list(APPEND TSAN_CFLAGS -DTSAN_DEBUG_OUTPUT=2)
endif()
-set(TSAN_RTL_CFLAGS ${TSAN_CFLAGS})
-append_list_if(COMPILER_RT_HAS_MSSE4_2_FLAG -msse4.2 TSAN_RTL_CFLAGS)
-append_list_if(SANITIZER_LIMIT_FRAME_SIZE -Wframe-larger-than=530
- TSAN_RTL_CFLAGS)
-append_list_if(COMPILER_RT_HAS_WGLOBAL_CONSTRUCTORS_FLAG -Wglobal-constructors
- TSAN_RTL_CFLAGS)
-
-set(TSAN_RTL_DYNAMIC_CFLAGS ${TSAN_RTL_CFLAGS})
-list(REMOVE_ITEM TSAN_RTL_DYNAMIC_CFLAGS -fPIE)
-
-set(TSAN_DYNAMIC_LINK_LIBS ${SANITIZER_CXX_ABI_LIBRARIES} ${SANITIZER_COMMON_LINK_LIBS})
-
-append_list_if(COMPILER_RT_HAS_LIBDL dl TSAN_DYNAMIC_LINK_LIBS)
-append_list_if(COMPILER_RT_HAS_LIBM m TSAN_DYNAMIC_LINK_LIBS)
-append_list_if(COMPILER_RT_HAS_LIBPTHREAD pthread TSAN_DYNAMIC_LINK_LIBS)
-
-set(TSAN_SOURCES
- rtl/tsan_clock.cpp
- rtl/tsan_debugging.cpp
- rtl/tsan_external.cpp
- rtl/tsan_fd.cpp
- rtl/tsan_flags.cpp
- rtl/tsan_ignoreset.cpp
- rtl/tsan_interceptors_posix.cpp
- rtl/tsan_interface.cpp
- rtl/tsan_interface_ann.cpp
- rtl/tsan_interface_atomic.cpp
- rtl/tsan_interface_java.cpp
- rtl/tsan_malloc_mac.cpp
- rtl/tsan_md5.cpp
- rtl/tsan_mman.cpp
- rtl/tsan_mutexset.cpp
- rtl/tsan_report.cpp
- rtl/tsan_rtl.cpp
- rtl/tsan_rtl_access.cpp
- rtl/tsan_rtl_mutex.cpp
- rtl/tsan_rtl_proc.cpp
- rtl/tsan_rtl_report.cpp
- rtl/tsan_rtl_thread.cpp
- rtl/tsan_stack_trace.cpp
- rtl/tsan_suppressions.cpp
- rtl/tsan_symbolize.cpp
- rtl/tsan_sync.cpp
- rtl/tsan_vector_clock.cpp
- )
-
-set(TSAN_CXX_SOURCES
- rtl/tsan_new_delete.cpp
- )
-
-set(TSAN_PREINIT_SOURCES
- rtl/tsan_preinit.cpp
- )
-
-if(APPLE)
- list(APPEND TSAN_SOURCES
- rtl/tsan_interceptors_mac.cpp
- rtl/tsan_interceptors_mach_vm.cpp
- rtl/tsan_platform_mac.cpp
- rtl/tsan_platform_posix.cpp
- )
-elseif(UNIX)
- # Assume Linux
- list(APPEND TSAN_SOURCES
- rtl/tsan_platform_linux.cpp
- rtl/tsan_platform_posix.cpp
- )
-endif()
-
-if(COMPILER_RT_INTERCEPT_LIBDISPATCH)
- list(APPEND TSAN_SOURCES
- rtl/tsan_interceptors_libdispatch.cpp
- )
- list(APPEND TSAN_RTL_CFLAGS ${COMPILER_RT_LIBDISPATCH_CFLAGS})
-endif()
-
-set(TSAN_HEADERS
- rtl/tsan_clock.h
- rtl/tsan_defs.h
- rtl/tsan_dense_alloc.h
- rtl/tsan_fd.h
- rtl/tsan_flags.h
- rtl/tsan_flags.inc
- rtl/tsan_ignoreset.h
- rtl/tsan_ilist.h
- rtl/tsan_interceptors.h
- rtl/tsan_interface.h
- rtl/tsan_interface.inc
- rtl/tsan_interface_ann.h
- rtl/tsan_interface_java.h
- rtl/tsan_mman.h
- rtl/tsan_mutexset.h
- rtl/tsan_platform.h
- rtl/tsan_ppc_regs.h
- rtl/tsan_report.h
- rtl/tsan_rtl.h
- rtl/tsan_shadow.h
- rtl/tsan_stack_trace.h
- rtl/tsan_suppressions.h
- rtl/tsan_symbolize.h
- rtl/tsan_sync.h
- rtl/tsan_trace.h
- rtl/tsan_update_shadow_word.inc
- rtl/tsan_vector_clock.h
- )
-
-set(TSAN_RUNTIME_LIBRARIES)
-add_compiler_rt_component(tsan)
-
-if("${CMAKE_C_FLAGS}" MATCHES "-Wno-(error=)?unused-command-line-argument")
- set(EXTRA_CFLAGS "-Wno-error=unused-command-line-argument ${EXTRA_CFLAGS}")
-endif()
-
-if(APPLE)
- # Ideally we would check the SDK version for the actual platform we are
- # building for here. To make our lifes easier we assume the host SDK setup is
- # sane and use the macOS SDK version as a proxy for aligned SDKs.
- find_darwin_sdk_version(macosx_sdk_version "macosx")
- if ("${macosx_sdk_version}" VERSION_LESS 10.12)
- message(FATAL_ERROR "Building the TSan runtime requires at least macOS SDK 10.12 (or aligned SDK on other platforms)")
- endif()
-
- add_asm_sources(TSAN_ASM_SOURCES
- rtl/tsan_rtl_amd64.S
- rtl/tsan_rtl_aarch64.S
- )
-
- set(TSAN_LINK_LIBS ${SANITIZER_COMMON_LINK_LIBS})
-
- add_weak_symbols("ubsan" WEAK_SYMBOL_LINK_FLAGS)
- add_weak_symbols("sanitizer_common" WEAK_SYMBOL_LINK_FLAGS)
-
- add_compiler_rt_runtime(clang_rt.tsan
- SHARED
- OS ${TSAN_SUPPORTED_OS}
- ARCHS ${TSAN_SUPPORTED_ARCH}
- SOURCES ${TSAN_SOURCES} ${TSAN_CXX_SOURCES} ${TSAN_ASM_SOURCES}
- ADDITIONAL_HEADERS ${TSAN_HEADERS}
- OBJECT_LIBS RTInterception
- RTSanitizerCommon
- RTSanitizerCommonLibc
- RTSanitizerCommonCoverage
- RTSanitizerCommonSymbolizer
- RTUbsan
- CFLAGS ${TSAN_RTL_CFLAGS}
- LINK_FLAGS ${SANITIZER_COMMON_LINK_FLAGS} ${WEAK_SYMBOL_LINK_FLAGS}
- LINK_LIBS ${TSAN_LINK_LIBS} objc
- PARENT_TARGET tsan)
- add_compiler_rt_object_libraries(RTTsan_dynamic
- OS ${TSAN_SUPPORTED_OS}
- ARCHS ${TSAN_SUPPORTED_ARCH}
- SOURCES ${TSAN_SOURCES} ${TSAN_CXX_SOURCES} ${TSAN_ASM_SOURCES}
- ADDITIONAL_HEADERS ${TSAN_HEADERS}
- CFLAGS ${TSAN_RTL_CFLAGS})
-
- # Build and check Go runtime.
- set(BUILDGO_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/go/buildgo.sh)
- add_custom_target(GotsanRuntimeCheck
- COMMAND env "CC=${CMAKE_C_COMPILER} ${OSX_SYSROOT_FLAG}"
- EXTRA_CFLAGS=${EXTRA_CFLAGS}
- IN_TMPDIR=1 SILENT=1 ${BUILDGO_SCRIPT}
- DEPENDS tsan ${BUILDGO_SCRIPT}
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/go
- COMMENT "Checking TSan Go runtime..."
- VERBATIM)
- set_target_properties(GotsanRuntimeCheck PROPERTIES FOLDER "Compiler-RT Misc")
-else()
- foreach(arch ${TSAN_SUPPORTED_ARCH})
- if(arch STREQUAL "x86_64")
- add_asm_sources(TSAN_ASM_SOURCES
- rtl/tsan_rtl_amd64.S
- )
- # Sanity check for Go runtime.
- set(BUILDGO_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/go/buildgo.sh)
- add_custom_target(GotsanRuntimeCheck
- COMMAND env "CC=${CMAKE_C_COMPILER} ${CMAKE_C_COMPILER_ARG1}"
- EXTRA_CFLAGS=${EXTRA_CFLAGS}
- IN_TMPDIR=1 SILENT=1 ${BUILDGO_SCRIPT}
- DEPENDS clang_rt.tsan-${arch} ${BUILDGO_SCRIPT}
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/go
- COMMENT "Checking TSan Go runtime..."
- VERBATIM)
- elseif(arch STREQUAL "aarch64")
- add_asm_sources(TSAN_ASM_SOURCES
- rtl/tsan_rtl_aarch64.S
- )
- # Sanity check for Go runtime.
- set(BUILDGO_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/go/buildgo.sh)
- add_custom_target(GotsanRuntimeCheck
- COMMAND env "CC=${CMAKE_C_COMPILER} ${CMAKE_C_COMPILER_ARG1}"
- EXTRA_CFLAGS=${EXTRA_CFLAGS}
- IN_TMPDIR=1 SILENT=1 ${BUILDGO_SCRIPT}
- DEPENDS clang_rt.tsan-${arch} ${BUILDGO_SCRIPT}
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/go
- COMMENT "Checking TSan Go runtime..."
- VERBATIM)
- elseif(arch MATCHES "powerpc64|powerpc64le")
- add_asm_sources(TSAN_ASM_SOURCES
- rtl/tsan_rtl_ppc64.S
- )
- # Sanity check for Go runtime.
- set(BUILDGO_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/go/buildgo.sh)
- add_custom_target(GotsanRuntimeCheck
- COMMAND env "CC=${CMAKE_C_COMPILER} ${CMAKE_C_COMPILER_ARG1}"
- EXTRA_CFLAGS=${EXTRA_CFLAGS}
- IN_TMPDIR=1 SILENT=1 ${BUILDGO_SCRIPT}
- DEPENDS clang_rt.tsan-${arch} ${BUILDGO_SCRIPT}
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/go
- COMMENT "Checking TSan Go runtime..."
- VERBATIM)
- elseif(arch MATCHES "mips64|mips64le")
- add_asm_sources(TSAN_ASM_SOURCES
- rtl/tsan_rtl_mips64.S
- )
- elseif(arch MATCHES "s390x")
- add_asm_sources(TSAN_ASM_SOURCES
- rtl/tsan_rtl_s390x.S
- )
- # Sanity check for Go runtime.
- set(BUILDGO_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/go/buildgo.sh)
- add_custom_target(GotsanRuntimeCheck
- COMMAND env "CC=${CMAKE_C_COMPILER} ${CMAKE_C_COMPILER_ARG1}"
- EXTRA_CFLAGS=${EXTRA_CFLAGS}
- IN_TMPDIR=1 SILENT=1 ${BUILDGO_SCRIPT}
- DEPENDS clang_rt.tsan-${arch} ${BUILDGO_SCRIPT}
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/go
- COMMENT "Checking TSan Go runtime..."
- VERBATIM)
- else()
- set(TSAN_ASM_SOURCES)
- endif()
- add_compiler_rt_runtime(clang_rt.tsan
- STATIC
- ARCHS ${arch}
- SOURCES ${TSAN_SOURCES} ${TSAN_ASM_SOURCES} ${TSAN_PREINIT_SOURCES}
- $<TARGET_OBJECTS:RTInterception.${arch}>
- $<TARGET_OBJECTS:RTSanitizerCommon.${arch}>
- $<TARGET_OBJECTS:RTSanitizerCommonLibc.${arch}>
- $<TARGET_OBJECTS:RTSanitizerCommonCoverage.${arch}>
- $<TARGET_OBJECTS:RTSanitizerCommonSymbolizer.${arch}>
- $<TARGET_OBJECTS:RTUbsan.${arch}>
- ADDITIONAL_HEADERS ${TSAN_HEADERS}
- CFLAGS ${TSAN_RTL_CFLAGS}
- PARENT_TARGET tsan)
- add_compiler_rt_runtime(clang_rt.tsan_cxx
- STATIC
- ARCHS ${arch}
- SOURCES ${TSAN_CXX_SOURCES}
- $<TARGET_OBJECTS:RTUbsan_cxx.${arch}>
- ADDITIONAL_HEADERS ${TSAN_HEADERS}
- CFLAGS ${TSAN_RTL_CFLAGS}
- PARENT_TARGET tsan)
- list(APPEND TSAN_RUNTIME_LIBRARIES clang_rt.tsan-${arch}
- clang_rt.tsan_cxx-${arch})
- add_compiler_rt_runtime(clang_rt.tsan
- SHARED
- ARCHS ${arch}
- SOURCES ${TSAN_SOURCES} ${TSAN_ASM_SOURCES}
- $<TARGET_OBJECTS:RTInterception.${arch}>
- $<TARGET_OBJECTS:RTSanitizerCommon.${arch}>
- $<TARGET_OBJECTS:RTSanitizerCommonLibc.${arch}>
- $<TARGET_OBJECTS:RTSanitizerCommonCoverage.${arch}>
- $<TARGET_OBJECTS:RTSanitizerCommonSymbolizer.${arch}>
- $<TARGET_OBJECTS:RTUbsan.${arch}>
- ADDITIONAL_HEADERS ${TSAN_HEADERS}
- CFLAGS ${TSAN_RTL_DYNAMIC_CFLAGS}
- LINK_LIBS ${TSAN_DYNAMIC_LINK_LIBS}
- LINK_FLAGS ${SANITIZER_COMMON_LINK_FLAGS}
- PARENT_TARGET tsan)
- add_sanitizer_rt_symbols(clang_rt.tsan
- ARCHS ${arch}
- EXTRA rtl/tsan.syms.extra)
- add_sanitizer_rt_symbols(clang_rt.tsan_cxx
- ARCHS ${arch}
- EXTRA rtl/tsan.syms.extra)
- add_dependencies(tsan clang_rt.tsan-${arch}
- clang_rt.tsan_cxx-${arch}
- clang_rt.tsan-${arch}-symbols
- clang_rt.tsan_cxx-${arch}-symbols)
- endforeach()
-endif()
+# Add the actual runtime library.
+add_subdirectory(rtl)
# Build libcxx instrumented with TSan.
if(COMPILER_RT_LIBCXX_PATH AND
diff --git a/compiler-rt/lib/tsan/rtl/CMakeLists.txt b/compiler-rt/lib/tsan/rtl/CMakeLists.txt
new file mode 100644
index 0000000000000..061f6c33690be
--- /dev/null
+++ b/compiler-rt/lib/tsan/rtl/CMakeLists.txt
@@ -0,0 +1,285 @@
+include_directories(../..)
+
+set(TSAN_RTL_CFLAGS ${TSAN_CFLAGS})
+append_list_if(COMPILER_RT_HAS_MSSE4_2_FLAG -msse4.2 TSAN_RTL_CFLAGS)
+append_list_if(SANITIZER_LIMIT_FRAME_SIZE -Wframe-larger-than=530
+ TSAN_RTL_CFLAGS)
+append_list_if(COMPILER_RT_HAS_WGLOBAL_CONSTRUCTORS_FLAG -Wglobal-constructors
+ TSAN_RTL_CFLAGS)
+
+set(TSAN_RTL_DYNAMIC_CFLAGS ${TSAN_RTL_CFLAGS})
+list(REMOVE_ITEM TSAN_RTL_DYNAMIC_CFLAGS -fPIE)
+
+set(TSAN_DYNAMIC_LINK_LIBS ${SANITIZER_CXX_ABI_LIBRARIES} ${SANITIZER_COMMON_LINK_LIBS})
+
+append_list_if(COMPILER_RT_HAS_LIBDL dl TSAN_DYNAMIC_LINK_LIBS)
+append_list_if(COMPILER_RT_HAS_LIBM m TSAN_DYNAMIC_LINK_LIBS)
+append_list_if(COMPILER_RT_HAS_LIBPTHREAD pthread TSAN_DYNAMIC_LINK_LIBS)
+
+set(TSAN_SOURCES
+ tsan_clock.cpp
+ tsan_debugging.cpp
+ tsan_external.cpp
+ tsan_fd.cpp
+ tsan_flags.cpp
+ tsan_ignoreset.cpp
+ tsan_interceptors_posix.cpp
+ tsan_interface.cpp
+ tsan_interface_ann.cpp
+ tsan_interface_atomic.cpp
+ tsan_interface_java.cpp
+ tsan_malloc_mac.cpp
+ tsan_md5.cpp
+ tsan_mman.cpp
+ tsan_mutexset.cpp
+ tsan_report.cpp
+ tsan_rtl.cpp
+ tsan_rtl_access.cpp
+ tsan_rtl_mutex.cpp
+ tsan_rtl_proc.cpp
+ tsan_rtl_report.cpp
+ tsan_rtl_thread.cpp
+ tsan_stack_trace.cpp
+ tsan_suppressions.cpp
+ tsan_symbolize.cpp
+ tsan_sync.cpp
+ tsan_vector_clock.cpp
+ )
+
+set(TSAN_CXX_SOURCES
+ tsan_new_delete.cpp
+ )
+
+set(TSAN_PREINIT_SOURCES
+ tsan_preinit.cpp
+ )
+
+if(APPLE)
+ list(APPEND TSAN_SOURCES
+ tsan_interceptors_mac.cpp
+ tsan_interceptors_mach_vm.cpp
+ tsan_platform_mac.cpp
+ tsan_platform_posix.cpp
+ )
+elseif(UNIX)
+ # Assume Linux
+ list(APPEND TSAN_SOURCES
+ tsan_platform_linux.cpp
+ tsan_platform_posix.cpp
+ )
+endif()
+
+if(COMPILER_RT_INTERCEPT_LIBDISPATCH)
+ list(APPEND TSAN_SOURCES
+ tsan_interceptors_libdispatch.cpp
+ )
+ list(APPEND TSAN_RTL_CFLAGS ${COMPILER_RT_LIBDISPATCH_CFLAGS})
+endif()
+
+set(TSAN_HEADERS
+ tsan_clock.h
+ tsan_defs.h
+ tsan_dense_alloc.h
+ tsan_fd.h
+ tsan_flags.h
+ tsan_flags.inc
+ tsan_ignoreset.h
+ tsan_ilist.h
+ tsan_interceptors.h
+ tsan_interface.h
+ tsan_interface.inc
+ tsan_interface_ann.h
+ tsan_interface_java.h
+ tsan_mman.h
+ tsan_mutexset.h
+ tsan_platform.h
+ tsan_ppc_regs.h
+ tsan_report.h
+ tsan_rtl.h
+ tsan_shadow.h
+ tsan_stack_trace.h
+ tsan_suppressions.h
+ tsan_symbolize.h
+ tsan_sync.h
+ tsan_trace.h
+ tsan_update_shadow_word.inc
+ tsan_vector_clock.h
+ )
+
+set(TSAN_RUNTIME_LIBRARIES)
+add_compiler_rt_component(tsan)
+
+if("${CMAKE_C_FLAGS}" MATCHES "-Wno-(error=)?unused-command-line-argument")
+ set(EXTRA_CFLAGS "-Wno-error=unused-command-line-argument ${EXTRA_CFLAGS}")
+endif()
+
+if(APPLE)
+ # Ideally we would check the SDK version for the actual platform we are
+ # building for here. To make our lifes easier we assume the host SDK setup is
+ # sane and use the macOS SDK version as a proxy for aligned SDKs.
+ find_darwin_sdk_version(macosx_sdk_version "macosx")
+ if ("${macosx_sdk_version}" VERSION_LESS 10.12)
+ message(FATAL_ERROR "Building the TSan runtime requires at least macOS SDK 10.12 (or aligned SDK on other platforms)")
+ endif()
+
+ add_asm_sources(TSAN_ASM_SOURCES
+ tsan_rtl_amd64.S
+ tsan_rtl_aarch64.S
+ )
+
+ set(TSAN_LINK_LIBS ${SANITIZER_COMMON_LINK_LIBS})
+
+ add_weak_symbols("ubsan" WEAK_SYMBOL_LINK_FLAGS)
+ add_weak_symbols("sanitizer_common" WEAK_SYMBOL_LINK_FLAGS)
+
+ add_compiler_rt_runtime(clang_rt.tsan
+ SHARED
+ OS ${TSAN_SUPPORTED_OS}
+ ARCHS ${TSAN_SUPPORTED_ARCH}
+ SOURCES ${TSAN_SOURCES} ${TSAN_CXX_SOURCES} ${TSAN_ASM_SOURCES}
+ ADDITIONAL_HEADERS ${TSAN_HEADERS}
+ OBJECT_LIBS RTInterception
+ RTSanitizerCommon
+ RTSanitizerCommonLibc
+ RTSanitizerCommonCoverage
+ RTSanitizerCommonSymbolizer
+ RTUbsan
+ CFLAGS ${TSAN_RTL_CFLAGS}
+ LINK_FLAGS ${SANITIZER_COMMON_LINK_FLAGS} ${WEAK_SYMBOL_LINK_FLAGS}
+ LINK_LIBS ${TSAN_LINK_LIBS} objc
+ PARENT_TARGET tsan)
+ add_compiler_rt_object_libraries(RTTsan_dynamic
+ OS ${TSAN_SUPPORTED_OS}
+ ARCHS ${TSAN_SUPPORTED_ARCH}
+ SOURCES ${TSAN_SOURCES} ${TSAN_CXX_SOURCES} ${TSAN_ASM_SOURCES}
+ ADDITIONAL_HEADERS ${TSAN_HEADERS}
+ CFLAGS ${TSAN_RTL_CFLAGS})
+
+ # Build and check Go runtime.
+ set(BUILDGO_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/../go/buildgo.sh)
+ add_custom_target(GotsanRuntimeCheck
+ COMMAND env "CC=${CMAKE_C_COMPILER} ${OSX_SYSROOT_FLAG}"
+ EXTRA_CFLAGS=${EXTRA_CFLAGS}
+ IN_TMPDIR=1 SILENT=1 ${BUILDGO_SCRIPT}
+ DEPENDS tsan ${BUILDGO_SCRIPT}
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../go
+ COMMENT "Checking TSan Go runtime..."
+ VERBATIM)
+ set_target_properties(GotsanRuntimeCheck PROPERTIES FOLDER "Compiler-RT Misc")
+else()
+ foreach(arch ${TSAN_SUPPORTED_ARCH})
+ if(arch STREQUAL "x86_64")
+ add_asm_sources(TSAN_ASM_SOURCES
+ tsan_rtl_amd64.S
+ )
+ # Sanity check for Go runtime.
+ set(BUILDGO_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/../go/buildgo.sh)
+ add_custom_target(GotsanRuntimeCheck
+ COMMAND env "CC=${CMAKE_C_COMPILER} ${CMAKE_C_COMPILER_ARG1}"
+ EXTRA_CFLAGS=${EXTRA_CFLAGS}
+ IN_TMPDIR=1 SILENT=1 ${BUILDGO_SCRIPT}
+ DEPENDS clang_rt.tsan-${arch} ${BUILDGO_SCRIPT}
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../go
+ COMMENT "Checking TSan Go runtime..."
+ VERBATIM)
+ elseif(arch STREQUAL "aarch64")
+ add_asm_sources(TSAN_ASM_SOURCES
+ tsan_rtl_aarch64.S
+ )
+ # Sanity check for Go runtime.
+ set(BUILDGO_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/../go/buildgo.sh)
+ add_custom_target(GotsanRuntimeCheck
+ COMMAND env "CC=${CMAKE_C_COMPILER} ${CMAKE_C_COMPILER_ARG1}"
+ EXTRA_CFLAGS=${EXTRA_CFLAGS}
+ IN_TMPDIR=1 SILENT=1 ${BUILDGO_SCRIPT}
+ DEPENDS clang_rt.tsan-${arch} ${BUILDGO_SCRIPT}
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../go
+ COMMENT "Checking TSan Go runtime..."
+ VERBATIM)
+ elseif(arch MATCHES "powerpc64|powerpc64le")
+ add_asm_sources(TSAN_ASM_SOURCES
+ tsan_rtl_ppc64.S
+ )
+ # Sanity check for Go runtime.
+ set(BUILDGO_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/../go/buildgo.sh)
+ add_custom_target(GotsanRuntimeCheck
+ COMMAND env "CC=${CMAKE_C_COMPILER} ${CMAKE_C_COMPILER_ARG1}"
+ EXTRA_CFLAGS=${EXTRA_CFLAGS}
+ IN_TMPDIR=1 SILENT=1 ${BUILDGO_SCRIPT}
+ DEPENDS clang_rt.tsan-${arch} ${BUILDGO_SCRIPT}
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../go
+ COMMENT "Checking TSan Go runtime..."
+ VERBATIM)
+ elseif(arch MATCHES "mips64|mips64le")
+ add_asm_sources(TSAN_ASM_SOURCES
+ tsan_rtl_mips64.S
+ )
+ elseif(arch MATCHES "s390x")
+ add_asm_sources(TSAN_ASM_SOURCES
+ tsan_rtl_s390x.S
+ )
+ # Sanity check for Go runtime.
+ set(BUILDGO_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/../go/buildgo.sh)
+ add_custom_target(GotsanRuntimeCheck
+ COMMAND env "CC=${CMAKE_C_COMPILER} ${CMAKE_C_COMPILER_ARG1}"
+ EXTRA_CFLAGS=${EXTRA_CFLAGS}
+ IN_TMPDIR=1 SILENT=1 ${BUILDGO_SCRIPT}
+ DEPENDS clang_rt.tsan-${arch} ${BUILDGO_SCRIPT}
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../go
+ COMMENT "Checking TSan Go runtime..."
+ VERBATIM)
+ else()
+ set(TSAN_ASM_SOURCES)
+ endif()
+ add_compiler_rt_runtime(clang_rt.tsan
+ STATIC
+ ARCHS ${arch}
+ SOURCES ${TSAN_SOURCES} ${TSAN_ASM_SOURCES} ${TSAN_PREINIT_SOURCES}
+ $<TARGET_OBJECTS:RTInterception.${arch}>
+ $<TARGET_OBJECTS:RTSanitizerCommon.${arch}>
+ $<TARGET_OBJECTS:RTSanitizerCommonLibc.${arch}>
+ $<TARGET_OBJECTS:RTSanitizerCommonCoverage.${arch}>
+ $<TARGET_OBJECTS:RTSanitizerCommonSymbolizer.${arch}>
+ $<TARGET_OBJECTS:RTUbsan.${arch}>
+ ADDITIONAL_HEADERS ${TSAN_HEADERS}
+ CFLAGS ${TSAN_RTL_CFLAGS}
+ PARENT_TARGET tsan)
+ add_compiler_rt_runtime(clang_rt.tsan_cxx
+ STATIC
+ ARCHS ${arch}
+ SOURCES ${TSAN_CXX_SOURCES}
+ $<TARGET_OBJECTS:RTUbsan_cxx.${arch}>
+ ADDITIONAL_HEADERS ${TSAN_HEADERS}
+ CFLAGS ${TSAN_RTL_CFLAGS}
+ PARENT_TARGET tsan)
+ list(APPEND TSAN_RUNTIME_LIBRARIES clang_rt.tsan-${arch}
+ clang_rt.tsan_cxx-${arch})
+ add_compiler_rt_runtime(clang_rt.tsan
+ SHARED
+ ARCHS ${arch}
+ SOURCES ${TSAN_SOURCES} ${TSAN_ASM_SOURCES}
+ $<TARGET_OBJECTS:RTInterception.${arch}>
+ $<TARGET_OBJECTS:RTSanitizerCommon.${arch}>
+ $<TARGET_OBJECTS:RTSanitizerCommonLibc.${arch}>
+ $<TARGET_OBJECTS:RTSanitizerCommonCoverage.${arch}>
+ $<TARGET_OBJECTS:RTSanitizerCommonSymbolizer.${arch}>
+ $<TARGET_OBJECTS:RTUbsan.${arch}>
+ ADDITIONAL_HEADERS ${TSAN_HEADERS}
+ CFLAGS ${TSAN_RTL_DYNAMIC_CFLAGS}
+ LINK_LIBS ${TSAN_DYNAMIC_LINK_LIBS}
+ LINK_FLAGS ${SANITIZER_COMMON_LINK_FLAGS}
+ PARENT_TARGET tsan)
+ add_sanitizer_rt_symbols(clang_rt.tsan
+ ARCHS ${arch}
+ EXTRA tsan.syms.extra)
+ add_sanitizer_rt_symbols(clang_rt.tsan_cxx
+ ARCHS ${arch}
+ EXTRA tsan.syms.extra)
+ add_dependencies(tsan clang_rt.tsan-${arch}
+ clang_rt.tsan_cxx-${arch}
+ clang_rt.tsan-${arch}-symbols
+ clang_rt.tsan_cxx-${arch}-symbols)
+ endforeach()
+endif()
+
+
diff --git a/llvm/utils/gn/secondary/compiler-rt/lib/BUILD.gn b/llvm/utils/gn/secondary/compiler-rt/lib/BUILD.gn
index 09ff20d2fe1a5..e2b67667d3790 100644
--- a/llvm/utils/gn/secondary/compiler-rt/lib/BUILD.gn
+++ b/llvm/utils/gn/secondary/compiler-rt/lib/BUILD.gn
@@ -15,7 +15,7 @@ group("lib") {
"//compiler-rt/lib/builtins",
]
if (current_cpu == "x64" || current_cpu == "arm64") {
- deps += [ "//compiler-rt/lib/tsan" ]
+ deps += [ "//compiler-rt/lib/tsan/rtl" ]
}
}
}
diff --git a/llvm/utils/gn/secondary/compiler-rt/lib/tsan/BUILD.gn b/llvm/utils/gn/secondary/compiler-rt/lib/tsan/rtl/BUILD.gn
similarity index 59%
rename from llvm/utils/gn/secondary/compiler-rt/lib/tsan/BUILD.gn
rename to llvm/utils/gn/secondary/compiler-rt/lib/tsan/rtl/BUILD.gn
index 89d30827cd74c..197008ce45b14 100644
--- a/llvm/utils/gn/secondary/compiler-rt/lib/tsan/BUILD.gn
+++ b/llvm/utils/gn/secondary/compiler-rt/lib/tsan/rtl/BUILD.gn
@@ -3,7 +3,7 @@ import("//compiler-rt/target.gni")
source_set("cxx_sources") {
configs -= [ "//llvm/utils/gn/build:llvm_code" ]
configs += [ "//llvm/utils/gn/build:crt_code" ]
- sources = [ "rtl/tsan_new_delete.cpp" ]
+ sources = [ "tsan_new_delete.cpp" ]
}
if (current_os == "mac") {
@@ -12,7 +12,7 @@ if (current_os == "mac") {
tsan_target_type = "static_library"
}
-target(tsan_target_type, "tsan") {
+target(tsan_target_type, "rtl") {
configs -= [ "//llvm/utils/gn/build:llvm_code" ]
configs += [ "//llvm/utils/gn/build:crt_code" ]
@@ -46,88 +46,88 @@ target(tsan_target_type, "tsan") {
cflags = [ "-fPIE" ]
sources = [
- "rtl/tsan_clock.cpp",
- "rtl/tsan_clock.h",
- "rtl/tsan_debugging.cpp",
- "rtl/tsan_defs.h",
- "rtl/tsan_dense_alloc.h",
- "rtl/tsan_external.cpp",
- "rtl/tsan_fd.cpp",
- "rtl/tsan_fd.h",
- "rtl/tsan_flags.cpp",
- "rtl/tsan_flags.h",
- "rtl/tsan_flags.inc",
- "rtl/tsan_ignoreset.cpp",
- "rtl/tsan_ignoreset.h",
- "rtl/tsan_ilist.h",
- "rtl/tsan_interceptors.h",
- "rtl/tsan_interceptors_posix.cpp",
- "rtl/tsan_interface.cpp",
- "rtl/tsan_interface.h",
- "rtl/tsan_interface.inc",
- "rtl/tsan_interface_ann.cpp",
- "rtl/tsan_interface_ann.h",
- "rtl/tsan_interface_atomic.cpp",
- "rtl/tsan_interface_java.cpp",
- "rtl/tsan_interface_java.h",
- "rtl/tsan_malloc_mac.cpp",
- "rtl/tsan_md5.cpp",
- "rtl/tsan_mman.cpp",
- "rtl/tsan_mman.h",
- "rtl/tsan_mutexset.cpp",
- "rtl/tsan_mutexset.h",
- "rtl/tsan_platform.h",
- "rtl/tsan_ppc_regs.h",
- "rtl/tsan_preinit.cpp",
- "rtl/tsan_report.cpp",
- "rtl/tsan_report.h",
- "rtl/tsan_rtl.cpp",
- "rtl/tsan_rtl.h",
- "rtl/tsan_rtl_access.cpp",
- "rtl/tsan_rtl_mutex.cpp",
- "rtl/tsan_rtl_proc.cpp",
- "rtl/tsan_rtl_report.cpp",
- "rtl/tsan_rtl_thread.cpp",
- "rtl/tsan_shadow.h",
- "rtl/tsan_stack_trace.cpp",
- "rtl/tsan_stack_trace.h",
- "rtl/tsan_suppressions.cpp",
- "rtl/tsan_suppressions.h",
- "rtl/tsan_symbolize.cpp",
- "rtl/tsan_symbolize.h",
- "rtl/tsan_sync.cpp",
- "rtl/tsan_sync.h",
- "rtl/tsan_trace.h",
- "rtl/tsan_update_shadow_word.inc",
- "rtl/tsan_vector_clock.cpp",
- "rtl/tsan_vector_clock.h",
+ "tsan_clock.cpp",
+ "tsan_clock.h",
+ "tsan_debugging.cpp",
+ "tsan_defs.h",
+ "tsan_dense_alloc.h",
+ "tsan_external.cpp",
+ "tsan_fd.cpp",
+ "tsan_fd.h",
+ "tsan_flags.cpp",
+ "tsan_flags.h",
+ "tsan_flags.inc",
+ "tsan_ignoreset.cpp",
+ "tsan_ignoreset.h",
+ "tsan_ilist.h",
+ "tsan_interceptors.h",
+ "tsan_interceptors_posix.cpp",
+ "tsan_interface.cpp",
+ "tsan_interface.h",
+ "tsan_interface.inc",
+ "tsan_interface_ann.cpp",
+ "tsan_interface_ann.h",
+ "tsan_interface_atomic.cpp",
+ "tsan_interface_java.cpp",
+ "tsan_interface_java.h",
+ "tsan_malloc_mac.cpp",
+ "tsan_md5.cpp",
+ "tsan_mman.cpp",
+ "tsan_mman.h",
+ "tsan_mutexset.cpp",
+ "tsan_mutexset.h",
+ "tsan_platform.h",
+ "tsan_ppc_regs.h",
+ "tsan_preinit.cpp",
+ "tsan_report.cpp",
+ "tsan_report.h",
+ "tsan_rtl.cpp",
+ "tsan_rtl.h",
+ "tsan_rtl_access.cpp",
+ "tsan_rtl_mutex.cpp",
+ "tsan_rtl_proc.cpp",
+ "tsan_rtl_report.cpp",
+ "tsan_rtl_thread.cpp",
+ "tsan_shadow.h",
+ "tsan_stack_trace.cpp",
+ "tsan_stack_trace.h",
+ "tsan_suppressions.cpp",
+ "tsan_suppressions.h",
+ "tsan_symbolize.cpp",
+ "tsan_symbolize.h",
+ "tsan_sync.cpp",
+ "tsan_sync.h",
+ "tsan_trace.h",
+ "tsan_update_shadow_word.inc",
+ "tsan_vector_clock.cpp",
+ "tsan_vector_clock.h",
]
if (target_os == "mac") {
sources += [
- "rtl/tsan_interceptors_libdispatch.cpp",
- "rtl/tsan_interceptors_mac.cpp",
- "rtl/tsan_interceptors_mach_vm.cpp",
- "rtl/tsan_platform_mac.cpp",
- "rtl/tsan_platform_posix.cpp",
+ "tsan_interceptors_libdispatch.cpp",
+ "tsan_interceptors_mac.cpp",
+ "tsan_interceptors_mach_vm.cpp",
+ "tsan_platform_mac.cpp",
+ "tsan_platform_posix.cpp",
]
cflags += [ "-fblocks" ]
} else {
# Assume Linux
sources += [
- "rtl/tsan_platform_linux.cpp",
- "rtl/tsan_platform_posix.cpp",
+ "tsan_platform_linux.cpp",
+ "tsan_platform_posix.cpp",
]
}
if (target_cpu == "x64") {
- sources += [ "rtl/tsan_rtl_amd64.S" ]
+ sources += [ "tsan_rtl_amd64.S" ]
} else if (target_cpu == "arm64") {
- sources += [ "rtl/tsan_rtl_aarch64.S" ]
+ sources += [ "tsan_rtl_aarch64.S" ]
} else if (target_cpu == "powerpc64") {
- sources += [ "rtl/tsan_rtl_ppc64.S" ]
+ sources += [ "tsan_rtl_ppc64.S" ]
} else if (target_cpu == "mips64") {
- sources += [ "rtl/tsan_rtl_mips64.S" ]
+ sources += [ "tsan_rtl_mips64.S" ]
} else if (target_cpu == "s390x") {
- sources += [ "rtl/tsan_rtl_s390x.S" ]
+ sources += [ "tsan_rtl_s390x.S" ]
}
# To be able to include sanitizer_common.
More information about the llvm-commits
mailing list