cmake: enable -mcall-prologues

Reduces flash memory usage by ~300B

The CMake build outputs an ASM file for the firmware image and is human readable.
To see the impacted functions, look for these routines:

__prologue_saves__
__epilogue_restores__

They should come in pairs.

For more info about this option, see:
https://gcc.gnu.org/onlinedocs/gcc-7.3.0/gcc/AVR-Options.html#AVR-Options
pull/325/head
Guðni Már Gilbert 2024-07-27 22:28:28 +00:00
parent 88a241c741
commit 1d3a469b49
1 changed files with 3 additions and 0 deletions

View File

@ -127,6 +127,9 @@ if(CMAKE_CROSSCOMPILING)
# split and gc sections # split and gc sections
add_compile_options(-ffunction-sections -fdata-sections) add_compile_options(-ffunction-sections -fdata-sections)
add_link_options(-ffunction-sections -fdata-sections -Wl,--gc-sections) add_link_options(-ffunction-sections -fdata-sections -Wl,--gc-sections)
# Call Prologues/Epilogues to reduce code size
add_compile_options(-mcall-prologues)
else() else()
if(CMAKE_BUILD_TYPE STREQUAL "Debug") if(CMAKE_BUILD_TYPE STREQUAL "Debug")
add_compile_options(-O0) add_compile_options(-O0)