]> git.lizzy.rs Git - rust.git/commit
rustc: Enable #[thread_local] for Windows
authorAlex Crichton <alex@alexcrichton.com>
Wed, 17 Feb 2016 07:07:09 +0000 (23:07 -0800)
committerAlex Crichton <alex@alexcrichton.com>
Fri, 23 Jun 2017 23:11:39 +0000 (16:11 -0700)
commit06540cb205545e5e7e509933af27142ca35eae17
tree61ae222629f05fdd91587e2b58e4dda3b95c1bea
parent622e7e6487b6fb7fdbb901720cd4214f9179ed67
rustc: Enable #[thread_local] for Windows

I think LLVM has had support for quite some time now for this, we just never got
around to testing it out and binding it. We've had some trouble landing this in
the past I believe, but it's time to try again!

This commit flags the `#[thread_local]` attribute as being available for Windows
targets and adds an implementation of `register_dtor` in the `thread::local`
module to ensure we can destroy these keys. The same functionality is
implemented in clang via a function called `__tlregdtor` (presumably provided in
some Windows runtime somewhere), but this function unfortunately does not take a
data pointer (just a thunk) which means we can't easily call it. For now
destructors are just run in the same way the Linux fallback is implemented,
which is just keeping track via a single OS-based TLS key.
src/librustc_back/target/x86_64_pc_windows_msvc.rs
src/libstd/sys/unix/fast_thread_local.rs
src/libstd/sys/windows/fast_thread_local.rs [new file with mode: 0644]
src/libstd/sys/windows/mod.rs
src/libstd/sys_common/thread_local.rs
src/libstd/thread/local.rs
src/libstd/thread/mod.rs