public inbox for binutils-cvs@sourceware.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@sourceware.org>
To: bfd-cvs@sourceware.org, gdb-cvs@sourceware.org
Subject: [binutils-gdb] libiberty: Fix build with GCC < 7
Date: Tue,  5 Dec 2023 22:34:21 +0000 (GMT)	[thread overview]
Message-ID: <20231205223421.AA7D8385840F@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=a286e98273a4a4ae260378a52f2db3cb12d1d7a4

commit a286e98273a4a4ae260378a52f2db3cb12d1d7a4
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Tue Dec 5 23:34:01 2023 +0100

    libiberty: Fix build with GCC < 7
    
    Tobias reported on IRC that the linker fails to build with GCC 4.8.5.
    In configure I've tried to use everything actually used in the sha1.c
    x86 hw implementation, but unfortunately I forgot about implicit function
    declarations.  GCC before 7 did have <cpuid.h> header and bit_SHA define
    and __get_cpuid function defined inline, but it didn't define
    __get_cpuid_count, which compiled fine (and the configure test is
    intentionally compile time only) due to implicit function declaration,
    but then failed to link when linking the linker, because
    __get_cpuid_count wasn't defined anywhere.
    
    The following patch fixes that by using what autoconf uses in AC_CHECK_DECL
    to make sure the functions are declared.
    
    2023-12-05  Jakub Jelinek  <jakub@redhat.com>
    
            * configure.ac (HAVE_X86_SHA1_HW_SUPPORT): Verify __get_cpuid and
            __get_cpuid_count are not implicitly declared.
            * configure: Regenerated.

Diff:
---
 libiberty/ChangeLog    | 6 ++++++
 libiberty/configure    | 2 ++
 libiberty/configure.ac | 2 ++
 3 files changed, 10 insertions(+)

diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog
index 3258d1a46f4..389fb14b96e 100644
--- a/libiberty/ChangeLog
+++ b/libiberty/ChangeLog
@@ -1,3 +1,9 @@
+2023-12-05  Jakub Jelinek  <jakub@redhat.com>
+
+	* configure.ac (HAVE_X86_SHA1_HW_SUPPORT): Verify __get_cpuid and
+	__get_cpuid_count are not implicitly declared.
+	* configure: Regenerated.
+
 2023-11-30  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
 
 	* configure.ac (GCC_CHECK_ASSEMBLER_HWCAP): Invoke.
diff --git a/libiberty/configure b/libiberty/configure
index d39b1b71233..291c910c9cf 100755
--- a/libiberty/configure
+++ b/libiberty/configure
@@ -7665,6 +7665,8 @@ void foo (__m128i *buf, unsigned int e, __m128i msg0, __m128i msg1)
 int bar (void)
 {
   unsigned int eax, ebx, ecx, edx;
+  (void) __get_cpuid;
+  (void) __get_cpuid_count;
   if (__get_cpuid_count (7, 0, &eax, &ebx, &ecx, &edx)
       && (ebx & bit_SHA) != 0
       && __get_cpuid (1, &eax, &ebx, &ecx, &edx)
diff --git a/libiberty/configure.ac b/libiberty/configure.ac
index cf2c9703781..20e41859757 100644
--- a/libiberty/configure.ac
+++ b/libiberty/configure.ac
@@ -769,6 +769,8 @@ void foo (__m128i *buf, unsigned int e, __m128i msg0, __m128i msg1)
 int bar (void)
 {
   unsigned int eax, ebx, ecx, edx;
+  (void) __get_cpuid;
+  (void) __get_cpuid_count;
   if (__get_cpuid_count (7, 0, &eax, &ebx, &ecx, &edx)
       && (ebx & bit_SHA) != 0
       && __get_cpuid (1, &eax, &ebx, &ecx, &edx)

                 reply	other threads:[~2023-12-05 22:34 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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

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

  git send-email \
    --in-reply-to=20231205223421.AA7D8385840F@sourceware.org \
    --to=jakub@sourceware.org \
    --cc=bfd-cvs@sourceware.org \
    --cc=gdb-cvs@sourceware.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).