Skip to the text
KDOS
Menu
kdos.dev KDOS from Scratch KDOS 0.2 · 4dd4a10 · 2026-11-30 Contents Index

84.6. bpftrace-0.27.0

High-level tracing language for eBPF, for tracing inside the kernel

Version 0.27.0, release 2
Shelf devtools — Debuggers, tracers, profilers, analysers, linters, language servers and developer utilities
Phase 41_system (System), 377 of 1047 in build order
Licence Apache-2.0
Homepage https://bpftrace.org/
Build time 3.6 SBU
Installed size 14.9 MiB in 88 files
Recipe ports/core/devtools/bpftrace/kpkgbuild

About

bpftrace is a tracing language for the kernel’s eBPF machinery: a one-line script names a probe (a kprobe, a uprobe, a tracepoint, a timer) and what to record when it fires, and bpftrace compiles it with LLVM into BPF bytecode, loads it, and prints the maps it fills. It is how to ask why something is slow when the answer lies inside the kernel. It needs a kernel with the bpf() system call, the BPF JIT, kprobes, uprobes and BTF type information. The kernel the linux port builds from its kdos.config has all of them, and that port’s build stops if CONFIG_DEBUG_INFO_BTF is lost, so this port needs no kernel change of its own.

Why it is in KDOS

The comment above it in script/phases/41_system/packages.d/devtools.txt:

Every kernel prerequisite is already set in kdos.config — DEBUG_INFO_BTF, BPF_SYSCALL, BPF_JIT, KPROBES, UPROBES — which is what makes bpftrace a port rather than a kernel change plus a port.

Sources

Dependencies

Depends on: cmake, ninja, pkgconf, flex, bison, llvm, clang, elfutils, zlib, zstd, libbpf, bcc, cereal, libpcap, binutils, asciidoctor, gzip.

Required by: no port names it.

Patches

build.sh applies these; kpkg applies nothing by itself.

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/41_system/phase.env && kpkg install bpftrace'

What kpkg does

kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/devtools/bpftrace.

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/bpftrace
echo '87bf01fc3269ada7109531b0d964ceb5527d1ef7b9c9a4269b3aabdf872f0e26  bpftrace-0.27.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/bpftrace
SRC=$SRC_ROOT/bpftrace-0.27.0
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf bpftrace-0.27.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:

patch -p1 -i $PORT_SRC/llvm-definitions.patch

mkdir -p build && cd build
cmake .. -G Ninja \
	-DCMAKE_POLICY_VERSION_MINIMUM=3.5 \
	-DCMAKE_BUILD_TYPE=Release \
	-DCMAKE_INSTALL_PREFIX=/usr \
	-DUSE_SYSTEM_LIBBPF=ON \
	-DBUILD_TESTING=OFF \
	-DENABLE_MAN=ON \
	-DASCIIDOCTOR=/usr/bin/asciidoctor \
	-DENABLE_SKB_OUTPUT=ON \
	-DENABLE_SYSTEMD=OFF \
	-DCMAKE_REQUIRE_FIND_PACKAGE_LibBfd=ON \
	-DCMAKE_REQUIRE_FIND_PACKAGE_LibOpcodes=ON \
	-DCMAKE_REQUIRE_FIND_PACKAGE_LibDw=ON \
	-DCMAKE_REQUIRE_FIND_PACKAGE_LibPcap=ON \
	-DCMAKE_DISABLE_FIND_PACKAGE_LibBlazesym=ON \
	-DSTATIC_LINKING=OFF \
	-DCMAKE_CXX_STANDARD_LIBRARIES="$(llvm-config --libs)"
ninja
DESTDIR=$PKG ninja install

The switches, and why each is set:

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/bpftrace, 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 bpftrace-0.27.0-2.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/bpftrace, and runs the triggers its paths call for.

Contents

Installed programs: bpftrace, bpftrace-aotrt.

Installed directories: /usr/share/bpftrace, /usr/share/licenses/bpftrace.

Short descriptions

bpftrace a high-level tracing language