Skip to content

Commit 778e8bf

Browse files
committed
Changes to optimization option
1 parent d83a4ac commit 778e8bf

File tree

16 files changed

+46
-37
lines changed

16 files changed

+46
-37
lines changed

ports/atmel-samd/Makefile

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,29 +87,27 @@ INC += -I. \
8787

8888
ifeq ($(CHIP_FAMILY), samd21)
8989
PERIPHERALS_CHIP_FAMILY=samd21
90-
CFLAGS += -Os -DNDEBUG
90+
OPTIMIZATION_FLAGS ?= -Os
9191
# TinyUSB defines
9292
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
9393
endif
9494

9595
ifeq ($(CHIP_FAMILY), samd51)
9696
PERIPHERALS_CHIP_FAMILY=sam_d5x_e5x
97-
CFLAGS += -Os -DNDEBUG
97+
OPTIMIZATION_FLAGS ?= -O2
9898
# TinyUSB defines
9999
CFLAGS += -DCFG_TUSB_MCU=OPT_MCU_SAMD51 -DCFG_TUD_MIDI_RX_BUFSIZE=128 -DCFG_TUD_CDC_RX_BUFSIZE=256 -DCFG_TUD_MIDI_TX_BUFSIZE=128 -DCFG_TUD_CDC_TX_BUFSIZE=256 -DCFG_TUD_MSC_BUFSIZE=1024
100100
endif
101101

102102
ifeq ($(CHIP_FAMILY), same54)
103103
PERIPHERALS_CHIP_FAMILY=sam_d5x_e5x
104-
CFLAGS += -Os -DNDEBUG
104+
OPTIMIZATION_FLAGS ?= -O2
105105
# TinyUSB defines
106106
CFLAGS += -DCFG_TUSB_MCU=OPT_MCU_SAMD51 -DCFG_TUD_MIDI_RX_BUFSIZE=128 -DCFG_TUD_CDC_RX_BUFSIZE=256 -DCFG_TUD_MIDI_TX_BUFSIZE=128 -DCFG_TUD_CDC_TX_BUFSIZE=256 -DCFG_TUD_MSC_BUFSIZE=1024
107107
endif
108108

109-
# option to override compiler optimization level, set in boards/$(BOARD)/mpconfigboard.mk
110-
ifdef OPTIMIZATION_LEVEL
111-
CFLAGS += -O$(OPTIMIZATION_LEVEL)
112-
endif
109+
# option to override default optimization level, set in boards/$(BOARD)/mpconfigboard.mk
110+
CFLAGS += $(OPTIMIZATION_FLAGS) -DNDEBUG
113111

114112
$(echo PERIPHERALS_CHIP_FAMILY=$(PERIPHERALS_CHIP_FAMILY))
115113
#Debugging/Optimization

ports/atmel-samd/boards/itsybitsy_m4_express/mpconfigboard.mk

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,3 @@ LONGINT_IMPL = MPZ
1515
CIRCUITPY_AUDIOBUSIO = 0
1616

1717
CIRCUITPY_BITBANG_APA102 = 1
18-
OPTIMIZATION_LEVEL = 2

ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.mk

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,7 @@ CIRCUITPY_PS2IO = 0
1818
CIRCUITPY_AUDIOMP3 = 0
1919

2020
CIRCUITPY_ULAB = 0
21+
22+
# Override optimization to keep binary small
23+
OPTIMIZATION_FLAGS = -Os
24+

ports/atmel-samd/boards/loc_ber_m4_base_board/mpconfigboard.mk

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,6 @@ LONGINT_IMPL = MPZ
1515
CIRCUITPY_AUDIOBUSIO = 0
1616

1717
CIRCUITPY_BITBANG_APA102 = 1
18+
# Override optimization to keep binary small
19+
OPTIMIZATION_FLAGS = -Os
20+

ports/atmel-samd/boards/pewpew_m4/mpconfigboard.mk

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,6 @@ CFLAGS_INLINE_LIMIT = 45
4646
else
4747
CFLAGS_INLINE_LIMIT = 70
4848
endif
49+
50+
# Override optimization to keep binary small
51+
OPTIMIZATION_FLAGS = -Os

ports/atmel-samd/boards/pybadge/mpconfigboard.mk

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,3 @@ CIRCUITPY_GAMEPADSHIFT = 1
1616
CIRCUITPY_STAGE = 1
1717

1818
FROZEN_MPY_DIRS += $(TOP)/frozen/circuitpython-stage/pybadge
19-
OPTIMIZATION_LEVEL = 2

ports/atmel-samd/boards/pyportal/mpconfigboard.mk

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,3 @@ QSPI_FLASH_FILESYSTEM = 1
1010
EXTERNAL_FLASH_DEVICE_COUNT = 2
1111
EXTERNAL_FLASH_DEVICES = "W25Q64JV_IQ, GD25Q64C"
1212
LONGINT_IMPL = MPZ
13-
OPTIMIZATION_LEVEL = 2

ports/cxd56/Makefile

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ CFLAGS += \
107107
-Dmain=spresense_main \
108108
-D_estack=__stack \
109109
-c \
110-
-Os \
111110
-pipe \
112111
-std=gnu11 \
113112
-mcpu=cortex-m4 \
@@ -123,10 +122,10 @@ CFLAGS += \
123122
-fdata-sections \
124123
-Wall \
125124

125+
OPTIMIZATION_FLAGS ?= -O2
126+
126127
# option to override compiler optimization level, set in boards/$(BOARD)/mpconfigboard.mk
127-
ifdef OPTIMIZATION_LEVEL
128-
CFLAGS += -O$(OPTIMIZATION_LEVEL)
129-
endif
128+
CFLAGS += $(OPTIMIZATION_FLAGS)
130129

131130

132131
LIBM = "${shell "$(CC)" $(CFLAGS) -print-file-name=libm.a}"

ports/esp32s2/Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,18 +101,18 @@ CFLAGS += -DSTACK_CANARY_VALUE=0xa5a5a5a5
101101
#Debugging/Optimization
102102
ifeq ($(DEBUG), 1)
103103
CFLAGS += -ggdb
104+
OPTIMIZATION_FLAGS ?= -Og
104105
# You may want to enable these flags to make setting breakpoints easier.
105106
# CFLAGS += -fno-inline -fno-ipa-sra
106107
else
107-
CFLAGS += -Os -DNDEBUG -ggdb3
108+
CFLAGS += -DNDEBUG -ggdb3
109+
OPTIMIZATION_FLAGS ?= -O2
108110
# TODO: Test with -flto
109111
### CFLAGS += -flto
110112
endif
111113

112114
# option to override compiler optimization level, set in boards/$(BOARD)/mpconfigboard.mk
113-
ifdef OPTIMIZATION_LEVEL
114-
CFLAGS += -O$(OPTIMIZATION_LEVEL)
115-
endif
115+
CFLAGS += $(OPTIMIZATION_FLAGS)
116116

117117
CFLAGS += $(INC) -Werror -Wall -mlongcalls -std=gnu11 -Wl,--gc-sections $(BASE_CFLAGS) $(C_DEFS) $(CFLAGS_MOD) $(COPT)
118118

ports/esp32s2/boards/espressif_saola_1_wroom/mpconfigboard.mk

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,3 @@ CIRCUITPY_ESP_FLASH_FREQ=40m
1717
CIRCUITPY_ESP_FLASH_SIZE=4MB
1818

1919
CIRCUITPY_MODULE=wroom
20-
OPTIMIZATION_LEVEL = 2

0 commit comments

Comments
 (0)