Skip to content

Commit 2f97b8d

Browse files
authored
Unrolled build for rust-lang#122790
Rollup merge of rust-lang#122790 - Zoxc:dllimp-rev, r=ChrisDenton Apply dllimport in ThinLTO This partially reverts rust-lang#103353 by properly applying `dllimport` if `-Z dylib-lto` is passed. That PR should probably fully be reverted as it looks quite sketchy. We don't know locally if the entire crate graph would be statically linked. This should hopefully be sufficient to make ThinLTO work for rustc on Windows. r? ``@wesleywiser`` --- Edit: This PR is changed to just generally revert rust-lang#103353.
2 parents 385970f + cc39e5f commit 2f97b8d

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)