From d3ed7d18a99211c021f1b2c1a47211c813db6915 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gu=C3=B0ni=20M=C3=A1r=20Gilbert?= Date: Sat, 27 Jul 2024 21:09:32 +0000 Subject: [PATCH] cmake: enable -mcall-prologues Reduces flash memory usage by ~5KB 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 --- CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 464535aae3..c0461ca26b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -341,6 +341,9 @@ if(CMAKE_CROSSCOMPILING) add_compile_options(-flto -fno-fat-lto-objects) add_link_options(-flto) + # Call Prologues/Epilogues to reduce code size + add_compile_options(-mcall-prologues) + # Create this target before we apply the GC options add_library(avr_core STATIC ${AVR_SOURCES}) set_reproducible_target(avr_core)