]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
libiberty: Fix build with GCC < 7
authorJakub Jelinek <jakub@redhat.com>
Tue, 5 Dec 2023 22:34:01 +0000 (23:34 +0100)
committerJakub Jelinek <jakub@redhat.com>
Tue, 5 Dec 2023 22:34:01 +0000 (23:34 +0100)
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.

libiberty/ChangeLog
libiberty/configure
libiberty/configure.ac

index 3258d1a46f492c127ecf594c433d58bb7f4e4ebf..389fb14b96ee60f6639c4decfb6b93e91fe56f26 100644 (file)
@@ -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.
index d39b1b71233c43384340b41ac979d4b150247f13..291c910c9cfb8ca9d9abd51c45acd06220cb06fc 100755 (executable)
@@ -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)
index cf2c97037817829e3e3cade60009b51998008fa1..20e41859757d941df9f38ea949e227c1e4ce6d7a 100644 (file)
@@ -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)