@@ -181,8 +181,7 @@ macro_rules! thread_local {
181
181
macro_rules! __thread_local_inner {
182
182
// used to generate the `LocalKey` value for const-initialized thread locals
183
183
( @key $t: ty, const $init: expr) => { {
184
- #[ cfg_attr( not( all( windows, target_thread_local) ) , inline) ] // see comments below
185
- #[ cfg_attr( all( windows, target_thread_local) , inline( never) ) ]
184
+ #[ cfg_attr( not( windows) , inline) ] // see comments below
186
185
#[ deny( unsafe_op_in_unsafe_fn) ]
187
186
unsafe fn __getit(
188
187
_init: $crate:: option:: Option <& mut $crate:: option:: Option <$t>>,
@@ -295,17 +294,12 @@ macro_rules! __thread_local_inner {
295
294
fn __init( ) -> $t { $init }
296
295
297
296
// When reading this function you might ask "why is this inlined
298
- // everywhere other than Windows?", and "why must it not be inlined
299
- // on Windows?" and these are very reasonable questions to ask.
300
- //
301
- // The short story is that Windows doesn't support referencing
302
- // `#[thread_local]` across DLL boundaries. The slightly longer
303
- // story is that each module (dll or exe) has its own separate set
304
- // of static thread locals, so if you try and reference a
305
- // `#[thread_local]` that comes from `crate1.dll` from within one of
306
- // `crate2.dll`'s functions, then it might give you a completely
307
- // different thread local than what you asked for (or it might just
308
- // crash).
297
+ // everywhere other than Windows?", and that's a very reasonable
298
+ // question to ask. The short story is that it segfaults rustc if
299
+ // this function is inlined. The longer story is that Windows looks
300
+ // to not support `extern` references to thread locals across DLL
301
+ // boundaries. This appears to at least not be supported in the ABI
302
+ // that LLVM implements.
309
303
//
310
304
// Because of this we never inline on Windows, but we do inline on
311
305
// other platforms (where external references to thread locals
@@ -320,9 +314,8 @@ macro_rules! __thread_local_inner {
320
314
// Cargo question kinda). This means that, unfortunately, Windows
321
315
// gets the pessimistic path for now where it's never inlined.
322
316
//
323
- // The issue of "should improve things on Windows" is #84933
324
- #[ cfg_attr( not( all( windows, target_thread_local) ) , inline) ]
325
- #[ cfg_attr( all( windows, target_thread_local) , inline( never) ) ]
317
+ // The issue of "should enable on Windows sometimes" is #84933
318
+ #[ cfg_attr( not( windows) , inline) ]
326
319
unsafe fn __getit(
327
320
init: $crate:: option:: Option <& mut $crate:: option:: Option <$t>>,
328
321
) -> $crate:: option:: Option <& ' static $t> {
0 commit comments