Skip to content

Commit

Permalink
Rollup merge of #106638 - RalfJung:realstd, r=thomcc
Browse files Browse the repository at this point in the history
std tests: use __OsLocalKeyInner from realstd

This is basically the same as #100201, but for __OsLocalKeyInner:

Some std tests are failing in Miri on Windows because [this static](https://github.com/rust-lang/rust/blob/a377893da2cd7124e5a18c7116cbb70e16dd5541/library/std/src/sys/windows/thread_local_key.rs#L234-L239) is getting duplicated, and Miri does not handle that properly -- Miri does not support this magic `.CRT$XLB` linker section, but instead just looks up this particular hard-coded static in the standard library. This PR lets the test suite use the std static instead of having its own copy.

Fixes rust-lang/miri#2754
r? `@thomcc`
  • Loading branch information
matthiaskrgr committed Jan 12, 2023
2 parents 890bc3c + ad79b20 commit db8301b
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions library/std/src/thread/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,19 +177,19 @@ use crate::sys_common::thread_parking::Parker;
use crate::sys_common::{AsInner, IntoInner};
use crate::time::Duration;

#[stable(feature = "scoped_threads", since = "1.63.0")]
mod scoped;

#[stable(feature = "scoped_threads", since = "1.63.0")]
pub use scoped::{scope, Scope, ScopedJoinHandle};

////////////////////////////////////////////////////////////////////////////////
// Thread-local storage
////////////////////////////////////////////////////////////////////////////////

#[macro_use]
mod local;

#[stable(feature = "scoped_threads", since = "1.63.0")]
mod scoped;

#[stable(feature = "scoped_threads", since = "1.63.0")]
pub use scoped::{scope, Scope, ScopedJoinHandle};

#[stable(feature = "rust1", since = "1.0.0")]
pub use self::local::{AccessError, LocalKey};

Expand All @@ -209,7 +209,6 @@ pub use self::local::{AccessError, LocalKey};
))]
#[doc(hidden)]
pub use self::local::fast::Key as __FastLocalKeyInner;

// when building for tests, use real std's type
#[unstable(feature = "libstd_thread_internals", issue = "none")]
#[cfg(test)]
Expand All @@ -220,12 +219,21 @@ pub use self::local::fast::Key as __FastLocalKeyInner;
pub use realstd::thread::__FastLocalKeyInner;

#[unstable(feature = "libstd_thread_internals", issue = "none")]
#[cfg(not(test))]
#[cfg(all(
not(target_thread_local),
not(all(target_family = "wasm", not(target_feature = "atomics"))),
))]
#[doc(hidden)]
pub use self::local::os::Key as __OsLocalKeyInner;
// when building for tests, use real std's type
#[unstable(feature = "libstd_thread_internals", issue = "none")]
#[cfg(test)]
#[cfg(all(
not(target_thread_local),
not(all(target_family = "wasm", not(target_feature = "atomics"))),
))]
pub use realstd::thread::__OsLocalKeyInner;

#[unstable(feature = "libstd_thread_internals", issue = "none")]
#[cfg(all(target_family = "wasm", not(target_feature = "atomics")))]
Expand Down

0 comments on commit db8301b

Please sign in to comment.