Skip to content

Commit 9f86471

Browse files
committed
Use RUSTC_LINKER's prefix as last resort for prefix_for_target().
1 parent 53fb72c commit 9f86471

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/lib.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2595,11 +2595,12 @@ impl Build {
25952595
}
25962596

25972597
fn prefix_for_target(&self, target: &str) -> Option<String> {
2598+
// Put aside RUSTC_LINKER's prefix to be used as last resort
2599+
let rustc_linker = self.getenv("RUSTC_LINKER").unwrap_or("".to_string());
2600+
let linker_prefix = rustc_linker.strip_suffix("-gcc");
25982601
// CROSS_COMPILE is of the form: "arm-linux-gnueabi-"
25992602
let cc_env = self.getenv("CROSS_COMPILE");
2600-
let cross_compile = cc_env
2601-
.as_ref()
2602-
.map(|s| s.trim_right_matches('-').to_owned());
2603+
let cross_compile = cc_env.as_ref().map(|s| s.trim_end_matches('-').to_owned());
26032604
cross_compile.or(match &target[..] {
26042605
"aarch64-pc-windows-gnu" => Some("aarch64-w64-mingw32"),
26052606
"aarch64-uwp-windows-gnu" => Some("aarch64-w64-mingw32"),
@@ -2706,7 +2707,7 @@ impl Build {
27062707
]), // explicit None if not found, so caller knows to fall back
27072708
"x86_64-unknown-linux-musl" => Some("musl"),
27082709
"x86_64-unknown-netbsd" => Some("x86_64--netbsd"),
2709-
_ => None,
2710+
_ => linker_prefix,
27102711
}
27112712
.map(|x| x.to_owned()))
27122713
}

0 commit comments

Comments
 (0)