diff options
author | Holger Hoffstätte <holger@applied-asynchrony.com> | 2024-08-05 20:49:36 +0200 |
---|---|---|
committer | Guilherme Amadio <amadio@gentoo.org> | 2024-08-06 12:15:43 +0200 |
commit | 0f0a37b4e11c414c39c18a7fbc53e7a0e9503ce2 (patch) | |
tree | 3f88e5004eb7d38fedb5a5aaed4e222e6861fd0e | |
parent | dev-util/perf: Use cross CLANG for compiler feature verification (diff) | |
download | gentoo-0f0a37b4e11c414c39c18a7fbc53e7a0e9503ce2.tar.gz gentoo-0f0a37b4e11c414c39c18a7fbc53e7a0e9503ce2.tar.bz2 gentoo-0f0a37b4e11c414c39c18a7fbc53e7a0e9503ce2.zip |
dev-util/bpftool: fix miscompilation with clang & correctly apply patches
Closes: https://bugs.gentoo.org/937402
Closes: https://bugs.gentoo.org/937403
Signed-off-by: Holger Hoffstätte <holger@applied-asynchrony.com>
Signed-off-by: Guilherme Amadio <amadio@gentoo.org>
-rw-r--r-- | dev-util/bpftool/bpftool-7.5.0-r1.ebuild | 127 |
1 files changed, 127 insertions, 0 deletions
diff --git a/dev-util/bpftool/bpftool-7.5.0-r1.ebuild b/dev-util/bpftool/bpftool-7.5.0-r1.ebuild new file mode 100644 index 000000000000..9c1fc75a9352 --- /dev/null +++ b/dev-util/bpftool/bpftool-7.5.0-r1.ebuild @@ -0,0 +1,127 @@ +# Copyright 2021-2024 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +PYTHON_COMPAT=( python3_{10..12} ) + +inherit estack linux-info optfeature python-any-r1 bash-completion-r1 toolchain-funcs + +DESCRIPTION="Tool for inspection and simple manipulation of eBPF programs and maps" +HOMEPAGE="https://kernel.org/" + +# Use LINUX_VERSION to specify the full kernel version triple (x.y.z) +LINUX_VERSION=6.10.3 +LINUX_VER=$(ver_cut 1-2 ${LINUX_VERSION}) +LINUX_V="${LINUX_VERSION:0:1}.x" + +LINUX_SOURCES="linux-${LINUX_VER}.tar.xz" +SRC_URI="https://www.kernel.org/pub/linux/kernel/v${LINUX_V}/${LINUX_SOURCES}" + +LINUX_PATCH="patch-${LINUX_VERSION}.xz" +SRC_URI+=" https://www.kernel.org/pub/linux/kernel/v${LINUX_V}/${LINUX_PATCH}" + +S_K="${WORKDIR}/linux-${LINUX_VER}" +S="${S_K}/tools/bpf/bpftool" + +LICENSE="GPL-2" +SLOT="0" +KEYWORDS="~amd64 ~arm ~arm64 ~loong ~ppc ~ppc64 ~riscv ~x86" +IUSE="caps +llvm" + +RDEPEND=" + sys-libs/binutils-libs:= + sys-libs/zlib:= + virtual/libelf:= + caps? ( sys-libs/libcap:= ) + llvm? ( sys-devel/llvm:= ) +" +DEPEND=" + ${RDEPEND} + >=sys-kernel/linux-headers-5.8 +" +BDEPEND=" + ${LINUX_PATCH+dev-util/patchutils} + ${PYTHON_DEPS} + app-arch/tar + dev-python/docutils +" + +CONFIG_CHECK="~DEBUG_INFO_BTF" + +# src_unpack and src_prepare are copied from dev-util/perf since +# it's building from the same tarball, please keep it in sync with perf +src_unpack() { + local paths=( + 'arch/*/include/*' 'arch/*/lib/*' 'arch/*/tools/*' 'include/*' + 'kernel/bpf/*' 'lib/*' 'scripts/*' 'tools/arch/*' 'tools/bpf/*' + 'tools/build/*' 'tools/include/*' 'tools/lib/*' 'tools/perf/*' + 'tools/scripts/*' + ) + + # We expect the tar implementation to support the -j and --wildcards option + echo ">>> Unpacking ${LINUX_SOURCES} (${paths[*]}) to ${PWD}" + gtar --wildcards -xpf "${DISTDIR}"/${LINUX_SOURCES} \ + "${paths[@]/#/linux-${LINUX_VER}/}" || die + + if [[ -n ${LINUX_PATCH} ]] ; then + eshopts_push -o noglob + ebegin "Filtering partial source patch" + xzcat "${DISTDIR}"/${LINUX_PATCH} | filterdiff -p1 ${paths[@]/#/-i} > ${P}.patch + test -s ${P}.patch + assert -n "Unpacking to ${P} from ${DISTDIR}/${LINUX_PATCH} failed" + eend $? || die "filterdiff failed" + eshopts_pop + fi + + local a + for a in ${A}; do + [[ ${a} == ${LINUX_SOURCES} ]] && continue + [[ ${a} == ${LINUX_PATCH} ]] && continue + unpack ${a} + done +} + +src_prepare() { + default + + if [[ -n ${LINUX_PATCH} ]] ; then + pushd "${S_K}" >/dev/null || die + eapply "${WORKDIR}"/${P}.patch + popd || die + fi + + # Use rst2man or rst2man.py depending on which one exists (#930076) + type -P rst2man >/dev/null || sed -i -e 's/rst2man/rst2man.py/g' Documentation/Makefile || die + + # remove -Werror (bug 887981) + sed -i -e 's/\-Werror//g' ../../lib/bpf/Makefile || die +} + +bpftool_make() { + local arch=$(tc-arch-kernel) + tc-export AR CC LD + + emake V=1 VF=1 \ + HOSTCC="$(tc-getBUILD_CC)" HOSTLD="$(tc-getBUILD_LD)" \ + EXTRA_CFLAGS="${CFLAGS}" ARCH="${arch}" \ + prefix="${EPREFIX}"/usr \ + bash_compdir="$(get_bashcompdir)" \ + feature-libcap="$(usex caps 1 0)" \ + feature-llvm="$(usex llvm 1 0)" \ + "$@" +} + +src_compile() { + bpftool_make + bpftool_make -C Documentation +} + +src_install() { + bpftool_make DESTDIR="${D}" install + bpftool_make mandir="${ED}"/usr/share/man -C Documentation install +} + +pkg_postinst() { + optfeature "clang-bpf-co-re support" sys-devel/clang[llvm_targets_BPF] +} |