You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ac...@apache.org on 2026/10/22 16:33:13 UTC
(nuttx) 02/06: arch/risc-v: Give --oformat to the linker with -Xlinker.
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 113a47cb709e5d2eaac4170196de169b254db5d3
Author: Marco Casaroli <ma...@gmail.com>
AuthorDate: Wed Oct 21 10:09:00 2026 +0200
arch/risc-v: Give --oformat to the linker with -Xlinker.
LDELFFLAGS has "--oformat elf32-littleriscv" (or elf64), an option of
the linker. The link of an ELF program uses MODULELD, which is LD by
default, and with clang, or with gcc and CONFIG_LTO_FULL, LD is the
compiler driver. The driver stops: "riscv-none-elf-gcc: error:
unrecognized command-line option '--oformat'", "clang: error: unknown
argument: '--oformat'".
The branches that set LD to a driver now set LDXLINKER to -Xlinker, and
LDELFFLAGS has "$(LDXLINKER) --oformat=elf32-littleriscv" (or elf64).
With ld the option is the same as before.
Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Marco Casaroli <ma...@gmail.com>
---
arch/risc-v/src/common/Toolchain.defs | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/arch/risc-v/src/common/Toolchain.defs b/arch/risc-v/src/common/Toolchain.defs
index ab8f08ff0e7..bf9f890d0a8 100644
--- a/arch/risc-v/src/common/Toolchain.defs
+++ b/arch/risc-v/src/common/Toolchain.defs
@@ -366,6 +366,10 @@ ifeq ($(CONFIG_ARCH_TOOLCHAIN_CLANG),y)
ARCHOPTIMIZATION += -fshort-enums
+ # LD is the compiler driver: give it the options of the linker with -Xlinker
+
+ LDXLINKER = -Xlinker
+
# Default toolchain
else
@@ -395,6 +399,7 @@ else
LDMODULELTOFLAGS = -flinker-output=nolto-rel $(CMODULEFLAGS)
LDELFLTOFLAGS = -flinker-output=nolto-rel $(CELFFLAGS)
+ LDXLINKER = -Xlinker
endif
endif
@@ -467,9 +472,9 @@ ifeq ($(CONFIG_BINFMT_ELF_RELOCATABLE),y)
endif
ifeq ($(CONFIG_ARCH_RV32),y)
- LDELFFLAGS += --oformat elf32-littleriscv
+ LDELFFLAGS += $(LDXLINKER) --oformat=elf32-littleriscv
else
- LDELFFLAGS += --oformat elf64-littleriscv
+ LDELFFLAGS += $(LDXLINKER) --oformat=elf64-littleriscv
endif
ifneq ($(CONFIG_BUILD_KERNEL),y)