-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Make the LocalKey facade of thread_local! inlineable cross-crate. #43931
Conversation
This doesn't work on stage0 apparently. |
@oli-obk Fixing. |
48c6988
to
2040db1
Compare
Awesome, looks great! One thing I noticed locally was that the Regardless of that decision r=me, just wanted to see what you thought |
Ah I didn't think much about it but in the cheap cases it'd definitely help. @bors r=alexcrichton |
📌 Commit ee1a970 has been approved by |
⌛ Testing commit ee1a970513d32d8a748e446d10b093f6d79225ea with merge 414b93e932ec81413dddc3d011c8f0a3f5a6145c... |
💔 Test failed - status-appveyor |
@bors retry Failed to build
|
⌛ Testing commit ee1a970513d32d8a748e446d10b093f6d79225ea with merge b60970f3ff1d0716c7ff153db0412ce677ea0e9b... |
💔 Test failed - status-appveyor |
Same issue. Legit. @eddyb |
Same failure. I have |
Perhaps a bug in the rvalue promotion to |
@kennytm That |
EDIT: I'm dumb, MSVC doesn't use OS TLS, so it's the fast TLS that's broken... |
@alexcrichton Weren't there some oddities ages ago, back in the old runtime, where some of the thread-local accesses had to be in non- |
@alexcrichton Do you think not having |
Personally, not really, but you seem eager to land this so I won't stop you if you'd like to do that. If you do, though, please leave a comment with as much information that you know. |
friendly ping @eddyb to keep this on your radar! |
@bors: r- This got back in the queue... |
… in order to limit stack frame sizes after extra inlining from rust-lang/rust#43931 See #18420 (comment)
… in order to limit stack frame sizes after extra inlining from rust-lang/rust#43931 See #18420 (comment)
Issue rust-lang#25088 has been part of `thread_local!` for quite some time now. Historical attempts have been made to add `#[inline]` to `__getit` in rust-lang#43931, rust-lang#50252, and rust-lang#59720, but these attempts ended up not landing at the time due to segfaults on Windows. In the interim though with `const`-initialized thread locals AFAIK this is the only remaining bug which is why you might want to use `#[thread_local]` over `thread_local!`. As a result I figured it was time to resubmit this and see how it fares on CI and if I can help debugging any issues that crop up. Closes rust-lang#25088
…ss-crate, r=Mark-Simulacrum std: Attempt again to inline thread-local-init across crates Issue rust-lang#25088 has been part of `thread_local!` for quite some time now. Historical attempts have been made to add `#[inline]` to `__getit` in rust-lang#43931, rust-lang#50252, and rust-lang#59720, but these attempts ended up not landing at the time due to segfaults on Windows. In the interim though with `const`-initialized thread locals AFAIK this is the only remaining bug which is why you might want to use `#[thread_local]` over `thread_local!`. As a result I figured it was time to resubmit this and see how it fares on CI and if I can help debugging any issues that crop up. Closes rust-lang#25088
Fixes (almost*) #25088 by changing the
LocalKey
static
thread_local!
generates to aconst
.This can be done because a
LocalKey
value holds no actual TLS data, only function pointers to get at said data, and it could even be madeCopy
without any negative consequences.The recent stabilization of rvalue promotion to
'static
allows doing this without changing the API.r? @alexcrichton
*almost because we can't yet inline
__getit
because it breaks on MSVC, see #43931 (comment)