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

36.1. xxhash-0.8.4

Non-cryptographic hash algorithm library

Version 0.8.4, release 1
Shelf devlibs — General-purpose C and C++ utility libraries with no domain
Phase 20_selfhost (Self-Hosting Bootstrap), 5 of 15 in build order
Licence BSD-2-Clause AND GPL-2.0-or-later
Homepage https://xxhash.com/
Build time 0.1 SBU
Installed size 769.9 KiB in 19 files
Recipe ports/core/devlibs/xxhash/kpkgbuild

About

xxHash is a family of very fast non-cryptographic hash functions (XXH32, XXH64 and the XXH3 variants), shipped as libxxhash, its headers and the xxhsum command. It is in 20_selfhost because binutils is configured --with-xxhash; no phase list names it, and the phase installs it as binutils’ dependency. binutils’ ld compiles the hash in from xxhash.h (XXH_INLINE_ALL), so it needs the header only while it is built; ccache, gdb and other later ports link libxxhash.so.

The build is upstream’s plain Makefile, with no configure step: the exported CFLAGS and LDFLAGS reach it through the environment, and PREFIX and DESTDIR place the install.

Sources

Dependencies

Depends on: nothing a recipe names.

Required by (14): binutils, binutils-arm-none-eabi, binutils-avr, binutils-riscv64-unknown-elf, calibre, ccache, gdb, libplacebo, libretro-mupen64plus-next, partclone, rdfind, rizin, rsync, wireshark.

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/20_selfhost/phase.env && kpkg install xxhash'

What kpkg does

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

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/devlibs/xxhash
echo '5738270935e7c3d38a79b3adf7c9692566ce7895a25f67de43ad52ab504acd32  xxhash-0.8.4.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/xxhash
SRC=$SRC_ROOT/xxhash-0.8.4
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf xxhash-0.8.4.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:

case "$(uname -m)" in
	x86_64|i?86) _dispatch=1 ;;
	*) _dispatch=0 ;;
esac
export CFLAGS="${CFLAGS/-O2/-O3}"
make DISPATCH=$_dispatch LIBXXH_DISPATCH=$_dispatch
make PREFIX=/usr DESTDIR=$PKG DISPATCH=$_dispatch LIBXXH_DISPATCH=$_dispatch install

The switches, and why each is set:

Both are set from uname -m: 1 on x86 and x86-64, 0 elsewhere, because the dispatcher is x86 code and its source stops the build with an #error on any other architecture. Choosing the vector code at run time is how the package uses AVX2 and AVX-512 while the tree compiles for the baseline x86-64 (see Every port, “No machine-specific code”).

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/xxhash, 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 xxhash-0.8.4-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/xxhash, and runs the triggers its paths call for.

Contents

Installed programs: xxh128sum, xxh32sum, xxh3sum, xxh64sum, xxhsum.

Installed libraries: libxxhash.a, libxxhash.so.

Installed directories: /usr/share/licenses/xxhash.

Short descriptions

xxhsum print or check xxHash non-cryptographic checksums
libxxhash.pc extremely fast hash algorithm