nrf: Make LTO configurable via Makefile flag.

LTO messes up debuggability and may cause some other issues.
Additionally, it does not always result in reduced code size.
This commit is contained in:
Ayke van Laethem 2018-02-18 19:20:52 +01:00 committed by Damien George
parent c486127378
commit 3cdecf90e6
1 changed files with 8 additions and 1 deletions

View File

@ -69,6 +69,13 @@ CFLAGS_MCU_m4 = $(CFLAGS_CORTEX_M) -mtune=cortex-m4 -mcpu=cortex-m4 -mfpu=fpv4-s
CFLAGS_MCU_m0 = $(CFLAGS_CORTEX_M) --short-enums -mtune=cortex-m0 -mcpu=cortex-m0 -mfloat-abi=soft -fno-builtin
LTO ?= 1
ifeq ($(LTO),1)
CFLAGS_LTO += -flto
else
CFLAGS_LTO += -Wl,--gc-sections -ffunction-sections -fdata-sections
endif
CFLAGS += $(CFLAGS_MCU_$(MCU_SERIES))
CFLAGS += $(INC) -Wall -Werror -ansi -std=gnu99 -nostdlib $(COPT) $(NRF_DEFINES) $(CFLAGS_MOD)
@ -76,7 +83,7 @@ CFLAGS += -fno-strict-aliasing
CFLAGS += -fstack-usage
CFLAGS += -Iboards/$(BOARD)
CFLAGS += -DNRF5_HAL_H='<$(MCU_VARIANT)_hal.h>'
CFLAGS += -flto
CFLAGS += $(CFLAGS_LTO)
LDFLAGS = $(CFLAGS)
LDFLAGS += -Xlinker -Map=$(@:.elf=.map)