linker: Remove laziness and caching from native search directory walks

It shouldn't be necessary for performance now.
This commit is contained in:
Vadim Petrochenkov
2024-04-12 17:01:46 +03:00
parent 7bdae134cb
commit ed62b57c86
5 changed files with 22 additions and 121 deletions

View File

@@ -17,14 +17,9 @@ use rustc_target::spec::abi::Abi;
use crate::errors;
use std::path::{Path, PathBuf};
use std::path::PathBuf;
pub fn find_native_static_library<'a>(
name: &str,
verbatim: bool,
search_paths: impl Iterator<Item = &'a Path>,
sess: &Session,
) -> PathBuf {
pub fn find_native_static_library(name: &str, verbatim: bool, sess: &Session) -> PathBuf {
let formats = if verbatim {
vec![("".into(), "".into())]
} else {
@@ -35,9 +30,9 @@ pub fn find_native_static_library<'a>(
if os == unix { vec![os] } else { vec![os, unix] }
};
for path in search_paths {
for path in sess.target_filesearch(PathKind::Native).search_paths() {
for (prefix, suffix) in &formats {
let test = path.join(format!("{prefix}{name}{suffix}"));
let test = path.dir.join(format!("{prefix}{name}{suffix}"));
if test.exists() {
return test;
}
@@ -60,8 +55,7 @@ fn find_bundled_library(
&& (sess.opts.unstable_opts.packed_bundled_libs || has_cfg || whole_archive == Some(true))
{
let verbatim = verbatim.unwrap_or(false);
let search_paths = sess.target_filesearch(PathKind::Native).search_path_dirs();
return find_native_static_library(name.as_str(), verbatim, search_paths, sess)
return find_native_static_library(name.as_str(), verbatim, sess)
.file_name()
.and_then(|s| s.to_str())
.map(Symbol::intern);