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

From: Xin Li <delphij_at_delphij.net>
Date: Sun, 03 Apr 2022 06:05:12 UTC

On 4/2/22 17:40, Peter Jeremy wrote:
> 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.

This was reported at 
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=262977

Would you mind sharing additional information about your build? (e.g. 
are you using some special compiling options, the kernel configuration, 
etc.)

This doesn't appear to be reproducible on ref14-aarch (I've added 
'options ZFS' to GENERIC and verified that crc32.c did get compiled 
during the process), nor does it show up in `make tinderbox` which was 
part of my testing.

In the meantime, could you help to test if the attached patch fixes the 
issue for you?  (Because I can't reproduce the issue, I can only verify 
that the build would work before and after the patch, but that's not 
quite useful...)

Cheers,