Skip to content

Commit 61b6fae

Browse files
aykevlglennrub
authored andcommitted
ports/nrf: Use --gc-sections to reduce code size
This saves about 6-7kB.
1 parent d18bf87 commit 61b6fae

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

ports/nrf/Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ NRF_DEFINES += -DCONFIG_GPIO_AS_PINRESET
6565

6666
CFLAGS_CORTEX_M = -mthumb -mabi=aapcs -fsingle-precision-constant -Wdouble-promotion
6767

68-
CFLAGS_MCU_m4 = $(CFLAGS_CORTEX_M) -mtune=cortex-m4 -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -ffunction-sections -fdata-sections
68+
CFLAGS_MCU_m4 = $(CFLAGS_CORTEX_M) -mtune=cortex-m4 -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard
6969

7070
CFLAGS_MCU_m0 = $(CFLAGS_CORTEX_M) --short-enums -mtune=cortex-m0 -mcpu=cortex-m0 -mfloat-abi=soft -fno-builtin
7171

@@ -74,12 +74,14 @@ CFLAGS += $(CFLAGS_MCU_$(MCU_SERIES))
7474
CFLAGS += $(INC) -Wall -Werror -ansi -std=gnu99 -nostdlib $(COPT) $(NRF_DEFINES) $(CFLAGS_MOD)
7575
CFLAGS += -fno-strict-aliasing
7676
CFLAGS += -fstack-usage
77+
CFLAGS += -fdata-sections -ffunction-sections
7778
CFLAGS += -Iboards/$(BOARD)
7879
CFLAGS += -DNRF5_HAL_H='<$(MCU_VARIANT)_hal.h>'
7980

8081
LDFLAGS = $(CFLAGS)
8182
LDFLAGS += -Xlinker -Map=$(@:.elf=.map)
8283
LDFLAGS += -mthumb -mabi=aapcs -T $(LD_FILE) -L boards/
84+
LDFLAGS += -Wl,--gc-sections
8385

8486
#Debugging/Optimization
8587
ifeq ($(DEBUG), 1)

0 commit comments

Comments
 (0)