Subject: Fix FTBFS on CentOS 8 and CentOS 8 Stream
From: Bruno Haible <[email-masked]>
To: [email-masked]
Date: Thu, 16 Jan 2025 22:14:10 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

Testing a current coreutils with a current gnulib on CentOS 8 and
CentOS 8 Stream, I see the same compilation error on both:

  CC       src/libcksum_avx512_a-cksum_avx512.o
../src/cksum_avx512.c: In function 'cksum_avx512':
../src/cksum_avx512.c:60:22: warning: implicit declaration of function '_mm512_set_epi8'; did you mean '_mm512_set1_epi8'? [-Wimplicit-function-declaration]
   shuffle_constant = _mm512_set_epi8 (0, 1, 2, 3, 4, 5, 6, 7, 8,
                      ^~~~~~~~~~~~~~~
                      _mm512_set1_epi8
../src/cksum_avx512.c:60:20: error: incompatible types when assigning to type '__m512i' {aka '__vector(8) long long int'} from type 'int'
   shuffle_constant = _mm512_set_epi8 (0, 1, 2, 3, 4, 5, 6, 7, 8,
                    ^
make[2]: *** [Makefile:20396: src/libcksum_avx512_a-cksum_avx512.o] Error 1

The cause is that USE_AVX512_CRC32 was determined to be true at configure
time, although the compiler does not support all builtin functions used
by cksum_avx512.c.

This proposed patch fixed it. I verified that on Ubuntu 24.04 and
CentOS Stream 9, USE_AVX512_CRC32 remains true.

From 9f00e68762c9457c8ef7e8fd90db102e5281de72 Mon Sep 17 00:00:00 2001
From: Bruno Haible <[email-masked]>
Date: Thu, 16 Jan 2025 22:10:26 +0100
Subject: [PATCH] build: Fix compilation error on CentOS 8 Stream

* configure.ac (USE_AVX512_CRC32): Set to false if the function
_mm512_set_epi8 does not exist.
---
 configure.ac | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/configure.ac b/configure.ac
index e3c8f4c30..bf6da2a5a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -727,6 +727,10 @@ AC_LINK_IFELSE(
     main (void)
     {
       __m512i a, b;
+      a = _mm512_set_epi8 (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+                           0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+                           0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+                           0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
       a = _mm512_clmulepi64_epi128 (a, b, 0x00);
       a = _mm512_shuffle_epi8 (a, b);
       return __builtin_cpu_supports ("avx512bw") &&
-- 
2.43.0