Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AVR: Cannot compile compiler_builtins in either release or debug mode with nightly 2021-08-21 #88252

Closed
gergoerdi opened this issue Aug 23, 2021 · 17 comments
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. O-AVR Target: AVR processors (ATtiny, ATmega, etc.) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@gergoerdi
Copy link

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/gh.neting.cc-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)

@gergoerdi gergoerdi added the C-bug Category: This is a bug. label Aug 23, 2021
@nikic
Copy link
Contributor

nikic commented Aug 23, 2021

Just to double check, this is a regression in nightly 2021-08-21 and worked fine with the previous nightly? In that case it's almost certainly an LLVM 13 regression.

@nikic nikic added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. O-AVR Target: AVR processors (ATtiny, ATmega, etc.) labels Aug 23, 2021
@gergoerdi
Copy link
Author

gergoerdi commented Aug 23, 2021 via email

@gergoerdi
Copy link
Author

OK so I just tried with some previous nightlies. On 2021-08-16 I am not getting a segfault; instead, it fails with:

LLVM ERROR: Not supported instr: <MCInst 296 <MCOperand Reg:1> <MCOperand Imm:15> <MCOperand Reg:47>>

I get the same error on 2021-05-21.

On 2021-02-22, I get:

LLVM ERROR: Not supported instr: <MCInst 258 <MCOperand Reg:1> <MCOperand Imm:15> <MCOperand Reg:45>>

@nikic
Copy link
Contributor

nikic commented Aug 23, 2021

Okay, that seems to be a long-standing issue then: rust-lang/compiler-builtins#400

@gergoerdi
Copy link
Author

I had to go back all the way to rustc 1.47.0-nightly (2d8a3b9 2020-08-26) to get this to work, at least up to compilation (I haven't done linking yet).

@MForster
Copy link

MForster commented Sep 8, 2021

I believe that there are two different issues at work here. I have a similar setup with a custom AVR target definition (for atmega32u4) that shows the ran out of registers issue first in nightly-2021-03-05. The previous day still works.

@gergoerdi
Copy link
Author

So is there a particular nightly that is known to work with AVR? I can compile my program with 2d8a3b9 2020-08-26 but the resulting program is juuuust a bit wrong when executing it. I hope I won't have to re-do all the LLVM AVR backend debugging from back in 2017...

@MForster
Copy link

I was experimenting with a later version from January 2021, and it also seemed to generate wrong code. Compilation succeeded, but the resulting program didn't seem to do what it should.

I'm not 100% sure about this, because I didn't have a debugging setup, but I couldn't get even the simplest logic to execute correctly.

@linclelinkpart5
Copy link

I had to go back all the way to rustc 1.47.0-nightly (2d8a3b9 2020-08-26) to get this to work, at least up to compilation (I haven't done linking yet).

Confirming that this nightly works for me. For reference, I'm following the steps in part 6 of https://book.avr-rust.com/ (after installing all the third-party tools linked in part 2 of the same link).

@bombela
Copy link

bombela commented Nov 23, 2021

For what is worth nightly-2021-01-07-x86_64-unknown-linux-gnu produces working machine code for me on attiny13a, attint24a and atmega328. Any version after that I get the LLVM ERROR: Not supported instr: <MCInst 312 <MCOperand Reg:1> <MCOperand Imm:15> <MCOperand Reg:47>> error.

@jeremysalwen
Copy link

I am hitting this crash with the latest nightly and https://reviews.llvm.org/D114611 applied (as well as the CONFIG-0000 and LLVM-0001 patches from https://gitlab.com/snowgoonspub/rust-avr-nightly-builder/-/tree/main/patches applied). I was able to compile rustc with debug info and get the following stack trace:

Command Line:

rustc --crate-name compiler_builtins /home/jeremy/.cargo/registry/src/gh.neting.cc-1ecc6299db9ec823/compiler_builtins-0.1.66/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --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=b3e737738101e8cc -C extra-filename=-b3e737738101e8cc --out-dir /home/jeremy/apechem/heapless/target/avr-atmega328p/release/deps --target /home/jeremy/apechem/heapless/avr-specs/avr-atmega328p.json -Z force-unstable-if-unmarked -L dependency=/home/jeremy/apechem/heapless/target/avr-atmega328p/release/deps -L dependency=/home/jeremy/apechem/heapless/target/release/deps --extern core=/home/jeremy/apechem/heapless/target/avr-atmega328p/release/deps/librustc_std_workspace_core-7e9ff7e977f1ead7.rmeta --cap-lints allow --cfg 'feature="unstable"'

Stack Trace:

Thread 25 "LTO compiler_bu" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffe4ffe640 (LWP 27539)]
0x00007ffff1660a5a in llvm::MachineInstr::addRegisterDead(llvm::Register, llvm::TargetRegisterInfo const*, bool) ()
   from /home/jeremy/.rustup/toolchains/snowgoons/lib/librustc_driver-c81e44a66c4bb924.so
(gdb) bt
#0  0x00007ffff1660a5a in llvm::MachineInstr::addRegisterDead(llvm::Register, llvm::TargetRegisterInfo const*, bool) ()
   from /home/jeremy/.rustup/toolchains/snowgoons/lib/librustc_driver-c81e44a66c4bb924.so
#1  0x00007ffff15981d0 in llvm::LiveIntervals::computeDeadValues(llvm::LiveInterval&, llvm::SmallVectorImpl<llvm::MachineInstr*>*) [clone .localalias] () from /home/jeremy/.rustup/toolchains/snowgoons/lib/librustc_driver-c81e44a66c4bb924.so
#2  0x00007ffff159e3aa in llvm::LiveIntervals::shrinkToUses(llvm::LiveInterval*, llvm::SmallVectorImpl<llvm::MachineInstr*>*) ()
   from /home/jeremy/.rustup/toolchains/snowgoons/lib/librustc_driver-c81e44a66c4bb924.so
#3  0x00007ffff15bbd8a in llvm::LiveRangeEdit::eliminateDeadDefs(llvm::SmallVectorImpl<llvm::MachineInstr*>&, llvm::ArrayRef<llvm::Register>, llvm::AAResults*) () from /home/jeremy/.rustup/toolchains/snowgoons/lib/librustc_driver-c81e44a66c4bb924.so
#4  0x00007ffff1561b03 in (anonymous namespace)::HoistSpillHelper::hoistAllSpills() ()
   from /home/jeremy/.rustup/toolchains/snowgoons/lib/librustc_driver-c81e44a66c4bb924.so
#5  0x00007ffff17aec62 in llvm::RegAllocBase::postOptimization() [clone .localalias] ()
   from /home/jeremy/.rustup/toolchains/snowgoons/lib/librustc_driver-c81e44a66c4bb924.so
#6  0x00007ffff17cd02e in (anonymous namespace)::RAGreedy::runOnMachineFunction(llvm::MachineFunction&) ()
   from /home/jeremy/.rustup/toolchains/snowgoons/lib/librustc_driver-c81e44a66c4bb924.so
#7  0x00007ffff16526d4 in llvm::MachineFunctionPass::runOnFunction(llvm::Function&) [clone .localalias] ()
   from /home/jeremy/.rustup/toolchains/snowgoons/lib/librustc_driver-c81e44a66c4bb924.so
#8  0x00007ffff25c8d20 in llvm::FPPassManager::runOnFunction(llvm::Function&) [clone .localalias] ()
   from /home/jeremy/.rustup/toolchains/snowgoons/lib/librustc_driver-c81e44a66c4bb924.so
#9  0x00007ffff25c8e8c in llvm::FPPassManager::runOnModule(llvm::Module&) [clone .localalias] ()
   from /home/jeremy/.rustup/toolchains/snowgoons/lib/librustc_driver-c81e44a66c4bb924.so
#10 0x00007ffff25ca8b1 in llvm::legacy::PassManagerImpl::run(llvm::Module&) [clone .localalias] ()
   from /home/jeremy/.rustup/toolchains/snowgoons/lib/librustc_driver-c81e44a66c4bb924.so
#11 0x00007ffff025c5c8 in LLVMRustWriteOutputFile () from /home/jeremy/.rustup/toolchains/snowgoons/lib/librustc_driver-c81e44a66c4bb924.so
#12 0x00007ffff00b270d in _RNvNtNtCs2Hy2UJfC2YD_18rustc_codegen_llvm4back5write17write_output_file ()
    at compiler/rustc_codegen_llvm/src/back/write.rs:72
#13 0x00007ffff00b91c7 in _RNCNvNtNtCs2Hy2UJfC2YD_18rustc_codegen_llvm4back5write7codegens0_0B7_ ()
    at compiler/rustc_codegen_llvm/src/back/write.rs:914
#14 _RINvNvNtNtCs2Hy2UJfC2YD_18rustc_codegen_llvm4back5write7codegen12with_codegenNCB2_s0_0INtNtCsaEJlGfOjSyv_4core6result6ResultuNtNtCs5LBiNHwbBUs_10rustc_span11fatal_error10FatalErrorEEB8_ () at compiler/rustc_codegen_llvm/src/back/write.rs:768
#15 _RNvNtNtCs2Hy2UJfC2YD_18rustc_codegen_llvm4back5write7codegen () at compiler/rustc_codegen_llvm/src/back/write.rs:913
#16 0x00007ffff010f382 in _RNvXs1_Cs2Hy2UJfC2YD_18rustc_codegen_llvmNtB5_18LlvmCodegenBackendNtNtNtCscKPc0T4Mv2G_17rustc_codegen_ssa6traits5write19WriteBackendMethods7codegen () at compiler/rustc_codegen_llvm/src/lib.rs:215
#17 _RINvNtNtCscKPc0T4Mv2G_17rustc_codegen_ssa4back5write24finish_intra_module_workNtCs2Hy2UJfC2YD_18rustc_codegen_llvm18LlvmCodegenBackendEB1g_ () at /home/jeremy/apechem/rust-avr-nightly-builder/build/rust/compiler/rustc_codegen_ssa/src/back/write.rs:911
#18 0x00007ffff010e088 in _RINvNtNtCscKPc0T4Mv2G_17rustc_codegen_ssa4back5write21execute_lto_work_itemNtCs2Hy2UJfC2YD_18rustc_codegen_llvm18LlvmCodegenBackendEB1d_ () at /home/jeremy/apechem/rust-avr-nightly-builder/build/rust/compiler/rustc_codegen_ssa/src/back/write.rs:897
--Type <RET> for more, q to quit, c to continue without paging--
#19 _RINvNtNtCscKPc0T4Mv2G_17rustc_codegen_ssa4back5write17execute_work_itemNtCs2Hy2UJfC2YD_18rustc_codegen_llvm18LlvmCodegenBackendEB19_ ()
    at /home/jeremy/apechem/rust-avr-nightly-builder/build/rust/compiler/rustc_codegen_ssa/src/back/write.rs:749
#20 0x00007ffff01ab6c5 in _RNCINvNtNtCscKPc0T4Mv2G_17rustc_codegen_ssa4back5write10spawn_workNtCs2Hy2UJfC2YD_18rustc_codegen_llvm18LlvmCodegenBackendE0B14_ () at /home/jeremy/apechem/rust-avr-nightly-builder/build/rust/compiler/rustc_codegen_ssa/src/back/write.rs:1665
#21 _RNCINvXs0_Cs2Hy2UJfC2YD_18rustc_codegen_llvmNtB8_18LlvmCodegenBackendNtNtNtCscKPc0T4Mv2G_17rustc_codegen_ssa6traits7backend19ExtraBackendMethods18spawn_named_threadNCINvNtNtB1b_4back5write10spawn_workBG_E0uE0B8_ () at compiler/rustc_codegen_llvm/src/lib.rs:157
#22 _RINvNtNtCsiRCMJYjrQF4_3std10sys_common9backtrace28___rust_begin_short_backtraceNCINvXs0_Cs2Hy2UJfC2YD_18rustc_codegen_llvmNtB1o_18LlvmCodegenBackendNtNtNtCscKPc0T4Mv2G_17rustc_codegen_ssa6traits7backend19ExtraBackendMethods18spawn_named_threadNCINvNtNtB2s_4back5write10spawn_workB1W_E0uE0uEB1o_ () at /home/jeremy/apechem/rust-avr-nightly-builder/build/rust/library/std/src/sys_common/backtrace.rs:123
#23 0x00007ffff0228cd7 in _RNCNCINvMNtCsiRCMJYjrQF4_3std6threadNtB7_7Builder15spawn_uncheckedNCINvXs0_Cs2Hy2UJfC2YD_18rustc_codegen_llvmNtB1b_18LlvmCodegenBackendNtNtNtCscKPc0T4Mv2G_17rustc_codegen_ssa6traits7backend19ExtraBackendMethods18spawn_named_threadNCINvNtNtB2f_4back5write10spawn_workB1J_E0uE0uEs_00B1b_ () at /home/jeremy/apechem/rust-avr-nightly-builder/build/rust/library/std/src/thread/mod.rs:477
#24 _RNvXsl_NtNtCsaEJlGfOjSyv_4core5panic11unwind_safeINtB5_16AssertUnwindSafeNCNCINvMNtCsiRCMJYjrQF4_3std6threadNtB1h_7Builder15spawn_uncheckedNCINvXs0_Cs2Hy2UJfC2YD_18rustc_codegen_llvmNtB2m_18LlvmCodegenBackendNtNtNtCscKPc0T4Mv2G_17rustc_codegen_ssa6traits7backend19ExtraBackendMethods18spawn_named_threadNCINvNtNtB3q_4back5write10spawn_workB2U_E0uE0uEs_00EINtNtNtB9_3ops8function6FnOnceuE9call_onceB2m_ ()
    at /home/jeremy/apechem/rust-avr-nightly-builder/build/rust/library/core/src/panic/unwind_safe.rs:271
#25 _RINvNvNtCsiRCMJYjrQF4_3std9panicking3try7do_callINtNtNtCsaEJlGfOjSyv_4core5panic11unwind_safe16AssertUnwindSafeNCNCINvMNtB6_6threadNtB1T_7Builder15spawn_uncheckedNCINvXs0_Cs2Hy2UJfC2YD_18rustc_codegen_llvmNtB2J_18LlvmCodegenBackendNtNtNtCscKPc0T4Mv2G_17rustc_codegen_ssa6traits7backend19ExtraBackendMethods18spawn_named_threadNCINvNtNtB3N_4back5write10spawn_workB3h_E0uE0uEs_00EuEB2J_ ()
    at /home/jeremy/apechem/rust-avr-nightly-builder/build/rust/library/std/src/panicking.rs:406
#26 _RINvNtCsiRCMJYjrQF4_3std9panicking3tryuINtNtNtCsaEJlGfOjSyv_4core5panic11unwind_safe16AssertUnwindSafeNCNCINvMNtB4_6threadNtB1K_7Builder15spawn_uncheckedNCINvXs0_Cs2Hy2UJfC2YD_18rustc_codegen_llvmNtB2A_18LlvmCodegenBackendNtNtNtCscKPc0T4Mv2G_17rustc_codegen_ssa6traits7backend19ExtraBackendMethods18spawn_named_threadNCINvNtNtB3E_4back5write10spawn_workB38_E0uE0uEs_00EEB2A_ ()
    at /home/jeremy/apechem/rust-avr-nightly-builder/build/rust/library/std/src/panicking.rs:370
#27 _RINvNtCsiRCMJYjrQF4_3std5panic12catch_unwindINtNtNtCsaEJlGfOjSyv_4core5panic11unwind_safe16AssertUnwindSafeNCNCINvMNtB4_6threadNtB1P_7Builder15spawn_uncheckedNCINvXs0_Cs2Hy2UJfC2YD_18rustc_codegen_llvmNtB2F_18LlvmCodegenBackendNtNtNtCscKPc0T4Mv2G_17rustc_codegen_ssa6traits7backend19ExtraBackendMethods18spawn_named_threadNCINvNtNtB3J_4back5write10spawn_workB3d_E0uE0uEs_00EuEB2F_ ()
    at /home/jeremy/apechem/rust-avr-nightly-builder/build/rust/library/std/src/panic.rs:133
#28 _RNCINvMNtCsiRCMJYjrQF4_3std6threadNtB5_7Builder15spawn_uncheckedNCINvXs0_Cs2Hy2UJfC2YD_18rustc_codegen_llvmNtB19_18LlvmCodegenBackendNtNtNtCscKPc0T4Mv2G_17rustc_codegen_ssa6traits7backend19ExtraBackendMethods18spawn_named_threadNCINvNtNtB2d_4back5write10spawn_workB1H_E0uE0uEs_0B19_
    () at /home/jeremy/apechem/rust-avr-nightly-builder/build/rust/library/std/src/thread/mod.rs:476
#29 _RNSNvYNCINvMNtCsiRCMJYjrQF4_3std6threadNtBa_7Builder15spawn_uncheckedNCINvXs0_Cs2Hy2UJfC2YD_18rustc_codegen_llvmNtB1e_18LlvmCodegenBackendNtNtNtCscKPc0T4Mv2G_17rustc_codegen_ssa6traits7backend19ExtraBackendMethods18spawn_named_threadNCINvNtNtB2i_4back5write10spawn_workB1M_E0uE0uEs_0INtNtNtCsaEJlGfOjSyv_4core3ops8function6FnOnceuE9call_once6vtableB1e_ ()
    at /home/jeremy/apechem/rust-avr-nightly-builder/build/rust/library/core/src/ops/function.rs:227
#30 0x00007fffeefd67e3 in <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once ()
--Type <RET> for more, q to quit, c to continue without paging--
    at /home/jeremy/apechem/rust-avr-nightly-builder/build/rust/library/alloc/src/boxed.rs:1854
#31 <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once ()
    at /home/jeremy/apechem/rust-avr-nightly-builder/build/rust/library/alloc/src/boxed.rs:1854
#32 std::sys::unix::thread::Thread::new::thread_start () at library/std/src/sys/unix/thread.rs:108
#33 0x00007fffeeedbd80 in start_thread (arg=0x7fffe4ffe640) at pthread_create.c:481
#34 0x00007fffeee06b6f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

@wuggen
Copy link

wuggen commented Jan 28, 2022

Confirming that I get this error on nightly-2022-01-11 (the most recent that I can use, since llvm_asm got removed and asm doesn't yet support AVR assembly), compiling for atmega32u2. As a workaround, setting RUSTFLAGS='-Ccodegen-units=1' gets past the segfault, but runs into the unsupported instruction error that @bombela mentioned.

@gergoerdi
Copy link
Author

It seems this has improved in the meantime. As of Rust nightly-2022-12-09 I was able to build https://github.com/gergoerdi/chirp8-avr/ and run it successfully at least on SimAVR. I haven't bothered uploading it to real hardware yet, but in the past, SimAVR has been very accurate so it seems it's all working now.

@workingjubilee
Copy link
Member

In light of the "it works in sim" report, I am potentially-overeagerly closing this. If this issue does return, please feel free to reopen this or open a new issue.

@workingjubilee
Copy link
Member

Note: This working, per @gergoerdi's report, likely depends on the

[profile.release]
lto = true

in chirp8-avr's Cargo.toml

As it is likely some of these AVR issues are related, probably we should coalesce some of them into a single issue and close the duplicates. However, my reasons for closing this one were incorrect, as such configuration should not be required just to build a minimal program. So, I have reopened this issue, until someone does the work to figure out which are actually duplicates (or just solve them all, that works too).

@Noratrieb Noratrieb added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Apr 5, 2023
@Patryk27
Copy link
Contributor

Probably same as #102278 - seems not to be crashing nowadays.

@workingjubilee
Copy link
Member

Oh good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. O-AVR Target: AVR processors (ATtiny, ATmega, etc.) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

10 participants