Control: tags -1 + patch
Control: found -1 1.5.7+dfsg-4

Dear Maintainer,

I believe I have found the cause: /usr/bin/zstd is a debug build. During
dh_auto_test, "make test" runs tests/Makefile, which exports DEBUGLEVEL=2 and
rebuilds programs/zstd in place; dh_auto_install then ships that binary.
libzstd1 is not affected.

To confirm:

    grep -c -aF '0<=level && level<=4' /usr/bin/zstd                         # 
assert()
    grep -c -aF 'ZSTD_compressBlock_internal (dstCapacity=' /usr/bin/zstd   # 
DEBUGLOG

Both are non-zero on the archive binary and 0 on a release build. With
symbols from debuginfod.debian.net, gdb shows g_debuglevel = 2.

All 1.5.7 builds I checked (-1 and -4, amd64 and arm64) are affected;
bookworm's 1.5.4 and bullseye's 1.4.8 also contain assert() strings.

On arm64 (Raspberry Pi 5, Silesia corpus) the archive binary is 7-25% slower
to compress and 10-13% slower to decompress than a release build of the same
source, which matches the reports above.

The patch below applies to 1.5.7+dfsg-4. Verified on 1.5.7+dfsg-1 with a
full "dpkg-buildpackage -rfakeroot" including tests (all 40 pass); the shipped
binary matches the nocheck build.

--- a/debian/rules
+++ b/debian/rules
@@ -52,6 +52,15 @@
 execute_after_dh_auto_build:
        dh_auto_build -D contrib/pzstd

+# The upstream test suite rebuilds programs/zstd in place with DEBUGLEVEL=2
+# (assert() and DEBUGLOG enabled), which dh_auto_install would then ship.
+# Keep the release binary aside and put it back once the tests have run.
+execute_before_dh_auto_test:
+       cp -p programs/zstd debian/zstd.release
+
+execute_after_dh_auto_test:
+       cp -p debian/zstd.release programs/zstd
+
 override_dh_auto_install:
        dh_auto_install -- libdir=/usr/lib/${DEB_HOST_MULTIARCH}
        dh_auto_install -D contrib/pzstd
--- a/debian/clean
+++ b/debian/clean
@@ -1 +1,2 @@
 tests/cli-tests/bin/symlinks/
+debian/zstd.release

Kind regards,
Richard Oliver

Reply via email to