diff --git a/bcc-0.24.0.tar.gz b/bcc-0.24.0.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..dba2f8b4bf64138c6de94863082087fc9a859af4 Binary files /dev/null and b/bcc-0.24.0.tar.gz differ diff --git a/bcc.spec b/bcc.spec new file mode 100644 index 0000000000000000000000000000000000000000..81eca49c7ce495d57cf3936587051deab3ef455c --- /dev/null +++ b/bcc.spec @@ -0,0 +1,192 @@ +%define anolis_release 1 + +%global with_llvm_shared 1 + +Name: bcc +Version: 0.24.0 +Release: %{anolis_release}%{?dist} +Summary: BPF Compiler Collection (BCC) +License: ASL 2.0 +URL: https://github.com/iovisor/bcc +Source0: %{url}/archive/v%{version}/%{name}-%{version}.tar.gz +# fix flag err +Patch0: libbpf-tools-Allow-to-use-different-cflags-for-bpf-t.patch + +ExclusiveArch: x86_64 aarch64 + +BuildRequires: bison +BuildRequires: cmake >= 2.8.7 +BuildRequires: flex +BuildRequires: libxml2-devel +BuildRequires: python3-devel +BuildRequires: elfutils-libelf-devel +BuildRequires: elfutils-debuginfod-client-devel +BuildRequires: llvm-devel +BuildRequires: clang-devel +BuildRequires: ncurses-devel +BuildRequires: pkgconfig(luajit) +BuildRequires: libbpf-devel >= 0.0.5, libbpf-static >= 0.0.5 + +Requires: libbpf >= 0.0.5 +Requires: tar +Recommends: kernel-devel + +Recommends: %{name}-tools = %{version}-%{release} + +%description +BCC is a toolkit for creating efficient kernel tracing and manipulation +programs, and includes several useful tools and examples. It makes use of +extended BPF (Berkeley Packet Filters), formally known as eBPF, a new feature +that was first added to Linux 3.15. BCC makes BPF programs easier to write, +with kernel instrumentation in C (and includes a C wrapper around LLVM), and +front-ends in Python and lua. It is suited for many tasks, including +performance analysis and network traffic control. + + +%package devel +Summary: Shared library for BPF Compiler Collection (BCC) +Requires: %{name} = %{version}-%{release} +Suggests: elfutils-debuginfod-client + +%description devel +The %{name}-devel package contains libraries and header files for developing +application that use BPF Compiler Collection (BCC). + + +%package doc +Summary: Examples for BPF Compiler Collection (BCC) +Recommends: python3-%{name} = %{version}-%{release} +Recommends: %{name}-lua = %{version}-%{release} +BuildArch: noarch + +%description doc +Examples for BPF Compiler Collection (BCC) + + +%package -n python3-%{name} +Summary: Python3 bindings for BPF Compiler Collection (BCC) +Requires: %{name} = %{version}-%{release} +BuildArch: noarch + +%description -n python3-%{name} +Python3 bindings for BPF Compiler Collection (BCC) + + +%package lua +Summary: Standalone tool to run BCC tracers written in Lua +Requires: %{name} = %{version}-%{release} + +%description lua +Standalone tool to run BCC tracers written in Lua + + +%package tools +Summary: Command line tools for BPF Compiler Collection (BCC) +Requires: bcc = %{version}-%{release} +Requires: python3-%{name} = %{version}-%{release} +Requires: python3-netaddr + +%description tools +Command line tools for BPF Compiler Collection (BCC) + +%package -n libbpf-tools +Summary: Command line libbpf tools for BPF Compiler Collection (BCC) +BuildRequires: libbpf-devel >= 0.0.5, libbpf-static >= 0.0.5 +BuildRequires: bpftool + +%description -n libbpf-tools +Command line libbpf tools for BPF Compiler Collection (BCC) + +%prep +%autosetup -p1 + + +%build +%cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo \ + -DREVISION_LAST=%{version} -DREVISION=%{version} -DPYTHON_CMD=python3 \ + -DCMAKE_USE_LIBBPF_PACKAGE:BOOL=TRUE \ + %{?with_llvm_shared:-DENABLE_LLVM_SHARED=1} +%cmake_build + +pushd libbpf-tools; +make BPFTOOL=bpftool LIBBPF_OBJ=%{_libdir}/libbpf.a CFLAGS="%{optflags}" LDFLAGS="%{build_ldflags}" +make DESTDIR=./tmp-install prefix= install +( + cd tmp-install/bin + for file in *; do + mv $file bpf-$file + done + # now fix the broken symlinks + for file in `find . -type l`; do + dest=$(readlink "$file") + ln -s -f bpf-$dest $file + done +) +popd + +%install +%cmake_install + +# Fix python shebangs +find %{buildroot}%{_datadir}/%{name}/{tools,examples} -type f -exec \ + sed -i -e '1s=^#!/usr/bin/python\([0-9.]\+\)\?$=#!%{__python3}=' \ + -e '1s=^#!/usr/bin/env python\([0-9.]\+\)\?$=#!%{__python3}=' \ + -e '1s=^#!/usr/bin/env bcc-lua$=#!/usr/bin/bcc-lua=' {} \; + +# Move man pages to the right location +mkdir -p %{buildroot}%{_mandir} +mv %{buildroot}%{_datadir}/%{name}/man/* %{buildroot}%{_mandir}/ +# Avoid conflict with other manpages +for i in `find %{buildroot}%{_mandir} -name "*.gz"`; do + tname=$(basename $i) + rename $tname %{name}-$tname $i +done +mkdir -p %{buildroot}%{_docdir}/%{name} +mv %{buildroot}%{_datadir}/%{name}/examples %{buildroot}%{_docdir}/%{name}/ + +# Delete old tools we don't want to ship +rm -rf %{buildroot}%{_datadir}/%{name}/tools/old/ + +%check + +mkdir -p %{buildroot}/%{_sbindir} +cp -a libbpf-tools/tmp-install/bin/* %{buildroot}/%{_sbindir}/ + +%ldconfig_scriptlets + +%files +%doc README.md +%license LICENSE.txt +%{_libdir}/lib%{name}.so.* +%{_libdir}/libbcc_bpf.so.* + +%files devel +%exclude %{_libdir}/lib%{name}*.a +%exclude %{_libdir}/lib%{name}*.la +%{_libdir}/lib%{name}.so +%{_libdir}/libbcc_bpf.so +%{_libdir}/pkgconfig/lib%{name}.pc +%{_includedir}/%{name}/ + +%files -n python3-%{name} +%{python3_sitelib}/%{name}* + +%files doc +%dir %{_docdir}/%{name} +%doc %{_docdir}/%{name}/examples/ + +%files tools +%dir %{_datadir}/%{name} +%{_datadir}/%{name}/tools/ +%{_datadir}/%{name}/introspection/ +%{_mandir}/man8/* + +%files lua +%{_bindir}/bcc-lua + +%files -n libbpf-tools +%{_sbindir}/bpf-* + +%changelog +* Thu May 5 2022 mgb01105731 - 0.24.0-1 +- Init from upstream version 0.24.0 diff --git a/libbpf-tools-Allow-to-use-different-cflags-for-bpf-t.patch b/libbpf-tools-Allow-to-use-different-cflags-for-bpf-t.patch new file mode 100644 index 0000000000000000000000000000000000000000..5429835fca5e2c112a818838bb4337e92301da5a --- /dev/null +++ b/libbpf-tools-Allow-to-use-different-cflags-for-bpf-t.patch @@ -0,0 +1,48 @@ +From c353d172e34f93eb281b679ee6ab3e039db0f420 Mon Sep 17 00:00:00 2001 +From: Jerome Marchand +Date: Tue, 15 Mar 2022 17:59:24 +0100 +Subject: [PATCH] libbpf-tools: Allow to use different cflags for bpf targets + +commit 531b698cdc20 ("libbpf-tools: Enable compilation warnings for +BPF programs") applies CFLAGS to all targets. However, some of the c +flags typically used by distribution are not available to the bpf +target. Add a new BPFCFLAGS macro to take care of that. + +Fixes the following compilation error on fedora: + + BPF bashreadline.bpf.o +clang-13: warning: optimization flag '-ffat-lto-objects' is not supported [-Wignored-optimization-argument] +clang-13: warning: argument unused during compilation: '-specs=/usr/lib/rpm/redhat/redhat-hardened-cc1' [-Wunused-command-line-argument] +clang-13: warning: argument unused during compilation: '-specs=/usr/lib/rpm/redhat/redhat-annobin-cc1' [-Wunused-command-line-argument] +clang-13: warning: argument unused during compilation: '-fstack-clash-protection' [-Wunused-command-line-argument] +error: option 'cf-protection=return' cannot be specified on this target +error: option 'cf-protection=branch' cannot be specified on this target +2 errors generated. +--- + libbpf-tools/Makefile | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/libbpf-tools/Makefile b/libbpf-tools/Makefile +index faa26139..aba19e00 100644 +--- a/libbpf-tools/Makefile ++++ b/libbpf-tools/Makefile +@@ -7,6 +7,7 @@ LIBBPF_SRC := $(abspath ../src/cc/libbpf/src) + LIBBPF_OBJ := $(abspath $(OUTPUT)/libbpf.a) + INCLUDES := -I$(OUTPUT) -I../src/cc/libbpf/include/uapi + CFLAGS := -g -O2 -Wall ++BPFCFLAGS := -g -O2 -Wall + INSTALL ?= install + prefix ?= /usr/local + ARCH := $(shell uname -m | sed 's/x86_64/x86/' | sed 's/aarch64/arm64/' | sed 's/ppc64le/powerpc/' | sed 's/mips.*/mips/') +@@ -107,7 +108,7 @@ $(OUTPUT)/%.skel.h: $(OUTPUT)/%.bpf.o | $(OUTPUT) + + $(OUTPUT)/%.bpf.o: %.bpf.c $(LIBBPF_OBJ) $(wildcard %.h) $(ARCH)/vmlinux.h | $(OUTPUT) + $(call msg,BPF,$@) +- $(Q)$(CLANG) $(CFLAGS) -target bpf -D__TARGET_ARCH_$(ARCH) \ ++ $(Q)$(CLANG) $(BPFCFLAGS) -target bpf -D__TARGET_ARCH_$(ARCH) \ + -I$(ARCH)/ $(INCLUDES) -c $(filter %.c,$^) -o $@ && \ + $(LLVM_STRIP) -g $@ + +-- +2.35.1 +