-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Description
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:
-
Updated Rustup and Nightly Toolchain: I have ensured my
rustup
andnightly
toolchain are up to date.rustup --version
:rustup 1.28.2 (e4f3ad6f8 2025-04-28)
rustc
version (fromrustup update nightly
output):rustc 1.90.0-nightly (0d9592026 2025-07-19)
-
Attempted different linker flavors:
- Initially, the
linker-flavor
in my custom target JSON wasgcc
. - I changed
linker-flavor
told.lld
in the target JSON to see if that resolved the issue, but the panic persists. (Note:rust-lld
component was not explicitly added asrustup
indicated it's not a separate component for this host target).
- Initially, the
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
}