public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] libgcc: Don't use weakrefs for glibc 2.34
@ 2024-04-25 18:23 Jakub Jelinek
  2024-04-25 18:33 ` Richard Biener
  2024-04-29 13:44 ` Joseph Myers
  0 siblings, 2 replies; 5+ messages in thread
From: Jakub Jelinek @ 2024-04-25 18:23 UTC (permalink / raw)
  To: Richard Biener; +Cc: gcc-patches, Jonathan Wakely, Florian Weimer

Hi!

glibc 2.34 and later doesn't have separate libpthread (libpthread.so.0 is a
dummy shared library with just some symbol versions for compatibility, but
all the pthread_* APIs are in libc.so.6).
So, we don't need to do the .weakref dances to check whether a program
has been linked with -lpthread or not, in dynamically linked apps those
will be always true anyway.
In -static linking, this fixes various issues people had when only linking
some parts of libpthread.a and getting weird crashes.  A hack for that was
what e.g. some Fedora glibcs used, where libpthread.a was a library
containing just one giant *.o file which had all the normal libpthread.a
*.o files linked with -r together.

libstdc++-v3 actually does something like this already since r10-10928,
the following patch is meant to fix it even for libgfortran, libobjc and
whatever else uses gthr.h.

Bootstrapped/regtested on x86_64-linux and i686-linux (with glibc 2.35), ok
for trunk?

2024-04-25  Jakub Jelinek  <jakub@redhat.com>

	* gthr.h (GTHREAD_USE_WEAK): Redefine to 0 for GLIBC 2.34 or later.

--- libgcc/gthr.h.jj	2024-01-03 12:07:28.623363560 +0100
+++ libgcc/gthr.h	2024-04-25 12:09:39.708622613 +0200
@@ -141,6 +141,15 @@ see the files COPYING3 and COPYING.RUNTI
 #define GTHREAD_USE_WEAK 0
 #endif
 
+#ifdef __GLIBC_PREREQ
+#if __GLIBC_PREREQ(2, 34)
+/* glibc 2.34 and later has all pthread_* APIs inside of libc,
+   no need to link separately with -lpthread.  */
+#undef GTHREAD_USE_WEAK
+#define GTHREAD_USE_WEAK 0
+#endif
+#endif
+
 #ifndef GTHREAD_USE_WEAK
 #define GTHREAD_USE_WEAK 1
 #endif

	Jakub


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

* Re: [PATCH] libgcc: Don't use weakrefs for glibc 2.34
  2024-04-25 18:23 [PATCH] libgcc: Don't use weakrefs for glibc 2.34 Jakub Jelinek
@ 2024-04-25 18:33 ` Richard Biener
  2024-04-29 13:44 ` Joseph Myers
  1 sibling, 0 replies; 5+ messages in thread
From: Richard Biener @ 2024-04-25 18:33 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: gcc-patches, Jonathan Wakely, Florian Weimer



> Am 25.04.2024 um 20:24 schrieb Jakub Jelinek <jakub@redhat.com>:
> 
> Hi!
> 
> glibc 2.34 and later doesn't have separate libpthread (libpthread.so.0 is a
> dummy shared library with just some symbol versions for compatibility, but
> all the pthread_* APIs are in libc.so.6).
> So, we don't need to do the .weakref dances to check whether a program
> has been linked with -lpthread or not, in dynamically linked apps those
> will be always true anyway.
> In -static linking, this fixes various issues people had when only linking
> some parts of libpthread.a and getting weird crashes.  A hack for that was
> what e.g. some Fedora glibcs used, where libpthread.a was a library
> containing just one giant *.o file which had all the normal libpthread.a
> *.o files linked with -r together.
> 
> libstdc++-v3 actually does something like this already since r10-10928,
> the following patch is meant to fix it even for libgfortran, libobjc and
> whatever else uses gthr.h.
> 
> Bootstrapped/regtested on x86_64-linux and i686-linux (with glibc 2.35), ok
> for trunk?

Ok

Richard 

> 2024-04-25  Jakub Jelinek  <jakub@redhat.com>
> 
>    * gthr.h (GTHREAD_USE_WEAK): Redefine to 0 for GLIBC 2.34 or later.
> 
> --- libgcc/gthr.h.jj    2024-01-03 12:07:28.623363560 +0100
> +++ libgcc/gthr.h    2024-04-25 12:09:39.708622613 +0200
> @@ -141,6 +141,15 @@ see the files COPYING3 and COPYING.RUNTI
> #define GTHREAD_USE_WEAK 0
> #endif
> 
> +#ifdef __GLIBC_PREREQ
> +#if __GLIBC_PREREQ(2, 34)
> +/* glibc 2.34 and later has all pthread_* APIs inside of libc,
> +   no need to link separately with -lpthread.  */
> +#undef GTHREAD_USE_WEAK
> +#define GTHREAD_USE_WEAK 0
> +#endif
> +#endif
> +
> #ifndef GTHREAD_USE_WEAK
> #define GTHREAD_USE_WEAK 1
> #endif
> 
>    Jakub
> 

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

* Re: [PATCH] libgcc: Don't use weakrefs for glibc 2.34
  2024-04-25 18:23 [PATCH] libgcc: Don't use weakrefs for glibc 2.34 Jakub Jelinek
  2024-04-25 18:33 ` Richard Biener
@ 2024-04-29 13:44 ` Joseph Myers
  2024-04-29 15:01   ` [PATCH] libgcc: Do use weakrefs for glibc 2.34 on GNU Hurd Jakub Jelinek
  1 sibling, 1 reply; 5+ messages in thread
From: Joseph Myers @ 2024-04-29 13:44 UTC (permalink / raw)
  To: Jakub Jelinek
  Cc: Richard Biener, gcc-patches, Jonathan Wakely, Florian Weimer

On Thu, 25 Apr 2024, Jakub Jelinek wrote:

> Hi!
> 
> glibc 2.34 and later doesn't have separate libpthread (libpthread.so.0 is a
> dummy shared library with just some symbol versions for compatibility, but
> all the pthread_* APIs are in libc.so.6).

I suspect this has caused link failures in the glibc testsuite for Hurd, 
which still has separate libpthread.

https://sourceware.org/pipermail/libc-testresults/2024q2/012556.html

-- 
Joseph S. Myers
josmyers@redhat.com


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

* [PATCH] libgcc: Do use weakrefs for glibc 2.34 on GNU Hurd
  2024-04-29 13:44 ` Joseph Myers
@ 2024-04-29 15:01   ` Jakub Jelinek
  2024-04-29 18:32     ` Joseph Myers
  0 siblings, 1 reply; 5+ messages in thread
From: Jakub Jelinek @ 2024-04-29 15:01 UTC (permalink / raw)
  To: Joseph Myers, Richard Biener; +Cc: gcc-patches, Jonathan Wakely, Florian Weimer

On Mon, Apr 29, 2024 at 01:44:24PM +0000, Joseph Myers wrote:
> > glibc 2.34 and later doesn't have separate libpthread (libpthread.so.0 is a
> > dummy shared library with just some symbol versions for compatibility, but
> > all the pthread_* APIs are in libc.so.6).
> 
> I suspect this has caused link failures in the glibc testsuite for Hurd, 
> which still has separate libpthread.
> 
> https://sourceware.org/pipermail/libc-testresults/2024q2/012556.html

So like this then?  I can't really test it on Hurd, but will certainly
test on x86_64-linux/i686-linux.

2024-04-29  Jakub Jelinek  <jakub@redhat.com>

	* gthr.h (GTHREAD_USE_WEAK): Don't redefine to 0 for glibc 2.34+
	on GNU Hurd.

--- libgcc/gthr.h.jj	2024-04-25 20:43:10.555694952 +0200
+++ libgcc/gthr.h	2024-04-29 16:57:40.734062691 +0200
@@ -142,7 +142,7 @@ see the files COPYING3 and COPYING.RUNTI
 #endif
 
 #ifdef __GLIBC_PREREQ
-#if __GLIBC_PREREQ(2, 34)
+#if __GLIBC_PREREQ(2, 34) && !defined(__gnu_hurd__)
 /* glibc 2.34 and later has all pthread_* APIs inside of libc,
    no need to link separately with -lpthread.  */
 #undef GTHREAD_USE_WEAK


	Jakub


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

* Re: [PATCH] libgcc: Do use weakrefs for glibc 2.34 on GNU Hurd
  2024-04-29 15:01   ` [PATCH] libgcc: Do use weakrefs for glibc 2.34 on GNU Hurd Jakub Jelinek
@ 2024-04-29 18:32     ` Joseph Myers
  0 siblings, 0 replies; 5+ messages in thread
From: Joseph Myers @ 2024-04-29 18:32 UTC (permalink / raw)
  To: Jakub Jelinek
  Cc: Richard Biener, gcc-patches, Jonathan Wakely, Florian Weimer

On Mon, 29 Apr 2024, Jakub Jelinek wrote:

> On Mon, Apr 29, 2024 at 01:44:24PM +0000, Joseph Myers wrote:
> > > glibc 2.34 and later doesn't have separate libpthread (libpthread.so.0 is a
> > > dummy shared library with just some symbol versions for compatibility, but
> > > all the pthread_* APIs are in libc.so.6).
> > 
> > I suspect this has caused link failures in the glibc testsuite for Hurd, 
> > which still has separate libpthread.
> > 
> > https://sourceware.org/pipermail/libc-testresults/2024q2/012556.html
> 
> So like this then?  I can't really test it on Hurd, but will certainly
> test on x86_64-linux/i686-linux.
> 
> 2024-04-29  Jakub Jelinek  <jakub@redhat.com>
> 
> 	* gthr.h (GTHREAD_USE_WEAK): Don't redefine to 0 for glibc 2.34+
> 	on GNU Hurd.

Yes, this fixes the problem seem for Hurd with build-many-glibcs.py.

-- 
Joseph S. Myers
josmyers@redhat.com


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

end of thread, other threads:[~2024-04-29 18:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-25 18:23 [PATCH] libgcc: Don't use weakrefs for glibc 2.34 Jakub Jelinek
2024-04-25 18:33 ` Richard Biener
2024-04-29 13:44 ` Joseph Myers
2024-04-29 15:01   ` [PATCH] libgcc: Do use weakrefs for glibc 2.34 on GNU Hurd Jakub Jelinek
2024-04-29 18:32     ` Joseph Myers

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