Skip to content

Commit 30ce2df

Browse files
committed
more hacks, yay
1 parent 7fa27a0 commit 30ce2df

File tree

1 file changed

+31
-2
lines changed
  • compiler/rustc_codegen_ssa/src/back

1 file changed

+31
-2
lines changed

compiler/rustc_codegen_ssa/src/back/link.rs

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2485,7 +2485,7 @@ fn add_order_independent_options(
24852485
// Take care of the flavors and CLI options requesting the `lld` linker.
24862486
add_lld_args(cmd, sess, flavor, self_contained_components);
24872487

2488-
add_wild_args(cmd, sess, flavor);
2488+
add_wild_args(cmd, sess, flavor, self_contained_components);
24892489

24902490
add_apple_link_args(cmd, sess, flavor);
24912491

@@ -3408,8 +3408,37 @@ fn add_lld_args(
34083408
}
34093409
}
34103410

3411-
fn add_wild_args(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor) {
3411+
fn add_wild_args(
3412+
cmd: &mut dyn Linker,
3413+
sess: &Session,
3414+
flavor: LinkerFlavor,
3415+
self_contained_components: LinkSelfContainedComponents,
3416+
) {
3417+
// Either Wild or LLD to make it work with CI
34123418
if flavor != LinkerFlavor::Wild || std::env::var_os("BUILDING_RUSTC").is_some() {
3419+
let self_contained_cli = sess.opts.cg.link_self_contained.is_linker_enabled();
3420+
let self_contained_target = self_contained_components.is_linker_enabled();
3421+
3422+
let self_contained_linker = self_contained_cli || self_contained_target;
3423+
if self_contained_linker && !sess.opts.cg.link_self_contained.is_linker_disabled() {
3424+
let mut linker_path_exists = false;
3425+
for path in sess.get_tools_search_paths(false) {
3426+
let linker_path = path.join("gcc-ld");
3427+
linker_path_exists |= linker_path.exists();
3428+
cmd.cc_arg({
3429+
let mut arg = OsString::from("-B");
3430+
arg.push(linker_path);
3431+
arg
3432+
});
3433+
}
3434+
if !linker_path_exists {
3435+
sess.dcx().emit_fatal(errors::SelfContainedLinkerMissing);
3436+
}
3437+
}
3438+
3439+
if !sess.target.is_like_wasm {
3440+
cmd.cc_arg("-fuse-ld=lld");
3441+
}
34133442
return ();
34143443
}
34153444

0 commit comments

Comments
 (0)