File tree 1 file changed +15
-5
lines changed
compiler/rustc_codegen_ssa/src/back
1 file changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -3116,12 +3116,22 @@ fn add_lld_args(
3116
3116
3117
3117
let self_contained_linker = self_contained_cli || self_contained_target;
3118
3118
if self_contained_linker && !sess. opts . cg . link_self_contained . is_linker_disabled ( ) {
3119
+ let mut linker_path_exists = false ;
3119
3120
for path in sess. get_tools_search_paths ( false ) {
3120
- cmd. arg ( {
3121
- let mut arg = OsString :: from ( "-B" ) ;
3122
- arg. push ( path. join ( "gcc-ld" ) ) ;
3123
- arg
3124
- } ) ;
3121
+ let linker_path = path. join ( "gcc-ld" ) ;
3122
+ if linker_path. exists ( ) {
3123
+ linker_path_exists = true ;
3124
+ cmd. arg ( {
3125
+ let mut arg = OsString :: from ( "-B" ) ;
3126
+ arg. push ( linker_path) ;
3127
+ arg
3128
+ } ) ;
3129
+ }
3130
+ }
3131
+ if !linker_path_exists {
3132
+ // As an additional sanity check, we do nothing if the sysroot doesn't contain the
3133
+ // linker path at all.
3134
+ return ;
3125
3135
}
3126
3136
}
3127
3137
You can’t perform that action at this time.
0 commit comments