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 AD05818784A for ; Mon, 30 Dec 2024 20:36:55 +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=1735591017; cv=none; b=ORneTbmrCDMsWSyY14QoJuyDmibOO4SEy1J+FJyWRLnbHAkUtnuOrWfFG3QPCcoOXnm3eza6wLF5+Rn4AUqHmYoiW4ow3rUR/OusCf2+Z7Z/KxD2wSkhL6scsZE2K7VyM7dGS96H3jGUXVMtwgwZxuni1mrYrEdjBdnYCDC5b9g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735591017; c=relaxed/simple; bh=RHAdE2uIsjZwjPWgw2pnrNwwJHdw/zeTk2bQBWdv3rE=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=mqaeSbJmaOM30OSR8rtjBfqdNTrwZQ5oedH5MgPtI9DaVHzZFD/vv68OOFUZaAgZdw1KCLmsw4toyzsw+AXGsyFO3DKVc3xsro6KGRtY1epHxmNkgyhOqFyNqO2GSvvAcmA5UcXUGKRhK5yCVVrdTVHQ2HAzPcO0jTH6yYpj/IU= 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: Andrew Pinski via Gcc Cc: Ihor Solodrai , Andrew Pinski , 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: (Andrew Pinski via Gcc's message of "Mon, 30 Dec 2024 12:24:32 -0800") Organization: Gentoo References: User-Agent: mu4e 1.12.7; emacs 31.0.50 Date: Mon, 30 Dec 2024 20:36:49 +0000 Message-ID: <87v7v0oqla.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 Andrew Pinski via Gcc writes: > On Mon, Dec 30, 2024 at 12:11=E2=80=AFPM Ihor Solodrai via Gcc 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:84= 83:9: error: expected identifier before =E2=80=98false=E2=80=99 >> 8483 | false =3D 0, >> | ^~~~~ >> >> A snippet from vmlinux.h: >> >> enum { >> false =3D 0, >> true =3D 1, >> }; >> >> And: >> >> /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; >> | ^~~~ >> >> Full log at [3], and also at [4]. > > > 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. 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. > > Thanks, > Andrew Pinski > >> >> You can easily reproduce the errors with a dummy program: >> >> #include "vmlinux.h" >> >> int main() { >> return 0; >> } >> >> The vmlinux.h is generated from BTF, produced by pahole v1.28 from >> DWARF data contained in the vmlinux binary. The vmlinux binary I used >> in these experiments is v6.12 (adc218676eef) compiled with gcc 13.3.0 >> (default Ubuntu installation). >> >> You can download the specific vmlinux.h I tried using a link below [5]. >> >> I bisected recent GCC snapshots and determined that the errors related >> to the bool declarations started happening on GCC 15-20241117. >> >> Older versions compile the dummy program without errors, however on >> attempt to build the selftests there is a different issue: conflicting >> int64 definitions (full log at [6]). >> >> In file included from /usr/include/x86_64-linux-gnu/sys/types.h:155, >> from /usr/include/x86_64-linux-gnu/bits/socket.h:29, >> from /usr/include/x86_64-linux-gnu/sys/socket.h:33, >> from /usr/include/linux/if.h:28, >> from /usr/include/linux/icmp.h:23, >> from progs/test_cls_redirect_dynptr.c:10: >> /usr/include/x86_64-linux-gnu/bits/stdint-intn.h:27:19: error: confl= icting types for =E2=80=98int64_t=E2=80=99; have =E2=80=98__int64_t=E2=80= =99 {aka =E2=80=98long long int=E2=80=99} >> 27 | typedef __int64_t int64_t; >> | ^~~~~~~ >> In file included from progs/test_cls_redirect_dynptr.c:6: >> /ci/workspace/bpfgcc.20240922/lib/gcc/bpf-unknown-none/15.0.0/includ= e/stdint.h:43:24: note: previous declaration of =E2=80=98int64_t=E2=80=99 w= ith type =E2=80=98int64_t=E2=80=99 {aka =E2=80=98long int=E2=80=99} >> 43 | typedef __INT64_TYPE__ int64_t; >> | ^~~~~~~ >> >> This is on a typical ubuntu:noble system: >> >> $ dpkg -s libc6 | grep Version >> Version: 2.39-0ubuntu8.3 >> >> I got this with snapshots 15-20241110 and 15-20240922 (the oldest I >> tested). This problem may or may not be present in the most recent >> versions, I can't tell for sure. >> >> GCC team, please investigate and let me know if you're aware of >> workarounds or if there is a specific GCC version that you know is >> capable of building BPF programs in selftests/bpf. >> >> If you suspect something might be wrong with the includes for BPF >> programs, or GCC snapshot build etc, please also let me know. I mostly >> relied on Cupertino scripts when setting that up, and assumed the >> selftests/bpf/Makefile is handling BPF_GCC correctly. >> >> Thank you, and happy holidays! >> >> [1] https://github.com/libbpf/ci/pull/164 >> [2] https://github.com/libbpf/ci/pull/144 >> [3] https://gist.github.com/theihor/98883c4266b3489cee69e5d5aa532e79 >> [4] https://github.com/libbpf/ci/actions/runs/12522053128/job/34929897322 >> [5] https://gist.github.com/theihor/785bb250dd1cce3612e70b5f6d258401 >> [6] https://gist.github.com/theihor/a8aa7201b30ac6b48df77bb1ea3ec0b2 >> >>