riscv: Use -mno-relax when using lld linker
PATCH v2 1/1 riscv: Use -mno-relax when using lld linker
lld does not implement the RISCV relaxation optimizations like GNU ld therefore disable it when building with lld, Also pass it to assembler when using external GNU assembler ( LLVM_IAS != 1 ), this ensures that relevant assembler option is also enabled along. if these options are not used then we see following relocations in objects
0000000000000000 R_RISCV_ALIGN *ABS*+0x0000000000000002
These are then rejected by lld
ld.lld: error: capability.c:(.fixup+0x0): relocation R_RISCV_ALIGN requires unimplemented linker relaxation; recompile with -mno-relax but the .o is already compiled with -mno-relax
---
v2: Use CONFIG_LD_IS_LLD instead of LLVM check
arch/riscv/Makefile | 9 +++++++++ 1 file changed, 9 insertions(+)
arch/riscv/Makefile +9 -0
@@ -38,6 +38,15 @@ else KBUILD_LDFLAGS += -melf32lriscv endif +ifeq ($(CONFIG_LD_IS_LLD),y) + KBUILD_CFLAGS += -mno-relax + KBUILD_AFLAGS += -mno-relax +ifneq ($(LLVM_IAS),1) + KBUILD_CFLAGS += -Wa,-mno-relax + KBUILD_AFLAGS += -Wa,-mno-relax +endif +endif + # ISA string setting riscv-march-$(CONFIG_ARCH_RV32I) := rv32ima riscv-march-$(CONFIG_ARCH_RV64I) := rv64ima
Signature · 7 lines
2.31.1 _______________________________________________ linux-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-riscv
Quoted 11 lines · Khem Raj
lld does not implement the RISCV relaxation optimizations like GNU ld therefore disable it when building with lld, Also pass it to assembler when using external GNU assembler (
LLVM_IAS!= 1 ), this ensures that relevant assembler option is also enabled along. if these options are not used then we see following relocations in objects0000000000000000
R_RISCV_ALIGN*ABS*+0x0000000000000002These are then rejected by lld
ld.lld: error: capability.c:(.fixup+0x0): relocationR_RISCV_ALIGNrequires unimplemented linker relaxation; recompile with -mno-relax but the .o is already compiled with -mno-relax
Quoted 6 lines
Signed-off-by Khem Raj <[email protected]>Cc Paul Walmsley <[email protected]>Cc Palmer Dabbelt <[email protected]>Cc Albert Ou <[email protected]>Cc Nathan Chancellor <[email protected]>Cc Nick Desaulniers <[email protected]>
Quoted 17 lines
---
v2: UseCONFIG_LD_IS_LLDinstead of LLVM checkarch/riscv/Makefile | 9 +++++++++ 1 file changed, 9 insertions(+)arch/riscv/Makefile +2
-0@@ -38,6 +38,15 @@ else KBUILD_LDFLAGS += -melf32lriscv endif +ifeq ($(CONFIG_LD_IS_LLD),y) + KBUILD_CFLAGS += -mno-relax
arch/riscv/Makefile else · line 52
Quoted 10 lines
arch/riscv/Makefile +7
-0+ KBUILD_AFLAGS += -mno-relax +ifneq ($(LLVM_IAS),1) + KBUILD_CFLAGS += -Wa,-mno-relax + KBUILD_AFLAGS += -Wa,-mno-relax +endif +endif + # ISA string setting riscv-march-$(CONFIG_ARCH_RV32I) := rv32ima riscv-march-$(CONFIG_ARCH_RV64I) := rv64ima
_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv