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 dd1b51fe837628a5f553b0c726e724b84113c2eb
Author: ouyangxiangzhen <[email protected]>
AuthorDate: Fri Nov 6 21:24:35 2026 +0800

    arch: wire optimization level into toolchains missing it [skip-cmake-parity]
    
    Nine toolchain definitions translate only the CONFIG_DEBUG_NOOPT half
    of the "Optimization Level" choice: arch/x86/src/common/Toolchain.defs
    passes -O2 for any non-NOOPT selection and the board-local toolchain
    blocks used by the hc/m9s12 and renesas m16c/rx65n/sh1 boards pass -Os
    plus -fno-strict-aliasing/-fomit-frame-pointer, while CONFIG_DEBUG_CUSTOMOPT
    and CONFIG_DEBUG_OPTLEVEL are never consulted.  This is the same wiring
    gap class as the avr32 one fixed in "arch/avr: wire optimization level into 
the avr32 toolchain flags" (there it degenerated
    into a silent -O0 build that blew up avr32dev1's flash; here the
    reachable selections happen to keep an optimization level, so the
    defect stays latent until an arch in this group selects
    ARCH_HAVE_CUSTOMOPT).
    
    Replace the two-way handling with the same three-level chain the
    mainstream toolchains use: NOOPT -> -O0, CUSTOMOPT ->
    CONFIG_DEBUG_OPTLEVEL, FULLOPT -> -Os (hc/renesas) or -O2 (x86), each
    keeping the file's previous full-optimization choice and its existing
    flags.  The FULLOPT output is unchanged; NOOPT builds now spell -O0
    explicitly instead of relying on the compiler default.
    
    Evidence (make -n V=1 on a scratch worktree of "arch/avr: wire optimization 
level into the avr32 toolchain flags" + this
    patch): rx65n:nsh FULLOPT compiles with
    "-fno-strict-aliasing -fomit-frame-pointer -Os" (same as before) and
    NOOPT compiles with -O0 (before: no -O option at all);
    qemu-i486:nsh FULLOPT compiles with -O2 (same as before).
    
    Assisted-By: mimo-v2.6-pro
    Signed-off-by: ouyangxiangzhen <[email protected]>
---
 arch/x86/src/common/Toolchain.defs                  | 6 +++++-
 boards/hc/m9s12/demo9s12ne64/scripts/Make.defs      | 8 ++++++--
 boards/hc/m9s12/ne64badge/scripts/Make.defs         | 8 ++++++--
 boards/renesas/m16c/skp16c26/scripts/Make.defs      | 8 ++++++--
 boards/renesas/rx65n/rx65n-grrose/scripts/Make.defs | 8 ++++++--
 boards/renesas/rx65n/rx65n-rsk1mb/scripts/Make.defs | 8 ++++++--
 boards/renesas/rx65n/rx65n-rsk2mb/scripts/Make.defs | 8 ++++++--
 boards/renesas/rx65n/rx65n/scripts/Make.defs        | 8 ++++++--
 boards/renesas/sh1/us7032evb1/scripts/Make.defs     | 8 ++++++--
 9 files changed, 53 insertions(+), 17 deletions(-)

diff --git a/arch/x86/src/common/Toolchain.defs 
b/arch/x86/src/common/Toolchain.defs
index 3ef04adb599..838cba7b1c9 100644
--- a/arch/x86/src/common/Toolchain.defs
+++ b/arch/x86/src/common/Toolchain.defs
@@ -24,7 +24,11 @@ ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
   ARCHOPTIMIZATION = $(CONFIG_DEBUG_SYMBOLS_LEVEL)
 endif
 
-ifneq ($(CONFIG_DEBUG_NOOPT),y)
+ifeq ($(CONFIG_DEBUG_NOOPT),y)
+  ARCHOPTIMIZATION += -O0
+else ifeq ($(CONFIG_DEBUG_CUSTOMOPT),y)
+  ARCHOPTIMIZATION += $(CONFIG_DEBUG_OPTLEVEL)
+else ifeq ($(CONFIG_DEBUG_FULLOPT),y)
   ARCHOPTIMIZATION += -O2
 endif
 
diff --git a/boards/hc/m9s12/demo9s12ne64/scripts/Make.defs 
b/boards/hc/m9s12/demo9s12ne64/scripts/Make.defs
index 55d43c86ff4..e23524afcaa 100644
--- a/boards/hc/m9s12/demo9s12ne64/scripts/Make.defs
+++ b/boards/hc/m9s12/demo9s12ne64/scripts/Make.defs
@@ -46,8 +46,12 @@ ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
   ARCHOPTIMIZATION = $(CONFIG_DEBUG_SYMBOLS_LEVEL)
 endif
 
-ifneq ($(CONFIG_DEBUG_NOOPT),y)
-  ARCHOPTIMIZATION += -Os -fno-strict-aliasing -fomit-frame-pointer
+ifeq ($(CONFIG_DEBUG_NOOPT),y)
+  ARCHOPTIMIZATION += -O0
+else ifeq ($(CONFIG_DEBUG_CUSTOMOPT),y)
+  ARCHOPTIMIZATION += -fno-strict-aliasing -fomit-frame-pointer 
$(CONFIG_DEBUG_OPTLEVEL)
+else ifeq ($(CONFIG_DEBUG_FULLOPT),y)
+  ARCHOPTIMIZATION += -fno-strict-aliasing -fomit-frame-pointer -Os
 endif
 
 ARCHCFLAGS = -fno-common
diff --git a/boards/hc/m9s12/ne64badge/scripts/Make.defs 
b/boards/hc/m9s12/ne64badge/scripts/Make.defs
index faef7bc49c6..68e6e31cbb9 100644
--- a/boards/hc/m9s12/ne64badge/scripts/Make.defs
+++ b/boards/hc/m9s12/ne64badge/scripts/Make.defs
@@ -46,8 +46,12 @@ ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
   ARCHOPTIMIZATION = $(CONFIG_DEBUG_SYMBOLS_LEVEL)
 endif
 
-ifneq ($(CONFIG_DEBUG_NOOPT),y)
-  ARCHOPTIMIZATION += -Os -fno-strict-aliasing -fomit-frame-pointer
+ifeq ($(CONFIG_DEBUG_NOOPT),y)
+  ARCHOPTIMIZATION += -O0
+else ifeq ($(CONFIG_DEBUG_CUSTOMOPT),y)
+  ARCHOPTIMIZATION += -fno-strict-aliasing -fomit-frame-pointer 
$(CONFIG_DEBUG_OPTLEVEL)
+else ifeq ($(CONFIG_DEBUG_FULLOPT),y)
+  ARCHOPTIMIZATION += -fno-strict-aliasing -fomit-frame-pointer -Os
 endif
 
 ARCHCFLAGS = -fno-common
diff --git a/boards/renesas/m16c/skp16c26/scripts/Make.defs 
b/boards/renesas/m16c/skp16c26/scripts/Make.defs
index 8a8228d4e4a..ab6300cbae0 100644
--- a/boards/renesas/m16c/skp16c26/scripts/Make.defs
+++ b/boards/renesas/m16c/skp16c26/scripts/Make.defs
@@ -36,8 +36,12 @@ ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
   ARCHOPTIMIZATION     = $(CONFIG_DEBUG_SYMBOLS_LEVEL)
 endif
 
-ifneq ($(CONFIG_DEBUG_NOOPT),y)
-  ARCHOPTIMIZATION     += -Os -fno-strict-aliasing -fomit-frame-pointer
+ifeq ($(CONFIG_DEBUG_NOOPT),y)
+  ARCHOPTIMIZATION     += -O0
+else ifeq ($(CONFIG_DEBUG_CUSTOMOPT),y)
+  ARCHOPTIMIZATION     += -fno-strict-aliasing -fomit-frame-pointer 
$(CONFIG_DEBUG_OPTLEVEL)
+else ifeq ($(CONFIG_DEBUG_FULLOPT),y)
+  ARCHOPTIMIZATION     += -fno-strict-aliasing -fomit-frame-pointer -Os
 endif
 
 ARCHCPUFLAGS           = -mcpu=m16c
diff --git a/boards/renesas/rx65n/rx65n-grrose/scripts/Make.defs 
b/boards/renesas/rx65n/rx65n-grrose/scripts/Make.defs
index bf0f578c3fb..fb3078276ec 100644
--- a/boards/renesas/rx65n/rx65n-grrose/scripts/Make.defs
+++ b/boards/renesas/rx65n/rx65n-grrose/scripts/Make.defs
@@ -42,8 +42,12 @@ ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
   ARCHOPTIMIZATION = $(CONFIG_DEBUG_SYMBOLS_LEVEL)
 endif
 
-ifneq ($(CONFIG_DEBUG_NOOPT),y)
-  ARCHOPTIMIZATION += -Os -fno-strict-aliasing -fomit-frame-pointer
+ifeq ($(CONFIG_DEBUG_NOOPT),y)
+  ARCHOPTIMIZATION += -O0
+else ifeq ($(CONFIG_DEBUG_CUSTOMOPT),y)
+  ARCHOPTIMIZATION += -fno-strict-aliasing -fomit-frame-pointer 
$(CONFIG_DEBUG_OPTLEVEL)
+else ifeq ($(CONFIG_DEBUG_FULLOPT),y)
+  ARCHOPTIMIZATION += -fno-strict-aliasing -fomit-frame-pointer -Os
 endif
 
 ARCHCFLAGS = -fno-common -std=c99
diff --git a/boards/renesas/rx65n/rx65n-rsk1mb/scripts/Make.defs 
b/boards/renesas/rx65n/rx65n-rsk1mb/scripts/Make.defs
index e00a3c9abef..6d9298c4a77 100644
--- a/boards/renesas/rx65n/rx65n-rsk1mb/scripts/Make.defs
+++ b/boards/renesas/rx65n/rx65n-rsk1mb/scripts/Make.defs
@@ -42,8 +42,12 @@ ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
   ARCHOPTIMIZATION = $(CONFIG_DEBUG_SYMBOLS_LEVEL)
 endif
 
-ifneq ($(CONFIG_DEBUG_NOOPT),y)
-  ARCHOPTIMIZATION += -Os -fno-strict-aliasing -fomit-frame-pointer
+ifeq ($(CONFIG_DEBUG_NOOPT),y)
+  ARCHOPTIMIZATION += -O0
+else ifeq ($(CONFIG_DEBUG_CUSTOMOPT),y)
+  ARCHOPTIMIZATION += -fno-strict-aliasing -fomit-frame-pointer 
$(CONFIG_DEBUG_OPTLEVEL)
+else ifeq ($(CONFIG_DEBUG_FULLOPT),y)
+  ARCHOPTIMIZATION += -fno-strict-aliasing -fomit-frame-pointer -Os
 endif
 
 ARCHCFLAGS = -fno-common -std=c99
diff --git a/boards/renesas/rx65n/rx65n-rsk2mb/scripts/Make.defs 
b/boards/renesas/rx65n/rx65n-rsk2mb/scripts/Make.defs
index 2ca198d3784..4521d4544bd 100644
--- a/boards/renesas/rx65n/rx65n-rsk2mb/scripts/Make.defs
+++ b/boards/renesas/rx65n/rx65n-rsk2mb/scripts/Make.defs
@@ -42,8 +42,12 @@ ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
   ARCHOPTIMIZATION = $(CONFIG_DEBUG_SYMBOLS_LEVEL)
 endif
 
-ifneq ($(CONFIG_DEBUG_NOOPT),y)
-  ARCHOPTIMIZATION += -Os -fno-strict-aliasing -fomit-frame-pointer
+ifeq ($(CONFIG_DEBUG_NOOPT),y)
+  ARCHOPTIMIZATION += -O0
+else ifeq ($(CONFIG_DEBUG_CUSTOMOPT),y)
+  ARCHOPTIMIZATION += -fno-strict-aliasing -fomit-frame-pointer 
$(CONFIG_DEBUG_OPTLEVEL)
+else ifeq ($(CONFIG_DEBUG_FULLOPT),y)
+  ARCHOPTIMIZATION += -fno-strict-aliasing -fomit-frame-pointer -Os
 endif
 
 ARCHCFLAGS = -fno-common -std=c99
diff --git a/boards/renesas/rx65n/rx65n/scripts/Make.defs 
b/boards/renesas/rx65n/rx65n/scripts/Make.defs
index 580b3f0301a..9d4b53c5e40 100644
--- a/boards/renesas/rx65n/rx65n/scripts/Make.defs
+++ b/boards/renesas/rx65n/rx65n/scripts/Make.defs
@@ -42,8 +42,12 @@ ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
   ARCHOPTIMIZATION = $(CONFIG_DEBUG_SYMBOLS_LEVEL)
 endif
 
-ifneq ($(CONFIG_DEBUG_NOOPT),y)
-  ARCHOPTIMIZATION += -Os -fno-strict-aliasing -fomit-frame-pointer
+ifeq ($(CONFIG_DEBUG_NOOPT),y)
+  ARCHOPTIMIZATION += -O0
+else ifeq ($(CONFIG_DEBUG_CUSTOMOPT),y)
+  ARCHOPTIMIZATION += -fno-strict-aliasing -fomit-frame-pointer 
$(CONFIG_DEBUG_OPTLEVEL)
+else ifeq ($(CONFIG_DEBUG_FULLOPT),y)
+  ARCHOPTIMIZATION += -fno-strict-aliasing -fomit-frame-pointer -Os
 endif
 
 ARCHCFLAGS = -fno-common -std=c99
diff --git a/boards/renesas/sh1/us7032evb1/scripts/Make.defs 
b/boards/renesas/sh1/us7032evb1/scripts/Make.defs
index ec2629c37ae..dfb3ff361d8 100644
--- a/boards/renesas/sh1/us7032evb1/scripts/Make.defs
+++ b/boards/renesas/sh1/us7032evb1/scripts/Make.defs
@@ -27,8 +27,12 @@ ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
   ARCHOPTIMIZATION = $(CONFIG_DEBUG_SYMBOLS_LEVEL)
 endif
 
-ifneq ($(CONFIG_DEBUG_NOOPT),y)
-  ARCHOPTIMIZATION += -Os -fno-strict-aliasing -fomit-frame-pointer
+ifeq ($(CONFIG_DEBUG_NOOPT),y)
+  ARCHOPTIMIZATION += -O0
+else ifeq ($(CONFIG_DEBUG_CUSTOMOPT),y)
+  ARCHOPTIMIZATION += -fno-strict-aliasing -fomit-frame-pointer 
$(CONFIG_DEBUG_OPTLEVEL)
+else ifeq ($(CONFIG_DEBUG_FULLOPT),y)
+  ARCHOPTIMIZATION += -fno-strict-aliasing -fomit-frame-pointer -Os
 endif
 
 ARCHCPUFLAGS = -m1

Reply via email to