aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAyke van Laethem2017-10-12 00:44:24 +0200
committerDamien George2018-07-18 17:12:25 +1000
commit38afc6553c85aa232ec6e2e5b4801cec2c8e0d49 (patch)
treeab0f9a1c18f9790c98f64fd766cb4d58c88b0ebd
parenta1116771b0c3f6b71e23e784609cc5deb1e2f3ea (diff)
nrf: Use --gc-sections to reduce code size
This saves about 6-7kB.
-rw-r--r--ports/nrf/Makefile4
1 files changed, 3 insertions, 1 deletions
diff --git a/ports/nrf/Makefile b/ports/nrf/Makefile
index 5bc36cade..ca22e093c 100644
--- a/ports/nrf/Makefile
+++ b/ports/nrf/Makefile
@@ -65,7 +65,7 @@ NRF_DEFINES += -DCONFIG_GPIO_AS_PINRESET
CFLAGS_CORTEX_M = -mthumb -mabi=aapcs -fsingle-precision-constant -Wdouble-promotion
-CFLAGS_MCU_m4 = $(CFLAGS_CORTEX_M) -mtune=cortex-m4 -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -ffunction-sections -fdata-sections
+CFLAGS_MCU_m4 = $(CFLAGS_CORTEX_M) -mtune=cortex-m4 -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard
CFLAGS_MCU_m0 = $(CFLAGS_CORTEX_M) --short-enums -mtune=cortex-m0 -mcpu=cortex-m0 -mfloat-abi=soft -fno-builtin
@@ -74,12 +74,14 @@ CFLAGS += $(CFLAGS_MCU_$(MCU_SERIES))
CFLAGS += $(INC) -Wall -Werror -ansi -std=gnu99 -nostdlib $(COPT) $(NRF_DEFINES) $(CFLAGS_MOD)
CFLAGS += -fno-strict-aliasing
CFLAGS += -fstack-usage
+CFLAGS += -fdata-sections -ffunction-sections
CFLAGS += -Iboards/$(BOARD)
CFLAGS += -DNRF5_HAL_H='<$(MCU_VARIANT)_hal.h>'
LDFLAGS = $(CFLAGS)
LDFLAGS += -Xlinker -Map=$(@:.elf=.map)
LDFLAGS += -mthumb -mabi=aapcs -T $(LD_FILE) -L boards/
+LDFLAGS += -Wl,--gc-sections
#Debugging/Optimization
ifeq ($(DEBUG), 1)