about summary refs log tree commit diff
path: root/library/std/src/sys/unix/process/process_unix.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-08-28 15:12:31 +0000
committerbors <bors@rust-lang.org>2022-08-28 15:12:31 +0000
commit223d16ebbde1bd309c58e853b053e14318e56b0e (patch)
tree2d1306a0557ef1887142442f9fdfc2e420f558c2 /library/std/src/sys/unix/process/process_unix.rs
parentee285eab69d515114ed54a8e6c25e359acd6b684 (diff)
parentd13699d0be14c47e57d1c8961d7e7348d93017fc (diff)
downloadrust-223d16ebbde1bd309c58e853b053e14318e56b0e.tar.gz
rust-223d16ebbde1bd309c58e853b053e14318e56b0e.zip
Auto merge of #100201 - RalfJung:thread-local-key, r=thomcc
std: use realstd fast key when building tests

Under `cfg(test)`, the `std` crate is not the actual standard library, just any old crate we are testing. It imports the real standard library as `realstd`, and then does some careful `cfg` magic so that the crate built for testing uses the `realstd` global state rather than having its own copy of that.

However, this was not done for all global state hidden in std: the 'fast' version of thread-local keys, at least on some platforms, also involves some global state. Specifically its macOS version has this [`static REGISTERED`](https://github.com/rust-lang/rust/blob/bc63d5a26a65752fb105957d3235cc9c8cb0767f/library/std/src/sys/unix/thread_local_dtor.rs#L62) that would get duplicated. So this PR imports the 'fast' key type from `realstd` rather than using the local copy, to ensure its internal state (and that of the functions it calls) does not get duplicated.

I also noticed that the `__OsLocalKeyInner` is unused under `cfg(target_thread_local)`, so I removed it for that configuration. There was a comment saying macOS picks between `__OsLocalKeyInner` and `__FastLocalKeyInner` at runtime, but I think that comment is outdated -- I found no trace of such a runtime switching mechanism, and the library still check-builds on apple targets with this PR. (I don't have a Mac so I cannot actually run it.)
Diffstat (limited to 'library/std/src/sys/unix/process/process_unix.rs')
0 files changed, 0 insertions, 0 deletions