ICE in link_staticlib: called Result::unwrap() on an Err value: Os { code: 2, kind: NotFound, message: No such file or directory }
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Summary
Incremental compilation of a crate with crate-type = ["lib", "cdylib", "staticlib"] panics in link_staticlib → each_linked_rlib → add_archive() with ENOENT. The stale rlib path persists from a prior compilation cycle.
Steps to Reproduce
cargo new ice-repro && cd ice-repro- Add
crc-fast = "=1.8.0"to[dependencies]inCargo.toml cargo check(creates incremental metadata)cargo clean -p ice-repro(cleans only the top crate, not deps)cargo build(triggers incremental rebuild ofcrc-fastwhich hascrate-type = ["lib", "cdylib", "staticlib"])
Alternatively, use this Cargo.toml:
[package]
name = "ice-repro"
version = "0.1.0"
edition = "2024"
[dependencies]
crc-fast = "=1.8.0"
The ICE is intermittent (~50% occurrence in the observed workspace).
Meta
rustc --version --verbose:
rustc 1.95.0 (59807616e 2026-04-14)
binary: rustc
commit-hash: 59807616e1fa2540724bfbac14d7976d7e4a3860
commit-date: 2026-04-14
host: x86_64-unknown-linux-gnu
release: 1.95.0
LLVM version: 20.1.4
Error Output
thread 'rustc' (1111947) panicked at /rustc-dev/59807616e1fa2540724bfbac14d7976d7e4a3860/compiler/rustc_codegen_ssa/src/back/link.rs:509:14:
called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: "No such file or directory" }
Full backtrace:
0: 0x7fc469f9314b - <<std[e28293b1aa0f68bd]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[c1f1a4ba060b9bfa]::fmt::Display>::fmt
1: 0x7fc46a61f408 - core[c1f1a4ba060b9bfa]::fmt::write
2: 0x7fc46bb683b6 - <std[e28293b1aa0f68bd]::sys::stdio::unix::Stderr as std[e28293b1aa0f68bd]::io::Write>::write_fmt
3: 0x7fc469f69238 - std[e28293b1aa0f68bd]::panicking::default_hook::{closure#0}
4: 0x7fc469f865b3 - std[e28293b1aa0f68bd]::panicking::default_hook
5: 0x7fc468f5cc30 - std[e28293b1aa0f68bd]::panicking::update_hook::<alloc[fdfd2bd8633a6659]::boxed::Box<rustc_driver_impl[e4ca9dd5dd6cf2a8]::install_ice_hook::{closure#1}>>::{closure#0}
6: 0x7fc469f86892 - std[e28293b1aa0f68bd]::panicking::panic_with_hook
7: 0x7fc469f692f8 - std[e28293b1aa0f68bd]::panicking::panic_handler::{closure#0}
8: 0x7fc469f60029 - std[e28293b1aa0f68bd]::sys::backtrace::__rust_end_short_backtrace::<std[e28293b1aa0f68bd]::panicking::panic_handler::{closure#0}, !>
9: 0x7fc469f6ad5d - __rustc[b7974e8690430dd9]::rust_begin_unwind
10: 0x7fc466cde82c - core[c1f1a4ba060b9bfa]::panicking::panic_fmt
11: 0x7fc4667076f2 - core[c1f1a4ba060b9bfa]::result::unwrap_failed
12: 0x7fc468dc368a - rustc_codegen_ssa[fd5ecd340cdb7a09]::back::link::link_staticlib::{closure#0}
13: 0x7fc46b96e27b - rustc_codegen_ssa[fd5ecd340cdb7a09]::back::link::each_linked_rlib
14: 0x7fc46b5c1024 - rustc_codegen_ssa[fd5ecd340cdb7a09]::back::link::link_binary
15: 0x7fc46b5bf8a9 - <rustc_codegen_llvm[3c18e353d9a32df8]::LlvmCodegenBackend as rustc_codegen_ssa[fd5ecd340cdb7a09]::traits::backend::CodegenBackend>::link
16: 0x7fc46b97807b - <rustc_interface[c8170c4b7b680ee8]::queries::Linker>::link
17: 0x7fc46b85651a - rustc_interface[c8170c4b7b680ee8]::interface::run_compiler::<(), rustc_driver_impl[e4ca9dd5dd6cf2a8]::run_compiler::{closure#0}>::{closure#1}
18: 0x7fc46b82663e - std[e28293b1aa0f68bd]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[c8170c4b7b680ee8]::util::run_in_thread_with_globals<rustc_interface[c8170c4b7b680ee8]::util::run_in_thread_pool_with_globals<rustc_interface[c8170c4b7b680ee8]::interface::run_compiler<(), rustc_driver_impl[e4ca9dd5dd6cf2a8]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
19: 0x7fc46b826ca0 - <std[e28293b1aa0f68bd]::thread::lifecycle::spawn_unchecked<rustc_interface[c8170c4b7b680ee8]::util::run_in_thread_with_globals<rustc_interface[c8170c4b7b680ee8]::util::run_in_thread_pool_with_globals<rustc_interface[c8170c4b7b680ee8]::interface::run_compiler<(), rustc_driver_impl[e4ca9dd5dd6cf2a8]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[c1f1a4ba060b9bfa]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
20: 0x7fc46b827b2c - <std[e28293b1aa0f68bd]::sys::thread::unix::Thread>::new::thread_start
21: 0x7fc4650981b9 - <unknown>
22: 0x7fc46511d21c - <unknown>
23: 0x0 - <unknown>
Compiler Flags
--crate-type lib --crate-type cdylib --crate-type staticlib -C embed-bitcode=no -C debuginfo=2
Notes
- The
crc-fastcrate declarescrate-type = ["lib", "cdylib", "staticlib"]to produce a C-compatible shared library alongside the Rust lib. - The panic occurs at
link.rs:509inlink_staticlibwheneach_linked_rlibreturns a path to an rlib that no longer exists on disk (stale incremental-cache reference). - The same thread ID (1111947) appeared consistently across runs, suggesting deterministic behavior based on the incremental cache state.
- Does NOT trigger on rustc 1.94.0.
- The
add_archive(path).unwrap()atlink.rs:509should handle this gracefully (e.g.expectwith a descriptive message, or skip missing rlibs).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the ICE with the provided cargo new, cargo check, cargo clean -p, and cargo build sequence. Read compiler/rustc_codegen_ssa/src/back/link.rs around link_staticlib, each_linked_rlib, and add_archive(), where the stale rlib path is reported. Done means the reproduction no longer panics when that rlib is missing and the failure is handled gracefully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100