Pádraig Brady <[email protected]> writes:

> On 22/09/2025 19:39, Sam James wrote:
>> Hi,
>> We had a report downstream in Gentoo at
>> https://bugs.gentoo.org/959467
>> of a build failure for coreutils when pasisng -mno-pclmul.
>> Ionen's analysis on the bug seems good to me, so quoting that:
>> """
>> Haven't looked all that in-depth, but I wonder why src/cksum.c checks for 
>> gnulib's GL_CRC_X86_64_PCLMUL at all, and also why it manages to be set?
>
> cksum.c checks GL_CRC_X86_64_PCLMUL only so it prints appropriate --debug 
> info.
> You could remove the "|| GL_CRC_X86_64_PCLMUL" clause and just loose that 
> minor
> feature with `cksum -a crc32b`

Ah, thanks. Done that then in the workaround downstream.

>> coreutils own's pclmul check to set USE_PCLMUL_CRC32 does:
>>      ac_save_CFLAGS=$CFLAGS
>>      CFLAGS="-mavx -mpclmul $CFLAGS"
>> CFLAGS here has -mno-pclmul and comes after -mpclmul, so as
>> expected:
>>      checking if vmull intrinsic exists... no
>>      checking if pclmul intrinsic exists... no
>>      checking if avx2 pclmul intrinsic exists... no
>>      checking if avx512 pclmul intrinsic exists... no
>> But then there is another (lone) check, done by gnulib's
>> m4/crc-x86_64.m4 which pass for some reason (despite i686 and
>> -mno-pclmul) and sets GL_CRC_X86_64_PCLMUL:
>>      checking if pclmul intrinsic exists... yes
>
> Well that should be fixed anyway.
>
>> Then pclmul_supported function has:
>>      # if USE_PCLMUL_CRC32 || GL_CRC_X86_64_PCLMUL
>> And finally src/cksum_pclmul.c is only built if USE_PCLMUL_CRC32,
>> while GL_CRC_X86_64_PCLMUL builds lib/crc-x86_64-pclmul.c (I see it
>> in the build.log)
>> However crc-x86_64-pclmul.c does not define cksum_pclmul, and
>> pclmul_supported does not use anything from that crc-x86_64-pclmul.c
>> that I can see? I could be missing something but the simple fix may be
>> to just drop the "|| GL_CRC_X86_64_PCLMUL" check.
>> """
>> I can reproduce it with e.g. coreutils-9.8 with:
>
> I think you would have seen the same with coreutils-9.7

Yes, to be clear, we did. I was just mentioning it such as to say the
bug isn't obsolete ;)

>> $ ./configure CFLAGS="-march=westmere -mno-aes -mno-avx -mno-pclmul -O2 
>> -pipe"
>> $ make
>> /usr/lib/gcc/x86_64-pc-linux-gnu/16/../../../../x86_64-pc-linux-gnu/bin/ld: 
>> src/cksum-cksum.o: in function `pclmul_supported':
>> cksum.c:(.text+0x2c6): undefined reference to `cksum_pclmul'
>> collect2: error: ld returned 1 exit status
>> make[2]: *** [Makefile:11791: src/cksum] Error 1
> Note the gl_cv_crc_pclmul and utils_cv_pclmul_intrinsic_exists configure vars
> are higher level ways to configure this feature in the coreutils build.

Passing -mno-pclmul is natural for users, looking at autoconf cache
variables isn't for many, though I'll mention it as an option.

>
> cheers,
> Padraig

thanks,
sam



Reply via email to