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 2ba1898abbd7d438b2975c82413761f8ddaba3a7 Author: Marco Casaroli <[email protected]> AuthorDate: Wed Oct 21 12:33:24 2026 +0200 arch/arm: Link an LTO program that is not relocatable with gcc. With CONFIG_PIC (not FDPIC), or with CONFIG_BINFMT_ELF_EXECUTABLE, a program is linked to an executable. With CONFIG_LTO_FULL, gcc links it: the PIC link gave it options of ld, and both links gave it no compile options, so gcc added its start files: arm-none-eabi-gcc: error: unrecognized command-line option '--unresolved-symbols=ignore-in-object-files' crt0.c:169: multiple definition of `_start' The gcc branch now sets LDXLINKER to -Xlinker and LDELFEXEFLAGS to the ELF compile options and -nostdlib. The PIC link gives its options of ld with $(LDXLINKER), and both executable links add $(LDELFEXEFLAGS). Without LTO the options are the same as before. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Marco Casaroli <[email protected]> --- arch/arm/src/common/Toolchain.defs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/arch/arm/src/common/Toolchain.defs b/arch/arm/src/common/Toolchain.defs index f6085ff3657..64534c2cd2b 100644 --- a/arch/arm/src/common/Toolchain.defs +++ b/arch/arm/src/common/Toolchain.defs @@ -324,6 +324,13 @@ else LDMODULELTOFLAGS = -flinker-output=nolto-rel $(CMODULEFLAGS) LDELFLTOFLAGS = -flinker-output=nolto-rel $(CELFFLAGS) + # A program that is not relocatable is linked to an executable, also + # with the ELF options and without the start files and libraries of + # gcc, and gets the options of ld with -Xlinker + + LDELFEXEFLAGS = $(CELFFLAGS) -nostdlib + LDXLINKER = -Xlinker + # The export gives the group options to the program link of a kernel build LDSTARTGROUP = -Wl,--start-group @@ -730,12 +737,15 @@ else CXXELFFLAGS += $(PICFLAGS) -mpic-register=r9 # Generate an executable elf, need to ignore undefined symbols - LDELFFLAGS += --unresolved-symbols=ignore-in-object-files --emit-relocs + LDELFFLAGS += $(LDXLINKER) --unresolved-symbols=ignore-in-object-files + LDELFFLAGS += $(LDXLINKER) --emit-relocs $(LDELFEXEFLAGS) endif else ifneq ($(CONFIG_BINFMT_ELF_EXECUTABLE),y) LDELFFLAGS += -r $(LDELFLTOFLAGS) + else + LDELFFLAGS += $(LDELFEXEFLAGS) endif endif
