-
-
Notifications
You must be signed in to change notification settings - Fork 7k
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
Move --relax from Compiler.java to some boards.txt param #2039
Comments
Woah, indeed, I was already wondering where that option came from. I don't think we already have a an "append compiler flags" feature from boards.txt? I wonder if we should take this opportunity to rethink where compiler flags come from, since there is also the wish to override or extend compiler flags from the commandline (#421) as well as using -D options to configure libraries, which would need per-sketch compiler flags (though #1808 solves library configuration differently, by using include files, having per-sketch compiler flags would still be useful in some cases). I did spend some time thinking about this though, and haven't come up with a satisfactory solution yet. Especially the "overriding" part is hard to get right. |
…ino#2039 and this fix is just a workaround
After @xxxajk pointed out that his Makefile produced smaller binaries than the IDE, I stumbled on this option. Apparently, passing --relax to the linker on non-mega targets turns out to be beneficial as well. The option tells to compiler to use RJMP / RCALL when possible, and JMP / CALL (which are a bit bigger) in other situations (e.g. when jumping to another 128kiB segment). You'd expect that on MCU's with < 128kiB, a RJMP / RCALL would be used unconditionally, regardless of the --relax option, but it turns out that it uses JMP / CALL instead. Perhaps this changed in recent compiler versions? In any case - we could just enable --relax always it seems. This would get rid of the hack in Compiler.java, as well as compiler smaller programs (an empty sketch for the Uno drops from 450 bytes to 436 bytes, bigger sketch will have more calls and jumps, so savings will be bigger there). |
Two more options help too. The second can save a ton if you use small functions a lot within a library and sketch. The only offset is that code will be delayed by a couple cycles, however with a large sketch on a smaller uC, it may be worth doing. |
Hm, not sure I like to add -fno-inline-small-functions, letting the compiler decide when to inline and when not to inline is often a good idea. Even more, the description of the option says:
Which would actually indicate that enabling Regarding I'll test both options against the full list of Arduino examples some time to see if they help. |
They do help, that's why I use them :-D On Mon, Nov 3, 2014 at 7:55 AM, Matthijs Kooijman [email protected]
Visit my github for awesome Arduino code @ https://github.com/xxxajk |
This issue just got reported on the arduino eclipse plugin as well Sloeber/arduino-eclipse-plugin#270 I'm wondering: boards.txt |
While we already have a handful of |
As said by @xxxajk and @matthijskooijman we can just add it permanently to the command line for all AVR boards. Does anyone know a reason to not do so? Previous versions of the IDE will continue to add the parameter to the command line and eventually ends to Just for the record, the relevant piece of code is now here
The current linker command is: compiler.c.elf.flags=-w -Os -Wl,--gc-sections with the relax options becomes: compiler.c.elf.flags=-w -Os -Wl,--gc-sections,--relax so ,--relax should be added specifically to the parameter -Wl,... (just appending to the whole command line as it now may not work if the command line is reordered).
|
This issue is essentially duplicated by arduino/arduino-cli#639 (which I reported last month, totally forgetting that this issue already existed). Regardless, that is now the location where the relevant code lives (nothing left to fix in this repo), so I'm going to close this issue in favor of that one. |
This piece of code should be removed and become part of a generic board specific flags configuration in boards.txt
https://github.com/arduino/Arduino/blob/ide-1.5.x/app/src/processing/app/debug/Compiler.java#L733-L739
The text was updated successfully, but these errors were encountered: