-
-
Notifications
You must be signed in to change notification settings - Fork 752
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
using newer compiler for ARM (13.2.Rel1) #2455
Comments
Forgot one more reason. The old compiler has very slow linker, in typical case this is longest part of whole build. Newer compilers are much faster in last LTO linking phase (like ~10 seconds instead of > 1 minute on slower computers). linking speed linking 8.2.1 (on i9 12900H - pretty fast computer, typically I use much slower machines) The size reduction is not that much but it is there, here is Bangle 1 build - saves about 1.1KB also the bootloader BANGLE1 bootloader with 8.2.1 - build with untested spi flashing - only 8 bytes free 0007DFE0 00 10 00 00 00 30 08 00 41 A5 07 00 00 00 00 00 |.....0..A.......| with gcc version 13.2.1 there is 244 bytes saving, now 252 bytes free 0007DEE0 01 00 FF FF 00 90 D0 03 10 00 00 00 00 10 00 00 |................| |
Where do I sign up? :) Even after a very expensive PC upgrade that is still frustrating! Things like this make me think I really do need to finally make a proper test harness that will test out the firmwares automatically on real hardware. It would make merging PRs like this seem a lot less risky.
Very strange - it's handled in https://github.com/espruino/Espruino/blob/master/targets/nrf5x_dfu/lcd.c#L839-L840 It should see space, realise it's less than char Do you have a picture of it? It should only be capable of setting pixels, and ONLY on X+0/1/2 - so if you see pixels being set at |
Added PR just to see what I did with the code in ram fix if you want to test it. |
here are photos https://ibb.co/album/hLbQ4M , just changing compiler back and rebuilding from same source fixes it |
my second fastest machine (Dell Optiplex 3000 thin client - 120EUR refurbished fanless thing from ebay, 3.3GHz Pentium Silver N6005) gcc version 8.2.1 8-2018-q4-major - linking takes 57s out of 1m28.715s make BOARD=BANGLEJS2 clean ; time make -j BOARD=BANGLEJS2 RELEASE=1 rm bin/*.elf ; time make -j BOARD=BANGLEJS2 RELEASE=1 gcc version 13.2.1 linking takes 9s our of 23s make BOARD=BANGLEJS2 clean ; time make -j BOARD=BANGLEJS2 RELEASE=1 rm bin/*.elf ; time make -j BOARD=BANGLEJS2 RELEASE=1 this is with
and for bootloader possibly also
|
Good news is that the bug is in the bootloader LCD code :-) There is mix of LCD_HEIGHT I guess LCD_DATA_HEIGHT should be used everywhere as that is what is in the EDIT: for bangle 2 it looks like sensible fix but when I tried to replace it everywhere I am not sure about these places I would guess that when x,y is used to access data in |
Great spot - thanks! Just a bit of background - to make it readable on most devices, we have an offscreen buffer and pixel-double. Those other bits look fine - although https://github.com/espruino/Espruino/blob/master/targets/nrf5x_dfu/lcd.c#L485 could change (but it doesn't matter really as all it wants to do is make For the other places, it's setting ymin/ymax to double because then it scans out all the pixels and uses Do you want to do a PR for that fix, or shall I stick it in? Just to add, on GCC 8, I get:
So it's a lot faster, but compiling everything else takes 2 seconds, and the final step takes 19 seconds - so updating the compiler would still be a great help. |
Please do without PR if possible. If you think everything else is OK then at least this causes the garbage (too much data copied) |
…en corruption on newer GCC builds (#2455)
Just done :) |
…rrent 8.2.1 compiler - should work faster with 13.2.1
I just added Am I right in thinking that there's actually not anything else that needs to change now before we swap compiler? I'm tempted to make a 2v21 firmware release before we do the swap, just in case anything comes up from it that we didn't notice. Then there'll be several weeks to notice any issues before 2v22 :) |
Yes, nothing else. There are those stdio warnings but should be harmless. Maybe debug builds could have more of that linked in? I do run Bangle2 build now in my watch and also started to use it for other builds but so far only flashed it to nrf52840 dongle which does not test more than Bangle2. EDIT: I also tried nrf52832 board with SDK12 and bootloader and it works. Will try stm32f103 and nrf51 in next days. |
Tried STM32F103 build for STLINK V2 USB dongle and it works fine in device however in this case new compiler produces larger code tried to build MICROBIT1 and that one is slightly smaller with newer compiler Tried also PICO_R1_3 build and that one is smaller with new compiler too and ESPRUINOBOARD, slightly bigger So looks like Cortex M3 thing(?) |
Interesting! Thanks for all that testing. It does look like an M3 thing (maybe they're putting more emphasis on M4 code generation and the M3 output is just M4 code with unsupported instructions replaced). It's a shame really as the M3 devices tend to have less flash so would really benefit. It feels like a 1.5k+ saving on all modern platforms should outweigh 1-200 bytes extra on old platforms though, so I'm still all for this |
Just looking into this a bit more - it's looking good. Interestingly the MICROBIT1 build doesn't have the
Makes them come back. Doing the builds the same way (using the compiler in a zip in GitHub) won't work as it's now too big (even when I remove all the targets we don't need), so I've done it direct from ARM for now. Last time it made the builds slower and unreliable as the 'external' server would sometimes fail, but we'll have to see what happens. |
It's in - and looks good: https://github.com/espruino/Espruino/actions/runs/7833136232 |
what is the limit? got it down from 170MB to 60MB by removing targets, stripping symbols from binaries and compressing into tar.zx ( |
I see it described as 100MB here https://github.com/espruino/EspruinoBuildTools/tree/master/arm
gives file size 83056216 |
That's great! The limit is 100 so that would be perfect. It must be the XZ_OPT - I tried here and I deleted everything apart from:
And it still was at 120 with the default options. Is there any side-effect of stripping the files? Does it hurt debugability? I just made the mistake of trying to google the man page for strip... |
Debuggability of gcc itself when it crashes or miscompiles probably yes. This strips just compiler executables, not target libraries. |
Oh wow, ok - that's perfect then. Thanks! I'm not going to get around to this before my break so I'll reopen for now, and close when I get the compiler in GitHub |
Creating this issue to track more issues and discuss rationale.
Current 8-2018-q4-major 8.2.1 compiler downloaded by provision script is quite old but produced shorter code than newer ones. However when testing latest one 13.2.rel1 gcc 13.2.1 from
https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads I see that it produces smaller code both for bootloader and main firmware. However there are some issues:
There is a breakage with newer gcc compilers in bootloader build - it cannot handle code in ".data" section, gives "Error: leb128 operand is an undefined symbol". https://www.mail-archive.com/gcc-bugs@gcc.gnu.org/msg718258.html I have a fix based on https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103698#c4 that seems to work, so I can create a PR, it works with old compiler too
When linking main firmware it produces set of (likely harmless) warnings like
Discussed here https://community.arm.com/support-forums/f/compilers-and-libraries-forum/53519/arm-gcc-11-3-rel1-newlib-nano-linker-warning-_read-is-not-implemented-and-will-always-fail
Looks like it works fine and the code calling this is not present in final binary but it is a bit strange. I did not succeed to make it go away when messing with nosys specs as mentioned in various places. However I don't see this in bootloader build (maybe something from stdio is not pulled in there at all, in main FW it may be there but optimized out).
The text was updated successfully, but these errors were encountered: