[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAADnVQLpyNiyghWLMq5AxkBgZX4J9VfX5j4ToNh6UsrQ=4yndg@mail.gmail.com>
Date: Fri, 2 May 2025 19:36:02 -0700
From: Alexei Starovoitov <alexei.starovoitov@...il.com>
To: Holger Hoffstätte <holger@...lied-asynchrony.com>
Cc: Quentin Monnet <qmo@...nel.org>, Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>, Andrii Nakryiko <andrii@...nel.org>,
Martin KaFai Lau <martin.lau@...ux.dev>, Eduard Zingerman <eddyz87@...il.com>, Song Liu <song@...nel.org>,
Yonghong Song <yonghong.song@...ux.dev>, John Fastabend <john.fastabend@...il.com>,
KP Singh <kpsingh@...nel.org>, Stanislav Fomichev <sdf@...ichev.me>, Hao Luo <haoluo@...gle.com>,
Jiri Olsa <jolsa@...nel.org>, bpf <bpf@...r.kernel.org>,
LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] bpftool: build bpf bits with -std=gnu11
On Fri, May 2, 2025 at 2:53 AM Holger Hoffstätte
<holger@...lied-asynchrony.com> wrote:
>
> On 2025-05-02 11:26, Quentin Monnet wrote:
> > On 02/05/2025 09:57, Holger Hoffstätte wrote:
> >> A gcc-15-based bpf toolchain defaults to C23 and fails to compile various
> >> kernel headers due to their use of a custom 'bool' type.
> >> Explicitly using -std=gnu11 works with both clang and bpf-toolchain.
> >>
> >> Signed-off-by: Holger Hoffstätte <holger@...lied-asynchrony.com>
> >
> > Thanks! I tested that it still works with clang.
> >
> > Acked-by: Quentin Monnet <qmo@...nel.org>
>
> Thanks!
>
> > I didn't manage to compile with gcc, though. I tried with gcc 15.1.1 but
> > option '--target=bpf' is apparently unrecognised by the gcc version on
> > my setup.
> >
> > Out of curiosity, how did you build using gcc for the skeleton? Was it
> > enough to run "CLANG=gcc make"? Does it pass the clang-bpf-co-re build
> > probe successfully?
>
> I'm on Gentoo where we have a gcc-14/15 based "bpf-toolchain" package,
> which is just gcc configured & packaged for the bpf target.
> Our bpftool package can be built with clang (default) or without, in
> which case it depend on the bpf-toolchain. The idea is to gradually
> allow bpf/xdp tooling to build/run without requiring clang.
>
> The --target definition is conditional and removed when not using clang:
> https://gitweb.gentoo.org/repo/gentoo.git/tree/dev-util/bpftool/bpftool-7.5.0.ebuild?id=bf70fbf7b0dc97fbc97af579954ea81a8df36113#n94
>
> The bug for building with the new gcc-15 based toolchain where this
> patch originated is here: https://bugs.gentoo.org/955156
So you're fixing this build error:
bpf-unknown-none-gcc \
-I. \
-I/var/tmp/portage/dev-util/bpftool-7.5.0/work/bpftool-libbpf-v7.5.0-sources/include/uapi/
\
-I/var/tmp/portage/dev-util/bpftool-7.5.0/work/bpftool-libbpf-v7.5.0-sources/src/bootstrap/libbpf/include
\
-g -O2 -Wall -fno-stack-protector \
-c skeleton/profiler.bpf.c -o profiler.bpf.o
In file included from skeleton/profiler.bpf.c:3:
./vmlinux.h:5: warning: ignoring '#pragma clang attribute' [-Wunknown-pragmas]
5 | #pragma clang attribute push
(__attribute__((preserve_access_index)), apply_to = record)
./vmlinux.h:9845:9: error: cannot use keyword 'false' as enumeration constant
9845 | false = 0,
| ^~~~~
./vmlinux.h:9845:9: note: 'false' is a keyword with '-std=c23' onwards
./vmlinux.h:31137:15: error: 'bool' cannot be defined via 'typedef'
31137 | typedef _Bool bool;
| ^~~~
with -std=gnu11 flag and
ignoring an important warning ?
It's a good thing that the build broke.
-std=gnu11 will silence the error, but that warning will still be there
and the generated bpf program will be broken.
End result: partially functional bpftool,
and users will have no idea why some features of bpftool are not working.
pw-bot: cr
Powered by blists - more mailing lists