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 2c9f91526a2f6308b220f1643f71ebec0081290a
Author: Xiang Xiao <[email protected]>
AuthorDate: Fri May 15 02:27:36 2026 +0800

    board: enable LTO on g431 nsh boards and fix LTO link with toolchain switch
    
    For boards b-g431b-esc1/nsh, nucleo-g431kb/nsh and nucleo-g431rb/nsh,
    the `.data` section of nuttx.elf overflows the 128 KB flash region by a
    few hundred bytes on default GNU EABI builds:
    
        arm-none-eabi-ld: nuttx section `.data' will not fit in region `flash'
        arm-none-eabi-ld: region `flash' overflowed by 296 bytes
    
    Enabling CONFIG_LTO_FULL=y in the corresponding defconfigs brings flash
    usage back below the 128 KB limit (~93%).
    
    Additionally, fix arch/arm/src/cmake/gcc.cmake so that when LTO is
    enabled it always uses the gcc-ar / gcc-nm / gcc-ranlib wrappers, not
    just when CONFIG_ARM_TOOLCHAIN_GNU_EABI is also set.  CI tooling (via
    tools/testbuild.sh) configures cmake first, then flips the toolchain
    choice in .config with kconfig-tweak before running `cmake --build`.
    With the previous "ARM_TOOLCHAIN_GNU_EABI && !LTO_NONE" guard the
    regen step would switch to plain `ar` for the .a files, even though the
    linker driver picked at configure time is still arm-none-eabi-g++ and
    the object files contain GCC LTO IR.  The result was a flood of
    "undefined reference to `printf' / `free' / `puts' ..." link errors
    when running tools/testbuild.sh -A -N -R on the *_CLANG variants.
    
    Now that we are inside gcc.cmake the toolchain is unambiguously GCC,
    so dropping the redundant CONFIG_ARM_TOOLCHAIN_GNU_EABI conjunct keeps
    the LTO-aware ar wrappers in place across kconfig-tweak toolchain
    switches.
    
    Signed-off-by: Xiang Xiao <[email protected]>
---
 boards/arm/stm32/b-g431b-esc1/configs/nsh/defconfig  | 1 +
 boards/arm/stm32/nucleo-g431kb/configs/nsh/defconfig | 1 +
 boards/arm/stm32/nucleo-g431rb/configs/nsh/defconfig | 1 +
 boards/arm/tiva/lm3s6432-s2e/configs/nsh/defconfig   | 8 ++------
 tools/ci/testlist/arm-09.dat                         | 2 +-
 5 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/boards/arm/stm32/b-g431b-esc1/configs/nsh/defconfig 
b/boards/arm/stm32/b-g431b-esc1/configs/nsh/defconfig
index a1215260ffc..7008df08655 100644
--- a/boards/arm/stm32/b-g431b-esc1/configs/nsh/defconfig
+++ b/boards/arm/stm32/b-g431b-esc1/configs/nsh/defconfig
@@ -26,6 +26,7 @@ CONFIG_HAVE_CXXINITIALIZE=y
 CONFIG_INIT_ENTRYPOINT="nsh_main"
 CONFIG_INTELHEX_BINARY=y
 CONFIG_LINE_MAX=64
+CONFIG_LTO_FULL=y
 CONFIG_NSH_BUILTIN_APPS=y
 CONFIG_NSH_FILEIOSIZE=512
 CONFIG_NSH_READLINE=y
diff --git a/boards/arm/stm32/nucleo-g431kb/configs/nsh/defconfig 
b/boards/arm/stm32/nucleo-g431kb/configs/nsh/defconfig
index 413ff8b06f3..2470af3cfac 100644
--- a/boards/arm/stm32/nucleo-g431kb/configs/nsh/defconfig
+++ b/boards/arm/stm32/nucleo-g431kb/configs/nsh/defconfig
@@ -25,6 +25,7 @@ CONFIG_HAVE_CXXINITIALIZE=y
 CONFIG_INIT_ENTRYPOINT="nsh_main"
 CONFIG_INTELHEX_BINARY=y
 CONFIG_LINE_MAX=64
+CONFIG_LTO_FULL=y
 CONFIG_NSH_BUILTIN_APPS=y
 CONFIG_NSH_FILEIOSIZE=512
 CONFIG_NSH_READLINE=y
diff --git a/boards/arm/stm32/nucleo-g431rb/configs/nsh/defconfig 
b/boards/arm/stm32/nucleo-g431rb/configs/nsh/defconfig
index 6b2c0c9aa21..b28e171393d 100644
--- a/boards/arm/stm32/nucleo-g431rb/configs/nsh/defconfig
+++ b/boards/arm/stm32/nucleo-g431rb/configs/nsh/defconfig
@@ -26,6 +26,7 @@ CONFIG_HAVE_CXXINITIALIZE=y
 CONFIG_INIT_ENTRYPOINT="nsh_main"
 CONFIG_INTELHEX_BINARY=y
 CONFIG_LINE_MAX=64
+CONFIG_LTO_FULL=y
 CONFIG_NSH_BUILTIN_APPS=y
 CONFIG_NSH_FILEIOSIZE=512
 CONFIG_NSH_READLINE=y
diff --git a/boards/arm/tiva/lm3s6432-s2e/configs/nsh/defconfig 
b/boards/arm/tiva/lm3s6432-s2e/configs/nsh/defconfig
index 86a3bdafa7d..267ca413171 100644
--- a/boards/arm/tiva/lm3s6432-s2e/configs/nsh/defconfig
+++ b/boards/arm/tiva/lm3s6432-s2e/configs/nsh/defconfig
@@ -16,10 +16,9 @@ CONFIG_ARCH_CHIP_LM3S=y
 CONFIG_ARCH_CHIP_LM=y
 CONFIG_ARCH_STACKDUMP=y
 CONFIG_BOARD_LOOPSPERMSEC=4531
-CONFIG_DISABLE_ENVIRON=y
-CONFIG_DISABLE_MQUEUE_SYSV=y
+CONFIG_DEFAULT_SMALL=y
+CONFIG_FILE_STREAM=y
 CONFIG_INIT_ENTRYPOINT="nsh_main"
-CONFIG_LINE_MAX=64
 CONFIG_LTO_FULL=y
 CONFIG_NET=y
 CONFIG_NETDB_DNSCLIENT=y
@@ -35,9 +34,6 @@ CONFIG_NET_STATISTICS=y
 CONFIG_NET_TCP=y
 CONFIG_NET_UDP=y
 CONFIG_NET_UDP_CHECKSUMS=y
-CONFIG_NSH_FILEIOSIZE=512
-CONFIG_NSH_READLINE=y
-CONFIG_PREALLOC_TIMERS=4
 CONFIG_RAM_SIZE=32768
 CONFIG_RAM_START=0x20000000
 CONFIG_RAW_BINARY=y
diff --git a/tools/ci/testlist/arm-09.dat b/tools/ci/testlist/arm-09.dat
index f3af9f5162c..cd9c27d5fdb 100644
--- a/tools/ci/testlist/arm-09.dat
+++ b/tools/ci/testlist/arm-09.dat
@@ -2,7 +2,7 @@
 
 /arm/stm32/nucleo-f4*,CONFIG_ARM_TOOLCHAIN_CLANG
 
-/arm/stm32/nucleo-g*,CONFIG_ARM_TOOLCHAIN_CLANG
+/arm/stm32/nucleo-g*,CONFIG_ARM_TOOLCHAIN_GNU_EABI
 
 /arm/stm32/nucleo-l*,CONFIG_ARM_TOOLCHAIN_CLANG
 

Reply via email to