From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A618A15E8B for ; Mon, 30 Dec 2024 21:08:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=140.211.166.183 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735592902; cv=none; b=Xz+YTPH00FJq83TTocKQBwzXLMHvYRdsBusbrTKv1vC+/jtg1egaPF18ljd6iDTZBY5In1MhLbgk9h5opZKy0WX8+U3h6NlG0L2/gYSIHdhOAw8WvEkRmvIQzcUvi+Kdfp7OBo0Kv2oQ43IWjxzLvjTkiTB614xMqbvVHiPEBP8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735592902; c=relaxed/simple; bh=OQ/qsKvOeMeLyyG5pBSSmfH/HMElLdYPygffMzk2h9s=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=ocLXVEW4bp3eM4e7DK32OtbnMyUSc8EJiPfFcSTfPcCnHPfB+PTJQHngwtS/PH19tlDfwYHkSEsDxmdq9XAPs0V8L3Fph5fgqxtopjj9yFPQ2IFxCqO/Fw+Lr/houu2Z6JaNssJ3Tj+ct3nCIExOI8bQWexnMsShzMI8qztyKCU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gentoo.org; spf=pass smtp.mailfrom=gentoo.org; arc=none smtp.client-ip=140.211.166.183 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gentoo.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gentoo.org From: Sam James To: Ihor Solodrai Cc: Andrew Pinski , Andrew Pinski via Gcc , Cupertino Miranda , David Faust , Elena Zannoni , "Jose E. Marchesi" , Alexei Starovoitov , Manu Bretelle , Eduard Zingerman , Mykola Lysenko , Yonghong Song , bpf Subject: Re: Errors compiling BPF programs from Linux selftests/bpf with GCC In-Reply-To: <7ZXLMz0XIsj0YzKNHVoLZ1JrCshOqeGCldUFbX3f8F14s0opaXTpmjfzZH2E10v0b2SFXk2x-DVTN5wGuUqPJQDhA3sOcVm7GeiGzKLRhRI=@pm.me> (Ihor Solodrai's message of "Mon, 30 Dec 2024 20:59:15 +0000") Organization: Gentoo References: <87v7v0oqla.fsf@gentoo.org> <7ZXLMz0XIsj0YzKNHVoLZ1JrCshOqeGCldUFbX3f8F14s0opaXTpmjfzZH2E10v0b2SFXk2x-DVTN5wGuUqPJQDhA3sOcVm7GeiGzKLRhRI=@pm.me> User-Agent: mu4e 1.12.7; emacs 31.0.50 Date: Mon, 30 Dec 2024 21:08:14 +0000 Message-ID: <87wmfgnakh.fsf@gentoo.org> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Ihor Solodrai writes: > On Monday, December 30th, 2024 at 12:36 PM, Sam James wr= ote: > >>=20 > >>=20 > >> Andrew Pinski via Gcc gcc@gcc.gnu.org writes: >>=20 > >> > On Mon, Dec 30, 2024 at 12:11=E2=80=AFPM Ihor Solodrai via Gcc gcc@gcc= .gnu.org wrote: >> >=20 > >> > > Hello everyone. >> > >=20 > >> > > I picked up the work adding GCC BPF backend to BPF CI pipeline [1], >> > > originally done by Cupertino Miranda [2]. >> > >=20 > >> > > 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. >> > >=20 > >> > > The first issue is compilation errors on vmlinux.h: >> > >=20 > >> > > In file included from progs/linked_maps1.c:4: >> > > /ci/workspace/tools/testing/selftests/bpf/tools/include/vmlinux.h:84= 83:9: error: expected identifier before =E2=80=98false=E2=80=99 >> > > 8483 | false =3D 0, >> > > | ^~~~~ >> > >=20 > >> > > A snippet from vmlinux.h: >> > >=20 > >> > > enum { >> > > false =3D 0, >> > > true =3D 1, >> > > }; >> > >=20 > >> > > And: >> > >=20 > >> > > /ci/workspace/tools/testing/selftests/bpf/tools/include/vmlinux.h:23= 539:15: error: two or more data types in declaration specifiers >> > > 23539 | typedef _Bool bool; >> > > | ^~~~ >> > >=20 > >> > > Full log at [3], and also at [4]. >> >=20 > >> > These are simple, the selftests/bpf programs need to compile with >> > -std=3Dgnu17 or -std=3Dgnu11 since GCC has changed the default to C23 >> > which defines false and bool as keywords now and can't be redeclared >> > like before. >>=20 > >>=20 > >> Yes, the kernel has various issues like this: >> https://lore.kernel.org/linux-kbuild/20241119044724.GA2246422@thelio-399= 0X/. >>=20 > >> Unfortunately, not all the Makefiles correctly declare that they need >> gnu11. >>=20 > >> 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 =3D 0, > true =3D 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. > >>=20 > >> > [...]