[PATCH 2/2] riscv: Restrict DWARF5 when building with LLVM to known working versions

Fangrui Song maskray at google.com
Tue Dec 5 15:39:39 PST 2023


On Mon, Dec 4, 2023 at 3:12 PM Nathan Chancellor <nathan at kernel.org> wrote:
>
> On Fri, Dec 01, 2023 at 08:31:12PM -0800, Fangrui Song wrote:
> > Perhaps: Clang generates .uleb128 with label differences for DWARF v5,
> > a feature that older binutils ports, utilizing RISC-V style linker
> > relaxation, do not support.
> >
> > (Signed LEB128 is used by DWARF as well, but it is encoded directly
> > into DW_OP_fbreg/DW_LNS_advance_line/etc, and explicit .sleb128
> > directives are not emitted)
> > (In assemblers, "label difference" is a more common term.)
> > (People working on DWARF tend to prefer DWARF v5 to DWARF5, when the
> > full "DWARF version 5" feels too verbose.)
>
> Thanks, does this diff seem reasonable to you? I'd like to keep the
> issue link as a paper trail and I figured that we might as well make the
> configuration name slightly more accurate with that additional
> information. I will send it as a separate patch in v2 tomorrow if so in
> order to give people a chance to further chime in on the series.
>
> Cheers,
> Nathan
>
> diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
> index a0ebce05a368..76c2cc697573 100644
> --- a/lib/Kconfig.debug
> +++ b/lib/Kconfig.debug
> @@ -231,9 +231,10 @@ config DEBUG_INFO
>           in the "Debug information" choice below, indicating that debug
>           information will be generated for build targets.
>
> -# Clang is known to generate .{s,u}leb128 with symbol deltas with DWARF5, which
> -# some targets may not support: https://sourceware.org/bugzilla/show_bug.cgi?id=27215
> -config AS_HAS_NON_CONST_LEB128
> +# Clang generates .uleb128 with label differences for DWARF v5, a feature that
> +# older binutils ports do not support when utilizing RISC-V style linker
> +# relaxation: https://sourceware.org/bugzilla/show_bug.cgi?id=27215
> +config AS_HAS_NON_CONST_ULEB128
>         def_bool $(as-instr,.uleb128 .Lexpr_end4 - .Lexpr_start3\n.Lexpr_start3:\n.Lexpr_end4:)
>
>  choice
> @@ -258,7 +259,7 @@ config DEBUG_INFO_NONE
>  config DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT
>         bool "Rely on the toolchain's implicit default DWARF version"
>         select DEBUG_INFO
> -       depends on !CC_IS_CLANG || AS_IS_LLVM || CLANG_VERSION < 140000 || (AS_IS_GNU && AS_VERSION >= 23502 && AS_HAS_NON_CONST_LEB128)
> +       depends on !CC_IS_CLANG || AS_IS_LLVM || CLANG_VERSION < 140000 || (AS_IS_GNU && AS_VERSION >= 23502 && AS_HAS_NON_CONST_ULEB128)
>         help
>           The implicit default version of DWARF debug info produced by a
>           toolchain changes over time.
> @@ -283,7 +284,7 @@ config DEBUG_INFO_DWARF5
>         bool "Generate DWARF Version 5 debuginfo"
>         select DEBUG_INFO
>         depends on !ARCH_HAS_BROKEN_DWARF5
> -       depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502 && AS_HAS_NON_CONST_LEB128)
> +       depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502 && AS_HAS_NON_CONST_ULEB128)
>         help
>           Generate DWARF v5 debug info. Requires binutils 2.35.2, gcc 5.0+ (gcc
>           5.0+ accepts the -gdwarf-5 flag but only had partial support for some

This diff looks good to me.


-- 
宋方睿



More information about the linux-riscv mailing list