-
-
Notifications
You must be signed in to change notification settings - Fork 400
Builder: Phase out --relax
option adding
#639
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
Comments
This is currently automatically added by arduino-builder/arduino-cli, but it should really be made explicit in the platform definition. This allows removing it from arduino-cli later, see arduino/arduino-cli#639 This option tells the linker to replace "call" instructions by "rcall" instructions where possible. This option was only automatically added for the atmega2560, but it is actually useful for any ATmega with > 8K flash (and a no-op for boards with <= 8K flash), so it can be added to the commandline unconditionally. This was tested on a Uno board (which saves a few bytes on the empty sketch) and an Arduino NG with atmega8, which also accepts the option but as expected it does not make a difference in sketch size.
This is currently automatically added by arduino-builder/arduino-cli, but it should really be made explicit in the platform definition. This allows removing it from arduino-cli later, see arduino/arduino-cli#639 This option tells the linker to replace "call" instructions by "rcall" instructions where possible. This option was only automatically added for the atmega2560, but it is actually useful for any ATmega with > 8K flash (and a no-op for boards with <= 8K flash), so it can be added to the commandline unconditionally. This was tested on a Uno board (which saves a few bytes on the empty sketch) and an Arduino NG with atmega8, which also accepts the option but as expected it does not make a difference in sketch size. Because this option is added at the end, it does not conflict with the automatically added option (the linker commandline just gets `-Wl,--relax,--relax` which works fine.
Pullrequest for ArduinoCore-AVR is here: arduino/ArduinoCore-avr#327 |
Any concern in merging this? It would also incidentally solve arduino/ArduinoCore-avr#339 (comment) |
It would indeed "solve" that, at least until arduino/ArduinoCore-avr#327 is merged. |
Correct, but before merging arduino/ArduinoCore-avr#327 we should check if it's still an hard requirement with latest toolchains |
If removing it doesn't break existing cores why not, do you care pushing a PR for this? |
I think it does not break anything (only increases flash space for function calls). I can make a PR for this, but might take a while until I get around to that. |
This removes the --relax option, potentially producing slightly bigger code for the atmega2560. On the longer term, the AVR core should just add this option for all boards, but this is not currently the case yet because removing --relax also works around a gcc miscompilation (see arduino/ArduinoCore-avr#339). Close: #639
When building a sketch, if the MCU is set to atmega2560,
,--relax
is added to the linker commandline:arduino-cli/legacy/builder/phases/linker.go
Lines 80 to 85 in 322bc6a
This is something that really should be taken care of in the
platform.txt
file, not in the builder, since the current code assumes to much about the platform, such as that you're actually using gcc, and that the last option on the link commandline is actually a-Wl
option (otherwise things break).This seems to stem from way back when the Arduino IDE still generated commandlines explicitly: arduino/Arduino@fa4ab4f
However, it seems that this option can be just be added to the commandline unconditionally, it is potentially helpful for any board with > 8K flash. Maybe this was different for the compiler versions used in 2011 when this was added, but I actually suspect this option was just misunderstood.
I just tried adding the option on a Uno board (which saves a few bytes on the empty sketch) and an Arduino NG with atmega8, which also accepts the option but as expected it does not make a difference.
I'll provide a PR for the AVR core in a minute.
Once that is done, I think this code should be removed from arduino-cli. How shall we approach this? I can imagine adding a check to see if the option is present in platform.txt and if not show a warning to notify core authors to update their core, except that we do not really have any machinery to toggle such warnings meaningfully (so it might just confuse users).
Since it is just an optimization (without it, some calls might end up 2 bytes longer), we could also consider just removing this?
The text was updated successfully, but these errors were encountered: