From patchwork Thu Apr 25 18:23:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 89014 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7AAE13858289 for ; Thu, 25 Apr 2024 18:24:01 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id A22C33858D20 for ; Thu, 25 Apr 2024 18:23:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A22C33858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A22C33858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714069409; cv=none; b=SAMaIlPBnkqKPVkmMyNj/Zg8Cnn5prA8V7mbULYmz1sc/WNkkyvRGop4erKt6gS1QMiGYu5SIz2cWRtVfr0krXfOq6Cwo19N9gZu2yVRX/94fjBLc2APQJ0FZt62NO2aZDsuFnHY2FnkbsejfhN+2HzZQks4poVeH9FI3a2Hu+I= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714069409; c=relaxed/simple; bh=48Lwr1co1+u4RFO7SJ07s6TuC5cSgzKux8r6kKsenhw=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=ji25ckqkxq7SaKn6rbW/elS+d7FYRLDuv7ISlTvwu5pTfLnQJQApglNx+mYHNU3EP3k5jpzr/SAx/J+O7DGlqhaiPI/zg1LyaKOcbbTwrTtjY0I9xGFiuyReTCpY/cuk+cTamL4T92Lrm3r9cnsOlkBKE9ghsrtM/yBQ4Nz2Ys4= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1714069406; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=j51GUuTIrjj2z9g2YbUqXiuKN0rATOtVeO+r/Iw03Ls=; b=TBg6mfSpKE1ujmg3zTYE1sykhYcFMBdg7BW8oK6qxzH4H3ZUX3LwAApSMHruueBOPelnHI lD/W4exl3AYE7saHbKzh4YrfAkvSm50KG6yePcYOKARoRIOjpdBaQo4Z4KfwpJPb7oCg00 TEmQ0rb5HUZcZ7J/VrjitOLq+lp22gA= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-645-JSAs70atOVOQ8n29DSxTqQ-1; Thu, 25 Apr 2024 14:23:23 -0400 X-MC-Unique: JSAs70atOVOQ8n29DSxTqQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A608D299E751; Thu, 25 Apr 2024 18:23:22 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.45.224.5]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 645BAC01595; Thu, 25 Apr 2024 18:23:22 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 43PINK13038072 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 25 Apr 2024 20:23:20 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 43PINKZK038071; Thu, 25 Apr 2024 20:23:20 +0200 Date: Thu, 25 Apr 2024 20:23:20 +0200 From: Jakub Jelinek To: Richard Biener Cc: gcc-patches@gcc.gnu.org, Jonathan Wakely , Florian Weimer Subject: [PATCH] libgcc: Don't use weakrefs for glibc 2.34 Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Jakub Jelinek Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org 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 * gthr.h (GTHREAD_USE_WEAK): Redefine to 0 for GLIBC 2.34 or later. Jakub --- 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