Skip to content

Commit 448857e

Browse files
Merge patch series "RISC-V: Disable DWARF5 with known broken LLVM versions"
Nathan Chancellor <nathan@kernel.org> says: This series disables DWARF5 for LLVM versions where it is known to be broken due to linker relaxation. * b4-shazam-merge: lib/Kconfig.debug: Update AS_HAS_NON_CONST_LEB128 comment and name riscv: Restrict DWARF5 when building with LLVM to known working versions riscv: Hoist linker relaxation disabling logic into Kconfig Link: llvm/llvm-project@bbc0f99 Link: https://lore.kernel.org/r/20231205-riscv-restrict-dwarf5-llvm-v2-0-aedf00a382ac@kernel.org Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
2 parents c640868 + a442664 commit 448857e

File tree

3 files changed

+22
-8
lines changed

3 files changed

+22
-8
lines changed

arch/riscv/Kconfig

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

186+
config RISCV_USE_LINKER_RELAXATION
187+
def_bool y
188+
# https://github.com/llvm/llvm-project/commit/6611d58f5bbcbec77262d392e2923e1d680f6985
189+
depends on !LD_IS_LLD || LLD_VERSION >= 150000
190+
191+
# https://github.com/llvm/llvm-project/commit/bbc0f99f3bc96f1db16f649fc21dd18e5b0918f6
192+
config ARCH_HAS_BROKEN_DWARF5
193+
def_bool y
194+
depends on RISCV_USE_LINKER_RELAXATION
195+
# https://github.com/llvm/llvm-project/commit/1df5ea29b43690b6622db2cad7b745607ca4de6a
196+
depends on AS_IS_LLVM && AS_VERSION < 180000
197+
# https://github.com/llvm/llvm-project/commit/7ffabb61a5569444b5ac9322e22e5471cc5e4a77
198+
depends on LD_IS_LLD && LLD_VERSION < 180000
199+
186200
config ARCH_MMAP_RND_BITS_MIN
187201
default 18 if 64BIT
188202
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

lib/Kconfig.debug

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,10 @@ config DEBUG_INFO
231231
in the "Debug information" choice below, indicating that debug
232232
information will be generated for build targets.
233233

234-
# Clang is known to generate .{s,u}leb128 with symbol deltas with DWARF5, which
235-
# some targets may not support: https://sourceware.org/bugzilla/show_bug.cgi?id=27215
236-
config AS_HAS_NON_CONST_LEB128
234+
# Clang generates .uleb128 with label differences for DWARF v5, a feature that
235+
# older binutils ports do not support when utilizing RISC-V style linker
236+
# relaxation: https://sourceware.org/bugzilla/show_bug.cgi?id=27215
237+
config AS_HAS_NON_CONST_ULEB128
237238
def_bool $(as-instr,.uleb128 .Lexpr_end4 - .Lexpr_start3\n.Lexpr_start3:\n.Lexpr_end4:)
238239

239240
choice
@@ -258,7 +259,7 @@ config DEBUG_INFO_NONE
258259
config DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT
259260
bool "Rely on the toolchain's implicit default DWARF version"
260261
select DEBUG_INFO
261-
depends on !CC_IS_CLANG || AS_IS_LLVM || CLANG_VERSION < 140000 || (AS_IS_GNU && AS_VERSION >= 23502 && AS_HAS_NON_CONST_LEB128)
262+
depends on !CC_IS_CLANG || AS_IS_LLVM || CLANG_VERSION < 140000 || (AS_IS_GNU && AS_VERSION >= 23502 && AS_HAS_NON_CONST_ULEB128)
262263
help
263264
The implicit default version of DWARF debug info produced by a
264265
toolchain changes over time.
@@ -282,7 +283,8 @@ config DEBUG_INFO_DWARF4
282283
config DEBUG_INFO_DWARF5
283284
bool "Generate DWARF Version 5 debuginfo"
284285
select DEBUG_INFO
285-
depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502 && AS_HAS_NON_CONST_LEB128)
286+
depends on !ARCH_HAS_BROKEN_DWARF5
287+
depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502 && AS_HAS_NON_CONST_ULEB128)
286288
help
287289
Generate DWARF v5 debug info. Requires binutils 2.35.2, gcc 5.0+ (gcc
288290
5.0+ accepts the -gdwarf-5 flag but only had partial support for some

0 commit comments

Comments
 (0)