Skip to content

Commit

Permalink
cmake: enable -mcall-prologues
Browse files Browse the repository at this point in the history
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
  • Loading branch information
gudnimg committed Jul 27, 2024
1 parent 75570a8 commit 49a82cd
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ if(CMAKE_CROSSCOMPILING)
# split and gc sections
add_compile_options(-ffunction-sections -fdata-sections)
add_link_options(-ffunction-sections -fdata-sections -Wl,--gc-sections)

# Call Prologues/Epilogues to reduce code size
add_compile_options(-mcall-prologues)
else()
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
add_compile_options(-O0)
Expand Down

0 comments on commit 49a82cd

Please sign in to comment.