Avoid redundant additions to PATH when linking

This commit is contained in:
Mads Marquart 2024-10-10 11:46:11 +02:00
parent df1b5d3cc2
commit 1edff466e1

View File

@ -454,6 +454,8 @@ pub fn get_tools_search_paths(&self, self_contained: bool) -> Vec<PathBuf> {
let bin_path = filesearch::make_target_bin_path(&self.sysroot, config::host_triple()); let bin_path = filesearch::make_target_bin_path(&self.sysroot, config::host_triple());
let fallback_sysroot_paths = filesearch::sysroot_candidates() let fallback_sysroot_paths = filesearch::sysroot_candidates()
.into_iter() .into_iter()
// Ignore sysroot candidate if it was the same as the sysroot path we just used.
.filter(|sysroot| *sysroot != self.sysroot)
.map(|sysroot| filesearch::make_target_bin_path(&sysroot, config::host_triple())); .map(|sysroot| filesearch::make_target_bin_path(&sysroot, config::host_triple()));
let search_paths = std::iter::once(bin_path).chain(fallback_sysroot_paths); let search_paths = std::iter::once(bin_path).chain(fallback_sysroot_paths);