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
This commit is contained in:
Nico Tonnhofer 2018-12-02 11:55:47 +01:00
parent 963a1ad76f
commit c5c58c82a8
2 changed files with 14 additions and 2 deletions

View File

@ -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
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.

View File

@ -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
ifeq ($(USE_FLTO),yes)
CFLAGS += -flto
endif
CFLAGS += -Wa,-adhlns=$(@:.o=.al)
#CFLAGS += -dM -E # To list all predefined macros into the .o file.