Hello!
Absolute rust newbie here. I'm trying to compile an absolutely minimal program for an attiny85 micro controller. No development board, just a plain attiny85.
Unfortunately, I'll get a SIGSEGV in rustc-std-workspace-core
when trying to compile. Those are the details:
± rustup show
Default host: x86_64-unknown-linux-gnu
rustup home: /home/markus/.rustup
installed toolchains
--------------------
stable-x86_64-unknown-linux-gnu (default)
nightly-x86_64-unknown-linux-gnu
active toolchain
----------------
nightly-x86_64-unknown-linux-gnu (directory override for '/home/markus/tmp/rust-playground/avr01')
rustc 1.69.0-nightly (0416b1a6f 2023-02-14)
Cargo.toml:
[package]
name = "avr01"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
[profile.dev]
panic = "abort"
[profile.release]
panic = "abort"
[dependencies.attiny-hal]
git = "https://github.com/rahix/avr-hal"
version = "*"
features = ["attiny85"]
main.rs:
#![no_std]
#![no_main]
#[no_mangle]
pub extern fn main() {
}
#[panic_handler]
fn my_panic(_info: &core::panic::PanicInfo) -> ! {
loop {}
}
I'm using the spec from avr-hal .
This is what happens:
± cargo build -Z build-std=core --target avr-attiny85.json
Blocking waiting for file lock on build directory
Compiling compiler_builtins v0.1.87
Compiling core v0.0.0 (/home/markus/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core)
Compiling proc-macro2 v1.0.51
Compiling unicode-ident v1.0.6
Compiling quote v1.0.23
Compiling syn v1.0.107
Compiling rustversion v1.0.11
Compiling proc-macro-hack v0.5.20+deprecated
Compiling paste v1.0.11
Compiling avr-hal-generic v0.1.0 (https://github.com/rahix/avr-hal#4c9c44c3)
Compiling ufmt-macros v0.2.0
Compiling rustc-std-workspace-core v1.99.0 (/home/markus/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/rustc-std-workspace-core)
/home/markus/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-0402d84ba5f47f34.so(+0x32c5e63)[0x14b8af8c5e63]
/lib/x86_64-linux-gnu/libc.so.6(+0x3bf90)[0x14b8ac45af90]
/home/markus/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/libLLVM-15-rust-1.69.0-nightly.so(_ZN4llvm12MachineInstr10addOperandERNS_15MachineFunctionERKNS_14MachineOperandE+0x1e6)[0x14b8aaa00542]
/home/markus/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/libLLVM-15-rust-1.69.0-nightly.so(+0x4c7d58c)[0x14b8aa27d58c]
/home/markus/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/libLLVM-15-rust-1.69.0-nightly.so(+0x4c7d2df)[0x14b8aa27d2df]
/home/markus/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/libLLVM-15-rust-1.69.0-nightly.so(_ZN4llvm13FPPassManager13runOnFunctionERNS_8FunctionE+0xafd)[0x14b8aac4acd9]
/home/markus/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/libLLVM-15-rust-1.69.0-nightly.so(_ZN4llvm13FPPassManager11runOnModuleERNS_6ModuleE+0x2f)[0x14b8aac4a1bb]
/home/markus/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/libLLVM-15-rust-1.69.0-nightly.so(_ZN4llvm6legacy15PassManagerImpl3runERNS_6ModuleE+0x21a)[0x14b8aad544a0]
/home/markus/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-0402d84ba5f47f34.so(+0x27bc892)[0x14b8aedbc892]
/home/markus/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-0402d84ba5f47f34.so(+0x27bc2aa)[0x14b8aedbc2aa]
/home/markus/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-0402d84ba5f47f34.so(+0x27ba4c5)[0x14b8aedba4c5]
/home/markus/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-0402d84ba5f47f34.so(+0x27b767d)[0x14b8aedb767d]
/home/markus/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-0402d84ba5f47f34.so(+0x27b65ff)[0x14b8aedb65ff]
/home/markus/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-0402d84ba5f47f34.so(+0x27b55e0)[0x14b8aedb55e0]
/home/markus/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-0402d84ba5f47f34.so(+0x26eff26)[0x14b8aeceff26]
/home/markus/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/libstd-67e0fe4bfa018a5e.so(rust_metadata_std_c4719229b53c8129+0x10ed23)[0x14b8b0b98d23]
/lib/x86_64-linux-gnu/libc.so.6(+0x88fd4)[0x14b8ac4a7fd4]
/lib/x86_64-linux-gnu/libc.so.6(+0x10966c)[0x14b8ac52866c]
Compiling nb v1.0.0
Compiling nb v0.1.3
Compiling ufmt-write v0.1.0
Compiling bare-metal v1.0.0
Compiling vcell v0.1.3
Compiling cfg-if v1.0.0
Compiling void v1.0.2
Compiling embedded-hal v0.2.7
Compiling avr-device v0.5.0
Compiling ufmt v0.1.2
error: could not compile `core`
Caused by:
process didn't exit successfully: `rustc --crate-name core --edition=2021 /home/markus/.rustup/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=225 --crate-type lib --emit=dep-info,metadata,link -C panic=abort -C embed-bitcode=no -C debuginfo=2 -C metadata=d0c1272c4f5cdc4e -C extra-filename=-d0c1272c4f5cdc4e --out-dir /home/markus/tmp/rust-playground/avr01/target/avr-attiny85/debug/deps --target /home/markus/tmp/rust-playground/avr01/avr-attiny85.json -Z force-unstable-if-unmarked -L dependency=/home/markus/tmp/rust-playground/avr01/target/avr-attiny85/debug/deps -L dependency=/home/markus/tmp/rust-playground/avr01/target/debug/deps --cap-lints allow` (signal: 11, SIGSEGV: invalid memory reference)
warning: build failed, waiting for other jobs to finish...
Since this happens when building rust core, I as an absolute beginner am a bit puzzled...
(Note that I'm only rust beginner. I have 30 years of programming experience, several years in the embedded world. Now an old dog wants to learn new tricks )
It would be absolutely awesome if you could help me.
Thanks,
The Grue.
bjorn3
February 15, 2023, 3:32pm
2
Good news: after rustup update nightly
today (i.e. rustc 1.69.0-nightly (4507fdaaa 2023-02-18)
, this error is gone.
Now I have this error (no changes in the minimal code that I have described above):
± cargo clean
[:~/tmp/rust-playground/avr01] master* ± cargo build -Z build-std=core --target avr-attiny85.json
Compiling compiler_builtins v0.1.87
Compiling core v0.0.0 (/home/markus/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core)
Compiling proc-macro2 v1.0.51
Compiling quote v1.0.23
Compiling unicode-ident v1.0.6
Compiling proc-macro-hack v0.5.20+deprecated
Compiling syn v1.0.107
Compiling rustversion v1.0.11
Compiling paste v1.0.11
Compiling avr-hal-generic v0.1.0 (https://github.com/rahix/avr-hal#4c9c44c3)
Compiling ufmt-macros v0.2.0
Compiling rustc-std-workspace-core v1.99.0 (/home/markus/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/rustc-std-workspace-core)
error: ran out of registers during register allocation
error: could not compile `core` due to previous error
And it seems very much related to this "solved" issue:
opened 08:15AM - 23 Aug 21 UTC
closed 06:07AM - 02 Feb 23 UTC
A-LLVM
C-bug
O-AVR
Compiling a pretty much empty project for AVR brings in `compiler_builtins` as a… dependency, but then building that fails with a segfault (with `--release`) or a a `ran out of registers during register allocation` error message.
To reproduce, make the following files:
# `Cargo.toml`
```
[package]
name = "foo"
version = "0.1.0"
```
# `.cargo/config`
```
[build]
target = "avr-unknown-gnu-atmega328"
[unstable]
build-std = ["core"]
```
# `src/main.rs`
```
#![no_std]
#![no_main]
#[no_mangle]
pub extern fn main() {
}
```
Build logs:
```
$ cargo build
Compiling core v0.0.0 (/home/cactus/sdk/rust/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core)
Compiling compiler_builtins v0.1.49
Compiling rustc-std-workspace-core v1.99.0 (rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/rustc-std-workspace-core)
error: ran out of registers during register allocation
error: could not compile `core` due to previous error
warning: build failed, waiting for other jobs to finish...
error: build failed
```
```
$ cargo build --release
Compiling compiler_builtins v0.1.49
Compiling core v0.0.0 (rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core)
Compiling rustc-std-workspace-core v1.99.0 (rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/rustc-std-workspace-core)
rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-f66b15f11dec651a.so(+0x4ffee3)[0x7f4b5705dee3]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x141f0)[0x7f4b567be1f0]
rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/../lib/libLLVM-13-rust-1.56.0-nightly.so(_ZN4llvm12MachineInstr15addRegisterDeadENS_8RegisterEPKNS_18TargetRegisterInfoEb+0xe1)[0x7f4b536eb021]
rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/../lib/libLLVM-13-rust-1.56.0-nightly.so(_ZN4llvm13LiveIntervals17computeDeadValuesERNS_12LiveIntervalEPNS_15SmallVectorImplIPNS_12MachineInstrEEE+0x2ab)[0x7f4b5363bd1b]
rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/../lib/libLLVM-13-rust-1.56.0-nightly.so(_ZN4llvm13LiveIntervals12shrinkToUsesEPNS_12LiveIntervalEPNS_15SmallVectorImplIPNS_12MachineInstrEEE+0x492)[0x7f4b5363d242]
rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/../lib/libLLVM-13-rust-1.56.0-nightly.so(_ZN4llvm13LiveRangeEdit17eliminateDeadDefsERNS_15SmallVectorImplIPNS_12MachineInstrEEENS_8ArrayRefINS_8RegisterEEEPNS_9AAResultsE+0x20a)[0x7f4b5365811a]
rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/../lib/libLLVM-13-rust-1.56.0-nightly.so(+0x25af0f2)[0x7f4b536090f2]
rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/../lib/libLLVM-13-rust-1.56.0-nightly.so(_ZN4llvm12RegAllocBase16postOptimizationEv+0x17)[0x7f4b5382adf7]
rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/../lib/libLLVM-13-rust-1.56.0-nightly.so(+0x27e04ca)[0x7f4b5383a4ca]
rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/../lib/libLLVM-13-rust-1.56.0-nightly.so(_ZN4llvm19MachineFunctionPass13runOnFunctionERNS_8FunctionE+0xee)[0x7f4b536dcfde]
rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/../lib/libLLVM-13-rust-1.56.0-nightly.so(_ZN4llvm13FPPassManager13runOnFunctionERNS_8FunctionE+0x639)[0x7f4b53479429]
rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/../lib/libLLVM-13-rust-1.56.0-nightly.so(_ZN4llvm13FPPassManager11runOnModuleERNS_6ModuleE+0x33)[0x7f4b534803e3]
rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/../lib/libLLVM-13-rust-1.56.0-nightly.so(_ZN4llvm6legacy15PassManagerImpl3runERNS_6ModuleE+0x470)[0x7f4b53479c90]
rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-f66b15f11dec651a.so(+0x2129268)[0x7f4b58c87268]
rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-f66b15f11dec651a.so(+0x20b004f)[0x7f4b58c0e04f]
rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-f66b15f11dec651a.so(+0x20b2f70)[0x7f4b58c10f70]
rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-f66b15f11dec651a.so(+0x20be46b)[0x7f4b58c1c46b]
rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-f66b15f11dec651a.so(+0x20b7d84)[0x7f4b58c15d84]
rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-f66b15f11dec651a.so(+0x20f9d3c)[0x7f4b58c57d3c]
rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-f66b15f11dec651a.so(+0x211631c)[0x7f4b58c7431c]
rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/libstd-1dd6c19f0820d51d.so(rust_metadata_std_155e9b00b45252a2+0xa9fe3)[0x7f4b5689bfe3]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x9450)[0x7f4b567b3450]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x43)[0x7f4b566c1d53]
error: could not compile `compiler_builtins`
Caused by:
process didn't exit successfully: `rustc --crate-name compiler_builtins .cargo/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.49/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C embed-bitcode=no --cfg 'feature="compiler-builtins"' --cfg 'feature="core"' --cfg 'feature="default"' --cfg 'feature="rustc-dep-of-std"' -C metadata=35ae16dbb58b86b3 -C extra-filename=-35ae16dbb58b86b3 --out-dir prog/rust/avr/compiler-builtins-bug/target/avr-unknown-gnu-atmega328/release/deps --target avr-unknown-gnu-atmega328 -Z force-unstable-if-unmarked -L dependency=prog/rust/avr/compiler-builtins-bug/target/avr-unknown-gnu-atmega328/release/deps -L dependency=prog/rust/avr/compiler-builtins-bug/target/release/deps --extern core=prog/rust/avr/compiler-builtins-bug/target/avr-unknown-gnu-atmega328/release/deps/librustc_std_workspace_core-feaa69e1bf1370b5.rmeta --cap-lints allow --cfg 'feature="unstable"'` (signal: 11, SIGSEGV: invalid memory reference)
```
Sigh…
Since they asked for it, I opened another ticket:
opened 10:18AM - 19 Feb 23 UTC
C-bug
I tried this code …
```rust
#![no_std]
#![no_main]
#[no_mangle]
pub ext… ern fn main() {
}
#[panic_handler]
fn my_panic(_info: &core::panic::PanicInfo) -> ! {
loop {}
}
```
… with this Cargo.toml …
``` toml
[package]
name = "avr01"
version = "0.1.0"
edition = "2021"
[dependencies]
[profile.dev]
panic = "abort"
[profile.release]
panic = "abort"
[dependencies.attiny-hal]
git = "https://github.com/rahix/avr-hal"
version = "*"
features = ["attiny85"]
```
… and this target avr-attiny85.json …
``` json
{
"arch": "avr",
"atomic-cas": false,
"cpu": "attiny85",
"data-layout": "e-P1-p:16:8-i8:8-i16:8-i32:8-i64:8-f32:8-f64:8-n8-a:8",
"eh-frame-header": false,
"exe-suffix": ".elf",
"executables": true,
"late-link-args": {
"gcc": [
"-lgcc"
]
},
"linker": "avr-gcc",
"llvm-target": "avr-unknown-unknown",
"max-atomic-width": 8,
"no-default-libraries": false,
"pre-link-args": {
"gcc": [
"-mmcu=attiny85"
]
},
"target-c-int-width": "16",
"target-pointer-width": "16"
}
```
… using today's rust nightly (`rustc 1.69.0-nightly (4507fdaaa 2023-02-18)`) and this commandline:
``` bash
cargo build -Z build-std=core --target avr-attiny85.json
```
I expected to see this happen: Given that I'm trying to compile rust for avr without success for a while, the only thing I expect is that the compiler doesn't crash.
Instead, this happened:
```
Compiling compiler_builtins v0.1.87
Compiling core v0.0.0 (/home/markus/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core)
Compiling proc-macro2 v1.0.51
Compiling quote v1.0.23
Compiling unicode-ident v1.0.6
Compiling proc-macro-hack v0.5.20+deprecated
Compiling syn v1.0.107
Compiling rustversion v1.0.11
Compiling paste v1.0.11
Compiling avr-hal-generic v0.1.0 (https://github.com/rahix/avr-hal#4c9c44c3)
Compiling ufmt-macros v0.2.0
Compiling rustc-std-workspace-core v1.99.0 (/home/markus/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/rustc-std-workspace-core)
error: ran out of registers during register allocation
error: could not compile `core` due to previous error
```
This seems very much related to this recently closed issue: https://github.com/rust-lang/rust/issues/88252
### Meta
<!--
If you're using the stable version of the compiler, you should also check if the
bug also exists in the beta or nightly versions.
-->
`rustc --version --verbose`:
```
rustc --version --verbose
rustc 1.69.0-nightly (4507fdaaa 2023-02-18)
binary: rustc
commit-hash: 4507fdaaa27ea2fb59a41df2ce7d1f290da53dae
commit-date: 2023-02-18
host: x86_64-unknown-linux-gnu
release: 1.69.0-nightly
LLVM version: 15.0.7
```
I wasn't able to create a backtrace using `RUST_BACKTRACE=1 cargo build`.
Background story in users.rust-lang.org:
https://users.rust-lang.org/t/sigsegv-when-trying-to-build-minimal-program-for-attiny85/89282
I have a working build now. The steps to fix it come from the github issue. I had to:
[profile.release]
lto = true
cargo build -Z build-std=core --target avr-attiny85.json --release
system
Closed
May 20, 2023, 11:26am
5
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.