Skip to content

Commit af256f2

Browse files
committed
Force rlibs to be linked in whole
1 parent 0c292c9 commit af256f2

File tree

1 file changed

+6
-4
lines changed
  • compiler/rustc_codegen_ssa/src/back

1 file changed

+6
-4
lines changed

compiler/rustc_codegen_ssa/src/back/link.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -2263,7 +2263,7 @@ fn add_upstream_rust_crates<'a, B: ArchiveBuilder<'a>>(
22632263
sess: &'a Session,
22642264
codegen_results: &CodegenResults,
22652265
tmpdir: &Path,
2266-
crate_type: CrateType,
2266+
_crate_type: CrateType,
22672267
cnum: CrateNum,
22682268
) {
22692269
let src = &codegen_results.crate_info.used_crate_source[&cnum];
@@ -2274,13 +2274,15 @@ fn add_upstream_rust_crates<'a, B: ArchiveBuilder<'a>>(
22742274
// whole of each object in our archive into that artifact. This is
22752275
// because a `dylib` can be reused as an intermediate artifact.
22762276
//
2277+
// NOTE(nbdd0121): Even for non-dylib, we still need to link rlibs
2278+
// in whole because so that `#[no_mangle]` and `#[used]` items from
2279+
// upstream need to be root (#47384, #50007).
2280+
//
22772281
// Note, though, that we don't want to include the whole of a
22782282
// compiler-builtins crate (e.g., compiler-rt) because it'll get
22792283
// repeatedly linked anyway.
22802284
let path = fix_windows_verbatim_for_gcc(path);
2281-
if crate_type == CrateType::Dylib
2282-
&& codegen_results.crate_info.compiler_builtins != Some(cnum)
2283-
{
2285+
if codegen_results.crate_info.compiler_builtins != Some(cnum) {
22842286
cmd.link_whole_rlib(&path);
22852287
} else {
22862288
cmd.link_rlib(&path);

0 commit comments

Comments
 (0)