Repository: rust
Issue: I used mock to compile the rust source package and it failed, saying “the compiler unexpectedly panicked. this is a bug” 
Labels: I-ICE,T-compiler,C-bug

<!--
Thank you for finding an Internal Compiler Error! 🧊  If possible, try to provide
a minimal verifiable example. You can read "Rust Bug Minimization Patterns" for
how to create smaller examples.
http://blog.pnkfx.org/blog/2019/11/18/rust-bug-minimization-patterns/
-->

### Code

```Rust
<code>
```


### Meta
<!--
If you're using the stable version of the compiler, you should also check if the
bug also exists in the beta or nightly versions.
-->

`rustc --version --verbose`:
```
bash-4.4# rustc --version --verbose
rustc 1.58.1 (Red Hat 1.58.1-1.module+an8.6.0+10685+b0dfaf8a)
binary: rustc
commit-hash: unknown
commit-date: unknown
host: aarch64-unknown-linux-gnu
release: 1.58.1
LLVM version: 13.0.1
bash-4.4# 
```

### Error output
This is a mock compiled log error
```
Rustbook (aarch64-unknown-linux-gnu) - rustc
Building stage0 tool fabricate (aarch64-unknown-linux-gnu)
   Compiling maybe-uninit v2.0.0
   Compiling cc v1.0.69
   Compiling pkg-config v0.3.18
   Compiling scopeguard v1.1.0
   Compiling rayon-core v1.7.1
   Compiling crc32fast v1.2.0
   Compiling adler v0.2.3
   Compiling either v1.6.0
   Compiling yaml-rust v0.3.5
   Compiling crossbeam-utils v0.7.2
   Compiling memoffset v0.5.5
   Compiling crossbeam-epoch v0.8.2
   Compiling rayon v1.3.1
   Compiling num_cpus v1.13.0
   Compiling filetime v0.2.14
   Compiling xattr v0.2.2
   Compiling miniz_oxide v0.4.0
   Compiling tar v0.4.37
   Compiling clap v2.33.3
   Compiling flate2 v1.0.16
   Compiling crossbeam-queue v0.2.3
   Compiling crossbeam-deque v0.7.4
   Compiling lzma-sys v0.1.16
   Compiling xz2 v0.1.6
Compiling installer v0.0.0 (/builddir/build/BUILD/rustc-1.58.1-src/src/tools/rust-installer)
Finished release [optimized + debuginfo] target(s) in 16.61s
Dist rust-docs-1.58.1-aarch64-unknown-linux-gnu
Error: failed to generate installer

Caused by:
0: failed to copy '/builddir/build/BUILD/rustc-1.58.1-src/build/tmp/tarball/rust-docs/aarch64-unknown-linux-gnu/image/share/doc/rust/html/.lock' to '/builddir/build/BUILD/rustc-1.58.1-src/build/tmp/tarball/rust-docs/aarch64-unknown-linux-gnu/rust-docs-1.58.1-aarch64-unknown-linux-gnu/rust-docs/share/doc/rust/html/.lock'
1: Invalid argument (os error 22)

command did not execute successfully: "/builddir/build/BUILD/rustc-1.58.1-src/build/aarch64-unknown-linux-gnu/stage0-tools-bin/fabricate" "generate" "--image-dir" "/builddir/build/BUILD/rustc-1.58.1-src/build/tmp/tarball/rust-docs/aarch64-unknown-linux-gnu/image" "--component-name=rust-docs" "--bulk-dirs" "share/doc/rust/html" "--rel-manifest-dir=rustlib" "--legacy-manifest-dirs=rustlib,cargo" "--product-name=Rust Documentation" "--success-message=rust-docs installed." "--package-name=rust-docs-1.58.1-aarch64-unknown-linux-gnu" "--non-installed-overlay" "/builddir/build/BUILD/rustc-1.58.1-src/build/tmp/tarball/rust-docs/aarch64-unknown-linux-gnu/overlay" "--output-dir" "/builddir/build/BUILD/rustc-1.58.1-src/build/dist" "--work-dir" "/builddir/build/BUILD/rustc-1.58.1-src/build/tmp/tarball/rust-docs/aarch64-unknown-linux-gnu" "--compression-formats" "gz"
expected success, got: exit status: 1

Build completed unsuccessfully in 0:57:50
error: Bad exit status from /var/tmp/rpm-tmp.AEuFEa (%install)
```
### Error output
This is more detailed information about the statements in the errant spec file that were executed after entering the chroot compilation environment
```

info: using vendored source, but .cargo/config is already present.
Reusing the current configuration file. But you may want to configure vendoring like this:
[source.crates-io]
replace-with = 'vendored-sources'
registry = 'https://example.com/'

[source.vendored-sources]
directory = '/builddir/build/BUILD/rustc-1.58.1-src/vendor'

Finished dev [unoptimized] target(s) in 0.31s
thread 'main' panicked at 'failed to get current_exe: no /proc/self/exe available. Is /proc mounted?', compiler/rustc_session/src/filesearch.rs:120:23
stack backtrace:
0: 0xffffa3d1691c - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::he66f8d238b905f76
1: 0xffffa3d6dc7c - core::fmt::write::h743399f14fac5e26
2: 0xffffa3d07654 -
3: 0xffffa3d195e4 -
4: 0xffffa3d191a0 -
5: 0xffffa44387fc -
6: 0xffffa3d19de8 - std::panicking::rust_panic_with_hook::h6953e7848a489496
7: 0xffffa3d198e0 -
8: 0xffffa3d16dd4 -
9: 0xffffa3d1984c - rust_begin_unwind
10: 0xffffa3ce4cd8 - core::panicking::panic_fmt::h42acc96d3fb41272
11: 0xffffa65ad904 - rustc_session[655b00a29dfa847e]::filesearch::get_or_default_sysroot
12: 0xffffa65d20a0 - rustc_session[655b00a29dfa847e]::config::build_session_options
13: 0xffffa4432488 - <rustc_driver[10ed386a85e4608f]::RunCompiler>::run
14: 0xffffa4453508 -
15: 0xffffa4439a10 - rustc_driver[10ed386a85e4608f]::main
16: 0xaaaad70eea94 -
17: 0xaaaad70eea80 -
18: 0xaaaad70eea54 -
19: 0xffffa3d165a4 - std::rt::lang_start_internal::h156b5c5dcd4da2da
20: 0xaaaad70eeac4 -
21: 0xffffa3b2485c - __libc_start_main
22: 0xaaaad70ee974 -

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: [Sign in to GitHub · GitHub](https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md)

note: rustc 1.58.1 (Red Hat 1.58.1-1.module+an8.6.0+10685+b0dfaf8a) running on aarch64-unknown-linux-gnu

query stack during panic:
end of query stack
thread 'main' panicked at 'command did not execute successfully: "/usr/bin/rustc" "--target" "aarch64-unknown-linux-gnu" "--print" "target-libdir"
expected success, got: exit status: 101', src/bootstrap/lib.rs:376:13
stack backtrace:
0: 0xaaaae47ffee8 -
1: 0xaaaae4822d5c -
2: 0xaaaae47fa648 -
3: 0xaaaae4801ec0 -
4: 0xaaaae4801a7c -
5: 0xaaaae4802528 -
6: 0xaaaae480204c -
7: 0xaaaae48003a0 -
8: 0xaaaae4801fb8 -
9: 0xaaaae40c9e08 -
10: 0xaaaae47dc3bc -
11: 0xaaaae4151638 -
12: 0xaaaae40ca770 -
13: 0xaaaae40cb290 -
14: 0xaaaae40cad48 -
15: 0xaaaae40cb454 -
16: 0xaaaae47ffc18 -
17: 0xaaaae40cb430 -
18: 0xaaaae40cac84 -
19: 0xffff96a1485c - __libc_start_main
20: 0xaaaae40ca3e0 -
Build completed unsuccessfully in 0:00:00
bash-4.4#
```
<!--
Include a backtrace in the code block by setting `RUST_BACKTRACE=1` in your
environment. E.g. `RUST_BACKTRACE=1 cargo build`.
-->
<details><summary><strong>Backtrace</strong></summary>
<p>

```
<backtrace>
```

</p>
</details>