summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAyke van Laethem <aykevanlaethem@gmail.com>2018-02-18 19:20:52 +0100
committerDamien George <damien.p.george@gmail.com>2018-07-18 17:12:25 +1000
commit3cdecf90e685d08ae2239fc80591fd96aa55610a (patch)
treee4786ebfc315a4c89ff8f8607e5fffcc6bb08f6b
parentc486127378e3eb977f45f335eafedd908cb2cf0c (diff)
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.
-rw-r--r--ports/nrf/Makefile9
1 files changed, 8 insertions, 1 deletions
diff --git a/ports/nrf/Makefile b/ports/nrf/Makefile
index 99dd60e82..680a7884b 100644
--- a/ports/nrf/Makefile
+++ b/ports/nrf/Makefile
@@ -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)