rust/library/std
Yuki Okushi 2f506e6dd4
Rollup merge of #101368 - thomcc:wintls-noinline, r=ChrisDenton
Forbid inlining `thread_local!`'s `__getit` function on Windows

Sadly, this will make things slower to avoid UB in an edge case, but it seems hard to avoid... and really whenever I look at this code I can't help but think we're asking for trouble.

It's pretty dodgy for us to leave this as a normal function rather than `#[inline(never)]`, given that if it *does* get inlined into a dynamically linked component, it's extremely unsafe (you get some other thread local, or if you're lucky, crash). Given that it's pretty rare for people to use dylibs on Windows, the fact that we haven't gotten bug reports about it isn't really that convincing. Ideally we'd come up with some kind of compiler solution (that avoids paying for this cost when static linking, or *at least* for use within the same crate...), but it's not clear what that looks like.

Oh, and because all this is only needed when we're implementing `thread_local!` with `#[thread_local]`, this patch adjusts the `cfg_attr` to be `all(windows, target_thread_local)` as well.

r? ``@ChrisDenton``

See also #84933, which is about improving the situation.
2022-11-23 06:40:21 +09:00
..
benches
primitive_docs
src Rollup merge of #101368 - thomcc:wintls-noinline, r=ChrisDenton 2022-11-23 06:40:21 +09:00
tests Sort target features alphabetically 2022-10-14 22:01:18 +02:00
build.rs
Cargo.toml Update compiler-builtins 2022-11-13 23:07:35 +05:30