Skip to content

ICE: AVR CPU not explicitly specified when building core for avr-atmega328p custom target #144227

@vincentmuriithi

Description

@vincentmuriithi

Problem Description:

I am attempting to cross-compile a Rust project for an AVR ATmega328p microcontroller. I'm using a custom target JSON file and trying to build core and compiler_builtins from source using cargo build -Z build-std.

The compiler consistently panics with the error "AVR CPU not explicitly specified" during the compilation of core (and subsequently compiler_builtins).

What I've tried:

  1. Updated Rustup and Nightly Toolchain: I have ensured my rustup and nightly toolchain are up to date.

    • rustup --version: rustup 1.28.2 (e4f3ad6f8 2025-04-28)
    • rustc version (from rustup update nightly output): rustc 1.90.0-nightly (0d9592026 2025-07-19)
  2. Attempted different linker flavors:

    • Initially, the linker-flavor in my custom target JSON was gcc.
    • I changed linker-flavor to ld.lld in the target JSON to see if that resolved the issue, but the panic persists. (Note: rust-lld component was not explicitly added as rustup indicated it's not a separate component for this host target).

Expected Behavior:

The core and compiler_builtins libraries should compile successfully for the avr-atmega328p target, recognizing the cpu specified in the target JSON.

My Custom Target JSON (../targets/avr-atmega328p.json):

{
  "llvm-target": "avr-unknown-unknown",
  "data-layout": "e-P1-p:16:8-i8:8-i16:8-i32:8-i64:8-f32:8-f64:8-n8-a:8",
  "target-endian": "little",
  "target-pointer-width": "16",
  "arch": "avr",
  "os": "none",
  "vendor": "unknown",
  "cpu": "atmega328p",
  "linker-flavor": "ld.lld",
  "relocation-model": "static",
  "panic-strategy": "abort",
  "disable-redzone": true,
  "executables": true,
  "max-atomic-width": 8
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-discussionCategory: Discussion or questions that doesn't represent real issues.O-AVRTarget: AVR processors (ATtiny, ATmega, etc.)T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions