363.1. dwarves-1.32
pahole and the DWARF tools — encodes the kernel's BTF type information
| Version | 1.32, release 1 |
| Shelf | devtools — Debuggers, tracers, profilers, analysers, linters, language servers and developer utilities |
| Phase | 60_kernel (Kernel), 1 of 2 in build order |
| Licence | GPL-2.0-only |
| Homepage | https://git.kernel.org/pub/scm/devel/pahole/pahole.git |
| Build time | 0.1 SBU |
| Installed size | 974.8 KiB in 42 files |
| Recipe | ports/core/devtools/dwarves/kpkgbuild |
About
dwarves is pahole and the other tools that read DWARF debugging information: pfunct, pdwtags, codiff, ctracer, btfdiff and the rest. KDOS builds it for the kernel. The linux port’s configuration turns on CONFIG_, and with it CONFIG_, which defaults on. kbuild then runs pahole over the kernel’s DWARF to produce BTF, the compact description of the kernel’s own types that bpftrace, sched_ext and CO-RE BPF programs read. linux is the only port that depends on it, and 60_kernel builds it just before the kernel.
Without pahole in the root, the kernel’s olddefconfig drops BTF without a word. The kernel recipe checks for that afterwards and stops the build; see The kernel configuration.
Why it is in KDOS
The comment above it in script/phases/60_kernel/packages.txt:
pahole, which turns the kernel's DWARF into the BTF that DEBUG_INFO_BTF embeds; linux depends on it.
Sources
dwarves-1.32.tar.xz(2.4 MiB)
sha256319cbf319e9fc92065a5407ce47eb868d73566f3d4840a56832734e4579df947
upstream: https://fedorapeople.org/~acme/dwarves/dwarves-1.32.tar.xz
archive copy: sources-1/devtools--dwarves-1.32.tar.xz
Dependencies
Depends on: cmake, ninja, pkgconf, elfutils, zlib, libbpf, argp-standalone, musl-obstack.
Required by (1): linux.
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_Python3=ON, line 20: python3 (explained with the switches below)
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/60_kernel/phase.env && kpkg install dwarves'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/devtools/dwarves.
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/dwarves
echo '319cbf319e9fc92065a5407ce47eb868d73566f3d4840a56832734e4579df947 dwarves-1.32.tar.xz' | 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/dwarves
SRC=$SRC_ROOT/dwarves-1.32
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf dwarves-1.32.tar.xz -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:
mkdir -p build && cd build
cmake .. -G Ninja \
-DCMAKE_POLICY_VERSION_MINIMUM=3.5 \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_INSTALL_LIBDIR=lib \
-DLIB_INSTALL_DIR=lib \
-DLIBBPF_EMBEDDED=OFF \
-DCMAKE_DISABLE_FIND_PACKAGE_Python3=ON
ninja
DESTDIR=$PKG ninja install
The switches, and why each is set:
-DLIBBPF_EMBEDDED=OFF— Link the libbpf port, found through pkg-config, instead of compiling the copy of libbpf the tarball carries inlib/bpf, which is upstream’s default. CMake then stops if pkg-config finds nolibbpfnew enough.-DLIB_INSTALL_DIR=lib—CMakeLists.txtinstallslibdwarves,libdwarves_emitandlibdwarves_reorganizeto${LIB_INSTALL_DIR}, a variable it never sets;CMAKE_INSTALL_LIBDIRdoes not reach those two install lines. This puts the libraries in/usr/libwith the rest.-DCMAKE_DISABLE_FIND_PACKAGE_Python3=ON— Stop CMake looking for Python. When it finds one, the build installsostra-cg, a Python script that draws call graphs from actracertrace, and its module under/usr/share/dwarves/runtime/python. With the switch neither is installed, so what the package holds does not depend on whetherpython3happens to be in the root when it is built.
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/dwarves, 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 dwarves-1.32-1.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/dwarves, and runs the triggers its paths call for.
Contents
Installed programs: btfdiff, codiff, ctracer, dtagnames, fullcircle, pahole, pdwtags, pfunct, pglobal, prefcnt, scncopy, syscse.
Installed libraries: libdwarves.so, libdwarves_emit.so, libdwarves_reorganize.so.
Installed directories: /usr/include/dwarves, /usr/share/dwarves, /usr/share/licenses/dwarves.
Short descriptions
pahole |
show or manipulate data structure layout and pretty print raw data |
pfunct |
Shows function information in debug information. |
Notes
- musl has neither argp nor obstack, the two glibc interfaces the tools are written against. argp-standalone and musl-obstack provide them as libraries. dwarves’ own
Findargp.cmakeandFindobstack.cmakelook forlibargpandlibobstack, and when one finds nothing it printsAssuming argp is in libc(orobstack) and carries on, so a root without the two ports passes configure and fails to compile at the first#include <argp.h>.