Skip to content

Commit cc39e5f

Browse files
committed
Apply dllimport in ThinLTO
1 parent 81d8edc commit cc39e5f

File tree

3 files changed

+5
-34
lines changed

3 files changed

+5
-34
lines changed

compiler/rustc_codegen_llvm/src/consts.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ use rustc_middle::mir::mono::MonoItem;
1616
use rustc_middle::ty::Instance;
1717
use rustc_middle::ty::layout::{HasTypingEnv, LayoutOf};
1818
use rustc_middle::{bug, span_bug};
19-
use rustc_session::config::Lto;
2019
use tracing::{debug, instrument, trace};
2120

2221
use crate::common::{AsCCharPtr, CodegenCx};
@@ -344,11 +343,11 @@ impl<'ll> CodegenCx<'ll, '_> {
344343
// Local definitions can never be imported, so we must not apply
345344
// the DLLImport annotation.
346345
&& !dso_local
347-
// ThinLTO can't handle this workaround in all cases, so we don't
348-
// emit the attrs. Instead we make them unnecessary by disallowing
349-
// dynamic linking when linker plugin based LTO is enabled.
350-
&& !self.tcx.sess.opts.cg.linker_plugin_lto.enabled()
351-
&& self.tcx.sess.lto() != Lto::Thin;
346+
// Linker plugin ThinLTO doesn't create the self-dllimport Rust uses for rlibs
347+
// as the code generation happens out of process. Instead we assume static linkage
348+
// and disallow dynamic linking when linker plugin based LTO is enabled.
349+
// Regular in-process ThinLTO doesn't need this workaround.
350+
&& !self.tcx.sess.opts.cg.linker_plugin_lto.enabled();
352351

353352
// If this assertion triggers, there's something wrong with commandline
354353
// argument validation.

tests/codegen/issues/auxiliary/static_dllimport_aux.rs

-13
This file was deleted.

tests/codegen/issues/issue-81408-dllimport-thinlto-windows.rs

-15
This file was deleted.

0 commit comments

Comments
 (0)