Skip to content

Commit 713a006

Browse files
committed
Create _imp__ symbols also when doing ThinLTO
1 parent 9859bf2 commit 713a006

File tree

1 file changed

+7
-1
lines changed
  • compiler/rustc_codegen_ssa/src/back

1 file changed

+7
-1
lines changed

compiler/rustc_codegen_ssa/src/back/write.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -2163,8 +2163,14 @@ fn msvc_imps_needed(tcx: TyCtxt<'_>) -> bool {
21632163
&& tcx.sess.opts.cg.prefer_dynamic)
21642164
);
21652165

2166+
// We need to generate _imp__ symbol if we are generating an rlib or we include one
2167+
// indirectly from ThinLTO. In theory these are not needed as ThinLTO could resolve
2168+
// these, but it currently does not do so.
2169+
let can_have_static_objects =
2170+
tcx.sess.lto() == Lto::Thin || tcx.crate_types().iter().any(|ct| *ct == CrateType::Rlib);
2171+
21662172
tcx.sess.target.is_like_windows &&
2167-
tcx.crate_types().iter().any(|ct| *ct == CrateType::Rlib) &&
2173+
can_have_static_objects &&
21682174
// ThinLTO can't handle this workaround in all cases, so we don't
21692175
// emit the `__imp_` symbols. Instead we make them unnecessary by disallowing
21702176
// dynamic linking when linker plugin LTO is enabled.

0 commit comments

Comments
 (0)