nanofil/nix/zlib.nix
zlib built entirely by nanofil. libz.a, example and minigzip are compiled through nanofil-cc (all 17 objects must come from nanofil), zlib's own maketest runs, and minigzip's output must be byte for byte the same as a filcc-built zlib's, at levels 1, 6 and 9 on text and on random data, with each build inflating the other's output. Once per middle-end, register and check-reuse choice, each in its own derivation (configurations.nix); the tests also run under FUGC_SCRIBBLE and FUGC_VERIFY.
λpkgs, filcc
let
Middle end and target cache are independent choices.
in
import./configurations.nix inherit pkgs; "nanofil-zlib" configurations
λlabel opt
cc=${import./nanofil-cc.nix inherit pkgs filcc;}
ref=${reference}/bin/minigzip
${unpack}
head -c 2000000 /dev/urandom > random
echo "== zlib, nanofil ${opt}"
unpack nf
export NANOFIL_OPT="${opt}" NANOFIL_LOG=$PWD/nanofil.log
make -C nf -j$NIX_BUILD_CORES CC=$cc libz.a example minigzip
objects=$(find nf -name '*.o' | wc -l)
compiled=$(sort -u nanofil.log | wc -l)
echo "nanofil compiled $compiled of $objects objects"
[ "$objects" -gt 0 ] && [ "$compiled" -eq "$objects" ]
for env in "" "FUGC_SCRIBBLE=1 FUGC_VERIFY=1"; do
env $env make -C nf CC=$cc test | tee test.log
grep -q '\*\*\* zlib test OK \*\*\*' test.log
for f in text random; do
for level in 1 6 9; do
$ref -$level <$f >$f.ref.gz
env $env nf/minigzip -$level <$f >$f.nf.gz
cmp $f.ref.gz $f.nf.gz
env $env nf/minigzip -d <$f.ref.gz | cmp - $f
$ref -d <$f.nf.gz | cmp - $f
done
done
echo "minigzip matches filcc's zlib byte for byte ($env)"
done
touch $out