Skip to content

Commit

Permalink
Use RUSTC_LINKER's prefix as last resort for prefix_for_target().
Browse files Browse the repository at this point in the history
  • Loading branch information
dot-asm committed Jun 5, 2022
1 parent f2e1b1c commit 55c8697
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2547,11 +2547,12 @@ impl Build {
}

fn prefix_for_target(&self, target: &str) -> Option<String> {
// Put aside RUSTC_LINKER's prefix to be used as last resort
let rustc_linker = self.getenv("RUSTC_LINKER").unwrap_or("".to_string());
let linker_prefix = rustc_linker.strip_suffix("-gcc");
// CROSS_COMPILE is of the form: "arm-linux-gnueabi-"
let cc_env = self.getenv("CROSS_COMPILE");
let cross_compile = cc_env
.as_ref()
.map(|s| s.trim_right_matches('-').to_owned());
let cross_compile = cc_env.as_ref().map(|s| s.trim_end_matches('-').to_owned());
cross_compile.or(match &target[..] {
"aarch64-pc-windows-gnu" => Some("aarch64-w64-mingw32"),
"aarch64-uwp-windows-gnu" => Some("aarch64-w64-mingw32"),
Expand Down Expand Up @@ -2658,7 +2659,7 @@ impl Build {
]), // explicit None if not found, so caller knows to fall back
"x86_64-unknown-linux-musl" => Some("musl"),
"x86_64-unknown-netbsd" => Some("x86_64--netbsd"),
_ => None,
_ => linker_prefix,
}
.map(|x| x.to_owned()))
}
Expand Down

0 comments on commit 55c8697

Please # to comment.