Repository: rust
Issue: "failed to open bitcode file: No such file or directory" 2, electric boogaloo
Labels: I-ICE,T-compiler,A-incr-comp,C-bug

This has similarities to #72006: the incremental cache gets into the exact same bad state as in that issue (missing .pre-lto.bc file, all other expected files are there), and the diagnostic message is exactly the same. But it must be getting into this bad state some other way. I've yet to find any way to consistently reproduce. But I see this a lot while doing a git pull that triggers an inotify-triggered build. So my best guess is this is some kind of race condition that can happen when a compiler input file changes while the compiler is running.

Feel free to provide suggestions for diagnostics I could try to collect.
```
rustc 1.61.0-nightly (d2710dbb3 2022-03-08)
```
```
 RUST_BACKTRACE=full ../../prebuilt/third_party/rust/linux-x64/bin/rustc --color=always --crate-name v2_argh_wrapper ../../src/diagnostics/lib/util/v2-argh-wrapper/src/lib.rs --crate-type rlib --emit=dep-info=obj/src/diagnostics/lib/util/v2-argh-wrapper/libv2_argh_wrapper.rlib.d,link -Zdep-info-omit-d-target -Zmutable-noalias=off --cfg=rust_panic=\"abort\" --cfg=__rust_toolchain=\"-hgFZdM6KdKdZFqdeJILjg1iwY_iBdeE3t8tWFvScmwC\" -L gen/zircon/public/sysroot/cpp/lib -Clinker=../../prebuilt/third_party/clang/linux-x64/bin/lld -Clink-arg=--sysroot=gen/zircon/public/sysroot/cpp -Clink-arg=-L../../prebuilt/third_party/clang/linux-x64/bin/../lib/x86_64-unknown-fuchsia -Clink-arg=-L../../prebuilt/third_party/clang/linux-x64/lib/clang/15.0.0/lib/x86_64-unknown-fuchsia -Clink-arg=--pack-dyn-relocs=relr -Clink-arg=-dynamic-linker=ld.so.1 -Clink-arg=--icf=all -Clink-arg=-zrel -Zremap-cwd-prefix=. -Copt-level=s -Cdebuginfo=2 --edition=2018 -Cincremental=jakikiwen -Zallow-features= --target x86_64-fuchsia --cap-lints=deny -Wrust-2018-idioms -Dwarnings -Clink-args=-zstack-size=0x200000 -Cpanic=abort -Cforce-unwind-tables=yes -Zpanic_abort_tests -Dunused_results -Aunused_results -o obj/src/diagnostics/lib/util/v2-argh-wrapper/libv2_argh_wrapper.rlib -Ldependency=obj/third_party/rust_crates -Ldependency=host_x64/obj/third_party/rust_crates --extern anyhow=obj/third_party/rust_crates/libanyhow-34b5b8ef286e2000.rlib --extern argh=obj/third_party/rust_crates/libargh-85679041d363e90a.rlib --extern tracing=obj/third_party/rust_crates/libtracing-145e529ba33a39f9.rlib && ../../prebuilt/third_party/python3/linux-x64/bin/python3.8 -S ../../build/gn/verify_depfile.py -t "//src/diagnostics/lib/util/v2-argh-wrapper:v2-argh-wrapper" -d obj/src/diagnostics/lib/util/v2-argh-wrapper/libv2_argh_wrapper.rlib.d ../../src/diagnostics/lib/util/v2-argh-wrapper/src/lib.rs
thread 'rustc' panicked at 'failed to open bitcode file `/mnt/dozen/fuchsian/out/default/jakikiwen/v2_argh_wrapper-3ycvmx8m65x/s-g7x4bwdrd1-ladtfg-working/11sss69rhj457fdz.pre-lto.bc`: No such file or directory (os error 2)', rustlib/src/rust/compiler/rustc_codegen_ssa/src/back/write.rs:1931:29
stack backtrace:
   0:     0x7f812e2c37bc - std::backtrace_rs::backtrace::libunwind::trace::h73f0f792c4645f45
                               at rustlib/src/rust/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f812e2c37bc - std::backtrace_rs::backtrace::trace_unsynchronized::hd6026972f2f373f8
                               at rustlib/src/rust/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f812e2c37bc - std::sys_common::backtrace::_print_fmt::h5f481182ebba4914
                               at rustlib/src/rust/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7f812e2c37bc - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h191e306f79401821
                               at rustlib/src/rust/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7f812e32529c - core::fmt::write::he8b5297636bad58d
                               at rustlib/src/rust/library/core/src/fmt/mod.rs:1190:17
   5:     0x7f812e2b3971 - std::io::Write::write_fmt::h40e9f74a686740f9
                               at rustlib/src/rust/library/std/src/io/mod.rs:1655:15
   6:     0x7f812e2c6705 - std::sys_common::backtrace::_print::h392e06902700d1fb
                               at rustlib/src/rust/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7f812e2c6705 - std::sys_common::backtrace::print::he20c335dc7d2c276
                               at rustlib/src/rust/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7f812e2c6705 - std::panicking::default_hook::{{closure}}::heb84f5944e014831
                               at rustlib/src/rust/library/std/src/panicking.rs:295:22
   9:     0x7f812e2c63a8 - std::panicking::default_hook::hf5a243f1c943641d
                               at rustlib/src/rust/library/std/src/panicking.rs:314:9
  10:     0x7f812f491b19 - rustc_driver[d28a50c3a3afa2b2]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7f812e2c70b1 - std::panicking::rust_panic_with_hook::h7653850edec1d116
                               at rustlib/src/rust/library/std/src/panicking.rs:702:17
  12:     0x7f812e2c6d97 - std::panicking::begin_panic_handler::{{closure}}::h8defdf2a4458fe4e
                               at rustlib/src/rust/library/std/src/panicking.rs:588:13
  13:     0x7f812e2c3c74 - std::sys_common::backtrace::__rust_end_short_backtrace::h92a97e791170a366
                               at rustlib/src/rust/library/std/src/sys_common/backtrace.rs:138:18
  14:     0x7f812e2c6ac9 - rust_begin_unwind
                               at rustlib/src/rust/library/std/src/panicking.rs:584:5
  15:     0x7f812e321fb3 - core::panicking::panic_fmt::hf4f285aaf3a746d9
                               at rustlib/src/rust/library/core/src/panicking.rs:143:14
  16:     0x7f812f69f428 - rustc_codegen_ssa[946b39ad1d506a72]::back::write::submit_pre_lto_module_to_llvm::<rustc_codegen_llvm[3f7fe0ad8e33fedf]::LlvmCodegenBackend>
  17:     0x7f812f71f055 - <rustc_codegen_llvm[3f7fe0ad8e33fedf]::LlvmCodegenBackend as rustc_codegen_ssa[946b39ad1d506a72]::traits::backend::CodegenBackend>::codegen_crate
  18:     0x7f812f636b98 - <rustc_session[97065d6042e0afda]::session::Session>::time::<alloc[dcdbd229b72d459c]::boxed::Box<dyn core[e6eca20fcba53f83]::any::Any>, rustc_interface[c422b88f9e16f9be]::passes::start_codegen::{closure#0}>
  19:     0x7f812f5bc0d2 - <rustc_interface[c422b88f9e16f9be]::passes::QueryContext>::enter::<<rustc_interface[c422b88f9e16f9be]::queries::Queries>::ongoing_codegen::{closure#0}::{closure#0}, core[e6eca20fcba53f83]::result::Result<alloc[dcdbd229b72d459c]::boxed::Box<dyn core[e6eca20fcba53f83]::any::Any>, rustc_errors[bb2d24414af95986]::ErrorGuaranteed>>
  20:     0x7f812f5ac758 - <rustc_interface[c422b88f9e16f9be]::queries::Queries>::ongoing_codegen
  21:     0x7f812f4191c7 - <rustc_interface[c422b88f9e16f9be]::interface::Compiler>::enter::<rustc_driver[d28a50c3a3afa2b2]::run_compiler::{closure#1}::{closure#2}, core[e6eca20fcba53f83]::result::Result<core[e6eca20fcba53f83]::option::Option<rustc_interface[c422b88f9e16f9be]::queries::Linker>, rustc_errors[bb2d24414af95986]::ErrorGuaranteed>>
  22:     0x7f812f43de03 - rustc_span[608e99c4f78a4c6]::with_source_map::<core[e6eca20fcba53f83]::result::Result<(), rustc_errors[bb2d24414af95986]::ErrorGuaranteed>, rustc_interface[c422b88f9e16f9be]::interface::create_compiler_and_run<core[e6eca20fcba53f83]::result::Result<(), rustc_errors[bb2d24414af95986]::ErrorGuaranteed>, rustc_driver[d28a50c3a3afa2b2]::run_compiler::{closure#1}>::{closure#1}>
  23:     0x7f812f41a031 - rustc_interface[c422b88f9e16f9be]::interface::create_compiler_and_run::<core[e6eca20fcba53f83]::result::Result<(), rustc_errors[bb2d24414af95986]::ErrorGuaranteed>, rustc_driver[d28a50c3a3afa2b2]::run_compiler::{closure#1}>
  24:     0x7f812f411f62 - <scoped_tls[81d76e6229c8cf6a]::ScopedKey<rustc_span[608e99c4f78a4c6]::SessionGlobals>>::set::<rustc_interface[c422b88f9e16f9be]::interface::run_compiler<core[e6eca20fcba53f83]::result::Result<(), rustc_errors[bb2d24414af95986]::ErrorGuaranteed>, rustc_driver[d28a50c3a3afa2b2]::run_compiler::{closure#1}>::{closure#0}, core[e6eca20fcba53f83]::result::Result<(), rustc_errors[bb2d24414af95986]::ErrorGuaranteed>>
  25:     0x7f812f40c39f - std[dd95ab88d4603f0d]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[c422b88f9e16f9be]::util::run_in_thread_pool_with_globals<rustc_interface[c422b88f9e16f9be]::interface::run_compiler<core[e6eca20fcba53f83]::result::Result<(), rustc_errors[bb2d24414af95986]::ErrorGuaranteed>, rustc_driver[d28a50c3a3afa2b2]::run_compiler::{closure#1}>::{closure#0}, core[e6eca20fcba53f83]::result::Result<(), rustc_errors[bb2d24414af95986]::ErrorGuaranteed>>::{closure#0}, core[e6eca20fcba53f83]::result::Result<(), rustc_errors[bb2d24414af95986]::ErrorGuaranteed>>
  26:     0x7f812f40dfa9 - <<std[dd95ab88d4603f0d]::thread::Builder>::spawn_unchecked_<rustc_interface[c422b88f9e16f9be]::util::run_in_thread_pool_with_globals<rustc_interface[c422b88f9e16f9be]::interface::run_compiler<core[e6eca20fcba53f83]::result::Result<(), rustc_errors[bb2d24414af95986]::ErrorGuaranteed>, rustc_driver[d28a50c3a3afa2b2]::run_compiler::{closure#1}>::{closure#0}, core[e6eca20fcba53f83]::result::Result<(), rustc_errors[bb2d24414af95986]::ErrorGuaranteed>>::{closure#0}, core[e6eca20fcba53f83]::result::Result<(), rustc_errors[bb2d24414af95986]::ErrorGuaranteed>>::{closure#1} as core[e6eca20fcba53f83]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  27:     0x7f812e2d1523 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hf99165057ead5fc1
                               at rustlib/src/rust/rustlib/src/rust/library/alloc/src/boxed.rs:1854:9
  28:     0x7f812e2d1523 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h9b3af15e5402f89b
                               at rustlib/src/rust/rustlib/src/rust/library/alloc/src/boxed.rs:1854:9
  29:     0x7f812e2d1523 - std::sys::unix::thread::Thread::new::thread_start::h2cbe4df4a7bc2cba
                               at rustlib/src/rust/library/std/src/sys/unix/thread.rs:108:17
  30:     0x7f812e188d80 - start_thread
                               at ./nptl/./nptl/pthread_create.c:481:8
  31:     0x7f812e0a6bdf - __GI___clone
                               at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone.S:95

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.
```