commit:     caf1b774b9b723e622a2b64f68f4cc4769fb1d78
Author:     Holger Hoffstätte <holger <AT> applied-asynchrony <DOT> com>
AuthorDate: Sat May  3 08:12:19 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sat May  3 19:38:51 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=caf1b774

dev-util/bpftool: prevent attribute warning with bpf-toolchain

The bpf-generated kernel headers currently use a clang-specific
pragma to annotate data structures with the preserve_access_index
attribute; since this does not work with gcc, the attribute will
be ignored. Luckily the BPF test suite already has a macro guard
called BPF_NO_PRESERVE_ACCESS_INDEX for this case, so just define
that for the bpftool build as well.

Signed-off-by: Holger Hoffstätte <holger <AT> applied-asynchrony.com>
Part-of: https://github.com/gentoo/gentoo/pull/41913
Signed-off-by: Sam James <sam <AT> gentoo.org>

 dev-util/bpftool/bpftool-7.5.0-r1.ebuild | 5 +++++
 dev-util/bpftool/bpftool-9999.ebuild     | 5 +++++
 2 files changed, 10 insertions(+)

diff --git a/dev-util/bpftool/bpftool-7.5.0-r1.ebuild 
b/dev-util/bpftool/bpftool-7.5.0-r1.ebuild
index 45d7eba2f7a7..e35ec289b5ca 100644
--- a/dev-util/bpftool/bpftool-7.5.0-r1.ebuild
+++ b/dev-util/bpftool/bpftool-7.5.0-r1.ebuild
@@ -94,6 +94,11 @@ src_prepare() {
        sed -i 's/-fno-stack-protector/& -std=gnu11/g' src/Makefile || die
 
        if ! use clang; then
+               # prevent attribute warning about preserve_access_index
+               # since gcc does not support '#pragma clang attribute push':
+               # 
https://web.git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=675b4e2
+               sed -i 's/std=gnu11/& -DBPF_NO_PRESERVE_ACCESS_INDEX/g' 
src/Makefile || die
+
                # remove bpf target & add assembly annotations to fix CO-RE 
feature detection
                sed -i -e 's/-target bpf/-dA/' src/Makefile.feature || die
 

diff --git a/dev-util/bpftool/bpftool-9999.ebuild 
b/dev-util/bpftool/bpftool-9999.ebuild
index 9f08e4d48071..3658c8d318bd 100644
--- a/dev-util/bpftool/bpftool-9999.ebuild
+++ b/dev-util/bpftool/bpftool-9999.ebuild
@@ -92,6 +92,11 @@ src_prepare() {
        sed -i 's/-fno-stack-protector/& -std=gnu11/g' src/Makefile || die
 
        if ! use clang; then
+               # prevent attribute warning about preserve_access_index
+               # since gcc does not support '#pragma clang attribute push':
+               # 
https://web.git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=675b4e2
+               sed -i 's/std=gnu11/& -DBPF_NO_PRESERVE_ACCESS_INDEX/g' 
src/Makefile || die
+
                # remove bpf target & add assembly annotations to fix CO-RE 
feature detection
                sed -i -e 's/-target bpf/-dA/' src/Makefile.feature || die
 

Reply via email to