From 85db1a229cc792bd01a8fb151bb0e08698a7e1cd Mon Sep 17 00:00:00 2001 From: iabdalkader Date: Sat, 31 Aug 2024 13:16:39 +0200 Subject: [PATCH] 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. --- src/Makefile | 1 + src/omv/common/export.mk | 1 + src/omv/modules/micropython.mk | 5 +++++ 3 files changed, 7 insertions(+) diff --git a/src/Makefile b/src/Makefile index 25649c0ec..81d058826 100755 --- a/src/Makefile +++ b/src/Makefile @@ -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 diff --git a/src/omv/common/export.mk b/src/omv/common/export.mk index 7f5cf1c54..c89428f0e 100644 --- a/src/omv/common/export.mk +++ b/src/omv/common/export.mk @@ -34,6 +34,7 @@ export CFLAGS export AFLAGS export LDFLAGS export MPY_CFLAGS +export USERMOD_OPT # Export variables export TARGET diff --git a/src/omv/modules/micropython.mk b/src/omv/modules/micropython.mk index 9000a5230..1f96f2d69 100644 --- a/src/omv/modules/micropython.mk +++ b/src/omv/modules/micropython.mk @@ -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