File tree 2 files changed +21
-11
lines changed
rustc_codegen_ssa/src/back
2 files changed +21
-11
lines changed Original file line number Diff line number Diff line change @@ -3117,16 +3117,12 @@ fn add_lld_args(
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
3119
// We tell `cc` where to find the lld wrappers, in a similar way to how we locate
3120
- // codegen-backends dylibs:
3121
- // - in the tool search paths: the sysroot's `rustlib` bin path,
3122
- // - and as a fallback for cases where `--sysroot` only contains a target std: in the
3123
- // default host sysroot where rustc is currently located.
3124
- let fallback_sysroot_paths = filesearch:: sysroot_candidates ( )
3125
- . into_iter ( )
3126
- . map ( |sysroot| filesearch:: make_target_bin_path ( & sysroot, config:: host_triple ( ) ) ) ;
3127
-
3120
+ // codegen-backends dylibs, in the tools search paths, which contain:
3121
+ // - the sysroot's `rustlib` bin path,
3122
+ // - and as a fallback for cases using `--sysroot` without tools: in the default host
3123
+ // sysroot where rustc is currently located.
3128
3124
let mut linker_path_exists = false ;
3129
- for path in sess. get_tools_search_paths ( false ) . into_iter ( ) . chain ( fallback_sysroot_paths ) {
3125
+ for path in sess. get_tools_search_paths ( false ) {
3130
3126
let linker_path = path. join ( "gcc-ld" ) ;
3131
3127
if linker_path. exists ( ) {
3132
3128
linker_path_exists = true ;
Original file line number Diff line number Diff line change @@ -449,15 +449,29 @@ impl Session {
449
449
)
450
450
}
451
451
452
- /// Returns a list of directories where target-specific tool binaries are located.
452
+ /// Returns a list of directories where target-specific tool binaries are located. Some fallback
453
+ /// directories are also returned, for example if `--sysroot` is used but tools are missing
454
+ /// (#125246): we also add the bin directories to the sysroot where rustc is located.
453
455
pub fn get_tools_search_paths ( & self , self_contained : bool ) -> Vec < PathBuf > {
454
456
let rustlib_path = rustc_target:: target_rustlib_path ( & self . sysroot , config:: host_triple ( ) ) ;
455
457
let p = PathBuf :: from_iter ( [
456
458
Path :: new ( & self . sysroot ) ,
457
459
Path :: new ( & rustlib_path) ,
458
460
Path :: new ( "bin" ) ,
459
461
] ) ;
460
- if self_contained { vec ! [ p. clone( ) , p. join( "self-contained" ) ] } else { vec ! [ p] }
462
+
463
+ let fallback_sysroot_paths = filesearch:: sysroot_candidates ( )
464
+ . into_iter ( )
465
+ . map ( |sysroot| filesearch:: make_target_bin_path ( & sysroot, config:: host_triple ( ) ) ) ;
466
+
467
+ if self_contained {
468
+ [ p. clone ( ) , p. join ( "self-contained" ) ]
469
+ . into_iter ( )
470
+ . chain ( fallback_sysroot_paths)
471
+ . collect ( )
472
+ } else {
473
+ std:: iter:: once ( p) . chain ( fallback_sysroot_paths) . collect ( )
474
+ }
461
475
}
462
476
463
477
pub fn init_incr_comp_session ( & self , session_dir : PathBuf , lock_file : flock:: Lock ) {
You can’t perform that action at this time.
0 commit comments