Skip to content

Commit 55b71d2

Browse files
nathanchancepalmer-dabbelt
authored andcommitted
riscv: Hoist linker relaxation disabling logic into Kconfig
Certain configurations may need to be disabled if linker relaxation is in use, such as DWARF5 with ld.lld < 18. Hoist the logic of whether or not linker relaxation is in use into Kconfig so decisions can be made at configuration time. Reviewed-by: Fangrui Song <maskray@google.com> Signed-off-by: Nathan Chancellor <nathan@kernel.org> Link: https://lore.kernel.org/r/20231205-riscv-restrict-dwarf5-llvm-v2-1-aedf00a382ac@kernel.org Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
1 parent b85ea95 commit 55b71d2

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

arch/riscv/Kconfig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,11 @@ config HAVE_SHADOW_CALL_STACK
181181
# https://github.com/riscv-non-isa/riscv-elf-psabi-doc/commit/a484e843e6eeb51f0cb7b8819e50da6d2444d769
182182
depends on $(ld-option,--no-relax-gp)
183183

184+
config RISCV_USE_LINKER_RELAXATION
185+
def_bool y
186+
# https://github.com/llvm/llvm-project/commit/6611d58f5bbcbec77262d392e2923e1d680f6985
187+
depends on !LD_IS_LLD || LLD_VERSION >= 150000
188+
184189
config ARCH_MMAP_RND_BITS_MIN
185190
default 18 if 64BIT
186191
default 8

arch/riscv/Makefile

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,14 @@ else
4343
KBUILD_LDFLAGS += -melf32lriscv
4444
endif
4545

46-
ifeq ($(CONFIG_LD_IS_LLD),y)
47-
ifeq ($(call test-lt, $(CONFIG_LLD_VERSION), 150000),y)
46+
ifndef CONFIG_RISCV_USE_LINKER_RELAXATION
4847
KBUILD_CFLAGS += -mno-relax
4948
KBUILD_AFLAGS += -mno-relax
5049
ifndef CONFIG_AS_IS_LLVM
5150
KBUILD_CFLAGS += -Wa,-mno-relax
5251
KBUILD_AFLAGS += -Wa,-mno-relax
5352
endif
5453
endif
55-
endif
5654

5755
ifeq ($(CONFIG_SHADOW_CALL_STACK),y)
5856
KBUILD_LDFLAGS += --no-relax-gp

0 commit comments

Comments
 (0)