8000 Merge pull request #3190 from DavePutz/opt-test · adafruit/circuitpython@7ab5c52 · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7ab5c52

Browse files
authored
Merge pull request #3190 from DavePutz/opt-test
Changes to allow different compiler optimizations per board
2 parents b7e6bf9 + c481796 commit 7ab5c52

File tree

12 files changed

+54
-10
lines changed

12 files changed

+54
-10
lines changed

ports/atmel-samd/Makefile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,25 +87,28 @@ 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 default optimization level, set in boards/$(BOARD)/mpconfigboard.mk
110+
CFLAGS += $(OPTIMIZATION_FLAGS) -DNDEBUG
111+
109112
$(echo PERIPHERALS_CHIP_FAMILY=$(PERIPHERALS_CHIP_FAMILY))
110113
#Debugging/Optimization
111114
ifeq ($(DEBUG), 1)

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

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

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

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

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

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

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

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

ports/cxd56/Makefile

Lines changed: 6 additions & 1 deletion
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,6 +122,12 @@ CFLAGS += \
123122
-fdata-sections \
124123
-Wall \
125124

125+
OPTIMIZATION_FLAGS ?= -O2
126+
127+
# option to override compiler optimization level, set in boards/$(BOARD)/mpconfigboard.mk
128+
CFLAGS += $(OPTIMIZATION_FLAGS)
129+
130+
126131
LIBM = "${shell "$(CC)" $(CFLAGS) -print-file-name=libm.a}"
127132

128133
LIBGCC = "${shell "$(CC)" $(CFLAGS) -print-libgcc-file-name}"

ports/esp32s2/Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,19 @@ 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

114+
# option to override compiler optimization level, set in boards/$(BOARD)/mpconfigboard.mk
115+
CFLAGS += $(OPTIMIZATION_FLAGS)
116+
112117
CFLAGS += $(INC) -Werror -Wall -mlongcalls -std=gnu11 -Wl,--gc-sections $(BASE_CFLAGS) $(C_DEFS) $(CFLAGS_MOD) $(COPT)
113118

114119
LDFLAGS = $(CFLAGS) -Wl,-nostdlib -Wl,-Map=$@.map -Wl,-cref

ports/litex/Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,17 @@ ifeq ($(DEBUG), 1)
7777
CFLAGS += -ggdb
7878
# You may want to enable these flags to make setting breakpoints easier.
7979
CFLAGS += -fno-inline -fno-ipa-sra
80+
OPTIMIZATION_FLAGS ?= -Og
8081
else
81-
CFLAGS += -Os -DNDEBUG -ggdb3
82+
CFLAGS += -DNDEBUG -ggdb3
83+
OPTIMIZATION_FLAGS ?= -O2
8284
# TODO: Test with -flto
8385
### CFLAGS += -flto
8486
endif
8587

88+
# option to override compiler optimization level, set in boards/$(BOARD)/mpconfigboard.mk
89+
CFLAGS += $(OPTIMIZATION_FLAGS)
90+
8691
CFLAGS += $(INC) -Werror -Wall -std=gnu11 -nostdlib -fshort-enums $(BASE_CFLAGS) $(C_DEFS) $(CFLAGS_MOD) $(COPT)
8792

8893
# TODO: check this

ports/mimxrt10xx/Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,14 @@ CFLAGS += \
105105
-DCPU_$(CHIP_VARIANT) \
106106
-DDEBUG \
107107
-DIMXRT10XX \
108-
-Os -g3 -Wno-unused-parameter \
108+
-g3 -Wno-unused-parameter \
109109
-ffunction-sections -fdata-sections -fstack-usage
110110

111+
OPTIMIZATION_FLAGS ?= -O2
112+
113+
# option to override compiler optimization level, set in boards/$(BOARD)/mpconfigboard.mk
114+
CFLAGS += $(OPTIMIZATION_FLAGS)
115+
111116
LD_FILES = $(wildcard boards/$(BOARD)/*.ld) $(addprefix linking/, flash/$(FLASH).ld chip_family/$(CHIP_FAMILY).ld common.ld)
112117

113118
LD_SCRIPT_FLAG := -Wl,-T,

ports/nrf/Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,16 @@ INC += -I../../supervisor/shared/usb
8686

8787
#Debugging/Optimization
8888
ifeq ($(DEBUG), 1)
89-
CFLAGS += -ggdb3 -Og
89+
CFLAGS += -ggdb3
90+
OPTIMIZATION_FLAGS = -Og
9091
else
91-
CFLAGS += -Os -DNDEBUG -ggdb3
92+
OPTIMIZATION_FLAGS ?= -O2
93+
CFLAGS += -DNDEBUG -ggdb3
9294
CFLAGS += -flto -flto-partition=none
9395
endif
9496

97+
# option to override compiler optimization level, set in boards/$(BOARD)/mpconfigboard.mk
98+
CFLAGS += $(OPTIMIZATION_FLAGS)
9599

96100
CFLAGS += $(INC) -Wall -Werror -std=gnu11 -nostdlib -fshort-enums $(BASE_CFLAGS) $(CFLAGS_MOD) $(COPT)
97101

ports/nrf/boards/pca10100/mpconfigboard.mk

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,6 @@ SUPEROPT_GC = 0
3030
# These defines must be overridden before mpconfigboard.h is included, which is
3131
# why they are passed on the command line.
3232
CFLAGS += -DSPIM3_BUFFER_SIZE=0 -DSOFTDEVICE_RAM_SIZE='(32*1024)'
33+
34+
# Override optimization to keep binary small
35+
OPTIMIZATION_FLAGS = -Os

ports/nrf/boards/simmel/mpconfigboard.mk

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,6 @@ CIRCUITPY_WATCHDOG = 1
3232
# These defines must be overridden before mpconfigboard.h is included, which is
3333
# why they are passed on the command line.
3434
CFLAGS += -DSPIM3_BUFFER_SIZE=0 -DSOFTDEVICE_RAM_SIZE='(32*1024)' -DNRFX_SPIM3_ENABLED=0
35+
36+
# Override optimization to keep binary small
37+
OPTIMIZATION_FLAGS = -Os

ports/stm/Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,16 @@ ifeq ($(DEBUG), 1)
8585
# You may want to enable these flags to make setting breakpoints easier.
8686
CFLAGS += -fno-inline -fno-ipa-sra
8787
else
88-
CFLAGS += -Os -DNDEBUG
88+
CFLAGS += -DNDEBUG
89+
OPTIMIZATION_FLAGS ?= -O2
8990
CFLAGS += -ggdb3
9091
# TODO: Test with -flto
9192
# CFLAGS += -flto
9293
endif
9394

95+
# to override compiler optimization level, set in boards/$(BOARD)/mpconfigboard.mk
96+
CFLAGS += $(OPTIMIZATION_FLAGS)
97+
9498
# MCU Series is defined by the HAL package and doesn't need to be specified here
9599
C_DEFS = -D$(MCU_PACKAGE) -DUSE_HAL_DRIVER -DUSE_FULL_LL_DRIVER -D$(MCU_VARIANT)
96100

0 commit comments

Comments
 (0)
0