From 9f39b373a9d6bcfeb031555b216f08e85bfafa20 Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Sun, 16 Oct 2022 14:35:34 +0200 Subject: [PATCH] build: Set -mrelax to remove trampolines while linking Avr GCC automatically marks all indirect calls for trampoline generation irregardless of the target. This can be avoided by forcing -mshort-calls or using -mrelax that removes the trampoline at link time (after the call location has been proven to be reachable). This saves 510 bytes on the current build (the trampolines section is now empty as expected). --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 86136b3..9ea34f6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -106,7 +106,7 @@ if(CMAKE_CROSSCOMPILING) set(CMAKE_C_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE}) # mcu related settings - set(MCU_FLAGS -mmcu=atmega32u4 -DF_CPU=16000000L) + set(MCU_FLAGS -mmcu=atmega32u4 -DF_CPU=16000000L -mrelax) add_compile_options(${MCU_FLAGS}) add_link_options(${MCU_FLAGS})