Skip to content

Unify TLS destructor list implementations#116850

Closed
joboet wants to merge 4 commits intorust-lang:masterfrom
joboet:unify_tls_dtor_lists
Closed

Unify TLS destructor list implementations#116850
joboet wants to merge 4 commits intorust-lang:masterfrom
joboet:unify_tls_dtor_lists

Conversation

@joboet
Copy link
Member

@joboet joboet commented Oct 17, 2023

Part of #110897.

Currently, nearly every platform implements its own TLS destructor list. This adds unnecessary code and means that issues like #116390 are harder to find and fix. Therefore, this PR unifies all of these implementations into a shared one inside sys::common::fast_local, leaving behind only the platform calls needed to ensure the list is emptied.

This changes behaviour on some Linux-like platforms, because we now keep our own list. This should however not impact performance too much, as the platform calls would also have needed to allocate.

Because it is only used on UNIX and is now much easier, I've removed the fallback implementation in sys_common. Because StaticKey may now be unused, this resulted in errors for Windows, which is why I have refactored that code to move the at-exit hack to the new thread_local_guard module. If it causes too much review pain, I can split this part out.

Tested on aarch64 macOS, checked on all other platforms. Best reviewed per-commit.

@rustbot label +T-libs +A-thread-locals

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

O-hermit Operating System: Hermit O-itron Operating System: ITRON O-solid Operating System: SOLID O-unix Operating system: Unix-like O-windows Operating system: Windows S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants