-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
Check target definitions to see if more should have cfg(target_thread_local) enabled. #91659
Copy link
Copy link
Open
Labels
A-thread-localsArea: Thread local storage (TLS)Area: Thread local storage (TLS)F-thread_local`#![feature(thread_local)]``#![feature(thread_local)]`O-dragonflyOperating system: DragonFly BSDOperating system: DragonFly BSDO-freebsdOperating system: FreeBSDOperating system: FreeBSDO-netbsdOperating system: NetBSDOperating system: NetBSDO-openbsdOperating system: OpenBSDOperating system: OpenBSDO-windows-gnuToolchain: GNU, Operating system: WindowsToolchain: GNU, Operating system: Windows
Metadata
Metadata
Assignees
Labels
A-thread-localsArea: Thread local storage (TLS)Area: Thread local storage (TLS)F-thread_local`#![feature(thread_local)]``#![feature(thread_local)]`O-dragonflyOperating system: DragonFly BSDOperating system: DragonFly BSDO-freebsdOperating system: FreeBSDOperating system: FreeBSDO-netbsdOperating system: NetBSDOperating system: NetBSDO-openbsdOperating system: OpenBSDOperating system: OpenBSDO-windows-gnuToolchain: GNU, Operating system: WindowsToolchain: GNU, Operating system: Windows
Type
Fields
Give feedbackNo fields configured for issues without a type.
Out of curiosity, I ran a script to print out the list of targets where
cfg(target_thread_local)(indicating support for#[thread_local]) is not true.The results (and script) are available here: https://gist.github.com/thomcc/766d76e4da35ce1a73b93ccd548fd143
This looks somewhat wrong to me — I believe several of these should have support for static/linker thread local (or at least
__thread/__declspec(thread)has worked there for me). Here are some items in that list which are... fairly suspicious to me.Playing around with1
clang,gcc, andmsvca bit indicates that (the ones I can easily test of these) should have it, and probably others.My suspicion is:
If the issue is about old versions, I guess a question would be what should the cfg do in situations where the support is version-dependent...
This sounds like a tricky thing to decide! Worth noting: support for TLS is what caused us to choose 10.7 as the minimum supported version for macOS: #11927, but I guess back then2 we might not have had a
#[cfg(target_thread_local)]?.But if nothing else, libstd probably has more concrete ideas about what it supports, and this causes it to be far more pessimistic in
std::thread_local!.And more concretely: I'm pretty sure if I used
#[thread_local]in a malloc, I'd be pretty annoyed if it couldn't support, say, FreeBSD, since I know that at least GCC/Clang support__threadon that target.Footnotes
I think the correct thing to compare against would be
_Thread_local/__thread/__declspec(thread)rather than C++'sthread_local— these don't have ctor/dtor support, and thus map more directly to Rust's#[thread_local]. That said, I don't really see a difference in what I've checked. ↩I don't feel doing that much spelunking, seems likely that given the numeric gap between the macOS issue and the
thread_localissue, that things probably worked very differently! ↩