mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Nathan Chancellor <nathan@kernel.org>
To: Nick Desaulniers <ndesaulniers@google.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Masahiro Yamada <masahiroy@kernel.org>, Tom Rix <trix@redhat.com>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	linux-kbuild@vger.kernel.org, linux-riscv@lists.infradead.org,
	linux-kernel@vger.kernel.org, patches@lists.linux.dev,
	llvm@lists.linux.dev, Conor Dooley <conor.dooley@microchip.com>
Subject: Re: [PATCH] lib/Kconfig.debug: Add check for non-constant .{s,u}leb128 support to DWARF5
Date: Wed, 28 Sep 2022 14:36:45 -0700	[thread overview]
Message-ID: <YzS+bQT1zJAUpp/6@dev-arch.thelio-3990X> (raw)
In-Reply-To: <CAKwvOdmPLqX=oCwg43TYHj=tdoaU5OYc=bO906u=LeqcSrx+Dw@mail.gmail.com>

On Wed, Sep 28, 2022 at 02:13:47PM -0700, Nick Desaulniers wrote:
> On Wed, Sep 28, 2022 at 11:25 AM Nathan Chancellor <nathan@kernel.org> wrote:
> >
> > When building with a RISC-V kernel with DWARF5 debug info using clang
> > and the GNU assembler, several instances of the following error appear:
> >
> >   /tmp/vgettimeofday-48aa35.s:2963: Error: non-constant .uleb128 is not supported
> >
> > Dumping the .s file reveals these .uleb128 directives come from
> > .debug_loc and .debug_ranges:
> >
> >   .Ldebug_loc0:
> >           .byte   4                               # DW_LLE_offset_pair
> >           .uleb128 .Lfunc_begin0-.Lfunc_begin0    #   starting offset
> >           .uleb128 .Ltmp1-.Lfunc_begin0           #   ending offset
> >           .byte   1                               # Loc expr size
> >           .byte   90                              # DW_OP_reg10
> >           .byte   0                               # DW_LLE_end_of_list
> >
> >   .Ldebug_ranges0:
> >           .byte   4                               # DW_RLE_offset_pair
> >           .uleb128 .Ltmp6-.Lfunc_begin0           #   starting offset
> >           .uleb128 .Ltmp27-.Lfunc_begin0          #   ending offset
> >           .byte   4                               # DW_RLE_offset_pair
> >           .uleb128 .Ltmp28-.Lfunc_begin0          #   starting offset
> >           .uleb128 .Ltmp30-.Lfunc_begin0          #   ending offset
> >           .byte   0                               # DW_RLE_end_of_list
> >
> > There is an outstanding binutils issue to support a non-constant operand
> > to .sleb128 and .uleb128 in GAS for RISC-V but there does not appear to
> > be any movement on it, due to concerns over how it would work with
> > linker relaxation.
> >
> > To avoid these build errors, prevent DWARF5 from being selected when
> > using clang and an assembler that does not have support for these symbol
> > deltas, which can be easily checked in Kconfig with as-instr plus the
> > small test program from the dwz test suite from the binutils issue.
> >
> > Link: https://sourceware.org/bugzilla/show_bug.cgi?id=27215
> > Link: https://github.com/ClangBuiltLinux/linux/issues/1719
> > Tested-by: Conor Dooley <conor.dooley@microchip.com>
> > Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> > ---
> >  lib/Kconfig.debug | 7 +++++++
> >  1 file changed, 7 insertions(+)
> >
> > diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
> > index d3e5f36bb01e..19de03ead2ed 100644
> > --- a/lib/Kconfig.debug
> > +++ b/lib/Kconfig.debug
> > @@ -231,6 +231,9 @@ config DEBUG_INFO
> >           in the "Debug information" choice below, indicating that debug
> >           information will be generated for build targets.
> >
> > +config AS_HAS_NON_CONST_LEB128
> > +       def_bool $(as-instr,.uleb128 .Lexpr_end4 - .Lexpr_start3\n.Lexpr_start3:\n.Lexpr_end4:)
> > +
> >  choice
> >         prompt "Debug information"
> >         depends on DEBUG_KERNEL
> > @@ -277,6 +280,10 @@ config DEBUG_INFO_DWARF5
> >         bool "Generate DWARF Version 5 debuginfo"
> >         select DEBUG_INFO
> >         depends on !CC_IS_CLANG || (CC_IS_CLANG && (AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502)))
> > +       # 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
> > +       depends on !CC_IS_CLANG || AS_HAS_NON_CONST_LEB128
> 
> Reraising my concern from
> https://github.com/ClangBuiltLinux/linux/issues/1719#issuecomment-1258678969

Sorry, I thought I addressed your concern with my comment right below it
but I probably should have worded it better.

> We've put a fair amount of work into getting CC=clang LLVM_IAS=0 to
> work for DWARF v5 (both on the GNU binutils side, and Kbuild), I'd
> hate to see that effectively knee-capped because of an issue in GNU
> binutils that is only relevant for one architecture.

Sure, that is a completely reasonable concern. However...

> I'd concede support for ARCH=riscv, but not for all other
> architectures, which this effectively does.

No, it does not, CONFIG_AS_HAS_NON_CONST_LEB128 can still be enabled
when GNU as supports this construct for a particular architecture; as
far as I can tell, RISC-V is the only one that doesn't. See the tests
with ARCH=arm64 and ARCH=x86_64 compared with ARCH=riscv below.

$ make -skj"$(nproc)" ARCH=x86_64 LLVM=1 LLVM_IAS=0 defconfig

$ rg "CONFIG_AS_(IS|VERSION|HAS)" .config
9:CONFIG_AS_IS_GNU=y
10:CONFIG_AS_VERSION=23950
4750:CONFIG_AS_HAS_NON_CONST_LEB128=y

$ make -skj"$(nproc)" ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- LLVM=1 LLVM_IAS=0 defconfig

$ rg "CONFIG_AS_(IS|VERSION|HAS)" .config
9:CONFIG_AS_IS_GNU=y
10:CONFIG_AS_VERSION=23950
442:CONFIG_AS_HAS_LDAPR=y
443:CONFIG_AS_HAS_LSE_ATOMICS=y
451:CONFIG_AS_HAS_ARMV8_2=y
452:CONFIG_AS_HAS_SHA3=y
465:CONFIG_AS_HAS_PAC=y
466:CONFIG_AS_HAS_CFI_NEGATE_RA_STATE=y
473:CONFIG_AS_HAS_ARMV8_4=y
480:CONFIG_AS_HAS_ARMV8_5=y
9719:CONFIG_AS_HAS_NON_CONST_LEB128=y

$ make -skj"$(nproc)" ARCH=riscv CROSS_COMPILE=riscv64-linux-gnu- LLVM=1 LLVM_IAS=0 defconfig

$ rg "CONFIG_AS_(IS|VERSION|HAS)" .config
9:CONFIG_AS_IS_GNU=y
10:CONFIG_AS_VERSION=23950

Cheers,
Nathan

  reply	other threads:[~2022-09-28 21:36 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-28 18:25 Nathan Chancellor
2022-09-28 21:13 ` Nick Desaulniers
2022-09-28 21:36   ` Nathan Chancellor [this message]
2022-09-28 21:53     ` Nick Desaulniers
2022-10-02 17:59       ` Masahiro Yamada
2022-10-02 18:47 ` Masahiro Yamada
2022-10-03 16:10   ` Nathan Chancellor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YzS+bQT1zJAUpp/6@dev-arch.thelio-3990X \
    --to=nathan@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=conor.dooley@microchip.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=llvm@lists.linux.dev \
    --cc=masahiroy@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=palmer@dabbelt.com \
    --cc=patches@lists.linux.dev \
    --cc=trix@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®