Re: git: cd8822075a38 - main - MFV c144cc54795d: zlib 1.2.12.

From: Peter Jeremy <peterj_at_freebsd.org>
Date: Sun, 03 Apr 2022 00:40:49 UTC
On 2022-Mar-31 14:26:36 +0000, Xin LI <delphij@FreeBSD.org> wrote:
>The branch main has been updated by delphij:
>
>URL: https://cgit.FreeBSD.org/src/commit/?id=cd8822075a38d0734e74b1735e4b5dbef9789170
>
>commit cd8822075a38d0734e74b1735e4b5dbef9789170
>Merge: e57f6630d9d4 c144cc54795d
>Author:     Xin LI <delphij@FreeBSD.org>
>AuthorDate: 2022-03-31 14:25:53 +0000
>Commit:     Xin LI <delphij@FreeBSD.org>
>CommitDate: 2022-03-31 14:25:53 +0000
>
>    MFV c144cc54795d: zlib 1.2.12.

This breaks the build on my arm64 box:
--- crc32.o ---
/usr/src/sys/contrib/zlib/crc32.c:106:61: error: 'W' is not defined, evaluates to 0 [-Werror,-Wundef]
#if defined(__aarch64__) && defined(__ARM_FEATURE_CRC32) && W == 8

The code in sys/contrib/zlib/crc32.c:74-99 is rather convoluted but
doing a test compile with '-E -dD', I get:
# 57 "/usr/src/sys/contrib/zlib/crc32.c"
#define N 5
# 83 "/usr/src/sys/contrib/zlib/crc32.c"
#define W 8
# 97 "/usr/src/sys/contrib/zlib/crc32.c"
#undef W

Working through the various tests:
- Z_TESTW is undefined
- MAKECRCH is undefined
- __aarch64__ is defined
- Z_U8 is undefined
- Z_U4 is undefined

Z_U8 sounds like it should be defined on a 64-bit arch and there's logic in
sys/contrib/zlib/zutil.h:45-54 to do so but:
- Z_U8 is not predefined
- Z_SOLO is defined at sys/contrib/zlib/zconf.h:13 because it's in the kernel.

The backup Z_U4 definition at sys/contrib/zlib/zconf.h:423:432 is likewise
bypassed because Z_SOLO is defined.

I believe that the correct fix for arm64 is along the lines of:
  #define Z_U8 unsigned long
but I'm not sure how to weave that into the fairly complex mess of
conditionals.  Could you please look into the logic for arm64.

And, whilst I haven't yet checked, I suspect that the lack of Z_U4 and
Z_U8 definitions within the kernel is at least a misconfiguration on all
architecture, even if it only actively breaks the build on arm64.

-- 
Peter Jeremy