modules: Use the default optimization level for all user C modules.

By appending the optimization level to modules CFLAGS. Note this
works because according to the man page: If you use multiple -O
options, with or without level numbers, the last such option is
the one that is effective.
This commit is contained in:
iabdalkader 2024-08-31 13:16:39 +02:00
parent 5fe32bdc8a
commit 85db1a229c
3 changed files with 7 additions and 0 deletions

View File

@ -83,6 +83,7 @@ else
DEBUG=0
ROM_TEXT_COMPRESSION = 1
CFLAGS += -O2 -DNDEBUG
USERMOD_OPT = -O2
MPY_CFLAGS += -DMICROPY_ROM_TEXT_COMPRESSION=1
endif

View File

@ -34,6 +34,7 @@ export CFLAGS
export AFLAGS
export LDFLAGS
export MPY_CFLAGS
export USERMOD_OPT
# Export variables
export TARGET

View File

@ -38,3 +38,8 @@ ifeq ($(MICROPY_PY_ULAB), 1)
USERMOD_DIR := $(USERMOD_DIR)/ulab/code
include $(USERMOD_DIR)/micropython.mk
endif
ifeq ($(DEBUG), 0)
# Use a higher optimization level for user C modules.
$(BUILD)/modules/%.o: override CFLAGS += $(USERMOD_OPT)
endif