Rahix / avr-hal

embedded-hal abstractions for AVR microcontrollers
Apache License 2.0
1.3k stars 219 forks source link

tier 3 target and broken #560

Open stappersg opened 3 months ago

stappersg commented 3 months ago

This issue is for creating awareness for https://github.com/rust-lang/rust/issues/126349

avr-unknown-gnu-atmega328 (ran out of registers during register allocation)

That rust lang request got my attention, but have no resources available for any follow-up. Hence this issue.

I hope some one accepts the challenge.

Any way: Happy Hacking

adicarlo commented 1 month ago

BTW, I'm still a bit newbie when it comes to rust-avr, but I found that core will build debug mode if you add to Cargo.toml:

[profile.dev]
opt-level = 1

Reviewing https://github.com/rust-lang/rust/issues/126349 it seems like we might have a few ways to go here, maybe from easiest to hardest:

  1. hack on rustc guts so raise opt-level 0 to 1 in all cases ?
  2. track down what is causing the register allocation problem and fix it in the source
  3. accelerate the shift away from GCC and towards LLVM

I'm happy to pitch in here but I would probably need a bit of guidance on which approach to take...

Rahix commented 1 month ago

Slightly off-topic for this issue, but @adicarlo, you should be setting even more compiler tunes to get AVR programs to build properly:

https://github.com/Rahix/avr-hal/blob/65b304ec974a13f27ebc2ced21aa462c4b81ce82/Cargo.toml#L1-L11

adicarlo commented 1 month ago

@Rahix i see that, from over at https://github.com/Rahix/avr-hal-template/blob/main/Cargo.toml#L55

You say "needed to build" but I'm able to build without all that -- I assume you're saying it wouldn't work (or work well) on actual hardware w/o those settings from the template?

stappersg commented 1 month ago

On Thu, Aug 15, 2024 at 04:08:14PM -0700, Adam Di Carlo wrote:

you're saying it wouldn't work (or work well) on actual hardware

Yes.

Experiment for those who don't want to get their feet wet on true hardware:

aykevl commented 1 month ago

I suspect this is the same register allocation bug: https://github.com/llvm/llvm-project/issues/104032

adicarlo commented 1 month ago

@aykevl that's very promising! You boiled out a simple/general test case. Looks like its getting some action too...