[PATCH v2] Makefile: Add -fuse-ld for merge_objs
Xiang W
wxjstz at 126.com
Mon Dec 1 23:05:55 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>
---
v2 changes:
- s/-no-pie -Wl,-r/-r/
Makefile | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/Makefile b/Makefile
index eb95164c..794f6f38 100644
--- a/Makefile
+++ b/Makefile
@@ -433,13 +433,15 @@ ELFFLAGS += -Wl,--no-dynamic-linker -Wl,-pie
ELFFLAGS += $(platform-ldflags-y)
ELFFLAGS += $(firmware-ldflags-y)
+MERGEFLAGS += $(USE_LD_FLAG)
+MERGEFLAGS += -nostdlib
MERGEFLAGS += -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 +461,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