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 @@ -302,15 +302,20 @@ impl<'ll> CodegenCx<'ll, '_> {
302
302
}
303
303
304
304
if !def_id. is_local ( ) {
305
+ // Workaround an LLD bug with importing static symbols triggered by ThinLTO if we're
306
+ // not using -Z dylib-lto. Note this workaround may not be sound for crate graphs
307
+ // with dylibs.
308
+ let workaround_lld_bug =
309
+ self . tcx . sess . lto ( ) == Lto :: Thin && !self . tcx . sess . opts . unstable_opts . dylib_lto ;
310
+
305
311
let needs_dll_storage_attr = self . use_dll_storage_attrs && !self . tcx . is_foreign_item ( def_id) &&
306
312
// Local definitions can never be imported, so we must not apply
307
313
// the DLLImport annotation.
308
314
!dso_local &&
309
315
// ThinLTO can't handle this workaround in all cases, so we don't
310
316
// emit the attrs. Instead we make them unnecessary by disallowing
311
317
// dynamic linking when linker plugin based LTO is enabled.
312
- !self . tcx . sess . opts . cg . linker_plugin_lto . enabled ( ) &&
313
- self . tcx . sess . lto ( ) != Lto :: Thin ;
318
+ !self . tcx . sess . opts . cg . linker_plugin_lto . enabled ( ) && !workaround_lld_bug;
314
319
315
320
// If this assertion triggers, there's something wrong with commandline
316
321
// argument validation.
You can’t perform that action at this time.
0 commit comments