Skip to content

Commit 244476e

Browse files
committed
stmhal: For non-debug compile, enable CC/LD opt to remove dead code.
Saves over 35k ROM due to elimination of unused HAL functions. All tests pass. Addresses issue adafruit#702.
1 parent c84aa41 commit 244476e

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

stmhal/Makefile

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,21 @@ INC += -I$(CC3K_DIR)
4242

4343
CFLAGS_CORTEX_M4 = -mthumb -mtune=cortex-m4 -mabi=aapcs-linux -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -fsingle-precision-constant -Wdouble-promotion
4444
CFLAGS = $(INC) -Wall -Werror -ansi -std=gnu99 -nostdlib $(CFLAGS_CORTEX_M4) $(COPT)
45-
4645
CFLAGS += -Iboards/$(BOARD)
4746

48-
#Debugging/Optimization
47+
LDFLAGS = -nostdlib -T stm32f405.ld -Map=$(@:.elf=.map) --cref
48+
LIBS =
49+
50+
# Debugging/Optimization
4951
ifeq ($(DEBUG), 1)
5052
CFLAGS += -g -DPENDSV_DEBUG
5153
COPT = -O0
5254
else
55+
CFLAGS += -fdata-sections -ffunction-sections
5356
COPT += -Os -DNDEBUG
57+
LDFLAGS += --gc-sections
5458
endif
5559

56-
LDFLAGS = -nostdlib -T stm32f405.ld -Map=$(@:.elf=.map) --cref
57-
LIBS =
58-
5960
# uncomment this if you want libgcc
6061
#LIBS += $(shell $(CC) -print-libgcc-file-name)
6162

0 commit comments

Comments
 (0)