coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] configure.ac: fix __get_cpuid_count check to catch link fail


From: Pádraig Brady
Subject: Re: [PATCH] configure.ac: fix __get_cpuid_count check to catch link failure
Date: Mon, 10 May 2021 13:49:11 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:84.0) Gecko/20100101 Thunderbird/84.0

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]