From 360872d269e799c9c8237c06e8271f0c27eb9910 Mon Sep 17 00:00:00 2001 From: tmk Date: Tue, 31 May 2022 13:16:30 +0900 Subject: [PATCH] core: Build option for LTO(Link Time Optimization) This makes firmware size small but need to be tested more. https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html#Optimize-Options https://github.com/arduino/Arduino/issues/660 https://github.com/arduino/ArduinoCore-avr/blob/master/platform.txt * No `-fno-fat-lto-objects` is needed, it is the default. https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html#index-ffat-lto-objects * No `-fuse-linker-plugin` is needed, it is the default. https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html#index-fuse-linker-plugin --- tmk_core/rules.mk | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tmk_core/rules.mk b/tmk_core/rules.mk index b559e57b..cd2c0d8b 100644 --- a/tmk_core/rules.mk +++ b/tmk_core/rules.mk @@ -139,6 +139,7 @@ CFLAGS += -Wstrict-prototypes CFLAGS += -Wa,-adhlns=$(@:%.o=%.lst) CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) CFLAGS += $(CSTANDARD) +CFLAGS += -flto ifdef CONFIG_H CFLAGS += -include $(CONFIG_H) endif @@ -173,6 +174,7 @@ CPPFLAGS += -Wundef CPPFLAGS += -Wa,-adhlns=$(@:%.o=%.lst) CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) #CPPFLAGS += $(CSTANDARD) +CPPFLAGS += -flto ifdef CONFIG_H CPPFLAGS += -include $(CONFIG_H) endif @@ -189,6 +191,7 @@ endif # dump that will be displayed for a given single line of source input. ASFLAGS = $(ADEFS) -Wa,-adhlns=$(@:%.o=%.lst),-gstabs,--listing-cont-lines=100 ASFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) +ASFLAGS += -flto ifdef CONFIG_H ASFLAGS += -include $(CONFIG_H) endif @@ -261,6 +264,7 @@ LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB) #LDFLAGS += -T linker_script.x # You can give EXTRALDFLAGS at 'make' command line. LDFLAGS += $(EXTRALDFLAGS) +LDFLAGS += -flto