Skip to content

Commit 2be866c

Browse files
authored
Rollup merge of #131493 - madsmtm:avoid-redundant-linker-path, r=jieyouxu
Avoid redundant sysroot additions to `PATH` when linking Currently, `rustc` prepends `$HOME/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/bin` to the `PATH` three times before invoking the linker, which is unnecessary, once should be enough. Spotted this while trying to get `-Clinker-flavor=gcc` and `-Clinker-flavor=ld` closer together, not really important. ``@rustbot`` A-linkage
2 parents efb10c7 + 1edff46 commit 2be866c

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

Diff for: compiler/rustc_session/src/session.rs

+2
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,8 @@ impl Session {
454454
let bin_path = filesearch::make_target_bin_path(&self.sysroot, config::host_triple());
455455
let fallback_sysroot_paths = filesearch::sysroot_candidates()
456456
.into_iter()
457+
// Ignore sysroot candidate if it was the same as the sysroot path we just used.
458+
.filter(|sysroot| *sysroot != self.sysroot)
457459
.map(|sysroot| filesearch::make_target_bin_path(&sysroot, config::host_triple()));
458460
let search_paths = std::iter::once(bin_path).chain(fallback_sysroot_paths);
459461

0 commit comments

Comments
 (0)