Commit Graph

22 Commits

Author SHA1 Message Date
Alastair Houghton
bad716f2cd [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
2023-06-19 17:00:39 +01:00
Alastair Houghton
8ed8a28478 [Threading][TSan] Move ThreadSanitizer.cpp into the main runtime.
On Darwin, `RTLD_NEXT` doesn't do what we need it to here, with the
result that if `libswiftCore`'s TSan initializer gets found first,
then `libswift_Concurrency` won't have its initializer called at all,
in spite of us using `RTLD_NEXT` to find the next definition.

Fix this by centralising the initializer in `libswiftCore` instead.

rdar://110665213
2023-06-19 15:33:36 +01:00
Alastair Houghton
ee5efff5b1 [Threading][TSan] Update after review comments.
* Use the longer name ThreadSanitizer rather than TSan for the new files.
* Don't implement `tsan::consume` at all for now.
* Do the `tsan::release` for `ulock_unlock()` at the head of the function,
  not at the tail.
* Add a comment to test/Sanitizers/tsan/once.swift to explain the test a
  little more clearly.

rdar://110665213
2023-06-19 15:32:50 +01:00
Alastair Houghton
41f46ec085 [Threading][TSan] Fix TSan errors from lazy init on Linux.
Move the TSan functionality from Concurrency into Threading.  Use it
in the Linux `ulock` implementation so that TSan knows about `ulock`
and will tolerate the newer `swift_once` implementation that uses it.

rdar://110665213
2023-06-19 15:32:50 +01:00
Alastair Houghton
a12490fd86 [Runtime] Move swiftCompatibilityThreading to toolchain.
This is the right place for it, and simplifies a few other things.

rdar://99125585
2022-08-25 09:14:10 +01:00
Alastair Houghton
df9332795d [Threading] Fix compatibility library deployment target issue.
The threading library is being pulled into the compatibility libraries,
but in order to do that we need to make sure it gets built with the
correct deployment target.  (Which means we need a special version for
the compatibility libraries.)

rdar://96690200
2022-07-12 08:24:05 +01:00
Alastair Houghton
c46d4af0e9 [Build] Explicitly include threading library when not building stdlib.
The threading code is required by some of the compatibility modules,
but we weren't pulling it in unless we were building the standard library.
That breaks the build when the standard library build is disabled, so
explicitly include it.

rdar://90776105
2022-06-07 07:40:54 +01:00
Alastair Houghton
c7c1c1be80 [Threading] Fix some problems with the C11 threading code.
These changes are needed to get things building with a C11 threads shim
header on macOS.

rdar://90776105
2022-06-07 07:39:53 +01:00
Alastair Houghton
f3a412dd53 [Threading] Remove thread_get_main().
Removing thread_get_main() means we don't need a static initializer on
Darwin, which means we can delete Darwin.cpp as well.  We can also delete
Nothreads.cpp while we're about it, because there's nothing in that file.

rdar://90776105
2022-06-07 07:39:53 +01:00
Alastair Houghton
14a4bd45b6 [Concurrency][Threading] Remove use of platform thread functions.
The concurrency library can use the new threading library functions,
which avoids the problem of including <windows.h>.

rdar://90776105
2022-06-07 07:39:52 +01:00
Alastair Houghton
8615983174 [Build] Fix static linking.
When we static link against libswiftCore, we need it to contain the
actual object modules from the threading library (when it's dynamically
linked, the shared object will already contain those modules because it's
been linked against libswiftThreading), which means that the threading
library in the stdlib needs to be an OBJECT_LIBRARY rather than a STATIC
library (otherwise people will have to statically link against the
threading library as well, and that'll need to be installed, and we don't
want that).

rdar://90776105
2022-06-07 07:39:52 +01:00
Alastair Houghton
6d1b6dbd1c [Threading] Fix the Linux build.
A few fixes specifically for the Linux build.

rdar://90776105
2022-06-07 07:39:52 +01:00
Alastair Houghton
e934cbcf23 [Threading] Fix case sensitivity bug.
The file is called Nothreads.cpp, not NoThreads.cpp.

rdar://90776105
2022-06-07 07:39:51 +01:00
Alastair Houghton
f5bdb858e0 [Threading] Create new threading library and use it.
Moved all the threading code to one place.  Added explicit support for
Darwin, Linux, Pthreads, C11 threads and Win32 threads, including new
implementations of Once for Linux, Pthreads, C11 and Win32.

rdar://90776105
2022-06-07 07:39:51 +01:00
Alex Hoppen
4aa2bbbf06 Revert "Merge pull request #42447 from al45tair/eng/PR-90776105"
This reverts commit 8bcb71140f, reversing
changes made to c4dd271d36.
2022-06-02 18:03:23 +02:00
Alastair Houghton
2884ddbc3e [Threading] Fix some problems with the C11 threading code.
These changes are needed to get things building with a C11 threads shim
header on macOS.

rdar://90776105
2022-05-24 14:57:42 +01:00
Alastair Houghton
6e875dacc9 [Threading] Remove thread_get_main().
Removing thread_get_main() means we don't need a static initializer on
Darwin, which means we can delete Darwin.cpp as well.  We can also delete
Nothreads.cpp while we're about it, because there's nothing in that file.

rdar://90776105
2022-05-24 14:57:41 +01:00
Alastair Houghton
c034d6c3da [Concurrency][Threading] Remove use of platform thread functions.
The concurrency library can use the new threading library functions,
which avoids the problem of including <windows.h>.

rdar://90776105
2022-05-24 14:57:41 +01:00
Alastair Houghton
982aa29817 [Build] Fix static linking.
When we static link against libswiftCore, we need it to contain the
actual object modules from the threading library (when it's dynamically
linked, the shared object will already contain those modules because it's
been linked against libswiftThreading), which means that the threading
library in the stdlib needs to be an OBJECT_LIBRARY rather than a STATIC
library (otherwise people will have to statically link against the
threading library as well, and that'll need to be installed, and we don't
want that).

rdar://90776105
2022-05-24 14:57:40 +01:00
Alastair Houghton
fc90280e34 [Threading] Fix the Linux build.
A few fixes specifically for the Linux build.

rdar://90776105
2022-05-24 14:57:39 +01:00
Alastair Houghton
c37c146d32 [Threading] Fix case sensitivity bug.
The file is called Nothreads.cpp, not NoThreads.cpp.

rdar://90776105
2022-05-24 14:57:39 +01:00
Alastair Houghton
63a09007a1 [Threading] Create new threading library and use it.
Moved all the threading code to one place.  Added explicit support for
Darwin, Linux, Pthreads, C11 threads and Win32 threads, including new
implementations of Once for Linux, Pthreads, C11 and Win32.

rdar://90776105
2022-05-24 14:57:39 +01:00