From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 7E90E3858035 for ; Thu, 9 Nov 2023 08:21:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7E90E3858035 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 7E90E3858035 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699518076; cv=none; b=OScEDDfMxzvnZf6cTnNao0oK3HFVnmu7BgC3UWb/Tsmn+T63GEzpdqbJtiOkCSZeMqJ3NHZEPCVwfRhv4UWMa1h35rV/msrEw3cJAuVw9lu6AaJP+IZ9xY2aEU4rYENpmjNFabXP7JfY5iyihGoIhHYBQR7M6fLKSWK7wUxEYHk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699518076; c=relaxed/simple; bh=rTWWAPNRfBFLC2N2XOfpniwDydc93DIs3Hyn3zkGtGo=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=fGm2H4HZD8seM6C9ujZ+sG/tU3epshYRBDkYuoB8WY19CLn0qksG3IWxGttog58pTPgRQ0+Ln3Dc8ii34Vxf6WaLx+UL3WrPoBNFYCdU9YEpFyNODyHeU/SIPvL/QhqWNJQlbFB2BE0SHTa2RA9NTEGINHXTqJ/9ezJpiKnToMg= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699518075; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=hLLjkzL4NSN3MyfcGV4M61jrZndYHVHNO3S8KEuuQkw=; b=QE4KsefkeOM3GebZ98bHKyaSl5mVC0JLzOu1wlZfAIU6LxBM++pbOIeOE+CQF8Fo4kiFZd PWPn4yG2WYYdzztA0Sbf3jt5ereSe1CeNWpzWtyGop1X/yO9nhr2CGbCy0xtBW+k2e2ORZ yoohR2Ez4eJp143pcU8XqtEjKHTDXcs= Received: from mail-yw1-f199.google.com (mail-yw1-f199.google.com [209.85.128.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-588-elguZOWYMAaKwkE6qFMvPw-1; Thu, 09 Nov 2023 03:21:11 -0500 X-MC-Unique: elguZOWYMAaKwkE6qFMvPw-1 Received: by mail-yw1-f199.google.com with SMTP id 00721157ae682-5b1ff96d5b9so8682187b3.1 for ; Thu, 09 Nov 2023 00:21:11 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699518070; x=1700122870; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=hLLjkzL4NSN3MyfcGV4M61jrZndYHVHNO3S8KEuuQkw=; b=V2MgNnVD+17XkAYK3ejHr6abXy7ISclbpGDDIzMWhD0eiGnJv4QN0mYugYLXCmI1p5 +HPOfH/RbZbXk27qfZL8TyntgSe20oidxg3IJsgRnY/b8NvXafubP9lQh2bP8M+Djq9K QoO2P2W81EzbnT/r06rcNX5uvlsqT9b0XqTbav03fJGCaMIzmvGBHAmX2y5TXr/D4st9 6JhttdKx/SmuRtijpW7u0oubzgGbSnj0DX9LwIQLHIhhmajrGRtb9yJxJvJlQIk/N5lt FdkizPcli9UzQK6+0kz958frgR6sG1kRwMqV0wpSClNNqzz5VxLeS3CfxQ23qbRGsqho QAtg== X-Gm-Message-State: AOJu0YwkkouEtWjTrPpmBbAjroI4Lga583I0TKv3xq5wUF6Tw1J+xG2U Jq2c+JBMnI5hr3y7dSHit6h3LLoXcx3GUxbpLrYLSKooXy12EJOJI7Kdc48bKXJUhwbzG5SqZQp WDsIYRd1iM3GkmUUWuqCLgYhlp3Nlg9E= X-Received: by 2002:a81:a00b:0:b0:5a7:ba53:6544 with SMTP id x11-20020a81a00b000000b005a7ba536544mr4590657ywg.12.1699518070671; Thu, 09 Nov 2023 00:21:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IHfIX/J5Ebx0Q+YvKP+miStIqi6mHGpClgHPXVUpKCIKk7AapZEjMzG1eKDp9ALVXmKepwO7VpWtiBNyzUrchY= X-Received: by 2002:a81:a00b:0:b0:5a7:ba53:6544 with SMTP id x11-20020a81a00b000000b005a7ba536544mr4590650ywg.12.1699518070443; Thu, 09 Nov 2023 00:21:10 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Jonathan Wakely Date: Thu, 9 Nov 2023 08:20:59 +0000 Message-ID: Subject: Re: [PATCH] libsupc++: try cxa_thread_atexit_impl at runtime To: Alexandre Oliva Cc: gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org, Jason Merrill X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE,WEIRD_QUOTING autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Thu, 9 Nov 2023 at 01:56, Alexandre Oliva wrote: > > > g++.dg/tls/thread_local-order2.C fails when the toolchain is built for > a platform that lacks __cxa_thread_atexit_impl, even if the program is > built and run using that toolchain on a (later) platform that offers > __cxa_thread_atexit_impl. > > This patch adds runtime testing for __cxa_thread_atexit_impl on > platforms that support weak symbols. > > Regstrapped on x86_64-linux-gnu, also tested with gcc-13 on i686- and > x86_64-, and with ac_cv_func___cxa_thread_atexit_impl=no, that, on a > distro that lacks __cxa_thread_atexit in libc, forces the newly-added > code to be exercised, and that enabled thread_local-order2.C to pass > where the runtime libc has __cxa_thread_atexit_impl. Ok to install? Seems fine to me. Any objections, Jason? > > > for libstdc++-v3/ChangeLog > > * libsupc++/atexit_thread.cc [__GXX_WEAK__]: Add dynamic > detection of __cxa_thread_atexit_impl. > --- > libstdc++-v3/libsupc++/atexit_thread.cc | 15 ++++++++++++++- > 1 file changed, 14 insertions(+), 1 deletion(-) > > diff --git a/libstdc++-v3/libsupc++/atexit_thread.cc b/libstdc++-v3/libsupc++/atexit_thread.cc > index 9346d50f5dafe..cabd7c0a4a057 100644 > --- a/libstdc++-v3/libsupc++/atexit_thread.cc > +++ b/libstdc++-v3/libsupc++/atexit_thread.cc > @@ -138,11 +138,24 @@ namespace { > } > } > > +#if __GXX_WEAK__ > +extern "C" > +int __attribute__ ((__weak__)) > +__cxa_thread_atexit_impl (void (_GLIBCXX_CDTOR_CALLABI *func) (void *), > + void *arg, void *d); > +#endif > + > +// ??? We can't make it an ifunc, can we? > extern "C" int > __cxxabiv1::__cxa_thread_atexit (void (_GLIBCXX_CDTOR_CALLABI *dtor)(void *), > - void *obj, void */*dso_handle*/) > + void *obj, void *dso_handle) > _GLIBCXX_NOTHROW > { > +#if __GXX_WEAK__ > + if (__cxa_thread_atexit_impl) > + return __cxa_thread_atexit_impl (dtor, obj, dso_handle); > +#endif > + > // Do this initialization once. > if (__gthread_active_p ()) > { > > -- > Alexandre Oliva, happy hacker https://FSFLA.org/blogs/lxo/ > Free Software Activist GNU Toolchain Engineer > More tolerance and less prejudice are key for inclusion and diversity > Excluding neuro-others for not behaving ""normal"" is *not* inclusive >