bug-coreutils@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
From: Bruno Haible <bruno@clisp.org>
To: 65276@debbugs.gnu.org
Subject: bug#65276: Build failure with gcc < 4.8
Date: Mon, 14 Aug 2023 01:46:17 +0200	[thread overview]
Message-ID: <5665019.lgHvMVqyjX@nimes> (raw)

[-- Attachment #1: Type: text/plain, Size: 1362 bytes --]

Building the current coreutils on GNU/kFreeBSD 7, I get link errors:

  CCLD     src/cksum
src/cksum-cksum.o: In function `pclmul_supported':
/home/bruno/coreutils-2023-08-13/build-64/../src/cksum.c:149: undefined reference to `__builtin_cpu_supports'
/home/bruno/coreutils-2023-08-13/build-64/../src/cksum.c:150: undefined reference to `__builtin_cpu_supports'
collect2: error: ld returned 1 exit status
make[2]: *** [src/cksum] Error 1
  CCLD     src/wc
src/wc.o: In function `avx2_supported':
/home/bruno/coreutils-2023-08-13/build-64/../src/wc.c:150: undefined reference to `__builtin_cpu_supports'
collect2: error: ld returned 1 exit status
make[2]: *** [src/wc] Error 1

The reason is that the __builtin_cpu_supports function does not exist
(since the gcc version is 4.7.2 and __builtin_cpu_supports was only
introduced in gcc 4.8), but the configure test succeeds: Compiling this file
=========================== foo.c ===========================
#include <x86intrin.h>

int
main (void)
{
  return __builtin_cpu_supports ("pclmul");
}
=============================================================
merely produces warnings:
$ gcc -c -Wall foo.c
foo.c: In function ‘main’:
foo.c:6:3: warning: implicit declaration of function ‘__builtin_cpu_supports’ [-Wimplicit-function-declaration]

The attached patch fixes it.


[-- Attachment #2: 0001-cksum-wc-Fix-link-errors-with-gcc-4.8.patch --]
[-- Type: text/x-patch, Size: 964 bytes --]

From a57d40e3f6997845ce88be6f40813b1b26cb6e16 Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Mon, 14 Aug 2023 01:45:39 +0200
Subject: [PATCH] cksum,wc: Fix link errors with gcc < 4.8

* configure.ac: Attempt to link, not only compile, the test programs
with __builtin_cpu_supports.
---
 configure.ac | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index 786ce81a5..5e5a55dab 100644
--- a/configure.ac
+++ b/configure.ac
@@ -519,7 +519,7 @@ ac_c_werror_flag=$cu_save_c_werror_flag
 ac_save_CFLAGS=$CFLAGS
 CFLAGS="-mavx -mpclmul $CFLAGS"
 AC_MSG_CHECKING([if pclmul intrinsic exists])
-AC_COMPILE_IFELSE(
+AC_LINK_IFELSE(
   [AC_LANG_SOURCE([[
     #include <x86intrin.h>
 
@@ -548,7 +548,7 @@ CFLAGS=$ac_save_CFLAGS
 
 CFLAGS="-mavx2 $CFLAGS"
 AC_MSG_CHECKING([if avx2 intrinstics exists])
-AC_COMPILE_IFELSE(
+AC_LINK_IFELSE(
   [AC_LANG_SOURCE([[
     #include <x86intrin.h>
 
-- 
2.34.1


             reply	other threads:[~2023-08-13 23:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-13 23:46 Bruno Haible [this message]
2023-08-14 13:06 ` bug#65276: Build failure with gcc < 4.8 Pádraig Brady

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://lists.gnu.org/mailman/listinfo/bug-coreutils

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5665019.lgHvMVqyjX@nimes \
    --to=bruno@clisp.org \
    --cc=65276@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).