Skip to content

Commit

Permalink
Create _imp__ symbols also when doing ThinLTO
Browse files Browse the repository at this point in the history
  • Loading branch information
Zoxc authored and lqd committed Sep 6, 2024
1 parent d678b81 commit 538edcd
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion compiler/rustc_codegen_ssa/src/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2165,8 +2165,14 @@ fn msvc_imps_needed(tcx: TyCtxt<'_>) -> bool {
&& tcx.sess.opts.cg.prefer_dynamic)
);

// We need to generate _imp__ symbol if we are generating an rlib or we include one
// indirectly from ThinLTO. In theory these are not needed as ThinLTO could resolve
// these, but it currently does not do so.
let can_have_static_objects =
tcx.sess.lto() == Lto::Thin || tcx.crate_types().iter().any(|ct| *ct == CrateType::Rlib);

tcx.sess.target.is_like_windows &&
tcx.crate_types().iter().any(|ct| *ct == CrateType::Rlib) &&
can_have_static_objects &&
// ThinLTO can't handle this workaround in all cases, so we don't
// emit the `__imp_` symbols. Instead we make them unnecessary by disallowing
// dynamic linking when linker plugin LTO is enabled.
Expand Down

0 comments on commit 538edcd

Please sign in to comment.