Zephry LTO optimization

Hello!

Code size is quite crucial in our project, naturally CONFIG_SIZE_OPTIMIZATIONS is enabled. In other projects I've experience with LTO (link time optimization), this feature could cut off a few more percents from final binary size. Alas I haven't seen any easily reachable option to activate LTO in Zephyr.

My best guess was the following in CMakeLists.txt:

zephyr_ld_options("-flto")

but the resulting binary size remained the same. I've digged into the build directory and found this in build.ninja:

...
LINK_FLAGS = -gdwarf-4
LINK_LIBRARIES = ... -flto
...

This tells me the build system added -flto to LINK_LIBRARIES instead of LINK_FLAGS. How can I make Zephyr build system use my custom linker flag? Possibly without hacking, the standard Zephyr way is preferred...

Parents Reply Children
No Data
Related