This is an automated email from the ASF dual-hosted git repository. acassis pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 8cfffa5419c421af722a8cd9ef21ec7e3ba836f5 Author: Marco Casaroli <[email protected]> AuthorDate: Wed Oct 21 10:57:19 2026 +0200 arch, tools/mkexport.sh: Export the group options of a driver link. With CONFIG_LTO_FULL and GCC on arm, arm64 and risc-v, or with clang on risc-v, LD is the compiler driver. The arch Makefile then links nuttx with -Wl,--start-group and -Wl,--end-group. The export of a kernel build (mkexport.sh -u) did not have LDSTARTGROUP and LDENDGROUP, so apps linked each program with its default --start-group, and the driver stopped: riscv-none-elf-gcc: error: unrecognized command-line option '--start-group' The Toolchain.defs branches that set LD to the driver now set LDSTARTGROUP and LDENDGROUP, and mkexport.sh writes them for every export. Without a value the apps default stays --start-group. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Marco Casaroli <[email protected]> --- arch/arm/src/common/Toolchain.defs | 5 +++++ arch/arm64/src/Toolchain.defs | 5 +++++ arch/risc-v/src/common/Toolchain.defs | 10 ++++++++++ tools/mkexport.sh | 11 +++++++---- 4 files changed, 27 insertions(+), 4 deletions(-) diff --git a/arch/arm/src/common/Toolchain.defs b/arch/arm/src/common/Toolchain.defs index bec4dfbb971..f6085ff3657 100644 --- a/arch/arm/src/common/Toolchain.defs +++ b/arch/arm/src/common/Toolchain.defs @@ -323,6 +323,11 @@ else LDMODULELTOFLAGS = -flinker-output=nolto-rel $(CMODULEFLAGS) LDELFLTOFLAGS = -flinker-output=nolto-rel $(CELFFLAGS) + + # The export gives the group options to the program link of a kernel build + + LDSTARTGROUP = -Wl,--start-group + LDENDGROUP = -Wl,--end-group endif endif diff --git a/arch/arm64/src/Toolchain.defs b/arch/arm64/src/Toolchain.defs index 102d19c38ac..c36ba795098 100644 --- a/arch/arm64/src/Toolchain.defs +++ b/arch/arm64/src/Toolchain.defs @@ -256,6 +256,11 @@ ifeq ($(CONFIG_LTO_FULL),y) LDMODULELTOFLAGS = -flinker-output=nolto-rel $(CMODULEFLAGS) LDELFLTOFLAGS = -flinker-output=nolto-rel $(CELFFLAGS) + + # The export gives the group options to the program link of a kernel build + + LDSTARTGROUP = -Wl,--start-group + LDENDGROUP = -Wl,--end-group endif endif diff --git a/arch/risc-v/src/common/Toolchain.defs b/arch/risc-v/src/common/Toolchain.defs index bf9f890d0a8..62637b1d26b 100644 --- a/arch/risc-v/src/common/Toolchain.defs +++ b/arch/risc-v/src/common/Toolchain.defs @@ -370,6 +370,11 @@ ifeq ($(CONFIG_ARCH_TOOLCHAIN_CLANG),y) LDXLINKER = -Xlinker + # The export gives the group options to the program link of a kernel build + + LDSTARTGROUP = -Wl,--start-group + LDENDGROUP = -Wl,--end-group + # Default toolchain else @@ -400,6 +405,11 @@ else LDMODULELTOFLAGS = -flinker-output=nolto-rel $(CMODULEFLAGS) LDELFLTOFLAGS = -flinker-output=nolto-rel $(CELFFLAGS) LDXLINKER = -Xlinker + + # The export gives the group options to the program link of a kernel build + + LDSTARTGROUP = -Wl,--start-group + LDENDGROUP = -Wl,--end-group endif endif diff --git a/tools/mkexport.sh b/tools/mkexport.sh index cdb695ac7f5..27b3db7917b 100755 --- a/tools/mkexport.sh +++ b/tools/mkexport.sh @@ -325,22 +325,25 @@ echo "set(LLVM_CPUTYPE \"${LLVM_CPUTYPE}\")" >>"${EXPORTDIR}/scripts/ echo "set(LLVM_ABITYPE \"${LLVM_ABITYPE}\")" >>"${EXPORTDIR}/scripts/target.cmake" +# The library group options of the linker, for the program links too + +echo "LDENDGROUP = ${LDENDGROUP}" >>"${EXPORTDIR}/scripts/Make.defs" +echo "LDSTARTGROUP = ${LDSTARTGROUP}" >>"${EXPORTDIR}/scripts/Make.defs" +echo "set(LDENDGROUP \"${LDENDGROUP}\")" >>"${EXPORTDIR}/scripts/target.cmake" +echo "set(LDSTARTGROUP \"${LDSTARTGROUP}\")" >>"${EXPORTDIR}/scripts/target.cmake" + # Additional compilation options when the kernel is built if [ "X${USRONLY}" != "Xy" ]; then echo "EXTRA_LIBS = ${EXTRA_LIBS}" >>"${EXPORTDIR}/scripts/Make.defs" echo "EXTRA_OBJS = ${EXTRA_OBJS}" >>"${EXPORTDIR}/scripts/Make.defs" echo "HEAD_OBJ = ${HEAD_OBJ}" >>"${EXPORTDIR}/scripts/Make.defs" - echo "LDENDGROUP = ${LDENDGROUP}" >>"${EXPORTDIR}/scripts/Make.defs" echo "LDFLAGS = ${LDFLAGS}" >>"${EXPORTDIR}/scripts/Make.defs" - echo "LDSTARTGROUP = ${LDSTARTGROUP}" >>"${EXPORTDIR}/scripts/Make.defs" echo "set(EXTRA_LIBS \"${EXTRA_LIBS}\")" >>"${EXPORTDIR}/scripts/target.cmake" echo "set(EXTRA_OBJS \"${EXTRA_OBJS}\")" >>"${EXPORTDIR}/scripts/target.cmake" echo "set(HEAD_OBJ \"${HEAD_OBJ}\")" >>"${EXPORTDIR}/scripts/target.cmake" - echo "set(LDENDGROUP \"${LDENDGROUP}\")" >>"${EXPORTDIR}/scripts/target.cmake" echo "set(LDFLAGS \"${LDFLAGS}\")" >>"${EXPORTDIR}/scripts/target.cmake" - echo "set(LDSTARTGROUP \"${LDSTARTGROUP}\")" >>"${EXPORTDIR}/scripts/target.cmake" fi # Copy the CMake toolchain file
