[riscv] Disable linker relaxations when linking with ld.lld

We have to compile RISC-V code with -mno-relax when linking with ld.lld
since ld.lld does not yet support RISC-V linker relaxations. Without this
change, linking with ld.lld results in many errors such as:
`relocation R_RISCV_ALIGN requires unimplemented linker relaxation`.

This support was implemented as part of LLVM 15, but to support older
versions of ld.lld we add the flag unconditionally for now.
This commit is contained in:
Alex Richardson
2021-12-09 11:43:39 +00:00
parent 8c20e005ca
commit 135479c70e

View File

@@ -216,6 +216,14 @@ ARCH_COMPILEFLAGS += -Wno-asm-operand-widths
endif
endif
ifeq ($(ARCH),riscv)
# ld.lld does not support linker relaxations yet.
# TODO: This is no longer true as of LLVM 15, so should add a version check
ifeq ($(LINKER_TYPE),lld)
ARCH_COMPILEFLAGS += -mno-relax
endif
endif
$(info PROJECT = $(PROJECT))
$(info PLATFORM = $(PLATFORM))
$(info TARGET = $(TARGET))