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 @@ -2617,11 +2617,22 @@ impl Build {
2617
2617
}
2618
2618
2619
2619
fn prefix_for_target ( & self , target : & str ) -> Option < String > {
2620
+ // Put aside RUSTC_LINKER's prefix to be used as last resort
2621
+ let rustc_linker = self . getenv ( "RUSTC_LINKER" ) . unwrap_or ( "" . to_string ( ) ) ;
2622
+ // let linker_prefix = rustc_linker.strip_suffix("-gcc"); // >=1.45.0
2623
+ let linker_prefix = if rustc_linker. len ( ) > 4 {
2624
+ let ( prefix, suffix) = rustc_linker. split_at ( rustc_linker. len ( ) - 4 ) ;
2625
+ if suffix == "-gcc" {
2626
+ Some ( prefix)
2627
+ } else {
2628
+ None
2629
+ }
2630
+ } else {
2631
+ None
2632
+ } ;
2620
2633
// CROSS_COMPILE is of the form: "arm-linux-gnueabi-"
2621
2634
let cc_env = self . getenv ( "CROSS_COMPILE" ) ;
2622
- let cross_compile = cc_env
2623
- . as_ref ( )
2624
- . map ( |s| s. trim_right_matches ( '-' ) . to_owned ( ) ) ;
2635
+ let cross_compile = cc_env. as_ref ( ) . map ( |s| s. trim_end_matches ( '-' ) . to_owned ( ) ) ;
2625
2636
cross_compile. or ( match & target[ ..] {
2626
2637
"aarch64-pc-windows-gnu" => Some ( "aarch64-w64-mingw32" ) ,
2627
2638
"aarch64-uwp-windows-gnu" => Some ( "aarch64-w64-mingw32" ) ,
@@ -2728,7 +2739,7 @@ impl Build {
2728
2739
] ) , // explicit None if not found, so caller knows to fall back
2729
2740
"x86_64-unknown-linux-musl" => Some ( "musl" ) ,
2730
2741
"x86_64-unknown-netbsd" => Some ( "x86_64--netbsd" ) ,
2731
- _ => None ,
2742
+ _ => linker_prefix ,
2732
2743
}
2733
2744
. map ( |x| x. to_owned ( ) ) )
2734
2745
}
You can’t perform that action at this time.
0 commit comments