Skip to content

Commit ae84ff9

Browse files
nathanchancepalmer-dabbelt
authored andcommitted
riscv: Restrict DWARF5 when building with LLVM to known working versions
LLVM prior to 18.0.0 would generate incorrect debug info for DWARF5 due to linker relaxation, which was worked around in clang by defaulting RISC-V to DWARF4 [1]. Unfortunately, this workaround does not work for the kernel because the DWARF version can be independently changed from the default in Kconfig. Do not allow DWARF5 to be selected for RISC-V when using linker relaxation (ld.lld >= 15.0.0) and a version of LLVM that does not have the fixes (the integrated assembler [2] and ld.lld [3] < 18.0.0) necessary to generate the correct debug info. Link: llvm/llvm-project@bbc0f99 [1] Link: llvm/llvm-project@1df5ea2 [2] Link: llvm/llvm-project@7ffabb6 [3] Signed-off-by: Nathan Chancellor <nathan@kernel.org> Reviewed-by: Fangrui Song <maskray@google.com> Link: https://lore.kernel.org/r/20231205-riscv-restrict-dwarf5-llvm-v2-2-aedf00a382ac@kernel.org Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
1 parent 55b71d2 commit ae84ff9

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

arch/riscv/Kconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,15 @@ config RISCV_USE_LINKER_RELAXATION
186186
# https://github.com/llvm/llvm-project/commit/6611d58f5bbcbec77262d392e2923e1d680f6985
187187
depends on !LD_IS_LLD || LLD_VERSION >= 150000
188188

189+
# https://github.com/llvm/llvm-project/commit/bbc0f99f3bc96f1db16f649fc21dd18e5b0918f6
190+
config ARCH_HAS_BROKEN_DWARF5
191+
def_bool y
192+
depends on RISCV_USE_LINKER_RELAXATION
193+
# https://github.com/llvm/llvm-project/commit/1df5ea29b43690b6622db2cad7b745607ca4de6a
194+
depends on AS_IS_LLVM && AS_VERSION < 180000
195+
# https://github.com/llvm/llvm-project/commit/7ffabb61a5569444b5ac9322e22e5471cc5e4a77
196+
depends on LD_IS_LLD && LLD_VERSION < 180000
197+
189198
config ARCH_MMAP_RND_BITS_MIN
190199
default 18 if 64BIT
191200
default 8

lib/Kconfig.debug

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ config DEBUG_INFO_DWARF4
282282
config DEBUG_INFO_DWARF5
283283
bool "Generate DWARF Version 5 debuginfo"
284284
select DEBUG_INFO
285+
depends on !ARCH_HAS_BROKEN_DWARF5
285286
depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502 && AS_HAS_NON_CONST_LEB128)
286287
help
287288
Generate DWARF v5 debug info. Requires binutils 2.35.2, gcc 5.0+ (gcc

0 commit comments

Comments
 (0)