Subject: Re: bug#78562: Coreutils-9.7 do not build on macOS High Sierra, Version 10.13.6, because src/cksum.c: uses invalid cpu feature string for builtin

From: Pádraig Brady <[email-masked]>
Date: Sat, 24 May 2025 00:37:59 +0100

On 23/05/2025 14:20, Peter Dyballa via GNU coreutils Bug Reports wrote:
> Hello!
> 
> The compile used is Clang, Apple LLVM version 10.0.0 (clang-1000.11.45.5). The CPU built into the Mac is Intel(R) Core(TM) i7-2860QM CPU @ 2.50GHz.
> 
> The error is:
> 
> 	mv -f src/blake2/.deps/cksum-b2sum.Tpo src/blake2/.deps/cksum-b2sum.Po
> 	/usr/bin/clang  -I. -I./lib  -DHASH_ALGO_CKSUM=1 -DHAVE_CONFIG_H -Ilib -I./lib -Isrc -I./src -I/opt/local/include  -Wno-format-extra-args -Wno-tautological-constant-out-of-range-compare -pipe -Os -arch x86_64 -MT src/cksum-crctab.o -MD -MP -MF src/.deps/cksum-crctab.Tpo -c -o src/cksum-crctab.o `test -f 'src/crctab.c' || echo './'`src/crctab.c
> 	/usr/bin/clang  -I. -I./lib  -Ilib -I./lib -Isrc -I./src -I/opt/local/include -mavx512bw -mavx512f -mvpclmulqdq  -Wno-format-extra-args -Wno-tautological-constant-out-of-range-compare -pipe -Os -arch x86_64 -MT src/libcksum_avx512_a-cksum_avx512.o -MD -MP -MF src/.deps/libcksum_avx512_a-cksum_avx512.Tpo -c -o src/libcksum_avx512_a-cksum_avx512.o `test -f 'src/cksum_avx512.c' || echo './'`src/cksum_avx512.c
> 	mv -f lib/.deps/libcoreutils_a-vasnprintf.Tpo lib/.deps/libcoreutils_a-vasnprintf.Po
> 	/usr/bin/clang  -I. -I./lib  -Ilib -I./lib -Isrc -I./src -I/opt/local/include -mavx -mpclmul  -Wno-format-extra-args -Wno-tautological-constant-out-of-range-compare -pipe -Os -arch x86_64 -MT src/libcksum_pclmul_a-cksum_pclmul.o -MD -MP -MF src/.deps/libcksum_pclmul_a-cksum_pclmul.Tpo -c -o src/libcksum_pclmul_a-cksum_pclmul.o `test -f 'src/cksum_pclmul.c' || echo './'`src/cksum_pclmul.c
> 	mv -f src/.deps/cksum-crctab.Tpo src/.deps/cksum-crctab.Po
> 	src/cksum.c:190:30: error: invalid cpu feature string for builtin
> 	  bool avx512_enabled = (0 < __builtin_cpu_supports ("vpclmulqdq")
> 	                             ^                       ~~~~~~~~~~~~
> 	mv -f src/.deps/cksum-sum.Tpo src/.deps/cksum-sum.Po
> 	1 error generated.
> 	depbase=`echo src/comm.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\
> 		/usr/bin/clang  -I. -I./lib  -Ilib -I./lib -Isrc -I./src -I/opt/local/include  -Wno-format-extra-args -Wno-tautological-constant-out-of-range-compare -pipe -Os -arch x86_64 -MT src/comm.o -MD -MP -MF $depbase.Tpo -c -o src/comm.o src/comm.c &&\
> 		mv -f $depbase.Tpo $depbase.Po
> 	depbase=`echo src/cp.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\
> 		/usr/bin/clang  -I. -I./lib  -Ilib -I./lib -Isrc -I./src -I/opt/local/include  -Wno-format-extra-args -Wno-tautological-constant-out-of-range-compare -pipe -Os -arch x86_64 -MT src/cp.o -MD -MP -MF $depbase.Tpo -c -o src/cp.o src/cp.c &&\
> 		mv -f $depbase.Tpo $depbase.Po
> 	make[2]: *** [src/cksum-cksum.o] Error 1
> 	make[2]: *** Waiting for unfinished jobs....
> 	mv -f src/.deps/cksum-digest.Tpo src/.deps/cksum-digest.Po
> 	mv -f src/.deps/libcksum_pclmul_a-cksum_pclmul.Tpo src/.deps/libcksum_pclmul_a-cksum_pclmul.Po
> 	mv -f src/.deps/libcksum_avx512_a-cksum_avx512.Tpo src/.deps/libcksum_avx512_a-cksum_avx512.Po
> 	mv -f src/blake2/.deps/cksum-blake2b-ref.Tpo src/blake2/.deps/cksum-blake2b-ref.Po
> 	make[2]: Leaving directory `/opt/local/var/macports/build/_opt_mports_macports-ports_sysutils_coreutils-devel/coreutils-devel/work/coreutils-9.7'
> 
> 
> First build started with "/usr/bin/make -j8 -w all", second build with "/usr/bin/make -w all" – same failure:
> 
> 	mv -f src/blake2/.deps/cksum-b2sum.Tpo src/blake2/.deps/cksum-b2sum.Po
> 	/usr/bin/clang  -I. -I./lib  -DHASH_ALGO_CKSUM=1 -DHAVE_CONFIG_H -Ilib -I./lib -Isrc -I./src -I/opt/local/include  -Wno-format-extra-args -Wno-tautological-constant-out-of-range-compare -pipe -Os -arch x86_64 -MT src/cksum-sum.o -MD -MP -MF src/.deps/cksum-sum.Tpo -c -o src/cksum-sum.o `test -f 'src/sum.c' || echo './'`src/sum.c
> 	mv -f src/.deps/cksum-sum.Tpo src/.deps/cksum-sum.Po
> 	/usr/bin/clang  -I. -I./lib  -DHASH_ALGO_CKSUM=1 -DHAVE_CONFIG_H -Ilib -I./lib -Isrc -I./src -I/opt/local/include  -Wno-format-extra-args -Wno-tautological-constant-out-of-range-compare -pipe -Os -arch x86_64 -MT src/cksum-cksum.o -MD -MP -MF src/.deps/cksum-cksum.Tpo -c -o src/cksum-cksum.o `test -f 'src/cksum.c' || echo './'`src/cksum.c
> 	src/cksum.c:190:30: error: invalid cpu feature string for builtin
> 	  bool avx512_enabled = (0 < __builtin_cpu_supports ("vpclmulqdq")
> 	                             ^                       ~~~~~~~~~~~~
> 	1 error generated.
> 	make[2]: *** [src/cksum-cksum.o] Error 1
> 	make[2]: Leaving directory `/opt/local/var/macports/build/_opt_mports_macports-ports_sysutils_coreutils-devel/coreutils-devel/work/coreutils-9.7'
> 	make[1]: *** [all-recursive] Error 1

That's a bit surprising.
I suspect the following will avoid the issue:

diff --git a/configure.ac b/configure.ac
index 5ea280f26..de380e16b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -693,8 +693,9 @@ AC_LINK_IFELSE(
                             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") &&
-        __builtin_cpu_supports ("avx512f");
+      return __builtin_cpu_supports ("vpclmulqdq")
+             && __builtin_cpu_supports ("avx512bw")
+             && __builtin_cpu_supports ("avx512f");
      }
    ]])
    ],[