File tree 1 file changed +11
-1
lines changed
compiler/rustc_session/src
1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -182,7 +182,17 @@ pub fn get_or_default_sysroot() -> Result<PathBuf, String> {
182
182
if dir. ends_with ( crate :: config:: host_triple ( ) ) {
183
183
dir. parent ( ) // chop off `$target`
184
184
. and_then ( |p| p. parent ( ) ) // chop off `rustlib`
185
- . and_then ( |p| p. parent ( ) ) // chop off `lib`
185
+ . and_then ( |p| {
186
+ // chop off `lib` (this could be also $arch dir if the host sysroot uses a
187
+ // multi-arch layout like Debian or Ubuntu)
188
+ match p. parent ( ) {
189
+ Some ( p) => match p. file_name ( ) {
190
+ Some ( f) if f == "lib" => p. parent ( ) , // first chop went for $arch, so chop again for `lib`
191
+ _ => Some ( p) ,
192
+ } ,
193
+ None => None ,
194
+ }
195
+ } )
186
196
. map ( |s| s. to_owned ( ) )
187
197
. ok_or ( format ! (
188
198
"Could not move 3 levels upper using `parent()` on {}" ,
You can’t perform that action at this time.
0 commit comments