gustavonihei commented on pull request #3602: URL: https://github.com/apache/incubator-nuttx/pull/3602#issuecomment-829236777
> Looking at the Kconfig, it is actually a choice: > > ``` > choice > prompt "Optimization Level" > default DEBUG_NOOPT if DEBUG_SYMBOLS > default DEBUG_FULLOPT if !DEBUG_SYMBOLS > > config DEBUG_NOOPT > bool "Suppress Optimization" > ---help--- > Build without optimization. This is often helpful when debugging code. > > config DEBUG_CUSTOMOPT > bool "Custom Optimization" > depends on ARCH_HAVE_CUSTOMOPT > ---help--- > Select a custom debug level. This is often helpful if you suspect an > optimization level error and want to lower the level of optimization. > > config DEBUG_FULLOPT > bool "Normal, Full optimization" > ---help--- > Build full optimization. This is the normal case for production > firmware. > > endchoice # Optimization Level > ``` > > and the custom level comes from > > ``` > config DEBUG_OPTLEVEL > string "Custom Optimization Level" > default "-O2" > depends on DEBUG_CUSTOMOPT > ---help--- > This string represents the custom optimization level that will be > used if DEBUG_CUSTOMOPT. > ``` > > This PR is hardcoding `-Os`. It should actually check for the three cases, mapping to `-O0`, `-Os` or the custom value from Kconfig. I believe you may have misunderstood it. ```patch diff --git a/arch/risc-v/src/rv32im/Toolchain.defs b/arch/risc-v/src/rv32im/Toolchain.defs index 281225685b..4f88e099b1 100644 --- a/arch/risc-v/src/rv32im/Toolchain.defs +++ b/arch/risc-v/src/rv32im/Toolchain.defs @@ -49,6 +49,8 @@ endif ifeq ($(CONFIG_DEBUG_CUSTOMOPT),y) MAXOPTIMIZATION := $(CONFIG_DEBUG_OPTLEVEL) +else + MAXOPTIMIZATION ?= -Os endif # Generic GNU RVG toolchain ``` If the user selects `CONFIG_DEBUG_CUSTOMOPT`, `MAXOPTIMIZATION` will be set to the custom flag defined by `CONFIG_DEBUG_OPTLEVEL`. Otherwise, the maximum level of optimization is depends on the architecture and the selected toolchain. Several architectures define it as `-Os`, but you may notice that some define it as `-O2`.  If the user selects `DEBUG_NOOPT`, then `MAXOPTIMIZATION` will not be added to the final C compiler invocation, resulting in no optimization at all, as expected. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org