Run TLS destructors for wasm32-wasip1-threads - #133472
Conversation
The target has support for pthreads and allows registration of TLS destructors.
commented
Nov 25, 2024
|
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @jhpratt (or someone else) some time within the next two weeks. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
|
|
As suggested I have switched to using the UNIX thread_local implementation for WASI. For now I have added the missing |
|
Note that the new implementation shows the behavior described in #28129. However, this is consistent with the behavior of other UNIX platforms. I tested on FreeBSD and there TLS destructors are also not run for the main thread. |
commented
Dec 3, 2024
|
I have created follow-up PR #133819 that deals with calling TLS destructors when the main thread exits on UNIX platforms other than Linux. |
commented
Dec 4, 2024
|
r? @joboet You seem to have more knowledge of how this works, so feel free to take it over. I don't see anything wrong with the PR, though. |
commented
Dec 4, 2024
Great, thanks!
I'm totally OK with temporarily adding these here. A PR on
Considering that this is documented as a caveat, I think this is fine for now, especially since this PR is already a big improvement over the status quo.
Cool, I'll have a look soon! @bors r+ |
commented
Dec 4, 2024
|
I believe this failed in rollup: Included the @bors r- |
commented
Dec 5, 2024
|
This was caused by not distinguishing between Should be fixed now. |
commented
Dec 5, 2024
|
@rustbot review |
commented
Dec 9, 2024
|
@bors r+ |
commented
Dec 9, 2024
| target_family = "unix", | ||
| ), | ||
| target_os = "teeos", | ||
| all(target_os = "wasi", target_env = "p1", target_feature = "atomics"), |
There was a problem hiding this comment.
When users compile to wasm32-wasip1-threads, they don't necessarily enable target_feature = "atomics", but the rust-std of wasm32-wasip1-threads always enables atomics, which causes some issues: #137510.
The target wasm32-wasip1-threads has support for pthreads and allows registration of TLS destructors.
For spawned threads, this registers Rust TLS destructors by creating a pthreads key with an attached destructor function.
For the main thread, this registers an
atexithandler to run the TLS destructors.try-job: test-various