Open stappersg opened 2 years ago
When adding --target ./avr-atmega328p.json
is there a complete other error, which is earlier, it comes from avr-config
:
Compiling avr-config v2.0.1
warning: target json file contains unused fields: no-compiler-rt
error[E0463]: can't find crate for `core`
|
= note: the `avr-atmega328p-9922596273948483120` target may not be installed
= help: consider downloading the target with `rustup target add avr-atmega328p-9922596273948483120`
= help: consider building the standard library from source with `cargo build -Zbuild-std`
error[E0463]: can't find crate for `compiler_builtins`
error: proc macro panicked
--> /home/stappers/.cargo/registry/src/github.com-1ecc6299db9ec823/avr-config-2.0.1/src/cpu_frequency.rs:22:36
|
22 | const CPU_FREQUENCY_HZ_IMPL: u32 = value_from_env!("AVR_CPU_FREQUENCY_HZ": u32); // Must be set whenever AVR is being targeted.
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: message: no value available for environment variable 'AVR_CPU_FREQUENCY_HZ'
error: requires `sized` lang_item
For more information about this error, try `rustc --explain E0463`.
warning: `avr-config` (lib) generated 1 warning
error: could not compile `avr-config` due to 4 previous errors; 1 warning emitted
$
So adding a target doesn't seem the correct way to set the correct register class. Yes, help is wanted.
Some information about my system:
In detail
$ rustup update
info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu'
info: syncing channel updates for 'nightly-x86_64-unknown-linux-gnu'
info: checking for self-updates
stable-x86_64-unknown-linux-gnu unchanged - rustc 1.61.0 (fe5b13d68 2022-05-18)
nightly-x86_64-unknown-linux-gnu unchanged - rustc 1.63.0-nightly (e6a4afc3a 2022-05-20)
info: cleaning up downloads & tmp directories
$ rustup target list | grep -i -e aRm | wc
17 17 428
$ rustup target list | grep -i -e aVr | wc
0 0 0
$
Asking @mbuesch, author of #18, how system looks there.
I have installed the nightly toolchain into a separate directory:
$ cat rust-unstable-activate
export RUSTUP_HOME="$HOME/.rust-unstable/rustup"
export CARGO_HOME="$HOME/.rust-unstable/cargo"
export PATH="$CARGO_HOME/bin:$PATH"
PS1="rust-unstable/$PS1"
$ . rust-unstable-activate
rust-unstable$ rustup show
Default host: x86_64-unknown-linux-gnu
rustup home: $HOME/.rust-unstable/rustup
installed toolchains
--------------------
nightly-2022-03-18-x86_64-unknown-linux-gnu
nightly-x86_64-unknown-linux-gnu (default)
active toolchain
----------------
nightly-x86_64-unknown-linux-gnu (default)
rustc 1.63.0-nightly (cd282d7f7 2022-05-18)
With that environment I build the project with:
rust-unstable$ cargo build --target avr-atmega328p.json -Z build-std=core --release
rust-unstable$ cat avr-atmega328p.json
{
"arch": "avr",
"cpu": "atmega328p",
"data-layout": "e-P1-p:16:8-i8:8-i16:8-i32:8-i64:8-f32:8-f64:8-n8-a:8",
"env": "",
"executables": true,
"linker": "avr-gcc",
"linker-flavor": "gcc",
"linker-is-gnu": true,
"llvm-target": "avr-unknown-unknown",
"no-compiler-rt": true,
"os": "unknown",
"position-independent-executables": false,
"exe-suffix": ".elf",
"eh-frame-header": false,
"pre-link-args": {
"gcc": ["-mmcu=atmega328p"]
},
"late-link-args": {
"gcc": ["-lgcc", "-lc"]
},
"target-c-int-width": "16",
"target-endian": "little",
"target-pointer-width": "16",
"vendor": "unknown"
}
Also see this documentation for reg constraints: https://doc.rust-lang.org/stable/unstable-book/language-features/asm-experimental-arch.html
Yes, progress. Thanks mbuesh. With commit cfe9848f8 and command line
AVR_CPU_FREQUENCY_HZ=8_000_000 cargo +nightly build --target ./avr-atmega328p.json -Z build-std=core --release
do I get a clean compile.
Issue is solved and left open for documentation purposes. (The long term goal is that avr rust book has the documentation.)
Hi,
Over here is this seen:
What would be the correct register class?