Skip to content

Commit 3cebf80

Browse files
MaskRaypalmer-dabbelt
authored andcommitted
riscv: Pass -mno-relax only on lld < 15.0.0
lld since llvm:6611d58f5bbc ("[ELF] Relax R_RISCV_ALIGN"), which will be included in the 15.0.0 release, 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 Signed-off-by: Fangrui Song <maskray@google.com> Link: https://lore.kernel.org/r/20220710071117.446112-1-maskray@google.com/ Link: https://lore.kernel.org/r/20220918092933.19943-1-palmer@rivosinc.com Reviewed-by: Nick Desaulniers <ndesaulniers@google.com> Tested-by: Nick Desaulniers <ndesaulniers@google.com> Tested-by: Nathan Chancellor <nathan@kernel.org> Tested-by: Conor Dooley <conor.dooley@microchip.com> Cc: stable@vger.kernel.org Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
1 parent f2913d0 commit 3cebf80

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

arch/riscv/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,15 @@ else
3737
endif
3838

3939
ifeq ($(CONFIG_LD_IS_LLD),y)
40+
ifeq ($(shell test $(CONFIG_LLD_VERSION) -lt 150000; echo $$?),0)
4041
KBUILD_CFLAGS += -mno-relax
4142
KBUILD_AFLAGS += -mno-relax
4243
ifndef CONFIG_AS_IS_LLVM
4344
KBUILD_CFLAGS += -Wa,-mno-relax
4445
KBUILD_AFLAGS += -Wa,-mno-relax
4546
endif
4647
endif
48+
endif
4749

4850
# ISA string setting
4951
riscv-march-$(CONFIG_ARCH_RV32I) := rv32ima

0 commit comments

Comments
 (0)