File tree 1 file changed +7
-2
lines changed
compiler/rustc_codegen_llvm/src
1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -320,15 +320,20 @@ impl<'ll> CodegenCx<'ll, '_> {
320
320
}
321
321
322
322
if !def_id. is_local ( ) {
323
+ // Workaround an LLD bug (https://github.com/rust-lang/rust/issues/81408) with importing
324
+ // static symbols triggered by ThinLTO if we're not using -Z dylib-lto. Note this
325
+ // workaround may not be sound for crate graphs with dylibs.
326
+ let workaround_lld_bug =
327
+ self . tcx . sess . lto ( ) == Lto :: Thin && !self . tcx . sess . opts . unstable_opts . dylib_lto ;
328
+
323
329
let needs_dll_storage_attr = self . use_dll_storage_attrs && !self . tcx . is_foreign_item ( def_id) &&
324
330
// Local definitions can never be imported, so we must not apply
325
331
// the DLLImport annotation.
326
332
!dso_local &&
327
333
// ThinLTO can't handle this workaround in all cases, so we don't
328
334
// emit the attrs. Instead we make them unnecessary by disallowing
329
335
// dynamic linking when linker plugin based LTO is enabled.
330
- !self . tcx . sess . opts . cg . linker_plugin_lto . enabled ( ) &&
331
- self . tcx . sess . lto ( ) != Lto :: Thin ;
336
+ !self . tcx . sess . opts . cg . linker_plugin_lto . enabled ( ) && !workaround_lld_bug;
332
337
333
338
// If this assertion triggers, there's something wrong with commandline
334
339
// argument validation.
You can’t perform that action at this time.
0 commit comments