public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] libiberty: Fix build with GCC < 7
@ 2023-12-05 22:06 Jakub Jelinek
  2023-12-05 22:30 ` Ian Lance Taylor
  0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2023-12-05 22:06 UTC (permalink / raw)
  To: Ian Lance Taylor, Nick Clifton; +Cc: gcc-patches, Tobias Burnus

Hi!

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.

Bootstrapped/regtested in GCC on x86_64-linux and i686-linux with GCC 12 as
system compiler (HAVE_X86_SHA1_HW_SUPPORT is defined there) and tested by
Tobias with GCC 4.8.5 (it isn't defined there anymore).

Ok for trunk (both gcc and binutils)?

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/configure.ac.jj	2023-12-01 08:10:44.877293904 +0100
+++ libiberty/configure.ac	2023-12-05 16:09:49.506323449 +0100
@@ -771,6 +771,8 @@ void foo (__m128i *buf, unsigned int e,
 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)
--- libiberty/configure.jj	2023-12-01 08:10:44.876293919 +0100
+++ libiberty/configure	2023-12-05 16:10:06.415083621 +0100
@@ -7667,6 +7667,8 @@ void foo (__m128i *buf, unsigned int e,
 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)

	Jakub


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] libiberty: Fix build with GCC < 7
  2023-12-05 22:06 [PATCH] libiberty: Fix build with GCC < 7 Jakub Jelinek
@ 2023-12-05 22:30 ` Ian Lance Taylor
  0 siblings, 0 replies; 2+ messages in thread
From: Ian Lance Taylor @ 2023-12-05 22:30 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Nick Clifton, gcc-patches, Tobias Burnus

On Tue, Dec 5, 2023 at 2:06 PM Jakub Jelinek <jakub@redhat.com> wrote:
>
> Ok for trunk (both gcc and binutils)?
>
> 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.

This is fine.  Thanks.

Ian

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-12-05 22:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-05 22:06 [PATCH] libiberty: Fix build with GCC < 7 Jakub Jelinek
2023-12-05 22:30 ` Ian Lance Taylor

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).