Skip to content

Commit

Permalink
rust-lld: fallback to the default linker if there's no path to the li…
Browse files Browse the repository at this point in the history
…nker
  • Loading branch information
lqd committed May 18, 2024
1 parent eb1a5c9 commit f2611aa
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions compiler/rustc_codegen_ssa/src/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3116,12 +3116,22 @@ fn add_lld_args(

let self_contained_linker = self_contained_cli || self_contained_target;
if self_contained_linker && !sess.opts.cg.link_self_contained.is_linker_disabled() {
let mut linker_path_exists = false;
for path in sess.get_tools_search_paths(false) {
cmd.arg({
let mut arg = OsString::from("-B");
arg.push(path.join("gcc-ld"));
arg
});
let linker_path = path.join("gcc-ld");
if linker_path.exists() {
linker_path_exists = true;
cmd.arg({
let mut arg = OsString::from("-B");
arg.push(linker_path);
arg
});
}
}
if !linker_path_exists {
// As an additional sanity check, we do nothing if the sysroot doesn't contain the
// linker path at all.
return;
}
}

Expand Down

0 comments on commit f2611aa

Please sign in to comment.