Rollup merge of #129418 - petrochenkov:libsearch2, r=jieyouxu
rustc: Simplify getting sysroot library directory It was very non-obvious that `sess.target_tlib_path`, `make_target_lib_path(...)`, and `sess.target_filesearch(...).search_paths()` result in the same sysroot library directory paths. They are however, indeed the same, because `sess.target_tlib_path` is initialized to `make_target_lib_path(...)` on `Session` creation, and they are used interchangeably. There are still some redundant calls to `make_target_lib_path` and other inconsistent ways to obtain sysroot directories, but fixing that requires some behavior changes, while this PR is a pure refactoring. Some places in the compiler even disagree on the number of sysroots - 1 (explicit `--sysroot` *or* default sysroot), 2 (explicit `--sysroot` *and* default sysroot), or an unclear number of `sysroot_candidates` every of which is considered. The logic currently using `sess.target_tlib_path` or equivalents assumes one sysroot.
This commit is contained in:
@@ -440,22 +440,10 @@ impl Session {
|
||||
}
|
||||
|
||||
pub fn target_filesearch(&self, kind: PathKind) -> filesearch::FileSearch<'_> {
|
||||
filesearch::FileSearch::new(
|
||||
&self.sysroot,
|
||||
self.opts.target_triple.triple(),
|
||||
&self.opts.search_paths,
|
||||
&self.target_tlib_path,
|
||||
kind,
|
||||
)
|
||||
filesearch::FileSearch::new(&self.opts.search_paths, &self.target_tlib_path, kind)
|
||||
}
|
||||
pub fn host_filesearch(&self, kind: PathKind) -> filesearch::FileSearch<'_> {
|
||||
filesearch::FileSearch::new(
|
||||
&self.sysroot,
|
||||
config::host_triple(),
|
||||
&self.opts.search_paths,
|
||||
&self.host_tlib_path,
|
||||
kind,
|
||||
)
|
||||
filesearch::FileSearch::new(&self.opts.search_paths, &self.host_tlib_path, kind)
|
||||
}
|
||||
|
||||
/// Returns a list of directories where target-specific tool binaries are located. Some fallback
|
||||
|
||||
Reference in New Issue
Block a user