Skip to content

[ICE]: compiler crashes when -Z instrument-mcount is used with -C linker-flavor=ld.lld #155972

@Freax13

Description

@Freax13

Code

fn main() {}

Compiling with -Z instrument-mcount -C linker-flavor=ld.lld fails (see error message below). Compiling with -Z instrument-mcount succeeds.

Meta

rustc --version --verbose:

rustc 1.97.0-nightly (52b6e2c20 2026-04-27)
binary: rustc
commit-hash: 52b6e2c208b73276ccb36ec0b68456913a801c96
commit-date: 2026-04-27
host: x86_64-unknown-linux-gnu
release: 1.97.0-nightly
LLVM version: 22.1.2
Compiler returned: 0

Error output

thread 'rustc' (3) panicked at /rustc-dev/52b6e2c208b73276ccb36ec0b68456913a801c96/compiler/rustc_codegen_ssa/src/back/linker.rs:228:5:
assertion failed: l.is_cc()
stack backtrace:
   0:     0x7103757024e9 - <<std[e484e3d4f01e0fed]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[9e0dc83c8483b671]::fmt::Display>::fmt
   1:     0x710375e15e08 - core[9e0dc83c8483b671]::fmt::write
   2:     0x710375718fd6 - <std[e484e3d4f01e0fed]::sys::stdio::unix::Stderr as std[e484e3d4f01e0fed]::io::Write>::write_fmt
   3:     0x7103756d86ee - std[e484e3d4f01e0fed]::panicking::default_hook::{closure#0}
   4:     0x7103756f5bd3 - std[e484e3d4f01e0fed]::panicking::default_hook
   5:     0x7103746e8941 - std[e484e3d4f01e0fed]::panicking::update_hook::<alloc[a6174e8bdd8d2dbd]::boxed::Box<rustc_driver_impl[95f540fa8300e03f]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7103756f5eb2 - std[e484e3d4f01e0fed]::panicking::panic_with_hook
   7:     0x7103756d87e4 - std[e484e3d4f01e0fed]::panicking::panic_handler::{closure#0}
   8:     0x7103756ccca9 - std[e484e3d4f01e0fed]::sys::backtrace::__rust_end_short_backtrace::<std[e484e3d4f01e0fed]::panicking::panic_handler::{closure#0}, !>
   9:     0x7103756da21d - __rustc[7b4d46beff6b228a]::rust_begin_unwind
  10:     0x71037238275c - core[9e0dc83c8483b671]::panicking::panic_fmt
  11:     0x710372257232 - core[9e0dc83c8483b671]::panicking::panic
  12:     0x71037458cafe - <rustc_codegen_ssa[fd83ad70eed13863]::back::linker::GccLinker as rustc_codegen_ssa[fd83ad70eed13863]::back::linker::Linker>::enable_profiling
  13:     0x710377227eae - rustc_codegen_ssa[fd83ad70eed13863]::back::link::add_order_independent_options
  14:     0x71037701fc4e - rustc_codegen_ssa[fd83ad70eed13863]::back::link::linker_with_args
  15:     0x7103772302db - rustc_codegen_ssa[fd83ad70eed13863]::back::link::link_natively
  16:     0x71037707946d - rustc_codegen_ssa[fd83ad70eed13863]::back::link::link_binary
  17:     0x710377078548 - <rustc_codegen_llvm[fbfa248efd937778]::LlvmCodegenBackend as rustc_codegen_ssa[fd83ad70eed13863]::traits::backend::CodegenBackend>::link
  18:     0x710376d19a27 - <rustc_interface[c8385e5c154774b7]::queries::Linker>::link
  19:     0x710376fba6f0 - rustc_interface[c8385e5c154774b7]::interface::run_compiler::<(), rustc_driver_impl[95f540fa8300e03f]::run_compiler::{closure#0}>::{closure#1}
  20:     0x710376f74efe - std[e484e3d4f01e0fed]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[c8385e5c154774b7]::util::run_in_thread_with_globals<rustc_interface[c8385e5c154774b7]::util::run_in_thread_pool_with_globals<rustc_interface[c8385e5c154774b7]::interface::run_compiler<(), rustc_driver_impl[95f540fa8300e03f]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  21:     0x710376f755ed - <std[e484e3d4f01e0fed]::thread::lifecycle::spawn_unchecked<rustc_interface[c8385e5c154774b7]::util::run_in_thread_with_globals<rustc_interface[c8385e5c154774b7]::util::run_in_thread_pool_with_globals<rustc_interface[c8385e5c154774b7]::interface::run_compiler<(), rustc_driver_impl[95f540fa8300e03f]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[9e0dc83c8483b671]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  22:     0x710376f7642c - <std[e484e3d4f01e0fed]::sys::thread::unix::Thread>::new::thread_start
  23:     0x710370894ac3 - <unknown>
  24:     0x7103709268d0 - <unknown>
  25:                0x0 - <unknown>

error: the compiler unexpectedly panicked. This is a bug

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: please make sure that you have updated to the latest nightly

note: please attach the file at `/app/rustc-ice-2026-04-29T18_56_35-1.txt` to your bug report

note: rustc 1.97.0-nightly (52b6e2c20 2026-04-27) running on x86_64-unknown-linux-gnu

note: compiler flags: -C debuginfo=2 --crate-type bin -C linker=/opt/compiler-explorer/gcc-15.2.0/bin/gcc -Z instrument-mcount -C linker-flavor=ld.lld

query stack during panic:
end of query stack
Compiler returned: 101

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions