-
Notifications
You must be signed in to change notification settings - Fork 1k
Improvement: Enable -g on all builds #873
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
Hi @matthijskooijman |
Is there any record of this discussion you could link to? I'm curious what the arguments against are.
Yeah, that could be an alternative. I guess Arduino should really support platform-level menus rather than just board-level menus, but that is probably difficult to implement wrt backward compatibility... |
Well don't remember where it was discussed (GitHub, forums,...) |
AFAIR, -g increases binary size even if -Os is activated. Can be very critical for MCUs with small flash memory size. |
It will certainly increase the .elf file size, but I would expect it does not affect the actual code size (though I could not find anything definitive about this).
Yeah, that is a downside, but I would think it is a minimal cost. |
I have done some tests with Speeduino code on a Black 407VE, here ar the results:
|
@VitorBoss, when you say -g, that means the current |
Also, thanks for taking the time to provide some test data! :-) |
I'm using only the menu options Just digg on boards.txt and -g actually is -g -Og |
Using -g -Os give almost same results from -Os except for ELF size, it increased to 1.648.196 bytes Edit: Actually adding -g just increase the ELF file, the performance is the same on all options. Can't tell about compile time as my PC is a very old i5-520M |
I think I will add a new menu to enable or not the debug. any feedback ar welcome on this proposal 😉 |
As no feedback, I will add the new menu. |
Fixes stm32duino#873 Signed-off-by: Frederic Pillon <[email protected]>
Fixes stm32duino#873 Signed-off-by: Frederic Pillon <[email protected]>
Fixes #873 Signed-off-by: Frederic Pillon <[email protected]>
Currently, the
-g
compiler option for adding debug symbols is only passed when the optimization level is "Debug". However, I think that passing -g is always a good idea, even with higher optimization levels.Of course, when you expect to be debugging, you can simply enable the debug optimization level for a build. However, sometimes you need to debug a production build, in particular when you cannot reproduce the problem using a debug build, or when you want to analyze a stack dump collected from some production system.
It is true that aggressive optimizations might interfere with debugging, but in practice debugging still works reasonably well (and certainly better than having no debugging symbols at all).
Also, AFAIK adding debug symbols does not affect the produced machine code, so the only downside of adding debug symbols might be that compilation is a little slower.
Implementing this would, I think, be a matter of removing the
-g
option from the Debug optimization levels inboards.txt
(and replacing-g
with-Og
in its description, which is a good idea regardless). Then, the-g
option can be added unconditionally inplatformt.txt
.The text was updated successfully, but these errors were encountered: