riscv: Pass -mno-relax only on lld < 15.0.0
PATCH 1/1 riscv: Pass -mno-relax only on lld < 15.0.0
lld since
https://github.com/llvm/llvm-project/commit/6611d58f5bbcbec77262d392e2923e1d680f6985
(milestone: 15.0.0) has implemented some RISC-V linker relaxation. -mno-relax is no longer needed in KBUILD_CFLAGS/KBUILD_AFLAGS to suppress R_RISCV_ALIGN which older lld can not handle:
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
--- arch/riscv/Makefile | 2 ++ 1 file changed, 2 insertions(+)
arch/riscv/Makefile +2 -0
@@ -37,6 +37,7 @@ else endif ifeq ($(CONFIG_LD_IS_LLD),y) +ifeq ($(shell test $(CONFIG_LLD_VERSION) -lt 150000; echo $$?),0) KBUILD_CFLAGS += -mno-relax KBUILD_AFLAGS += -mno-relax ifndef CONFIG_AS_IS_LLVM
@@ -44,6 +45,7 @@ ifndef CONFIG_AS_IS_LLVM KBUILD_AFLAGS += -Wa,-mno-relax endif endif +endif # ISA string setting riscv-march-$(CONFIG_ARCH_RV32I) := rv32ima
Signature · 1 line
2.37.0.144.g8ac04bfd2-goog
Quoted 9 lines · Fangrui Song
lld since
https://github.com/llvm/llvm-project/commit/6611d58f5bbcbec77262d392e2923e1d680f6985
(milestone: 15.0.0) has implemented some RISC-V linker relaxation. -mno-relax is no longer needed in KBUILD_CFLAGS/KBUILD_AFLAGS to suppressR_RISCV_ALIGNwhich older lld can not handle:ld.lld: error: capability.c:(.fixup+0x0): relocation
R_RISCV_ALIGNrequires unimplemented linker relaxation; recompile with -mno-relax but the .o is already compiled with -mno-relaxSigned-off-by Fangrui Song <[email protected]>
ld.lld 14 and 15 both continue to link kernels and I have no issues booting them in QEMU.
Quoted 28 lines
--- arch/riscv/Makefile | 2 ++ 1 file changed, 2 insertions(+)arch/riscv/Makefile +2
-0@@ -37,6 +37,7 @@ else endif ifeq ($(CONFIG_LD_IS_LLD),y) +ifeq ($(shell test $(CONFIG_LLD_VERSION) -lt 150000; echo $$?),0) KBUILD_CFLAGS += -mno-relax KBUILD_AFLAGS += -mno-relax ifndef CONFIG_AS_IS_LLVM@@ -44,6 +45,7 @@ ifndef CONFIG_AS_IS_LLVM KBUILD_AFLAGS += -Wa,-mno-relax endif endif +endif # ISA string setting riscv-march-$(CONFIG_ARCH_RV32I) := rv32imaSignature · 1 line
2.37.0.144.g8ac04bfd2-goog
Quoted 10 lines · Fangrui Song
lld since
https://github.com/llvm/llvm-project/commit/6611d58f5bbcbec77262d392e2923e1d680f6985
(milestone: 15.0.0) has implemented some RISC-V linker relaxation. -mno-relax is no longer needed in KBUILD_CFLAGS/KBUILD_AFLAGS to suppressR_RISCV_ALIGNwhich older lld can not handle:ld.lld: error: capability.c:(.fixup+0x0): relocation
R_RISCV_ALIGNrequires unimplemented linker relaxation; recompile with -mno-relax but the .o is already compiled with -mno-relaxSigned-off-by Fangrui Song <[email protected]>
Thanks for implementing relaxation in LLD for RISC-V!
Quoted 28 lines
--- arch/riscv/Makefile | 2 ++ 1 file changed, 2 insertions(+)arch/riscv/Makefile +2
-1@@ -37,6 +37,7 @@ else endif ifeq ($(CONFIG_LD_IS_LLD),y) +ifeq ($(shell test $(CONFIG_LLD_VERSION) -lt 150000; echo $$?),0) KBUILD_CFLAGS += -mno-relax KBUILD_AFLAGS += -mno-relax ifndef CONFIG_AS_IS_LLVM@@ -44,6 +45,7 @@ ifndef CONFIG_AS_IS_LLVM KBUILD_AFLAGS += -Wa,-mno-relax endif endif +endif # ISA string setting riscv-march-$(CONFIG_ARCH_RV32I) := rv32ima --2.37.0.144.g8ac04bfd2-goog
Signature · 2 lines
Thanks, ~Nick Desaulniers
It does not look like this ever got picked up? Would it be possible to pick it up for 6.1?
The original patch is at:
https://lore.kernel.org/[email protected]/
Cheers,
Nathan
Quoted 37 lines · Fangrui Song
lld since
https://github.com/llvm/llvm-project/commit/6611d58f5bbcbec77262d392e2923e1d680f6985
(milestone: 15.0.0) has implemented some RISC-V linker relaxation. -mno-relax is no longer needed in KBUILD_CFLAGS/KBUILD_AFLAGS to suppressR_RISCV_ALIGNwhich older lld can not handle:ld.lld: error: capability.c:(.fixup+0x0): relocation
R_RISCV_ALIGNrequires unimplemented linker relaxation; recompile with -mno-relax but the .o is already compiled with -mno-relaxSigned-off-by Fangrui Song <[email protected]>--- arch/riscv/Makefile | 2 ++ 1 file changed, 2 insertions(+)arch/riscv/Makefile +2
-0@@ -37,6 +37,7 @@ else endif ifeq ($(CONFIG_LD_IS_LLD),y) +ifeq ($(shell test $(CONFIG_LLD_VERSION) -lt 150000; echo $$?),0) KBUILD_CFLAGS += -mno-relax KBUILD_AFLAGS += -mno-relax ifndef CONFIG_AS_IS_LLVM@@ -44,6 +45,7 @@ ifndef CONFIG_AS_IS_LLVM KBUILD_AFLAGS += -Wa,-mno-relax endif endif +endif # ISA string setting riscv-march-$(CONFIG_ARCH_RV32I) := rv32imaSignature · 1 line
2.37.0.144.g8ac04bfd2-goog