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
xxhash-0.8.4.tar.gz(1.1 MiB)
sha2565738270935e7c3d38a79b3adf7c9692566ce7895a25f67de43ad52ab504acd32
upstream: https://github.com/Cyan4973/xxhash/archive/refs/tags/v0.8.4.tar.gz
archive copy: sources-1/devlibs--xxhash-0.8.4.tar.gz
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:
${CFLAGS/-O2/-O3}— Raise the optimisation level of the exportedCFLAGSto-O3. The Makefile’s own default is-O3, but only whenCFLAGSis unset, and the tree always sets it. This is the “-O3for a hot port by pattern” case of Every port.DISPATCH— Buildxxhsumwithxxh_x86dispatch.c, which checks the processor when the program starts and runs the XXH3 code for the widest vector unit it has: SSE2, AVX2 or AVX-512. On x86-64, where SSE2 is always present, the dispatcher leaves the scalar code out. The Makefile already does this when the compiler targets x86; the variable states it.LIBXXH_DISPATCH— Put the same dispatcher intolibxxhashand install its header,xxh_x86dispatch.h, so programs that link the library get the same run-time choice. Upstream leaves this off.
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 |