File tree 4 files changed +17
-6
lines changed
4 files changed +17
-6
lines changed Original file line number Diff line number Diff line change @@ -10,4 +10,5 @@ add_swift_host_library(swiftThreading STATIC
10
10
Linux.cpp
11
11
Pthreads.cpp
12
12
Win32 .cpp
13
- Errors.cpp)
13
+ Errors.cpp
14
+ ThreadSanitizer.cpp)
Original file line number Diff line number Diff line change 25
25
namespace swift {
26
26
namespace threading_impl {
27
27
28
- SWIFT_RUNTIME_EXPORT bool _swift_tsan_enabled = false ;
29
- SWIFT_RUNTIME_EXPORT void (*_swift_tsan_acquire)(const void *) = nullptr;
30
- SWIFT_RUNTIME_EXPORT void (*_swift_tsan_release)(const void *) = nullptr;
28
+ extern " C" SWIFT_ATTRIBUTE_FOR_EXPORTS
29
+ bool _swift_tsan_enabled = false ;
30
+ extern " C" SWIFT_ATTRIBUTE_FOR_EXPORTS
31
+ void (*_swift_tsan_acquire)(const void *) = nullptr ;
32
+ extern " C" SWIFT_ATTRIBUTE_FOR_EXPORTS
33
+ void (*_swift_tsan_release)(const void *) = nullptr ;
31
34
32
35
#if __has_include(<dlfcn.h>)
33
36
#include < dlfcn.h>
34
37
35
38
// The TSan library code will call this function when it starts up
36
- SWIFT_RUNTIME_EXPORT
39
+ extern " C " SWIFT_ATTRIBUTE_FOR_EXPORTS
37
40
void __tsan_on_initialize () {
38
41
_swift_tsan_enabled = true ;
39
42
_swift_tsan_acquire = (void (*)(const void *))dlsym (RTLD_DEFAULT,
Original file line number Diff line number Diff line change 4
4
list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR} /../../cmake/modules" )
5
5
include (AddSwiftStdlib)
6
6
7
+ # This should *not* include ThreadSanitizer.cpp, as that is part of libswiftCore
7
8
add_swift_target_library(swiftThreading OBJECT_LIBRARY
8
9
"${SWIFT_SOURCE_DIR} /lib/Threading/C11.cpp"
9
10
"${SWIFT_SOURCE_DIR} /lib/Threading/Linux.cpp"
Original file line number Diff line number Diff line change @@ -76,11 +76,16 @@ set(swift_runtime_sources
76
76
SwiftDtoa.cpp
77
77
SwiftTLSContext.cpp
78
78
ThreadingError.cpp
79
- ThreadSanitizer.cpp
80
79
Tracing.cpp
81
80
AccessibleFunction.cpp
82
81
Win32 .cpp)
83
82
83
+ # We pull this in separately here because other dylibs will need it, but only
84
+ # will have the __tsan_on_initialize called, and on Darwin, RTLD_NEXT can't be
85
+ # used to call subsequence dylibs' copies of that.
86
+ set (swift_runtime_threading_sources
87
+ ${SWIFT_SOURCE_DIR} /lib/Threading/ThreadSanitizer.cpp)
88
+
84
89
set (swift_runtime_backtracing_sources
85
90
Backtrace.cpp
86
91
CrashHandlerMacOS.cpp
@@ -133,6 +138,7 @@ add_swift_target_library(swiftRuntime OBJECT_LIBRARY
133
138
${swift_runtime_sources}
134
139
${swift_runtime_objc_sources}
135
140
${swift_runtime_leaks_sources}
141
+ ${swift_runtime_threading_sources}
136
142
C_COMPILE_FLAGS
137
143
${swift_runtime_library_compile_flags}
138
144
LINK_FLAGS ${swift_runtime_linker_flags}
You can’t perform that action at this time.
0 commit comments