#1149765 zlib: s390x CRC-32 crcvx optimization not built: contrib/crc32vx stripped from orig

Package:
src:zlib
Source:
src:zlib
Submitter:
Frank Heimes
Date:
2026-10-02 20:49:03 UTC
Severity:
normal
Tags:
#1149765#5
Date:
2026-10-02 20:38:13 UTC
From:
To:
Dear Maintainer, hi Mark,

zlib 1.3.2 (upstream) ships an s390x CRC-32 implementation (the "crcvx"
optimization, z13+ VGFMA) in contrib/crc32vx/.
In the Debian package it is not built at all, so s390x gets no
hardware-accelerated CRC-32 (~3x slower; see testing below).

Cause
-----
The build glue is present in the tree -- crc32.c, configure and Makefile.in all
reference contrib/crc32vx/ under HAVE_S390X_VX -- but the two source files
(crc32_vx.c, crc32_vx_hooks.h) are missing from the .orig tarball, which keeps
only contrib/minizip out of contrib/.
But contrib/crc32vx is Zlib-licensed and is NOT in debian/copyright
Files-Excluded, so this is an inadvertent repack artifact, I think.
With the files gone the s390x build fails ("No rule to make target
contrib/crc32vx/crc32_vx.c"), which is why -3 added --disable-crcvx.

crcvx is a generically-named switch, but in 1.3.2 its only backend is s390x,
gated behind __s390x__; this has no effect on other architectures.

The current .orig does not seems to be reproducible from the packaging:
running mk-origtargz with the current debian/copyright keeps contrib/crc32vx,
and the .orig additionally lacks amiga/ msdos/ os400/ qnx/ watcom/,
make_vms.com,
zlib.3.pdf, examples/zlib_how.html and more that Files-Excluded does not
mention.

Fix: regenerate the .orig with contrib/crc32vx included
-------------------------------------------------------
The intended fix is to stop dropping contrib/crc32vx from the .orig (no patch).

1. Make debian/copyright Files-Excluded accurate, so a regenerate adds only
   contrib/crc32vx and does not re-add the cruft above. Add (but NOT
   contrib/crc32vx):
     amiga  msdos  os400  qnx  watcom
     make_vms.com  zlib.3.pdf  examples/zlib_how.html
     contrib/CMakeLists.txt  contrib/README.contrib
     contrib/nuget  contrib/zlib1-dll  contrib/minizip/Makefile
   Also document contrib/crc32vx/* (IBM, Zlib) in debian/copyright.
   (both changes in the attached debian-copyright.diff)

2. Bump the repack suffix, since the corrected .orig has the same name but a
   different checksum and the archive will not accept a changed .orig for the
   existing upstream version: e.g. version 1:1.3.dfsg+really1.3.2+dfsg1-1,
   orig zlib_1.3.dfsg+really1.3.2+dfsg1.orig.tar.gz. Exact command (packaging
   tree, upstream zlib-1.3.2 tarball in the current dir):

     mk-origtargz --package zlib --version 1.3.dfsg+really1.3.2+dfsg1 \
         --repack --compression gzip --copyright-file debian/copyright \
         --directory . zlib-1.3.2.tar.gz

   Verify: tar tf zlib_1.3.dfsg+really1.3.2+dfsg1.orig.tar.gz | grep crc32vx
   (4 files). Refresh pristine-tar if used.

3. debian/rules: drop --disable-crcvx; add "contrib" to COPYLIST.
   (attached debian-rules.diff)

With the files back in the .orig, no (quilt) patch is needed.

Fallback (in case the .orig is not re-rolled)
---------------------------------------------
The attached restore-crc32vx-source.patch re-adds the two files verbatim from
upstream v1.3.2 as a quilt patch; the debian-rules.diff and debian-copyright
attribution still apply. This is a fallback and I think it's not the preferred
route.

Safety
------
No-op off s390x (HAVE_S390X gate). The relevant symbols (s390_crc32_vx,
crc32_z_hook) are local, so there is no exported-ABI/symbols change. The two
historical defects from Ubuntu LP #1982583 (uint32_t signature; define missing
from SFLAGS) are already correct in upstream 1.3.2.

Testing
-------
Native IBM z15 (machine 8561), s390x, VX facility present:
- VX libz (shared and static): correct CRC-32 across sizes 0..5,000,000 x 17
  byte-alignments, matching an independent reference and the scalar crc32_z.
- A deliberately-corrupted-VX control build fails from n=79 (VX_MIN_LEN+align),
  confirming the vector path is actually executed.
- Shared libz carries s390_crc32_vx + crc32_z_hook (VGFMA instructions
present).
- Real app (python3 zlib, ~300 MB): identical result to scalar, ~2.9x faster.
- amd64: crcvx inert; libz and contrib/minizip build unchanged.

This fixes also Ubuntu LP #1982583 (https://bugs.launchpad.net/bugs/1982583).

Attachments:
- debian-copyright.diff   (accurate Files-Excluded for the repack + crc32vx
                           copyright attribution)
- debian-rules.diff       (drop --disable-crcvx; COPYLIST += contrib)
- restore-crc32vx-source.patch  (fallback only: re-add the files as a quilt
patch)

Thanks for considering this and BR
Frank


*** /debian-copyright.diff
--- cmp/d3/debian/copyright     2026-03-24 01:05:22.000000000 +0000
+++ /tmp/opencode/copyright.combined    2026-10-02 19:39:40.024072518 +0000
@@ -35,6 +35,19 @@
  doc/rfc1951.txt
  doc/rfc1952.txt
  win32
+ amiga
+ msdos
+ os400
+ qnx
+ watcom
+ make_vms.com
+ zlib.3.pdf
+ examples/zlib_how.html
+ contrib/CMakeLists.txt
+ contrib/README.contrib
+ contrib/nuget
+ contrib/zlib1-dll
+ contrib/minizip/Makefile

 Files: *
 Copyright: 1995-2013 Jean-loup Gailly and Mark Adler
@@ -50,6 +63,13 @@
            2009-2010 Mathias Svensson
 License: Zlib

+Files: contrib/crc32vx/*
+Copyright: 2013-2017 IBM Corporation
+           Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
+License: Zlib
+Comment: Originally written for the Linux kernel and relicensed under Zlib
+ by the upstream zlib project.
+
 Files: debian/*
 Copyright: 2000-2017 Mark Brown


*** debian-rules.diff
--- cmp/d3/debian/rules 2026-04-01 21:50:49.000000000 +0000
+++ zlib-debpr/debian/rules     2026-10-02 15:05:44.419025112 +0000
@@ -70,14 +70,14 @@
 CFLAGS+=-DUNALIGNED_OK
 endif