rust-lang / rust-lang/rust

[ICE]: Trying to flash the builtin LED of the Arduino Uno WIFI R2 board

Open
#153,266 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-codegen A-metadata C-bug I-ICE O-AVR requires-nightly T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Code
#![no_std]
#![no_main]
#![feature(asm_experimental_arch)]

use avr_device::atmega4809;
use core::panic::PanicInfo;

#[no_mangle]
pub extern "C" fn main() -> ! {
  let dp = atmega4809::Peripherals::take().unwrap();

  dp.PORTE.dirset.write(|w| unsafe { w.bits(1 << 2) });

  loop {
    dp.PORTE.outtgl.write(|w| unsafe { w.bits(1 << 2) });

    for _ in 0..30000 {
      unsafe { core::arch::asm!("nop") };
    }
  }
}

#[panic_handler]
fn panic(_info: &PanicInfo) -> ! {
  loop {}
}
Meta

rustc --version --verbose:

rustc 1.92.0 (ded5c06cf 2025-12-08)
binary: rustc
commit-hash: ded5c06cf21d2b93bffd5d884aa6e96934ee4234
commit-date: 2025-12-08
host: x86_64-unknown-linux-gnu
release: 1.92.0
LLVM version: 21.1.3
Error output
Compiling core v0.0.0 (/home/uapaxyeya/.asdf/installs/rust/1.92.0/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core)
   Compiling compiler_builtins v0.1.160 (/home/uapaxyeya/.asdf/installs/rust/1.92.0/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/compiler-builtins/compiler-builtins)

thread 'rustc' (255327) panicked at /rustc-dev/38c0de8dcb14d42290042521be9958d37f3fa390/compiler/rustc_codegen_ssa/src/back/metadata.rs:376:17:
/rustc-dev/38c0de8dcb14d42290042521be9958d37f3fa390/compiler/rustc_codegen_ssa/src/back/metadata.rs:376:17: AVR CPU not explicitly specified
stack backtrace:
   0: std::panicking::begin_panic::<alloc::string::String>
   1: rustc_middle::util::bug::opt_span_bug_fmt::<rustc_span::span_encoding::Span>::{closure#0}
   2: rustc_middle::ty::context::tls::with_opt::<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}
   3: rustc_middle::ty::context::tls::with_context_opt::<rustc_middle::ty::context::tls::with_opt<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
   4: rustc_middle::util::bug::bug_fmt
   5: rustc_codegen_ssa::back::metadata::elf_e_flags.cold
   6: rustc_codegen_ssa::back::metadata::create_object_file
   7: rustc_codegen_ssa::back::metadata::create_wrapper_file
   8: rustc_codegen_ssa::back::link::link_rlib
   9: rustc_codegen_ssa::back::link::link_binary
  10: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::link
  11: <rustc_interface::queries::Linker>::link
  12: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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 `/home/uapaxyeya/.asdf/installs/rust/1.92.0/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/rustc-ice-2026-03-02T02_04_09-255325.txt` to your bug report

note: rustc 1.96.0-nightly (38c0de8dc 2026-02-28) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib -C opt-level=3 -C embed-bitcode=no -Z unstable-options -C strip=debuginfo -Z force-unstable-if-unmarked

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
error: could not compile `core` (lib)

Caused by:
  process didn't exit successfully: `/home/uapaxyeya/.asdf/installs/rust/1.92.0/toolchains/nightly-x86_64-unknown-linux-gnu/bin/rustc --crate-name core --edition=2024 /home/uapaxyeya/.asdf/installs/rust/1.92.0/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=208 --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C embed-bitcode=no --warn=unexpected_cfgs --check-cfg 'cfg(no_fp_fmt_parse)' --check-cfg 'cfg(feature, values(any()))' --check-cfg 'cfg(target_has_reliable_f16)' --check-cfg 'cfg(target_has_reliable_f16_math)' --check-cfg 'cfg(target_has_reliable_f128)' --check-cfg 'cfg(target_has_reliable_f128_math)' --check-cfg 'cfg(llvm_enzyme)' --check-cfg 'cfg(docsrs,test)' --check-cfg 'cfg(feature, values("debug_refcell", "llvm_enzyme", "optimize_for_size", "panic_immediate_abort"))' -C metadata=0871f1efbe247110 -C extra-filename=-296e39fb0880f35a --out-dir /usr/local/src/gittorrent/crates/microcontrollers/arduino_torrent/target/avr-atmega4809/release/deps --target /usr/local/src/gittorrent/crates/microcontrollers/arduino_torrent/avr-atmega4809.json -Zunstable-options -C strip=debuginfo -Z force-unstable-if-unmarked -L dependency=/usr/local/src/gittorrent/crates/microcontrollers/arduino_torrent/target/avr-atmega4809/release/deps -L dependency=/usr/local/src/gittorrent/crates/microcontrollers/arduino_torrent/target/release/deps --cap-lints allow` (exit status: 101)
warning: build failed, waiting for other jobs to finish...

thread 'rustc' (255362) panicked at /rustc-dev/38c0de8dcb14d42290042521be9958d37f3fa390/compiler/rustc_codegen_ssa/src/back/metadata.rs:376:17:
/rustc-dev/38c0de8dcb14d42290042521be9958d37f3fa390/compiler/rustc_codegen_ssa/src/back/metadata.rs:376:17: AVR CPU not explicitly specified
stack backtrace:
   0: std::panicking::begin_panic::<alloc::string::String>
   1: rustc_middle::util::bug::opt_span_bug_fmt::<rustc_span::span_encoding::Span>::{closure#0}
   2: rustc_middle::ty::context::tls::with_opt::<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}
   3: rustc_middle::ty::context::tls::with_context_opt::<rustc_middle::ty::context::tls::with_opt<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
   4: rustc_middle::util::bug::bug_fmt
   5: rustc_codegen_ssa::back::metadata::elf_e_flags.cold
   6: rustc_codegen_ssa::back::metadata::create_object_file
   7: rustc_codegen_ssa::back::metadata::create_wrapper_file
   8: rustc_codegen_ssa::back::link::link_rlib
   9: rustc_codegen_ssa::back::link::link_binary
  10: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::link
  11: <rustc_interface::queries::Linker>::link
  12: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

error: the compiler unexpectedly panicked. This is a bug

note: using internal features is not supported and expected to cause internal compiler errors when used incorrectly

note: please attach the file at `/home/uapaxyeya/.asdf/installs/rust/1.92.0/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/compiler-builtins/compiler-builtins/rustc-ice-2026-03-02T02_04_16-255359.txt` to your bug report

note: rustc 1.96.0-nightly (38c0de8dc 2026-02-28) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib -C opt-level=3 -C embed-bitcode=no -Z unstable-options -C strip=debuginfo -Z force-unstable-if-unmarked

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
error: could not compile `compiler_builtins` (lib)
Backtrace

thread 'rustc' panicked at /rustc-dev/38c0de8dcb14d42290042521be9958d37f3fa390/compiler/rustc_codegen_ssa/src/back/metadata.rs:376:17:
/rustc-dev/38c0de8dcb14d42290042521be9958d37f3fa390/compiler/rustc_codegen_ssa/src/back/metadata.rs:376:17: AVR CPU not explicitly specified
stack backtrace:
   0:     0x7f5eda57d6bb - <std[228bdc9d2b636708]::backtrace::Backtrace>::create
   1:     0x7f5eda57d605 - <std[228bdc9d2b636708]::backtrace::Backtrace>::force_capture
   2:     0x7f5ed956f3c4 - std[228bdc9d2b636708]::panicking::update_hook::<alloc[da121800ca3a425d]::boxed::Box<rustc_driver_impl[b079875acc15f158]::install_ice_hook::{closure#1}>>::{closure#0}
   3:     0x7f5eda5901b2 - std[228bdc9d2b636708]::panicking::panic_with_hook
   4:     0x7f5ed9b80992 - std[228bdc9d2b636708]::panicking::begin_panic::<alloc[da121800ca3a425d]::string::String>::{closure#0}
   5:     0x7f5ed9b6c9c6 - std[228bdc9d2b636708]::sys::backtrace::__rust_end_short_backtrace::<std[228bdc9d2b636708]::panicking::begin_panic<alloc[da121800ca3a425d]::string::String>::{closure#0}, !>
   6:     0x7f5ed9b65133 - std[228bdc9d2b636708]::panicking::begin_panic::<alloc[da121800ca3a425d]::string::String>
   7:     0x7f5ed9b80d86 - rustc_middle[ed586653b79aa9c2]::util::bug::opt_span_bug_fmt::<rustc_span[9fc5ff705eb51a66]::span_encoding::Span>::{closure#0}
   8:     0x7f5ed9b80f02 - rustc_middle[ed586653b79aa9c2]::ty::context::tls::with_opt::<rustc_middle[ed586653b79aa9c2]::util::bug::opt_span_bug_fmt<rustc_span[9fc5ff705eb51a66]::span_encoding::Span>::{closure#0}, !>::{closure#0}
   9:     0x7f5ed9b71f8b - rustc_middle[ed586653b79aa9c2]::ty::context::tls::with_context_opt::<rustc_middle[ed586653b79aa9c2]::ty::context::tls::with_opt<rustc_middle[ed586653b79aa9c2]::util::bug::opt_span_bug_fmt<rustc_span[9fc5ff705eb51a66]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  10:     0x7f5ed7e88f14 - rustc_middle[ed586653b79aa9c2]::util::bug::bug_fmt
  11:     0x7f5edcca1444 - rustc_codegen_ssa[9f9f62c73c3e6b04]::back::metadata::elf_e_flags.cold
  12:     0x7f5edbf4fa62 - rustc_codegen_ssa[9f9f62c73c3e6b04]::back::metadata::create_object_file
  13:     0x7f5edbf4ffb6 - rustc_codegen_ssa[9f9f62c73c3e6b04]::back::metadata::create_wrapper_file
  14:     0x7f5edbc12789 - rustc_codegen_ssa[9f9f62c73c3e6b04]::back::link::link_rlib
  15:     0x7f5edbba26e3 - rustc_codegen_ssa[9f9f62c73c3e6b04]::back::link::link_binary
  16:     0x7f5edbba20e9 - <rustc_codegen_llvm[f83347ca346a9490]::LlvmCodegenBackend as rustc_codegen_ssa[9f9f62c73c3e6b04]::traits::backend::CodegenBackend>::link
  17:     0x7f5edbee9d7a - <rustc_interface[d301261baebd53ed]::queries::Linker>::link
  18:     0x7f5edbe6a19a - rustc_interface[d301261baebd53ed]::interface::run_compiler::<(), rustc_driver_impl[b079875acc15f158]::run_compiler::{closure#0}>::{closure#1}
  19:     0x7f5edbde4f7e - std[228bdc9d2b636708]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[d301261baebd53ed]::util::run_in_thread_with_globals<rustc_interface[d301261baebd53ed]::util::run_in_thread_pool_with_globals<rustc_interface[d301261baebd53ed]::interface::run_compiler<(), rustc_driver_impl[b079875acc15f158]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  20:     0x7f5edbde55e0 - <std[228bdc9d2b636708]::thread::lifecycle::spawn_unchecked<rustc_interface[d301261baebd53ed]::util::run_in_thread_with_globals<rustc_interface[d301261baebd53ed]::util::run_in_thread_pool_with_globals<rustc_interface[d301261baebd53ed]::interface::run_compiler<(), rustc_driver_impl[b079875acc15f158]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[ca6b92032f8209e6]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  21:     0x7f5edbde646c - <std[228bdc9d2b636708]::sys::thread::unix::Thread>::new::thread_start
  22:     0x7f5ed58a597a - <unknown>
  23:     0x7f5ed59292bc - <unknown>
  24:                0x0 - <unknown>


rustc version: 1.96.0-nightly (38c0de8dc 2026-02-28)

I'm hesitant to make this bug report, because I easily fixed this bug by changing '/.cargo/config.toml' from this:

[build]
target = "avr-atmega4809.json"

[unstable]
build-std        = ["core"]
json-target-spec = true

to this:

[build]
target = "avr-atmega4809.json"
rustflags = ["-C", "target-cpu=atmega4809"]

[unstable]
build-std        = ["core"]
json-target-spec = true

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the AVR build from the supplied no_std example, then inspect compiler/rustc_codegen_ssa/src/back/metadata.rs around elf_e_flags, create_object_file, and create_wrapper_file. Done means the reported AVR compilation no longer causes an internal compiler panic, with regression coverage for the failing invocation.

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
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.