Skip to content

Changes to allow different compiler optimizations per board #3190

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Jul 25, 2020
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion frozen/circuitpython-stage
5 changes: 5 additions & 0 deletions ports/atmel-samd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ CFLAGS += -Os -DNDEBUG
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
endif

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

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't the CFLAGS from lines 90, 97 and 104 interfere with this?

$(echo PERIPHERALS_CHIP_FAMILY=$(PERIPHERALS_CHIP_FAMILY))
#Debugging/Optimization
ifeq ($(DEBUG), 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ LONGINT_IMPL = MPZ
CIRCUITPY_AUDIOBUSIO = 0

CIRCUITPY_BITBANG_APA102 = 1
OPTIMIZATION_LEVEL = 2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of adding this flag for individual boards, I think it would make sense to do -O2 by default for all SAMD51 and nRF52 Express boards. There may be space problems on non-Express boards.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dhalbert See comment below. I think we will need to implement this on a board-by-board basis.

Copy link
Collaborator Author

@DavePutz DavePutz Jul 23, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we can always use INTERNAL_FLASH_FILESYSTEM = 1 as a guide. There is at least one board (sam32) that has that set but has 1M of flash (i.e. plenty for the 10% size increase). And,as future chips may well fall into that same category. I would consider it safer to have a separate flag. Also, the non_SAMD chips need to be considered as well.

1 change: 1 addition & 0 deletions ports/atmel-samd/boards/pybadge/mpconfigboard.mk
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ CIRCUITPY_GAMEPADSHIFT = 1
CIRCUITPY_STAGE = 1

FROZEN_MPY_DIRS += $(TOP)/frozen/circuitpython-stage/pybadge
OPTIMIZATION_LEVEL = 2
1 change: 1 addition & 0 deletions ports/atmel-samd/boards/pyportal/mpconfigboard.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ QSPI_FLASH_FILESYSTEM = 1
EXTERNAL_FLASH_DEVICE_COUNT = 2
EXTERNAL_FLASH_DEVICES = "W25Q64JV_IQ, GD25Q64C"
LONGINT_IMPL = MPZ
OPTIMIZATION_LEVEL = 2
6 changes: 6 additions & 0 deletions ports/cxd56/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,12 @@ CFLAGS += \
-fdata-sections \
-Wall \

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


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

LIBGCC = "${shell "$(CC)" $(CFLAGS) -print-libgcc-file-name}"
Expand Down
5 changes: 5 additions & 0 deletions ports/esp32s2/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ else
### CFLAGS += -flto
endif

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

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

LDFLAGS = $(CFLAGS) -Wl,-nostdlib -Wl,[email protected] -Wl,-cref
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ CIRCUITPY_ESP_FLASH_FREQ=40m
CIRCUITPY_ESP_FLASH_SIZE=4MB

CIRCUITPY_MODULE=wroom
OPTIMIZATION_LEVEL = 2
5 changes: 5 additions & 0 deletions ports/litex/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ else
### CFLAGS += -flto
endif

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

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

# TODO: check this
Expand Down
5 changes: 5 additions & 0 deletions ports/mimxrt10xx/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ CFLAGS += \
-Os -g3 -Wno-unused-parameter \
-ffunction-sections -fdata-sections -fstack-usage

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

LD_FILES = $(wildcard boards/$(BOARD)/*.ld) $(addprefix linking/, flash/$(FLASH).ld chip_family/$(CHIP_FAMILY).ld common.ld)

LD_SCRIPT_FLAG := -Wl,-T,
Expand Down
4 changes: 4 additions & 0 deletions ports/nrf/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ else
CFLAGS += -flto -flto-partition=none
endif

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

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

Expand Down
2 changes: 2 additions & 0 deletions ports/nrf/boards/circuitplayground_bluefruit/mpconfigboard.mk
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ EXTERNAL_FLASH_DEVICES = "GD25Q16C"
# We use a CFLAGS define here because there are include order issues
# if we try to include "mpconfigport.h" into nrfx_config.h .
CFLAGS += -DCIRCUITPY_NRF_NUM_I2C=2

OPTIMIZATION_LEVEL = 2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this is left-over from the first version of this PR and can be removed.

5 changes: 5 additions & 0 deletions ports/stm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ else
# CFLAGS += -flto
endif

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

# MCU Series is defined by the HAL package and doesn't need to be specified here
C_DEFS = -D$(MCU_PACKAGE) -DUSE_HAL_DRIVER -DUSE_FULL_LL_DRIVER -D$(MCU_VARIANT)

Expand Down
2 changes: 2 additions & 0 deletions ports/stm/boards/feather_stm32f405_express/mpconfigboard.mk
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ LD_COMMON = boards/common_default.ld
LD_DEFAULT = boards/STM32F405_default.ld
LD_BOOT = boards/STM32F405_boot.ld # UF2 boot option
UF2_OFFSET = 0x8010000

OPTIMIZATION_LEVEL = 2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leftover?