50.3. lz4-1.10.0
LZ4 compression library and command-line tool
| Version | 1.10.0, release 1 |
| Shelf | archiver — Compression libraries and archive tools |
| Phase | 30_foundation (Build Foundation), 4 of 127 in build order |
| Licence | BSD-2-Clause AND GPL-2.0-or-later |
| Homepage | https://lz4.org/ |
| Build time | 0.6 SBU |
| Installed size | 1.6 MiB in 19 files |
| Recipe | ports/core/archiver/lz4/kpkgbuild |
About
LZ4 is a compression format built for speed rather than ratio: the library liblz4 and the lz4, unlz4 and lz4cat commands. In KDOS it is a dependency of zstd, whose command can read and write .lz4, and of the filesystem and archive tools, erofs-utils, f2fs-tools and libarchive among them. It is one of the ports kdos march measures with a benchmark of its own (see kdos march); the bench and bench_setup lines of the recipe are that benchmark.
The build is upstream’s plain makefiles, with no configure step: the exported flags reach them through the environment, and PREFIX and DESTDIR place the install.
Sources
lz4-1.10.0.tar.gz(378.0 KiB)
sha256537512904744b35e232912055ccf8ec66d768639ff3abe5788d90d792ec5f48b
upstream: https://github.com/lz4/lz4/archive/v1.10.0.tar.gz
archive copy: sources-1/archiver--lz4-1.10.0.tar.gz
Dependencies
Depends on: nothing a recipe names.
Required by (23): android-tools, c-blosc, erofs-utils, f2fs-tools, gdal, imhex, labplot, libarchive, librist, openconnect, opencpn, openvpn, postgresql, rizin, rsync, spice, spice-gtk, squashfs-tools, vte3, vtk, waypipe, wireshark, zstd.
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/30_foundation/phase.env && kpkg install lz4'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/archiver/lz4.
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/archiver/lz4
echo '537512904744b35e232912055ccf8ec66d768639ff3abe5788d90d792ec5f48b lz4-1.10.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/lz4
SRC=$SRC_ROOT/lz4-1.10.0
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf lz4-1.10.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:
lto="-flto=auto -ffat-lto-objects -frandom-seed=lz4"
export CFLAGS="${CFLAGS/-O2/-O3} $lto" CXXFLAGS="${CXXFLAGS/-O2/-O3} $lto"
export LDFLAGS="$LDFLAGS -flto=auto"
make PREFIX=/usr
make DESTDIR=$PKG PREFIX=/usr install
The switches, and why each is set:
${CFLAGS/-O2/-O3}— raise the exportedCFLAGSandCXXFLAGSto-O3. The library’s and the programs’ makefiles put their own-O3first and the environment’sCFLAGSafter it, so the tree’s-O2would otherwise win. This is the “-O3for a hot port by pattern” case of Every port.-flto=auto— compile and link with link-time optimisation, running the link-time stage in parallel through make’s job server, or on every processor when there is none. lz4 is one of the short list of hot libraries the tree builds with LTO (see Every port, “LTO only for the hot libraries”). It is added toLDFLAGStoo, so the link step optimises.-ffat-lto-objects— write ordinary machine code into every object beside the LTO bytecode. The package shipsliblz4.a, and without fat objects that archive would hold bytecode only and link only through GCC’s plugin.-frandom-seed=lz4— fix the seed GCC uses to name each object’s.gnu.lto_*sections. The static archive keeps those sections, and with a random seed it would differ on every build, so the package would not be reproducible.
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/lz4, 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 lz4-1.10.0-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/lz4, and runs the triggers its paths call for.
Contents
Installed programs: lz4, lz4c, lz4cat, unlz4.
Installed libraries: liblz4.a, liblz4.so.
Installed directories: /usr/share/licenses/lz4.
Short descriptions
lz4 |
lz4, unlz4, lz4cat - Compress or decompress lz4 files |
liblz4.pc |
extremely fast lossless compression algorithm library |