bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sedat Dilek <sedat.dilek@gmail.com>
To: "Fāng-ruì Sòng" <maskray@google.com>
Cc: "Yonghong Song" <yhs@fb.com>,
	"Arnaldo Carvalho de Melo" <arnaldo.melo@gmail.com>,
	dwarves@vger.kernel.org,
	"Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>,
	bpf <bpf@vger.kernel.org>, "Jiri Olsa" <jolsa@kernel.org>,
	"Jan Engelhardt" <jengelh@inai.de>,
	"Domenico Andreoli" <cavok@debian.org>,
	"Matthias Schwarzott" <zzam@gentoo.org>,
	"Andrii Nakryiko" <andriin@fb.com>,
	"Mark Wieelard" <mjw@redhat.com>,
	"Paul Moore" <paul@paul-moore.com>,
	"Ondrej Mosnacek" <omosnace@redhat.com>,
	"Daniel P. Berrangé" <berrange@redhat.com>,
	"Tom Stellard" <tstellar@redhat.com>
Subject: Re: ERROR: INT DW_ATE_unsigned_1 Error emitting BTF type
Date: Fri, 5 Feb 2021 20:38:04 +0100	[thread overview]
Message-ID: <CA+icZUVBHJ2eTxtt_3uCd=b4_i7WgJm5p2KpPvo=3AMd606w2g@mail.gmail.com> (raw)
In-Reply-To: <CAFP8O3KA6uR5Q29UGXqxahHmfn6V6GSeKzCsBiD3838WEAGO3Q@mail.gmail.com>

On Fri, Feb 5, 2021 at 8:30 PM Fāng-ruì Sòng <maskray@google.com> wrote:
>
> On Fri, Feb 5, 2021 at 11:21 AM Sedat Dilek <sedat.dilek@gmail.com> wrote:
> >
> > On Fri, Feb 5, 2021 at 8:15 PM Sedat Dilek <sedat.dilek@gmail.com> wrote:
> > >
> > > On Fri, Feb 5, 2021 at 8:10 PM Yonghong Song <yhs@fb.com> wrote:
> > > >
> > > >
> > > >
> > > > On 2/5/21 11:06 AM, Sedat Dilek wrote:
> > > > > On Fri, Feb 5, 2021 at 7:53 PM Sedat Dilek <sedat.dilek@gmail.com> wrote:
> > > > >>
> > > > >> On Fri, Feb 5, 2021 at 6:48 PM Sedat Dilek <sedat.dilek@gmail.com> wrote:
> > > > >>>
> > > > >>> On Fri, Feb 5, 2021 at 4:28 PM Arnaldo Carvalho de Melo
> > > > >>> <arnaldo.melo@gmail.com> wrote:
> > > > >>>>
> > > > >>>> Em Fri, Feb 05, 2021 at 04:23:59PM +0100, Sedat Dilek escreveu:
> > > > >>>>> On Fri, Feb 5, 2021 at 3:41 PM Sedat Dilek <sedat.dilek@gmail.com> wrote:
> > > > >>>>>>
> > > > >>>>>> On Fri, Feb 5, 2021 at 3:37 PM Sedat Dilek <sedat.dilek@gmail.com> wrote:
> > > > >>>>>>>
> > > > >>>>>>> Hi,
> > > > >>>>>>>
> > > > >>>>>>> when building with pahole v1.20 and binutils v2.35.2 plus Clang
> > > > >>>>>>> v12.0.0-rc1 and DWARF-v5 I see:
> > > > >>>>>>> ...
> > > > >>>>>>> + info BTF .btf.vmlinux.bin.o
> > > > >>>>>>> + [  != silent_ ]
> > > > >>>>>>> + printf   %-7s %s\n BTF .btf.vmlinux.bin.o
> > > > >>>>>>>   BTF     .btf.vmlinux.bin.o
> > > > >>>>>>> + LLVM_OBJCOPY=/opt/binutils/bin/objcopy /opt/pahole/bin/pahole -J
> > > > >>>>>>> .tmp_vmlinux.btf
> > > > >>>>>>> [115] INT DW_ATE_unsigned_1 Error emitting BTF type
> > > > >>>>>>> Encountered error while encoding BTF.
> > > > >>>>>>
> > > > >>>>>> Grepping the pahole sources:
> > > > >>>>>>
> > > > >>>>>> $ git grep DW_ATE
> > > > >>>>>> dwarf_loader.c:         bt->is_bool = encoding == DW_ATE_boolean;
> > > > >>>>>> dwarf_loader.c:         bt->is_signed = encoding == DW_ATE_signed;
> > > > >>>>>>
> > > > >>>>>> Missing DW_ATE_unsigned encoding?
> > > > >>>>>>
> > > > >>>>>
> > > > >>>>> Checked the LLVM sources:
> > > > >>>>>
> > > > >>>>> clang/lib/CodeGen/CGDebugInfo.cpp:    Encoding =
> > > > >>>>> llvm::dwarf::DW_ATE_unsigned_char;
> > > > >>>>> clang/lib/CodeGen/CGDebugInfo.cpp:    Encoding = llvm::dwarf::DW_ATE_unsigned;
> > > > >>>>> clang/lib/CodeGen/CGDebugInfo.cpp:    Encoding =
> > > > >>>>> llvm::dwarf::DW_ATE_unsigned_fixed;
> > > > >>>>> clang/lib/CodeGen/CGDebugInfo.cpp:
> > > > >>>>>    ? llvm::dwarf::DW_ATE_unsigned
> > > > >>>>> ...
> > > > >>>>> lld/test/wasm/debuginfo.test:CHECK-NEXT:                DW_AT_encoding
> > > > >>>>>   (DW_ATE_unsigned)
> > > > >>>>>
> > > > >>>>> So, I will switch from GNU ld.bfd v2.35.2 to LLD-12.
> > > > >>>>
> > > > >>>> Thanks for the research, probably your conclusion is correct, can you go
> > > > >>>> the next step and add that part and check if the end result is the
> > > > >>>> expected one?
> > > > >>>>
> > > > >>>
> > > > >>> Still building...
> > > > >>>
> > > > >>> Can you give me a hand on what has to be changed in dwarves/pahole?
> > > > >>>
> > > > >>> I guess switching from ld.bfd to ld.lld will show the same ERROR.
> > > > >>>
> > > > >>
> > > > >> This builds successfully - untested:
> > > > >>
> > > > >> $ git diff
> > > > >> diff --git a/btf_loader.c b/btf_loader.c
> > > > >> index ec286f413f36..a39edd3362db 100644
> > > > >> --- a/btf_loader.c
> > > > >> +++ b/btf_loader.c
> > > > >> @@ -107,6 +107,7 @@ static struct base_type *base_type__new(strings_t
> > > > >> name, uint32_t attrs,
> > > > >>                 bt->bit_size = size;
> > > > >>                 bt->is_signed = attrs & BTF_INT_SIGNED;
> > > > >>                 bt->is_bool = attrs & BTF_INT_BOOL;
> > > > >> +               bt->is_unsigned = attrs & BTF_INT_UNSIGNED;
> > > > >>                 bt->name_has_encoding = false;
> > > > >>                 bt->float_type = float_type;
> > > > >>         }
> > > > >> diff --git a/ctf.h b/ctf.h
> > > > >> index 25b79892bde3..9e47c3c74677 100644
> > > > >> --- a/ctf.h
> > > > >> +++ b/ctf.h
> > > > >> @@ -100,6 +100,7 @@ struct ctf_full_type {
> > > > >> #define CTF_TYPE_INT_CHAR      0x2
> > > > >> #define CTF_TYPE_INT_BOOL      0x4
> > > > >> #define CTF_TYPE_INT_VARARGS   0x8
> > > > >> +#define CTF_TYPE_INT_UNSIGNED  0x16
> > > > >>
> > > > >> #define CTF_TYPE_FP_ATTRS(VAL)         ((VAL) >> 24)
> > > > >> #define CTF_TYPE_FP_OFFSET(VAL)                (((VAL) >> 16) & 0xff)
> > > > >> diff --git a/dwarf_loader.c b/dwarf_loader.c
> > > > >> index b73d7867e1e6..79d40f183c24 100644
> > > > >> --- a/dwarf_loader.c
> > > > >> +++ b/dwarf_loader.c
> > > > >> @@ -473,6 +473,7 @@ static struct base_type *base_type__new(Dwarf_Die
> > > > >> *die, struct cu *cu)
> > > > >>                 bt->is_bool = encoding == DW_ATE_boolean;
> > > > >>                 bt->is_signed = encoding == DW_ATE_signed;
> > > > >>                 bt->is_varargs = false;
> > > > >> +               bt->is_unsigned = encoding == DW_ATE_unsigned;
> > > > >>                 bt->name_has_encoding = true;
> > > > >>         }
> > > > >>
> > > > >> diff --git a/dwarves.h b/dwarves.h
> > > > >> index 98caf1abc54d..edf32d2e6f80 100644
> > > > >> --- a/dwarves.h
> > > > >> +++ b/dwarves.h
> > > > >> @@ -1261,6 +1261,7 @@ struct base_type {
> > > > >>         uint8_t         is_signed:1;
> > > > >>         uint8_t         is_bool:1;
> > > > >>         uint8_t         is_varargs:1;
> > > > >> +       uint8_t         is_unsigned:1;
> > > > >>         uint8_t         float_type:4;
> > > > >> };
> > > > >>
> > > > >> diff --git a/lib/bpf b/lib/bpf
> > > > >> --- a/lib/bpf
> > > > >> +++ b/lib/bpf
> > > > >> @@ -1 +1 @@
> > > > >> -Subproject commit 5af3d86b5a2c5fecdc3ab83822d083edd32b4396
> > > > >> +Subproject commit 5af3d86b5a2c5fecdc3ab83822d083edd32b4396-dirty
> > > > >> diff --git a/libbtf.c b/libbtf.c
> > > > >> index 9f7628304495..a0661a7bbed9 100644
> > > > >> --- a/libbtf.c
> > > > >> +++ b/libbtf.c
> > > > >> @@ -247,6 +247,8 @@ static const char *
> > > > >> btf_elf__int_encoding_str(uint8_t encoding)
> > > > >>                 return "CHAR";
> > > > >>         else if (encoding == BTF_INT_BOOL)
> > > > >>                 return "BOOL";
> > > > >> +       else if (encoding == BTF_INT_UNSIGNED)
> > > > >> +               return "UNSIGNED";
> > > > >>         else
> > > > >>                 return "UNKN";
> > > > >> }
> > > > >> @@ -379,6 +381,8 @@ int32_t btf_elf__add_base_type(struct btf_elf
> > > > >> *btfe, const struct base_type *bt,
> > > > >>                 encoding = BTF_INT_SIGNED;
> > > > >>         } else if (bt->is_bool) {
> > > > >>                 encoding = BTF_INT_BOOL;
> > > > >> +       } else if (bt->is_unsigned) {
> > > > >> +               encoding = BTF_INT_UNSIGNED;
> > > > >>         } else if (bt->float_type) {
> > > > >>                 fprintf(stderr, "float_type is not supported\n");
> > > > >>                 return -1;
> > > > >>
> > > > >> Additionally - I cannot see it with `git diff`:
> > > > >>
> > > > >> [ lib/bpf/include/uapi/linux/btf.h ]
> > > > >>
> > > > >> /* Attributes stored in the BTF_INT_ENCODING */
> > > > >> #define BTF_INT_SIGNED (1 << 0)
> > > > >> #define BTF_INT_CHAR (1 << 1)
> > > > >> #define BTF_INT_BOOL (1 << 2)
> > > > >> #define BTF_INT_UNSIGNED (1 << 3)
> > > > >>
> > > > >> Comments?
> > > > >>
> > > > >
> > > > > Hmmm...
> > > > >
> > > > > + info BTF .btf.vmlinux.bin.o
> > > > > + [  != silent_ ]
> > > > > + printf   %-7s %s\n BTF .btf.vmlinux.bin.o
> > > > >   BTF     .btf.vmlinux.bin.o
> > > > > + LLVM_OBJCOPY=llvm-objcopy /opt/pahole/bin/pahole -J .tmp_vmlinux.btf
> > > > > [2] INT long unsigned int Error emitting BTF type
> > > > > Encountered error while encoding BTF.
> > > > > + llvm-objcopy --only-section=.BTF --set-section-flags
> > > > > .BTF=alloc,readonly --strip-all .tmp_vmlinux.btf .btf.vmlinux.bin.o
> > > > > ...
> > > > > + info BTFIDS vmlinux
> > > > > + [  != silent_ ]
> > > > > + printf   %-7s %s\n BTFIDS vmlinux
> > > > >   BTFIDS  vmlinux
> > > > > + ./tools/bpf/resolve_btfids/resolve_btfids vmlinux
> > > > > FAILED: load BTF from vmlinux: Invalid argument
> > > > > + on_exit
> > > > > + [ 255 -ne 0 ]
> > > > > + cleanup
> > > > > + rm -f .btf.vmlinux.bin.o
> > > > > + rm -f .tmp_System.map
> > > > > + rm -f .tmp_vmlinux.btf .tmp_vmlinux.kallsyms1
> > > > > .tmp_vmlinux.kallsyms1.S .tmp_vmlinux.kallsyms1.o
> > > > > .tmp_vmlinux.kallsyms2 .tmp_vmlinux.kallsyms2.S .tmp_vmlinux.kallsyms
> > > > > 2.o
> > > > > + rm -f System.map
> > > > > + rm -f vmlinux
> > > > > + rm -f vmlinux.o
> > > > > make[3]: *** [Makefile:1166: vmlinux] Error 255
> > > > >
> > > > > Grepping through linux.git/tools I guess some BTF tools/libs need to
> > > > > know what BTF_INT_UNSIGNED is?
> > > >
> > > > BTF_INT_UNSIGNED needs kernel support. Maybe to teach pahole to
> > > > ignore this for now until kernel infrastructure is ready.
> > > > Not sure whether this information will be useful or not
> > > > for BTF. This needs to be discussed separately.
> > > >
> > >
> > > [ CC Fangrui ]
> > >
> > > How can I teach pahole to ignore BTF_INT_UNSIGNED?
> > >
> > > Another tryout might be to use "-fbinutils-version=..." which is
> > > available for LLVM-12 according to Fangrui?
> > > Fangrui, which binutils versions can I pass and how?
> > >
> >
> > OK, I checked LLVM-12 sources:
> >
> > clang/docs/ReleaseNotes.rst:101:- New option ``-fbinutils-version=``
> > specifies the targeted binutils version.
> > clang/docs/ReleaseNotes.rst:102:  For example,
> > ``-fbinutils-version=2.35`` means compatibility with GNU as/ld
> > clang/docs/ReleaseNotes.rst-103-  before 2.35 is not needed: new
> > features can be used and there is no need to
> > clang/docs/ReleaseNotes.rst-104-  work around old GNU as/ld bugs.
> >
> > Can I pass (also patchlevel) like 2.35.2?
> > Here I have Debian's v2.35.1 and a selfmade v2.35.2?
> >
> > - Sedat -
> >
> > - Sedat -
>
> Answering specifically this question:
>
> clang -help displays:
> ...
>   -fbinutils-version=<major.minor>
>                           Produced object files can use all ELF
> features supported by this binutils version and newer. If
> -fno-integrated-as is specified, the generated assembly will consider
> GNU as support. 'none' means that all ELF features can be used,
> regardless of binutils support. Defaults to 2.26.
>
> The option was introduced in  https://reviews.llvm.org/D85474
> major.minor.patch is not supported. In reality, very few features are
> gated by this option, currently just SHF_MERGE and a pending
> SHF_LINK_ORDER PGO patch.
> I think we will be conservative. If a 2.37 fix is back ported to
> 2.35.2 and 2.36.1, we will ignore that and will use the feature only
> if -fbinutils-version=2.37 or above is specified.
>

Binutils v2.35.2 has DWARF-5 fixes which are not in vanilla v2.36 - I
might be wrong, please correct me.

So what shall I pass now to -fbinutils-version= ?

- Sedat -

  reply	other threads:[~2021-02-05 19:43 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-04 22:07 ANNOUNCE: pahole v1.20 (gcc11 DWARF5's default, lots of ELF sections, BTF) Arnaldo Carvalho de Melo
2021-02-04 22:10 ` Sedat Dilek
2021-02-05  0:01 ` Andrii Nakryiko
2021-02-05  4:33   ` Arnaldo Carvalho de Melo
2021-02-05  7:39     ` Andrii Nakryiko
2021-02-05  9:33       ` Arnaldo Carvalho de Melo
2021-02-05 16:25         ` Arnaldo Carvalho de Melo
2021-02-05 22:11           ` Andrii Nakryiko
2021-02-05 23:55             ` Arnaldo Carvalho de Melo
2021-02-07  6:40               ` Andrii Nakryiko
     [not found] ` <CA+icZUVQSojGgnis8Ds5GW-7-PVMZ2w4X5nQKSSkBPf-29NS6Q@mail.gmail.com>
2021-02-05 14:41   ` ERROR: INT DW_ATE_unsigned_1 Error emitting BTF type Sedat Dilek
2021-02-05 15:23     ` Sedat Dilek
2021-02-05 15:28       ` Arnaldo Carvalho de Melo
2021-02-05 15:40         ` Sedat Dilek
2021-02-05 17:48         ` Sedat Dilek
2021-02-05 18:53           ` Sedat Dilek
2021-02-05 19:06             ` Sedat Dilek
2021-02-05 19:10               ` Yonghong Song
2021-02-05 19:15                 ` Sedat Dilek
2021-02-05 19:20                   ` Yonghong Song
2021-02-05 19:24                     ` Sedat Dilek
2021-02-05 19:44                     ` Sedat Dilek
2021-02-05 19:21                   ` Sedat Dilek
2021-02-05 19:30                     ` Fāng-ruì Sòng
2021-02-05 19:38                       ` Sedat Dilek [this message]
2021-02-05 19:24                 ` Arnaldo Carvalho de Melo
2021-02-05 20:03                   ` Yonghong Song
2021-02-05 20:31                     ` Sedat Dilek
2021-02-05 21:54                       ` Yonghong Song
2021-02-06  3:34                         ` Sedat Dilek
2021-02-06  5:44                           ` Sedat Dilek
2021-02-06  5:53                             ` Sedat Dilek
2021-02-06  6:26                               ` Sedat Dilek
2021-02-06  6:52                                 ` Sedat Dilek
2021-02-06  8:26                                   ` Yonghong Song
2021-02-06  8:32                                     ` Sedat Dilek
2021-02-06  9:32                                       ` Sedat Dilek
2021-02-06  9:37                                         ` Sedat Dilek
2021-02-06  9:48                                         ` Sedat Dilek
2021-02-06 10:16                                           ` Sedat Dilek
2021-02-06 10:23                                             ` Sedat Dilek
     [not found]                                               ` <CA+icZUW2HVWSZiOHvrjXGP-ubL_iWEHy1u6B3zQn=pN-J1FnSQ@mail.gmail.com>
2021-02-06 12:54                                                 ` Sedat Dilek
2021-02-06 16:24                                     ` Mark Wieelard
2021-02-06 17:53                                       ` Yonghong Song
2021-02-06 18:10                                         ` Sedat Dilek
2021-02-06 19:17                                           ` Yonghong Song
2021-02-06 19:22                                             ` Sedat Dilek
2021-02-06 19:28                                               ` Sedat Dilek
2021-02-06 19:32                                                 ` Yonghong Song
2021-02-06 19:44                                                   ` Sedat Dilek
2021-02-06 20:12                                                     ` Yonghong Song
2021-02-06 20:46                                                       ` Sedat Dilek
2021-02-06  7:26                     ` Sedat Dilek
2021-02-05 21:10   ` Nick Desaulniers
2021-02-05 21:16     ` Sedat Dilek
2021-02-05 21:40       ` Nick Desaulniers
2021-02-05 21:42         ` Sedat Dilek
2021-02-08  2:44 ` ANNOUNCE: pahole v1.20 (gcc11 DWARF5's default, lots of ELF sections, BTF) Sedat Dilek
2021-02-08 12:32   ` Arnaldo Carvalho de Melo
2021-02-08 12:36     ` Sedat Dilek
2021-02-17 12:08     ` Domenico Andreoli
2021-02-17 12:48       ` Arnaldo Carvalho de Melo

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='CA+icZUVBHJ2eTxtt_3uCd=b4_i7WgJm5p2KpPvo=3AMd606w2g@mail.gmail.com' \
    --to=sedat.dilek@gmail.com \
    --cc=andriin@fb.com \
    --cc=arnaldo.melo@gmail.com \
    --cc=berrange@redhat.com \
    --cc=bpf@vger.kernel.org \
    --cc=cavok@debian.org \
    --cc=dwarves@vger.kernel.org \
    --cc=jengelh@inai.de \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maskray@google.com \
    --cc=mjw@redhat.com \
    --cc=omosnace@redhat.com \
    --cc=paul@paul-moore.com \
    --cc=tstellar@redhat.com \
    --cc=yhs@fb.com \
    --cc=zzam@gentoo.org \
    /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;
as well as URLs for NNTP newsgroup(s).