From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2153) id BC4D83858D20; Thu, 25 Apr 2024 18:43:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BC4D83858D20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1714070637; bh=apB5M6tHZlSI6/1c0rriZmbr4AAJB++S413eoPmPECk=; h=From:To:Subject:Date:From; b=EKuWbuEeb/OZTB8qY0gSAATjXXK9JtzJJzRazedBAmyqTbLajmSBLLmDMu9t5SurL zczbP9fgf/GTlRxJsK5royWuKMvQDO6rcfPGIrh8con98Mfsn1XJ4yjx89cQ5klRrl ZmgmupK07xzb9lA0pNZMVyRk+b09E5u227Uw9hr8= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jakub Jelinek To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-10133] libgcc: Don't use weakrefs for glibc 2.34 X-Act-Checkin: gcc X-Git-Author: Jakub Jelinek X-Git-Refname: refs/heads/master X-Git-Oldrev: c39654e7a431992773b48d61f804494b0d70855f X-Git-Newrev: fe02f6caac2d9b51ad311889e76ba0c484356ea1 Message-Id: <20240425184357.BC4D83858D20@sourceware.org> Date: Thu, 25 Apr 2024 18:43:57 +0000 (GMT) List-Id: https://gcc.gnu.org/g:fe02f6caac2d9b51ad311889e76ba0c484356ea1 commit r14-10133-gfe02f6caac2d9b51ad311889e76ba0c484356ea1 Author: Jakub Jelinek Date: Thu Apr 25 20:43:13 2024 +0200 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 * gthr.h (GTHREAD_USE_WEAK): Redefine to 0 for GLIBC 2.34 or later. Diff: --- libgcc/gthr.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/libgcc/gthr.h b/libgcc/gthr.h index 31c404250b8..53a5f0f7458 100644 --- a/libgcc/gthr.h +++ b/libgcc/gthr.h @@ -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