Skip to content

Commit 55c8697

Browse files
committed
Use RUSTC_LINKER's prefix as last resort for prefix_for_target().
1 parent f2e1b1c commit 55c8697

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/lib.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -2547,11 +2547,12 @@ impl Build {
25472547
}
25482548

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

0 commit comments

Comments
 (0)