This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit fcfb257d211f481a43ae9548bbabcfd8c29b0ecf Author: ouyangxiangzhen <[email protected]> AuthorDate: Fri Nov 6 20:17:36 2026 +0800 arch/avr: wire optimization level into the avr32 toolchain flags arch/avr/src/avr32/Toolchain.defs never set any -O level and never consumed CONFIG_DEBUG_OPTLEVEL, so avr32 builds compiled at the GCC default -O0 even with CONFIG_DEBUG_FULLOPT selected. Combined with the always_inline math32 helpers this exploded: at -O0 the magic-number setup of div64_const() is force-inlined unfolded at every 64-bit clock conversion call site (avr32-gcc 4.4.7 measurement: about 18KB per site with 13 __avr32_udiv64 and 3 __avr32_umod64 calls; avr32dev1:nsh grew 90444 bytes of text across 5 call sites and overflowed the flash region by 20312 bytes in CI). The same toolchain folds the setup away at -O2 and -Os (224 bytes per site), so the cause is the silent -O0 build, not a compiler limitation. Replace the optimization handling with the same three-level chain the other architectures use (NOOPT -> -O0, CUSTOMOPT -> CONFIG_DEBUG_OPTLEVEL, FULLOPT -> -Os), merged with the existing -fno-strict-aliasing flag. -Os matches the GCC convention of the other architectures (x86_64, arm, arm64, tricore, misoc) and suits a flash constrained target. Verified at the flag level with make -n on avr32dev1:nsh: the compile command line gains "-fno-strict-aliasing -Os" where it previously had no -O option at all. The CI avr32dev1:nsh build is the final confirmation. Assisted-By: mimo-v2.6-pro Signed-off-by: ouyangxiangzhen <[email protected]> --- arch/avr/src/avr32/Toolchain.defs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/avr/src/avr32/Toolchain.defs b/arch/avr/src/avr32/Toolchain.defs index a6c219453c1..5f5705124e2 100644 --- a/arch/avr/src/avr32/Toolchain.defs +++ b/arch/avr/src/avr32/Toolchain.defs @@ -33,8 +33,12 @@ # GNU, not AVRTOOLSW. # -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += -fno-strict-aliasing +ifeq ($(CONFIG_DEBUG_NOOPT),y) + ARCHOPTIMIZATION += -O0 +else ifeq ($(CONFIG_DEBUG_CUSTOMOPT),y) + ARCHOPTIMIZATION += -fno-strict-aliasing $(CONFIG_DEBUG_OPTLEVEL) +else ifeq ($(CONFIG_DEBUG_FULLOPT),y) + ARCHOPTIMIZATION += -fno-strict-aliasing -Os endif ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
