-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
Run TLS destructors for wasm32-wasip1-threads #133472
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The target has support for pthreads and allows registration of TLS destructors.
|
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. |
|
I have created follow-up PR #133819 that deals with calling TLS destructors when the main thread exits on UNIX platforms other than Linux. |
|
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. |
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+ |
|
I believe this failed in rollup: Included the @bors r- |
|
This was caused by not distinguishing between Should be fixed now. |
|
@rustbot review |
|
@bors r+ |
| target_family = "unix", | ||
| ), | ||
| target_os = "teeos", | ||
| all(target_os = "wasi", target_env = "p1", target_feature = "atomics"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this to #137510 (comment)
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