mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[Threading][TSan] Rearrange things again.
We need ThreadSanitizer.cpp in libswiftCore for the runtime case, but we also need it in libswiftThreading for non-runtime cases. rdar://1106655213
This commit is contained in:
@@ -10,4 +10,5 @@ add_swift_host_library(swiftThreading STATIC
|
||||
Linux.cpp
|
||||
Pthreads.cpp
|
||||
Win32.cpp
|
||||
Errors.cpp)
|
||||
Errors.cpp
|
||||
ThreadSanitizer.cpp)
|
||||
|
||||
@@ -25,15 +25,18 @@
|
||||
namespace swift {
|
||||
namespace threading_impl {
|
||||
|
||||
SWIFT_RUNTIME_EXPORT bool _swift_tsan_enabled = false;
|
||||
SWIFT_RUNTIME_EXPORT void (*_swift_tsan_acquire)(const void *) = nullptr;
|
||||
SWIFT_RUNTIME_EXPORT void (*_swift_tsan_release)(const void *) = nullptr;
|
||||
extern "C" SWIFT_ATTRIBUTE_FOR_EXPORTS
|
||||
bool _swift_tsan_enabled = false;
|
||||
extern "C" SWIFT_ATTRIBUTE_FOR_EXPORTS
|
||||
void (*_swift_tsan_acquire)(const void *) = nullptr;
|
||||
extern "C" SWIFT_ATTRIBUTE_FOR_EXPORTS
|
||||
void (*_swift_tsan_release)(const void *) = nullptr;
|
||||
|
||||
#if __has_include(<dlfcn.h>)
|
||||
#include <dlfcn.h>
|
||||
|
||||
// The TSan library code will call this function when it starts up
|
||||
SWIFT_RUNTIME_EXPORT
|
||||
extern "C" SWIFT_ATTRIBUTE_FOR_EXPORTS
|
||||
void __tsan_on_initialize() {
|
||||
_swift_tsan_enabled = true;
|
||||
_swift_tsan_acquire = (void (*)(const void *))dlsym(RTLD_DEFAULT,
|
||||
@@ -4,6 +4,7 @@
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/modules")
|
||||
include(AddSwiftStdlib)
|
||||
|
||||
# This should *not* include ThreadSanitizer.cpp, as that is part of libswiftCore
|
||||
add_swift_target_library(swiftThreading OBJECT_LIBRARY
|
||||
"${SWIFT_SOURCE_DIR}/lib/Threading/C11.cpp"
|
||||
"${SWIFT_SOURCE_DIR}/lib/Threading/Linux.cpp"
|
||||
|
||||
@@ -76,11 +76,16 @@ set(swift_runtime_sources
|
||||
SwiftDtoa.cpp
|
||||
SwiftTLSContext.cpp
|
||||
ThreadingError.cpp
|
||||
ThreadSanitizer.cpp
|
||||
Tracing.cpp
|
||||
AccessibleFunction.cpp
|
||||
Win32.cpp)
|
||||
|
||||
# We pull this in separately here because other dylibs will need it, but only
|
||||
# will have the __tsan_on_initialize called, and on Darwin, RTLD_NEXT can't be
|
||||
# used to call subsequence dylibs' copies of that.
|
||||
set(swift_runtime_threading_sources
|
||||
${SWIFT_SOURCE_DIR}/lib/Threading/ThreadSanitizer.cpp)
|
||||
|
||||
set(swift_runtime_backtracing_sources
|
||||
Backtrace.cpp
|
||||
CrashHandlerMacOS.cpp
|
||||
@@ -133,6 +138,7 @@ add_swift_target_library(swiftRuntime OBJECT_LIBRARY
|
||||
${swift_runtime_sources}
|
||||
${swift_runtime_objc_sources}
|
||||
${swift_runtime_leaks_sources}
|
||||
${swift_runtime_threading_sources}
|
||||
C_COMPILE_FLAGS
|
||||
${swift_runtime_library_compile_flags}
|
||||
LINK_FLAGS ${swift_runtime_linker_flags}
|
||||
|
||||
Reference in New Issue
Block a user