diff options
| author | liushuyu <liushuyu011@gmail.com> | 2023-02-27 13:31:35 -0700 |
|---|---|---|
| committer | liushuyu <liushuyu011@gmail.com> | 2023-02-28 10:02:38 -0700 |
| commit | 2186358e5a124d486f55a20220f720fb8f9a0694 (patch) | |
| tree | 69c3c53074026312ab92a0a213ac4462aed56d9c /compiler/rustc_session/src/filesearch.rs | |
| parent | 31f858d9a511f24fedb8ed997b28304fec809630 (diff) | |
| download | rust-2186358e5a124d486f55a20220f720fb8f9a0694.tar.gz rust-2186358e5a124d486f55a20220f720fb8f9a0694.zip | |
compiler/rustc_session: fix sysroot detection logic ...
... on systems where /usr/lib contains a multi-arch structure
Diffstat (limited to 'compiler/rustc_session/src/filesearch.rs')
| -rw-r--r-- | compiler/rustc_session/src/filesearch.rs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/compiler/rustc_session/src/filesearch.rs b/compiler/rustc_session/src/filesearch.rs index 2075ed57a94..f1fbf38217d 100644 --- a/compiler/rustc_session/src/filesearch.rs +++ b/compiler/rustc_session/src/filesearch.rs @@ -182,7 +182,17 @@ pub fn get_or_default_sysroot() -> Result<PathBuf, String> { if dir.ends_with(crate::config::host_triple()) { dir.parent() // chop off `$target` .and_then(|p| p.parent()) // chop off `rustlib` - .and_then(|p| p.parent()) // chop off `lib` + .and_then(|p| { + // chop off `lib` (this could be also $arch dir if the host sysroot uses a + // multi-arch layout like Debian or Ubuntu) + match p.parent() { + Some(p) => match p.file_name() { + Some(f) if f == "lib" => p.parent(), // first chop went for $arch, so chop again for `lib` + _ => Some(p), + }, + None => None, + } + }) .map(|s| s.to_owned()) .ok_or(format!( "Could not move 3 levels upper using `parent()` on {}", |
