Skip to content

Commit 2365f9b

Browse files
dhalbertgamblor21
authored andcommitted
shrink SAMD21 builds; rework shrink logic in Makefile
1 parent 3020893 commit 2365f9b

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

ports/atmel-samd/Makefile

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ INC += -I. \
5959
ifeq ($(CHIP_FAMILY), samd21)
6060
PERIPHERALS_CHIP_FAMILY=samd21
6161
OPTIMIZATION_FLAGS ?= -Os
62+
6263
# TinyUSB defines
6364
CFLAGS += -DCFG_TUSB_MCU=OPT_MCU_SAMD21 -DCFG_TUD_MIDI_RX_BUFSIZE=128 -DCFG_TUD_CDC_RX_BUFSIZE=128 -DCFG_TUD_MIDI_TX_BUFSIZE=128 -DCFG_TUD_CDC_TX_BUFSIZE=128 -DCFG_TUD_MSC_BUFSIZE=512
6465
endif
@@ -101,24 +102,26 @@ ifeq ($(DEBUG), 1)
101102
endif
102103
else
103104
CFLAGS += -DNDEBUG
104-
# -finline-limit can shrink the image size.
105-
# -finline-limit=80 or so is similar to not having it on.
106-
# There is no simple default value, though.
107105

108-
# Do a default shrink for small builds.
109-
ifndef CFLAGS_INLINE_LIMIT
110-
ifeq ($(CIRCUITPY_FULL_BUILD),0)
111-
CFLAGS_INLINE_LIMIT = 50
106+
# Do a default shrink for small builds, including all SAMD21 builds.
107+
ifeq ($(CIRCUITPY_FULL_BUILD),0)
108+
SHRINK_BUILD = 1
109+
else
110+
ifeq ($(CHIP_FAMILY), samd21)
111+
SHRINK_BUILD = 1
112112
endif
113113
endif
114114

115-
ifdef CFLAGS_INLINE_LIMIT
116-
CFLAGS += -finline-limit=$(CFLAGS_INLINE_LIMIT)
115+
# -finline-limit can shrink the image size.
116+
# -finline-limit=80 or so is similar to not having it on.
117+
# There is no simple default value, though.
118+
ifeq ($(SHRINK_BUILD), 1)
119+
CFLAGS += -finline-limit=45
117120
endif
118121

119-
ifeq ($(CIRCUITPY_FULL_BUILD),0)
120-
CFLAGS += --param inline-unit-growth=15 --param max-inline-insns-auto=20
121-
endif
122+
# We used to do this but it seems to not reduce space any more, at least in gcc 11.
123+
# Leave it here, commented out, just for reference.
124+
# --param inline-unit-growth=15 --param max-inline-insns-auto=20
122125

123126
ifdef CFLAGS_BOARD
124127
CFLAGS += $(CFLAGS_BOARD)

0 commit comments

Comments
 (0)