@@ -2864,23 +2864,14 @@ impl Build {
2864
2864
}
2865
2865
2866
2866
fn prefix_for_target ( & self , target : & str ) -> Option < String > {
2867
- // Put aside RUSTC_LINKER's prefix to be used as last resort
2868
- let rustc_linker = self . getenv ( "RUSTC_LINKER" ) . unwrap_or ( "" . to_string ( ) ) ;
2869
- // let linker_prefix = rustc_linker.strip_suffix("-gcc"); // >=1.45.0
2870
- let linker_prefix = if rustc_linker. len ( ) > 4 {
2871
- let ( prefix, suffix) = rustc_linker. split_at ( rustc_linker. len ( ) - 4 ) ;
2872
- if suffix == "-gcc" {
2873
- Some ( prefix)
2874
- } else {
2875
- None
2876
- }
2877
- } else {
2878
- None
2879
- } ;
2867
+ // Put aside RUSTC_LINKER's prefix to be used as second choice, after CROSS_COMPILE
2868
+ let linker_prefix = self
2869
+ . getenv ( "RUSTC_LINKER" )
2870
+ . and_then ( |var| var. strip_suffix ( "-gcc" ) . map ( str:: to_string) ) ;
2880
2871
// CROSS_COMPILE is of the form: "arm-linux-gnueabi-"
2881
2872
let cc_env = self . getenv ( "CROSS_COMPILE" ) ;
2882
2873
let cross_compile = cc_env. as_ref ( ) . map ( |s| s. trim_end_matches ( '-' ) . to_owned ( ) ) ;
2883
- cross_compile. or ( match & target[ ..] {
2874
+ cross_compile. or ( linker_prefix ) . or ( match & target[ ..] {
2884
2875
// Note: there is no `aarch64-pc-windows-gnu` target, only `-gnullvm`
2885
2876
"aarch64-pc-windows-gnullvm" => Some ( "aarch64-w64-mingw32" ) ,
2886
2877
"aarch64-uwp-windows-gnu" => Some ( "aarch64-w64-mingw32" ) ,
@@ -2994,7 +2985,7 @@ impl Build {
2994
2985
] ) , // explicit None if not found, so caller knows to fall back
2995
2986
"x86_64-unknown-linux-musl" => Some ( "musl" ) ,
2996
2987
"x86_64-unknown-netbsd" => Some ( "x86_64--netbsd" ) ,
2997
- _ => linker_prefix ,
2988
+ _ => None ,
2998
2989
}
2999
2990
. map ( |x| x. to_owned ( ) ) )
3000
2991
}
0 commit comments