Skip to content

Commit ec3a5cb

Browse files
krajpalmer-dabbelt
authored andcommitted
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 Signed-off-by: Khem Raj <[email protected]> Reviewed-by: Nathan Chancellor <[email protected]> Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent bab0d47 commit ec3a5cb

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

arch/riscv/Makefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,15 @@ else
3838
KBUILD_LDFLAGS += -melf32lriscv
3939
endif
4040

41+
ifeq ($(CONFIG_LD_IS_LLD),y)
42+
KBUILD_CFLAGS += -mno-relax
43+
KBUILD_AFLAGS += -mno-relax
44+
ifneq ($(LLVM_IAS),1)
45+
KBUILD_CFLAGS += -Wa,-mno-relax
46+
KBUILD_AFLAGS += -Wa,-mno-relax
47+
endif
48+
endif
49+
4150
# ISA string setting
4251
riscv-march-$(CONFIG_ARCH_RV32I) := rv32ima
4352
riscv-march-$(CONFIG_ARCH_RV64I) := rv64ima

0 commit comments

Comments
 (0)