adafruit / Adafruit_nRF52_Bootloader

USB-enabled bootloaders for the nRF52 BLE SoC chips
MIT License
450 stars 409 forks source link

Use -fno-ipa-modref when building with gcc-11 (or later) #221

Closed daniel-thompson closed 3 years ago

daniel-thompson commented 3 years ago

As the large comment in the body of the patch, there are mistakes in the inline assembler fragments contained in the Nordic Softdevice header files. Fixing the problem is a bit fiddly so for now we'll simply work around the issue by disabling an optimization pass that was introduced in gcc-11.

daniel-thompson commented 3 years ago

This is the PR discussed in #211 ...

Note that this PR does not currently revert the structure initializations added in #211 although I think it could because those warnings were arguably correct!

tannewt commented 3 years ago

Is there an issue on a nordic repo to fix the assembly that is broken by this? I had to add this flag for CircuitPython to work as well.

daniel-thompson commented 3 years ago

Is there an issue on a nordic repo to fix the assembly that is broken by this? I had to add this flag for CircuitPython to work as well.

Yes, the inline assembler can be fixed but fixing it properly is a fairly big change since it would require modifying all the callers of SVCALL() (IIRC S132 alone has 138) so they can provide the number and names of all the arguments that the inline assembler will consume. I thought it unlikely any project would be keen to carry around such a pervasive change.

I did try a couple of different hacks with weak symbols or aliases to try keep SVCALL() unmodified but they all had drawbacks (linker can't garbage collect weak symbols, can't work header only, etc, etc).