Skip to content
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

rustc: Enable #[thread_local] for Windows #42687

Merged
merged 1 commit into from
Jun 24, 2017

Conversation

alexcrichton
Copy link
Member

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.

@rust-highfive
Copy link
Collaborator

r? @sfackler

(rust_highfive has picked a reviewer for you, use r? to override)

@shepmaster shepmaster added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 16, 2017
@@ -334,6 +334,82 @@ impl<T: 'static> LocalKey<T> {
}

#[doc(hidden)]
#[cfg(target_thread_local)]
pub mod fast {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use pub (crate) here to avoid the #[doc(hidden)] sadness?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah unfortunately the inner type is reexported as #[doc(hidden)] for "macro hygiene" and rustdoc doesn't see through that so still demands documentation on all the internals :(

@sfackler
Copy link
Member

LGTM other than the one nit.

@alexcrichton
Copy link
Member Author

@bors: r=sfackler

@bors
Copy link
Contributor

bors commented Jun 21, 2017

📌 Commit 1a9567a has been approved by sfackler

@bors
Copy link
Contributor

bors commented Jun 21, 2017

⌛ Testing commit 1a9567a99ec266817b197a4321ce50840ac4de22 with merge 94cf20512562e34e8e091cff38a8675ef433041a...

@bors
Copy link
Contributor

bors commented Jun 21, 2017

💔 Test failed - status-appveyor

@alexcrichton
Copy link
Member Author

@bors: r=sfackler

@bors
Copy link
Contributor

bors commented Jun 21, 2017

📌 Commit b58ed7c has been approved by sfackler

@bors
Copy link
Contributor

bors commented Jun 22, 2017

⌛ Testing commit b58ed7c039850e33c6d83b75784976da112d5d5e with merge 3fbe2405f3f4e65c564d7e68cddfc9b6124eef8c...

@bors
Copy link
Contributor

bors commented Jun 22, 2017

💔 Test failed - status-appveyor

@alexcrichton
Copy link
Member Author

Hm I believe I successfully bootstrapped and ran tests for x86_64, but looks like i686 segfaults. I'll try disabling i686-msvc and see how far that gets us.

@bors: r=sfackler

@bors
Copy link
Contributor

bors commented Jun 22, 2017

📌 Commit ed3ed24 has been approved by sfackler

@bors
Copy link
Contributor

bors commented Jun 22, 2017

⌛ Testing commit ed3ed2414f00d3e03a08c35e7434c20aa838aca6 with merge ec79ceed8c7af7f63dbfe27225eaa6fc3becdb35...

@bors
Copy link
Contributor

bors commented Jun 22, 2017

💔 Test failed - status-appveyor

@Mark-Simulacrum
Copy link
Member

Feels... spurious? Or at least unrelated, maybe? But with such a change I'm not going to retry myself...

[00:36:43] error: failed to run custom build command for `pulldown-cmark v0.0.14`
[00:36:43] process didn't exit successfully: `C:\projects\rust\build\i686-pc-windows-gnu\stage1-rustc\release\build\pulldown-cmark-29fb490fe1066383\build-script-build` (exit code: 3221225477)
[00:36:43] Build failed, waiting for other jobs to finish...
[00:36:54] error: build failed
[00:36:54] thread 'main' panicked at 'command did not execute successfully: "C:\\projects\\rust\\build\\i686-pc-windows-gnu\\stage0/bin\\cargo.exe" "build" "-j" "2" "--target" "i686-pc-windows-gnu" "--release" "--locked" "--color" "always" "--features" " jemalloc" "--manifest-path" "C:\\projects\\rust\\src/rustc/Cargo.toml" "--message-format" "json"
[00:36:54] expected success, got: exit code: 101', src\bootstrap\compile.rs:587
[00:36:54] note: Run with `RUST_BACKTRACE=1` for a backtrace.
[00:36:54] failed to run: C:\projects\rust\build\bootstrap/debug/bootstrap test
[00:36:54] Build completed unsuccessfully in 0:31:23
[00:36:54] Command exited with code 1

@alexcrichton
Copy link
Member Author

Nah looks like this just doesn't work on 32-bit, I'll ignore the gnu target as well.

@alexcrichton
Copy link
Member Author

@bors: r=sfackler

@bors
Copy link
Contributor

bors commented Jun 22, 2017

📌 Commit 321c5be has been approved by sfackler

@bors
Copy link
Contributor

bors commented Jun 23, 2017

⌛ Testing commit 321c5beca38a1b819e37c6611dde3b69b325fe85 with merge f2f68d3778fae69f9bd8dbac02d11a64bd2a1ee8...

@bors
Copy link
Contributor

bors commented Jun 23, 2017

💔 Test failed - status-appveyor

@Mark-Simulacrum
Copy link
Member

Environment: MSYS_BITS=64, SCRIPT=python x.py dist, RUST_CONFIGURE_ARGS=--build=x86_64-pc-windows-gnu --enable-extended, MINGW_URL=https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror, MINGW_ARCHIVE=x86_64-6.3.0-release-posix-seh-rt_v5-rev2.7z, MINGW_DIR=mingw64, DEPLOY=1

[00:56:10] Building stage2 tool cargo (x86_64-pc-windows-gnu)
[00:56:12]    Compiling pkg-config v0.3.9
[00:56:12]    Compiling hex v0.2.0
[00:56:13] error: Could not compile `hex`.
[00:56:13] Build failed, waiting for other jobs to finish...
[00:56:13] error: Could not compile `pkg-config`.
[00:56:13]
[00:56:13] To learn more, run the command again with --verbose.
[00:56:13]
[00:56:13]
[00:56:13] command did not execute successfully: "C:\\projects\\rust\\build\\x86_64-pc-windows-gnu\\stage0/bin\\cargo.exe" "build" "-j" "2" "--target" "x86_64-pc-windows-gnu" "--release" "--locked" "--color" "always" "--manifest-path" "C:\\projects\\rust\\src/tools\\cargo\\Cargo.toml"
[00:56:13] expected success, got: exit code: 101
[00:56:13]

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.
@alexcrichton
Copy link
Member Author

Ok well I tested this on one platform before submitting, x86_64-pc-windows-msvc, and apparently it only works there. No idea why, but may as well land what we can!

@bors: r=sfackler

@bors
Copy link
Contributor

bors commented Jun 23, 2017

📌 Commit 06540cb has been approved by sfackler

@bors
Copy link
Contributor

bors commented Jun 24, 2017

⌛ Testing commit 06540cb with merge 1ccc330...

bors added a commit that referenced this pull request Jun 24, 2017
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.
@bors
Copy link
Contributor

bors commented Jun 24, 2017

☀️ Test successful - status-appveyor, status-travis
Approved by: sfackler
Pushing 1ccc330 to master...

@bors bors merged commit 06540cb into rust-lang:master Jun 24, 2017
@alexcrichton alexcrichton deleted the windows-tls branch June 24, 2017 17:26
ids1024 added a commit to ids1024/rust that referenced this pull request Jun 30, 2017

Verified

This commit was signed with the committer’s verified signature.
ids1024 Ian Douglas Scott
bors added a commit that referenced this pull request Jul 3, 2017
Fix Redox build, apparently broken by #42687
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants