[PATCH] Makefile: Add -fuse-ld for merge_objs
Xiang W
wxjstz at 126.com
Mon Dec 1 22:49:37 PST 2025
On some platforms, the default linker is `mold`, which can cause the
following error. Adding the `--fuse-ld` option can prevent this problem.
MERGE platform/generic/firmware/payloads/test.o
mold: fatal: unknown command line option: -b elf64-littleriscv
Signed-off-by: Xiang W <wangxiang at iscas.ac.cn>
---
Makefile | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/Makefile b/Makefile
index eb95164c..a8d702a1 100644
--- a/Makefile
+++ b/Makefile
@@ -433,13 +433,16 @@ ELFFLAGS += -Wl,--no-dynamic-linker -Wl,-pie
ELFFLAGS += $(platform-ldflags-y)
ELFFLAGS += $(firmware-ldflags-y)
-MERGEFLAGS += -r
+MERGEFLAGS += $(USE_LD_FLAG)
+MERGEFLAGS += -no-pie
+MERGEFLAGS += -nostdlib
+MERGEFLAGS += -Wl,-r
ifeq ($(LD_IS_LLD),y)
-MERGEFLAGS += -b elf
+MERGEFLAGS += -Wl,-b,elf
else
-MERGEFLAGS += -b elf$(PLATFORM_RISCV_XLEN)-littleriscv
+MERGEFLAGS += -Wl,-b,elf$(PLATFORM_RISCV_XLEN)-littleriscv
endif
-MERGEFLAGS += -m elf$(PLATFORM_RISCV_XLEN)lriscv
+MERGEFLAGS += -Wl,-m,elf$(PLATFORM_RISCV_XLEN)lriscv
DTSCPPFLAGS = $(CPPFLAGS) -nostdinc -nostdlib -fno-builtin -D__DTS__ -x assembler-with-cpp
@@ -459,7 +462,7 @@ define dynamic_flags
endef
merge_objs = $(CMD_PREFIX)mkdir -p `dirname $(1)`; \
echo " MERGE $(subst $(build_dir)/,,$(1))"; \
- $(LD) $(MERGEFLAGS) $(2) -o $(1)
+ $(CC) $(MERGEFLAGS) $(2) -o $(1)
merge_deps = $(CMD_PREFIX)mkdir -p `dirname $(1)`; \
echo " MERGE-DEP $(subst $(build_dir)/,,$(1))"; \
cat $(2) > $(1)
--
2.47.3
More information about the opensbi
mailing list