-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Enable #[thread_local]
for all windows-msvc targets
#92042
Conversation
r? @nagisa (rust-highfive has picked a reviewer for you, use r? to override) |
|
@@ -27,6 +27,7 @@ pub fn opts() -> TargetOptions { | |||
// linking some libraries which require a specific agreement, so it may | |||
// not ever be possible for us to pass this flag. | |||
no_default_libraries: false, | |||
has_elf_tls: true, |
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.
I think this field wants a rename to something like has_thread_local
or something of a similar nature?
EDIT: reading the issue, yeah it is fine to rename target fields.
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.
has_thread_local
sounds ok to me! If anybody wants to bikeshed the name I don't mind changing it again but it's probably not worth arguing about it too much 🙂.
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.
Are we sure that this field is never used in some ELF-specific way?
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.
Hm, well if it is then it was wrong to use it for msvc targets. But I did do a search and the only place it's used (other than specs) is here:
rust/compiler/rustc_session/src/config.rs
Lines 883 to 885 in c5ecc15
if sess.target.has_elf_tls { | |
ret.insert((sym::target_thread_local, None)); | |
} |
As far as I understand it, Rust defers to LLVM for actually generating the TLS access (it uses the LLVM IR thread_local
).
Hm, one thing that's curious to me is that we have a test Can you confirm this test is run on Windows? |
Yes it runs. But it succeeds regardless of if EDIT EDIT: Hm, I think |
/// this target. | ||
pub has_elf_tls: bool, | ||
/// Flag indicating whether #[thread_local] is available for this target. | ||
pub has_thread_local: bool, |
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.
Maybe call it has_object_thread_local
? This indicates whether thread locals are supported by the used object file format, not whether thread locals in general are supported. thread_local!{}
works even if this is false.
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.
has_target_thread_local
also makes sense. This matches the #[cfg(target_thread_local)]
attribute whose value it controls.
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.
has_target_thread_local
also makes sense.
This is already in the context of Target
though and many other fields don't have this prefix in target spec but has one as the cfg variable.
Some other options: has_static_thread_local
(as in “static initailizers”), has_native_thread_local
…
@bors r+ I think it is fine if we rename the field again if |
📌 Commit 391332c has been approved by |
…askrgr Rollup of 7 pull requests Successful merges: - rust-lang#91141 (Revert "Temporarily rename int_roundings functions to avoid conflicts") - rust-lang#91984 (Remove `in_band_lifetimes` from `rustc_middle`) - rust-lang#92028 (Sync portable-simd to fix libcore build for AVX-512 enabled targets) - rust-lang#92042 (Enable `#[thread_local]` for all windows-msvc targets) - rust-lang#92071 (Update example code for Vec::splice to change the length) - rust-lang#92077 (rustdoc: Remove unused `collapsed` field) - rust-lang#92081 (rustdoc: Remove unnecessary `need_backline` function) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Should the naming discussion be continued on the original issue? |
Seems reasonable to do so. Or in a new issue entirely. |
I noticed this has a regression on Unfortunately I can't provide a minimal reproducible example, but I'm sure turning off |
@quininer oh dear, that means our CI tests aren't able to tell when this regresses. This will likely need to be reverted again. But first would it be at all possible for you test this PR? No worries if not but it'd be nice to know if it helps your case or not. |
@ChrisDenton Sorry, due to COVID-19 I need to WFH, so there is no windows7 device can to test at the moment. |
As it stands,
#[thread_local]
is enabled haphazardly for msvc. It seems all 64-bit targets have it enabled, but not 32-bit targets unless they're also UWP targets (perhaps because UWP was added more recently?). So this PR simply enables it for 32-bit targets as well. I can't think of a reason not to and I've confirmed by running tests locally which pass.See also #91659