From c5c58c82a80b28b5b91358a78df0beec4d08d2a0 Mon Sep 17 00:00:00 2001 From: Nico Tonnhofer Date: Sun, 2 Dec 2018 11:55:47 +0100 Subject: [PATCH] Makefile: add an option flag for flto e.g. for make regressiontests you could disable it for little faster test simple: make regresstiontests USE_FLTO=no --- Makefile-ARM | 8 +++++++- Makefile-AVR | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Makefile-ARM b/Makefile-ARM index 6c472b2..0a5bb4f 100644 --- a/Makefile-ARM +++ b/Makefile-ARM @@ -125,6 +125,10 @@ else ifeq ($(MCU), stm32f411) STARTUP_FILE = cmsis-startup_stm32f411xe.s endif +# Link time optimization is on by default +ifeq ($(USE_FLTO),) + USE_FLTO=yes +endif # Startup definitions. Not target MCU specific. CFLAGS = -D__STARTUP_CLEAR_BSS -D__START=main ifeq ($(MCU), lpc1114) @@ -145,7 +149,9 @@ endif CFLAGS += -Wall CFLAGS += -Wstrict-prototypes CFLAGS += -Os -CFLAGS += -flto +ifeq ($(USE_FLTO),yes) + CFLAGS += -flto +endif CFLAGS += -ffunction-sections CFLAGS += -fdata-sections #CFLAGS += -dM -E # To list all predefined macros into the .o file. diff --git a/Makefile-AVR b/Makefile-AVR index 216bb79..ed1fede 100644 --- a/Makefile-AVR +++ b/Makefile-AVR @@ -113,6 +113,10 @@ TARGET = $(PROGRAM).hex # to keep this working and can take a shortcut: SOURCES = $(wildcard *.c) +# Link time optimization is on by default +ifeq ($(USE_FLTO),) + USE_FLTO=yes +endif CFLAGS = $(EXTRA_CFLAGS) CFLAGS += -DF_CPU=$(F_CPU) CFLAGS += -DMCU_STR=\"$(MCU)\" @@ -132,7 +136,9 @@ CFLAGS += -Os CFLAGS += -ffunction-sections CFLAGS += -finline-functions-called-once CFLAGS += -mcall-prologues -CFLAGS += -flto +ifeq ($(USE_FLTO),yes) + CFLAGS += -flto +endif CFLAGS += -Wa,-adhlns=$(@:.o=.al) #CFLAGS += -dM -E # To list all predefined macros into the .o file.