From: Sam James <sam@gentoo.org>
To: Ihor Solodrai <ihor.solodrai@pm.me>
Cc: Andrew Pinski <pinskia@gmail.com>,
Andrew Pinski via Gcc <gcc@gcc.gnu.org>,
Cupertino Miranda <cupertino.miranda@oracle.com>,
David Faust <david.faust@oracle.com>,
Elena Zannoni <elena.zannoni@oracle.com>,
"Jose E. Marchesi" <jose.marchesi@oracle.com>,
Alexei Starovoitov <alexei.starovoitov@gmail.com>,
Manu Bretelle <chantra@meta.com>,
Eduard Zingerman <eddyz87@gmail.com>,
Mykola Lysenko <mykolal@meta.com>,
Yonghong Song <yonghong.song@linux.dev>,
bpf <bpf@vger.kernel.org>
Subject: Re: Errors compiling BPF programs from Linux selftests/bpf with GCC
Date: Mon, 30 Dec 2024 21:08:14 +0000 [thread overview]
Message-ID: <87wmfgnakh.fsf@gentoo.org> (raw)
In-Reply-To: <7ZXLMz0XIsj0YzKNHVoLZ1JrCshOqeGCldUFbX3f8F14s0opaXTpmjfzZH2E10v0b2SFXk2x-DVTN5wGuUqPJQDhA3sOcVm7GeiGzKLRhRI=@pm.me> (Ihor Solodrai's message of "Mon, 30 Dec 2024 20:59:15 +0000")
Ihor Solodrai <ihor.solodrai@pm.me> writes:
> On Monday, December 30th, 2024 at 12:36 PM, Sam James <sam@gentoo.org> wrote:
>
>>
>
>>
>
>> Andrew Pinski via Gcc gcc@gcc.gnu.org writes:
>>
>
>> > On Mon, Dec 30, 2024 at 12:11 PM Ihor Solodrai via Gcc gcc@gcc.gnu.org wrote:
>> >
>
>> > > Hello everyone.
>> > >
>
>> > > I picked up the work adding GCC BPF backend to BPF CI pipeline [1],
>> > > originally done by Cupertino Miranda [2].
>> > >
>
>> > > I encountered issues compiling BPF objects for selftests/bpf with
>> > > recent GCC 15 snapshots. An additional test runner binary is supposed
>> > > to be generated by tools/testing/selftests/bpf/Makefile if BPF_GCC is
>> > > set to a directory with GCC binaries for BPF backend. The runner
>> > > binary depends on BPF binaries, which are produced by GCC.
>> > >
>
>> > > The first issue is compilation errors on vmlinux.h:
>> > >
>
>> > > In file included from progs/linked_maps1.c:4:
>> > > /ci/workspace/tools/testing/selftests/bpf/tools/include/vmlinux.h:8483:9: error: expected identifier before ‘false’
>> > > 8483 | false = 0,
>> > > | ^~~~~
>> > >
>
>> > > A snippet from vmlinux.h:
>> > >
>
>> > > enum {
>> > > false = 0,
>> > > true = 1,
>> > > };
>> > >
>
>> > > And:
>> > >
>
>> > > /ci/workspace/tools/testing/selftests/bpf/tools/include/vmlinux.h:23539:15: error: two or more data types in declaration specifiers
>> > > 23539 | typedef _Bool bool;
>> > > | ^~~~
>> > >
>
>> > > Full log at [3], and also at [4].
>> >
>
>> > These are simple, the selftests/bpf programs need to compile with
>> > -std=gnu17 or -std=gnu11 since GCC has changed the default to C23
>> > which defines false and bool as keywords now and can't be redeclared
>> > like before.
>>
>
>>
>
>> Yes, the kernel has various issues like this:
>> https://lore.kernel.org/linux-kbuild/20241119044724.GA2246422@thelio-3990X/.
>>
>
>> Unfortunately, not all the Makefiles correctly declare that they need
>> gnu11.
>>
>
>> Clang will hit issues like this too when they change default to gnu23.
>
> Andrew, Sam, thank you for a swift response.
Thank you for working on CI for this!
>
> vmlinux.h is generated code, so for the booleans perhaps it's more
> appropriate to generate a condition, for example:
>
> #if __STDC_VERSION__ < 202311L
> enum {
> false = 0,
> true = 1,
> };
> #endif
>
> Any drawbacks to this?
>
I think this is fine (enough), given the kernel isn't interested in using _Bool
as far as I know.
> Also if vmlinux was built with GCC C23 then I assume DWARF wouldn't
> contain the debug info for the enum, hence it wouldn't be present in
> vmlinux.h.
>
> I don't think downgrading the standard for a relatively new backend
> makes sense, especially in the context of CI testing.
The issue is that the kernel overall isn't yet worried about being built
as C23.
>
>>
>
>> > [...]
next prev parent reply other threads:[~2024-12-30 21:08 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-30 20:08 Errors compiling BPF programs from Linux selftests/bpf with GCC Ihor Solodrai
2024-12-30 20:24 ` Andrew Pinski
2024-12-30 20:36 ` Sam James
2024-12-30 20:59 ` Ihor Solodrai
2024-12-30 21:08 ` Sam James [this message]
2024-12-31 0:42 ` Alexei Starovoitov
2024-12-31 1:26 ` Ihor Solodrai
2024-12-31 4:09 ` Alexei Starovoitov
2025-01-02 9:47 ` Jose E. Marchesi
2025-01-02 17:35 ` Ihor Solodrai
2025-01-02 18:24 ` Jose E. Marchesi
2025-01-03 0:42 ` Eduard Zingerman
2025-01-03 13:23 ` Jose E. Marchesi
2025-01-02 23:04 ` Eduard Zingerman
2025-01-03 0:16 ` Jose E. Marchesi
2025-01-03 0:46 ` Eduard Zingerman
2025-01-03 10:17 ` Jose E. Marchesi
2025-01-03 12:52 ` Jose E. Marchesi
2025-01-03 23:48 ` Ihor Solodrai
2025-01-03 23:56 ` Andrew Pinski
2025-01-04 8:05 ` Jose E. Marchesi
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=87wmfgnakh.fsf@gentoo.org \
--to=sam@gentoo.org \
--cc=alexei.starovoitov@gmail.com \
--cc=bpf@vger.kernel.org \
--cc=chantra@meta.com \
--cc=cupertino.miranda@oracle.com \
--cc=david.faust@oracle.com \
--cc=eddyz87@gmail.com \
--cc=elena.zannoni@oracle.com \
--cc=gcc@gcc.gnu.org \
--cc=ihor.solodrai@pm.me \
--cc=jose.marchesi@oracle.com \
--cc=mykolal@meta.com \
--cc=pinskia@gmail.com \
--cc=yonghong.song@linux.dev \
/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