Skip to content
Snippets Groups Projects
Commit fe02f6ca authored by Jakub Jelinek's avatar Jakub Jelinek
Browse files

libgcc: Don't use weakrefs for glibc 2.34

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.

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

	* gthr.h (GTHREAD_USE_WEAK): Redefine to 0 for GLIBC 2.34 or later.
parent c39654e7
No related branches found
No related tags found
No related merge requests found
......@@ -141,6 +141,15 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment