On 10/05/2021 11:34, Carl Edquist wrote:
(Was: Re: [PATCH] wc: Add AVX2 optimization when counting only lines)So, it looks like the check for avx2 support is broken - the build broke for me after the update. Seems it is doing a compile check when a link check is necessary. I was seeing this in my build: src/wc.c: In function 'avx2_supported': src/wc.c:153:13: warning: implicit declaration of function '__get_cpuid_count' [-Wimplicit-function-declaration] if (! __get_cpuid_count (7, 0, &eax, &ebx, &ecx, &edx)) ^ ... src/wc.o: In function `avx2_supported': /.../coreutils/src/wc.c:153: undefined reference to `__get_cpuid_count' collect2: error: ld returned 1 exit status Makefile:9415: recipe for target 'src/wc' failed My config.h has: #define USE_AVX2_WC_LINECOUNT 1 My config.log has: configure:77113: checking if __get_cpuid_count exists configure:77129: gcc -c -g -O2 conftest.c >&5 conftest.c: In function 'main': conftest.c:842:7: warning: implicit declaration of function '__get_cpuid_count' [-Wimplicit-function-declaration] __get_cpuid_count(7, 0, &eax, &ebx, &ecx, &edx); ^ configure:77129: $? = 0 configure:77131: result: yes ... So it looks like '__get_cpuid_count' not being declared is just treated as a warning, and so the compile test succeeds. The actual failure happens at link time. Would it be more appropriate to use AC_LINK_IFELSE instead of AC_COMPILE_IFELSE ? I tried swapping this out (as in the attached patch), and now it correctly omits the #define for USE_AVX2_WC_LINECOUNT, and wc compiles & links properly.
Indeed. I adjusted your patch to also do this for __get_cpuid(), and pushed at: https://git.sv.gnu.org/gitweb/?p=coreutils.git;a=commitdiff;h=bf483155e thanks! Pádraig
