| 
10 | 10 | macro_rules! __thread_local_inner {  | 
11 | 11 |     // used to generate the `LocalKey` value for const-initialized thread locals  | 
12 | 12 |     (@key $t:ty, const $init:expr) => {{  | 
13 |  | -        #[cfg_attr(not(windows), inline)] // see comments below  | 
 | 13 | +        #[cfg_attr(not(bootstrap), inline)]  | 
14 | 14 |         #[deny(unsafe_op_in_unsafe_fn)]  | 
15 | 15 |         unsafe fn __getit(  | 
16 | 16 |             _init: $crate::option::Option<&mut $crate::option::Option<$t>>,  | 
@@ -77,29 +77,7 @@ macro_rules! __thread_local_inner {  | 
77 | 77 |             #[inline]  | 
78 | 78 |             fn __init() -> $t { $init }  | 
79 | 79 | 
 
  | 
80 |  | -            // When reading this function you might ask "why is this inlined  | 
81 |  | -            // everywhere other than Windows?", and that's a very reasonable  | 
82 |  | -            // question to ask. The short story is that it segfaults rustc if  | 
83 |  | -            // this function is inlined. The longer story is that Windows looks  | 
84 |  | -            // to not support `extern` references to thread locals across DLL  | 
85 |  | -            // boundaries. This appears to at least not be supported in the ABI  | 
86 |  | -            // that LLVM implements.  | 
87 |  | -            //  | 
88 |  | -            // Because of this we never inline on Windows, but we do inline on  | 
89 |  | -            // other platforms (where external references to thread locals  | 
90 |  | -            // across DLLs are supported). A better fix for this would be to  | 
91 |  | -            // inline this function on Windows, but only for "statically linked"  | 
92 |  | -            // components. For example if two separately compiled rlibs end up  | 
93 |  | -            // getting linked into a DLL then it's fine to inline this function  | 
94 |  | -            // across that boundary. It's only not fine to inline this function  | 
95 |  | -            // across a DLL boundary. Unfortunately rustc doesn't currently  | 
96 |  | -            // have this sort of logic available in an attribute, and it's not  | 
97 |  | -            // clear that rustc is even equipped to answer this (it's more of a  | 
98 |  | -            // Cargo question kinda). This means that, unfortunately, Windows  | 
99 |  | -            // gets the pessimistic path for now where it's never inlined.  | 
100 |  | -            //  | 
101 |  | -            // The issue of "should enable on Windows sometimes" is #84933  | 
102 |  | -            #[cfg_attr(not(windows), inline)]  | 
 | 80 | +            #[cfg_attr(not(bootstrap), inline)]  | 
103 | 81 |             unsafe fn __getit(  | 
104 | 82 |                 init: $crate::option::Option<&mut $crate::option::Option<$t>>,  | 
105 | 83 |             ) -> $crate::option::Option<&'static $t> {  | 
 | 
0 commit comments