67.10. bcc-0.37.0
The BPF Compiler Collection library, USDT probe support and the libbpf-tools tracers
| Version | 0.37.0, release 3 |
| Shelf | devtools — Debuggers, tracers, profilers, analysers, linters, language servers and developer utilities |
| Phase | 40_lang (Languages), 18 of 186 in build order |
| Licence | Apache-2.0 AND GPL-2.0-only AND GPL-3.0-only AND (LGPL-2.1-only OR BSD-2-Clause) |
| Homepage | https://github.com/iovisor/bcc |
| Build time | 0.6 SBU |
| Installed size | 43.8 MiB in 583 files |
| Recipe | ports/core/devtools/bcc/kpkgbuild |
About
The BPF Compiler Collection: libbcc, a library that compiles a BPF program from C with clang and loads it into the kernel, with USDT (user-level statically defined tracing) probe support; its Python module and the Python tools that use it, under /usr/share/bcc/tools; and the libbpf-tools, compiled CO-RE tracers such as execsnoop, opensnoop and biolatency, installed as bpf-<tool> in /usr/bin. bpftrace is the reason for the port: its find_package(LibBcc REQUIRED) is unconditional.
The source is upstream’s bcc-src-with-submodule release asset, not the tag archive. bcc carries libbpf, bpftool and blazesym as git submodules, which a tag archive leaves as empty directories.
Sources
bcc-0.37.0.tar.gz(9.3 MiB)
sha2567734b780202b22dff335780b506b56833ec6cf7435e03b1346d5bf644b4e1f95
upstream: https://github.com/iovisor/bcc/releases/download/v0.37.0/bcc-src-with-submodule-0.37.0.tar.gz
archive copy: sources-1/devtools--bcc-0.37.0.tar.gz
Dependencies
Depends on: cmake, ninja, pkgconf, flex, bison, python3, llvm, clang, elfutils, zlib, xz, libbpf, bpftool, argp-standalone.
Required by (1): bpftrace.
Optional, off in KDOS
These switches in build.sh turn off a feature whose library is a port here. The recipe may turn each off on purpose, or because the library was not yet a port when the recipe was written; this list cannot tell which.
-DCMAKE_DISABLE_FIND_PACKAGE_LuaJIT=TRUE, line 36: luajit (explained with the switches below)
Patches
build.sh applies these; kpkg applies nothing by itself.
llvm23-mccontext.patch— Insrc/cc/bcc_debug.cc, constructsMCContextwith itsMCAsmInfo,MCRegisterInfoandMCSubtargetInfopassed by reference whenLLVM_VERSION_MAJORis 23 or later, and by pointer otherwise. The source does not compile against the llvm port without it.
Installation
From the repository root, inside the build container, this is the line kdosbuild runs for the port:
script/chroot/exec.sh bash -c 'source script/phases/40_lang/phase.env && kpkg install bcc'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/devtools/bcc.
1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.
cd /ports/core/devtools/bcc
echo '7734b780202b22dff335780b506b56833ec6cf7435e03b1346d5bf644b4e1f95 bcc-0.37.0.tar.gz' | sha256sum -c -
2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.
SRC_ROOT=/var/cache/kpkg/work/bcc
SRC=$SRC_ROOT/bcc-0.37.0
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf bcc-0.37.0.tar.gz -C "$SRC" --strip-components=1
Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.
3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:
cd bcc
patch -p1 -i $PORT_SRC/llvm23-mccontext.patch
_clang=/usr/lib/libclang-cpp.so
_clang_libs=()
for _c in Analysis AST Basic CodeGen Driver Edit Frontend Lex Parse Rewrite Sema \
Serialization ASTMatchers Support APINotes; do
_clang_libs+=("-Dlibclang$_c=$_clang")
done
mkdir -p build && cd build
cmake .. -G Ninja \
-DREVISION=$version \
-DCMAKE_POLICY_VERSION_MINIMUM=3.5 \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_INSTALL_LIBDIR=lib \
-DCMAKE_USE_LIBBPF_PACKAGE=ON \
-DENABLE_LLVM_SHARED=OFF \
"${_clang_libs[@]}" \
-DENABLE_CLANG_JIT=ON \
-DENABLE_LIBDEBUGINFOD=OFF \
-DCMAKE_DISABLE_FIND_PACKAGE_LibDebuginfod=TRUE \
-DCMAKE_DISABLE_FIND_PACKAGE_LuaJIT=TRUE \
-DENABLE_MAN=ON \
-DENABLE_EXAMPLES=OFF \
-DENABLE_TESTS=OFF \
-DENABLE_USDT=ON \
-DPYTHON_CMD=python3
ninja
DESTDIR=$PKG ninja install
if ldd "$PKG/usr/lib/libbcc.so.0" 2>&1 | grep 'symbol not found'; then
echo 'bcc: libbcc.so.0 does not resolve against the installed clang and LLVM' >&2
exit 1
fi
export EXTRA_LDFLAGS=-largp
_mk=(USE_BLAZESYM=0 BPFTOOL=/usr/sbin/bpftool prefix=/usr APP_PREFIX=bpf-
CFLAGS="$CFLAGS -Wno-error=missing-field-initializers")
make -C ../libbpf-tools "${_mk[@]}"
make -C ../libbpf-tools "${_mk[@]}" DESTDIR=$PKG install
install -Dm644 ../LICENSE.txt "$PKG/usr/share/licenses/$name/LICENSE.txt"
install -Dm644 ../libbpf-tools/bpftool/LICENSE.GPL-2.0 \
"$PKG/usr/share/licenses/$name/libbpf-tools/LICENSE.GPL-2.0"
install -Dm644 /usr/share/licenses/bison/COPYING \
"$PKG/usr/share/licenses/$name/libbpf-tools/LICENSE.GPL-3.0"
install -Dm644 -t "$PKG/usr/share/licenses/$name/libbpf" \
../src/cc/libbpf/LICENSE ../src/cc/libbpf/LICENSE.BSD-2-Clause ../src/cc/libbpf/LICENSE.LGPL-2.1
The switches, and why each is set:
-DREVISION=$version— The version bcc giveslibbcc.soandlibbcc_bpf.so(theVERSIONproperty, so the file names end in the release) and its Python package. Unset,cmake/version.cmakeasks git for it, and a release tarball has no.git.-DCMAKE_USE_LIBBPF_PACKAGE=ON— Find and link the libbpf port. Without it bcc compiles the libbpf sources of its submodule intolibbcc_bpf, and bpftrace, which links both, would carry two copies.-DENABLE_LLVM_SHARED=OFF— Link LLVM’s component libraries by name. With it on,cmake/clang_libs.cmakelinks the single aggregatelibLLVM.so, which the llvm port does not build: it installs one shared library per component (LLVM_BUILD_LLVM_DYLIB=OFF,BUILD_SHARED_LIBS=ON).-Dlibclang$_c=$_clang— One cache entry per clang library the top-levelCMakeLists.txtlooks up,libclangAnalysisthroughlibclangAPINotes, each set to clang’s aggregatelibclang-cpp.so.find_librarykeeps a set entry, solibbcc.solinks that one shared library, as bpftrace does. Left to the search, each entry finds the staticlibclang<Name>.a, andcmake/clang_libs.cmakelinks only those fifteen archives; clang 23’s code in them calls into archives the list does not name (clangAnalysisLifetimeSafety,clangDependencyScanning,clangOptions, theclangScalableStaticAnalysis*set) and intolibLLVMABI, so 45 symbols would stay unresolved inlibbcc.so.0andimport bccwould stop at load. Thelddtest after the install fails the build when any symbol is unresolved.-DENABLE_CLANG_JIT=ON— Build the clang front end that compiles BPF C at run time. It is upstream’s default, and it is what bpftrace links; without it neither the tools nor the manual pages are built either.-DENABLE_LIBDEBUGINFOD=OFF,-DCMAKE_DISABLE_FIND_PACKAGE_LibDebuginfod=TRUE— No symbol lookup through debuginfod, which fetches debug information over the network. The option alone only guards the include directory;src/cc/CMakeLists.txtlinks libdebuginfod wheneverfind_packagefinds it, so the search is disabled too. elfutils is built with--disable-libdebuginfodin any case.-DCMAKE_DISABLE_FIND_PACKAGE_LuaJIT=TRUE— Build no Lua front end.src/luabuilds one whenever it finds LuaJIT, and luajit is a port, so without this the result would depend on whether it happened to be installed.-DENABLE_MAN=ON— Install the tools’ manual pages, under/usr/share/bcc/man. It is upstream’s default.-DENABLE_EXAMPLES=OFF,-DENABLE_TESTS=OFF— Build neither the example programs nor the test suite; both are on by default.-DENABLE_USDT=ON— Build USDT probe support, upstream’s default and the part bpftrace uses; the C++ API depends on it.-DPYTHON_CMD=python3— The interpreter the Python module is installed for.EXTRA_LDFLAGS=-largp— Appended to the libbpf-tools Makefile’sLDFLAGS. The tools parse their arguments withargp, which is part of glibc and a separate library, argp-standalone, on musl.USE_BLAZESYM=0— Build the tools without blazesym symbolisation. On x86 the Makefile turns it on whenevercargois on thePATH, and then builds the blazesym crate with cargo, which needs the network.BPFTOOL=/usr/sbin/bpftool— Generate the BPF skeletons with the bpftool port. Unset, the Makefile first builds a bootstrap bpftool from itsbpftoolsubmodule, whose ownlibbpfsubmodule is empty even in the release asset.APP_PREFIX=bpf-— Install each tool asbpf-<name>, so that generic names such asprofile,capableandoffcputimestay free in/usr/bin.-Wno-error=missing-field-initializers— Part of theCFLAGSgiven on the make command line. A command-lineCFLAGSreplaces the Makefile’s own line (-g -O2 -Wall -Wmissing-field-initializers -Werror -Werror=undef), so the tools compile with the tree’s flags and no-Werror; the appended switch keeps that one warning from ever being an error.
The common switches of each build system are explained in the Flag glossary.
4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/bcc, prunes what the image does not ship, lints the tree and rolls it reproducibly:
tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
--mtime=@$SOURCE_DATE_EPOCH \
--use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
-cf bcc-0.37.0-3.tar.xz -C "$PKG" .
5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/bcc, and runs the triggers its paths call for.
Contents
Installed programs: bpf-bashreadline, bpf-bcachefsdist, bpf-bcachefsslower, bpf-bindsnoop, bpf-biolatency, bpf-biopattern, bpf-biosnoop, bpf-biostacks, bpf-biotop, bpf-bitesize, bpf-btrfsdist, bpf-btrfsslower, bpf-cachestat, bpf-capable, bpf-cpudist, bpf-cpufreq, bpf-drsnoop, bpf-execsnoop, bpf-exitsnoop, bpf-ext4dist, bpf-ext4slower, bpf-f2fsdist, bpf-f2fsslower, bpf-filelife, bpf-filetop, bpf-fsdist, bpf-fsslower, bpf-funclatency, bpf-fusedist, bpf-fuseslower, bpf-futexctn, bpf-gethostlatency, bpf-hardirqs, bpf-javagc, bpf-killsnoop, bpf-klockstat, bpf-ksnoop, bpf-llcstat, bpf-mdflush, bpf-memleak, bpf-mountsnoop, bpf-nfsdist, bpf-nfsslower, bpf-numamove, bpf-offcputime, bpf-oomkill, bpf-opensnoop, bpf-profile, bpf-readahead, bpf-runqlat, bpf-runqlen, bpf-runqslower, bpf-sigsnoop, bpf-slabratetop, bpf-softirqs, bpf-solisten, bpf-statsnoop, bpf-syncsnoop, bpf-syscount, bpf-tcpconnect, bpf-tcpconnlat, bpf-tcplife, bpf-tcppktlat, bpf-tcprtt, bpf-tcpstates, bpf-tcpsynbl, bpf-tcptop, bpf-tcptracer, bpf-vfsstat, bpf-wakeuptime, bpf-xfsdist, bpf-xfsslower, bpf-zfsdist, bpf-zfsslower.
Installed libraries: libbcc-loader-static.a, libbcc.a, libbcc.so, libbcc_bpf.a, libbcc_bpf.so.
Installed directories: /usr/include/bcc, /usr/lib/python3.14/site-packages/bcc, /usr/lib/python3.14/site-packages/bcc-0.37.0-py3.14.egg-info, /usr/share/bcc, /usr/share/licenses/bcc.
Short descriptions
libbcc.pc |
BCC Program library |
Notes
The libbpf-tools are a separate Makefile outside the CMake build, run with make -C ../libbpf-tools from the CMake build directory. Each tool links a static libbpf the Makefile builds from the submodule’s sources, which is a copy inside that executable and not a second libbpf in any process that loads the shared one. The tools carry vmlinux.h per architecture in the source, so nothing is read from the build machine’s kernel.
/usr/share/licenses/bcc holds bcc’s Apache-2.0 text and, because the libbpf-tools are licensed apart from it, the texts they ship under: libbpf/ for the static libbpf in every tool (LGPL-2.1 OR BSD-2-Clause), libbpf-tools/LICENSE.GPL-2.0, taken from the bpftool submodule, for the tools under GPL-2.0, and libbpf-tools/LICENSE.GPL-3.0 for bpf-wakeuptime, whose BPF program wakeuptime.bpf.c is GPL-3.0. The source carries no GPL-3.0 text, so that one is bison’s COPYING, a full GPL version 3 text that the bison package, a build dependency, installs as /usr/share/licenses/bison/COPYING in the build root. The license key names all four.