rp-rs / rp2040-project-template

A basic rp2040-hal project with blinky and rtt logging example code. With this you can quickly get started on a new rp2040 project
480 stars 98 forks source link

Bare template crashes during release build with lto = 'fat' in nightly #71

Closed skrb-io closed 8 months ago

skrb-io commented 10 months ago

Building the rp2040 project template without any alterations with rust nightly results in an error caused by lto = 'fat' optimization

~/Documents/Projects/rp2040-nightly (main) $ cargo build --release
   Compiling rp2040-nightly v0.1.0 (/home/--/Documents/Projects/rp2040-nightly)
warning: Linking globals named '__addsf3': symbol multiply defined!

error: failed to load bitcode of module "rp2040_hal-33611457b63b1605.rp2040_hal.80f0522449fd3a4f-cgu.0.rcgu.o": 

warning: `rp2040-nightly` (bin "rp2040-nightly") generated 1 warning
error: could not compile `rp2040-nightly` (bin "rp2040-nightly") due to previous error; 1 warning emitted

It is possible that I am missing something, but changing lto = 'thin' seems to solve the issue albeit resulting in a larger binary size.

ithinuel commented 10 months ago

I confirm this is indeed broken on current nighly. it might be related to https://github.com/rust-lang/rust/issues/44322 but more investigation is still required at this stage.

jannic commented 10 months ago

I bisected this build error using cargo-bisect-rustc. The first bad commit was 8c2b57721728233e074db69d93517614de338055. https://github.com/rust-lang/rust/issues/118559 reports a regression in that commit that matches ours well enough that I assume it's the same issue.

ithinuel commented 10 months ago

Indeed, and there seem to be a PR attempting to fix something relate: https://github.com/rust-lang/rust/pull/118568

With a bit a luck it might be fixed in the next couple of days.

DianQK commented 10 months ago

Could you provide reproduction steps? I'm not sure #118568 will fix this. Sorry, I thought this was an issue filed to rust.

jannic commented 10 months ago

~Could you provide reproduction steps? I'm not sure #118568 will fix this.~ Sorry, I thought this was an issue filed to rust.

Still a good question:

rustup toolchain add nightly-2023-12-04 --target thumbv6m-none-eabi
git clone https://github.com/rp-rs/rp2040-project-template
cd rp2040-project-template
cargo +nightly-2023-12-04 build --target thumbv6m-none-eabi  --release
warning: Linking globals named '__addsf3': symbol multiply defined!

error: failed to load bitcode of module "rp2040_hal-33611457b63b1605.rp2040_hal.a08e78ef3bbbf4e6-cgu.0.rcgu.o": 

warning: `rp2040-project-template` (bin "rp2040-project-template") generated 1 warning
error: could not compile `rp2040-project-template` (bin "rp2040-project-template") due to 1 previous error; 1 warning emitted
DianQK commented 10 months ago

I can verify that https://github.com/rust-lang/rust/pull/118568 did not fix the issue. Could you please create a new issue of rust?

ithinuel commented 8 months ago

Checked with stable, beta & nightly. This is now resolved. 🎉