File tree 1 file changed +15
-4
lines changed
1 file changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -2595,11 +2595,22 @@ impl Build {
2595
2595
}
2596
2596
2597
2597
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"); // >=1.45.0
2601
+ let linker_prefix = if rustc_linker. len ( ) > 4 {
2602
+ let ( prefix, suffix) = rustc_linker. split_at ( rustc_linker. len ( ) - 4 ) ;
2603
+ if suffix == "-gcc" {
2604
+ Some ( prefix)
2605
+ } else {
2606
+ None
2607
+ }
2608
+ } else {
2609
+ None
2610
+ } ;
2598
2611
// CROSS_COMPILE is of the form: "arm-linux-gnueabi-"
2599
2612
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 ( ) ) ;
2613
+ let cross_compile = cc_env. as_ref ( ) . map ( |s| s. trim_end_matches ( '-' ) . to_owned ( ) ) ;
2603
2614
cross_compile. or ( match & target[ ..] {
2604
2615
"aarch64-pc-windows-gnu" => Some ( "aarch64-w64-mingw32" ) ,
2605
2616
"aarch64-uwp-windows-gnu" => Some ( "aarch64-w64-mingw32" ) ,
@@ -2706,7 +2717,7 @@ impl Build {
2706
2717
] ) , // explicit None if not found, so caller knows to fall back
2707
2718
"x86_64-unknown-linux-musl" => Some ( "musl" ) ,
2708
2719
"x86_64-unknown-netbsd" => Some ( "x86_64--netbsd" ) ,
2709
- _ => None ,
2720
+ _ => linker_prefix ,
2710
2721
}
2711
2722
. map ( |x| x. to_owned ( ) ) )
2712
2723
}
You can’t perform that action at this time.
0 commit comments