File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed
compiler/rustc_codegen_llvm/src Expand file tree Collapse file tree 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, '_> {
320320 }
321321
322322 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+
323329 let needs_dll_storage_attr = self . use_dll_storage_attrs && !self . tcx . is_foreign_item ( def_id) &&
324330 // Local definitions can never be imported, so we must not apply
325331 // the DLLImport annotation.
326332 !dso_local &&
327333 // ThinLTO can't handle this workaround in all cases, so we don't
328334 // emit the attrs. Instead we make them unnecessary by disallowing
329335 // 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;
332337
333338 // If this assertion triggers, there's something wrong with commandline
334339 // argument validation.
You can’t perform that action at this time.
0 commit comments