From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yw1-x1136.google.com (mail-yw1-x1136.google.com [IPv6:2607:f8b0:4864:20::1136]) by sourceware.org (Postfix) with ESMTPS id 54FFC3860760 for ; Thu, 9 Nov 2023 01:56:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 54FFC3860760 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 54FFC3860760 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::1136 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699494965; cv=none; b=mBoSM0RosUO5lp24qGcbztliZYCtFYJfOfMuPKI4f5iQ1ZKTPRXJwDKCaJ6tvXni/KLEaXEE2uJsyB38D6h39GK0s61P2/CVoptpgETYoqdXS/Bu7q5xC2GOYqBBDkwvNBPjY3LImzRR4QJLaC4RI8MYjiyLTH5WBsER+cgjgOE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699494965; c=relaxed/simple; bh=j4GV4/seTg+Y+1bx18kPxhDNx9A7gNcADzfO+cv/3b4=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=hSjsQkjFKxuOGv2x0mh7j9xzpFItU7Br5yc/CaZveaXb6YnnMgI5gX+uJMLOML1vWhDt7eTVZ4TvSuItFwXjwVNKLRjoRP9b3IgUKn+cHw8bK9WKnXrOi+zxG4rUyZNVO5UNqG4VZPBEVREkYlGaiLtYhRXih7WvskRwbUmwlJQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-yw1-x1136.google.com with SMTP id 00721157ae682-5be8f04585cso3654997b3.1 for ; Wed, 08 Nov 2023 17:56:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1699494959; x=1700099759; darn=gcc.gnu.org; h=mime-version:user-agent:message-id:date:organization:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=IVB4qnLIfz6IJ7MHenZ4AhD+HQt2hFqgWsLcMY/uK0A=; b=jXo9MK9LRmRVxio6Sv2w1KD7ZANAbu6nFzDxY8eEYusD2aCqwj0jR1AaxcS0Fy7m0y JrHt70DkGsoTNUMPtEG5bt+Hp0CkHCUBGTwmRJD2n3cpKN/a+87iTvmrwdB2m1kbe49+ +ALyiWnzq4e71erNLiqrvOKds4YdLDi+emeTQ3MpIsT09EpVSMar7C6g0qwm2eLO2WmI PQqJJJoG7MPXe3PgMC7VjS0Z66HsZqmRNXPwGXU65hrFmJiiNoYOtNaoWb9/ZAN5E3p+ wE3jf3se+02CRsmDXz1mMuUtwzOc0QAdGLdgVCI5+accYtdco9s9+xUohWXOT70WrrYK yLxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699494959; x=1700099759; h=mime-version:user-agent:message-id:date:organization:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=IVB4qnLIfz6IJ7MHenZ4AhD+HQt2hFqgWsLcMY/uK0A=; b=oU6h2BcHYVqRVtF76PGFEy8QigvF94eMKi8gZJrYZbcVItesHRHzbCaBYHyPdxPZjc 5I+rHabGErABwGpD3HtHb1zZSCf9UQdUD9AmfYWor8SjYRoZkmhlddVdnj5iVAYYRyJt 3yx6RtkWhdcKjdhwhqGhO/cNBpfZxslcozsPmy1l68sMSne+rEeFd/AGvkb+smE2uwHg DXj0da9wVNR/xJ5+mhJKGFRvNhB/uk8GE+f/gAlkOEh5y80XPx5O+amA6VO7K8zfl9ux IndrpmLM1Jrn5wLNhWLvmLGQe8A77ONVd6l4q0nMFS/qcI4wW9s92wcZfSqWiAeeyEl9 vpHg== X-Gm-Message-State: AOJu0YyNEjNanhbWpEUSY99UdDWjcwPxkW06aU+fE9rU5AMDraPa28Sw H7i1SCOi4IDzbv58y3EnAiWOYg== X-Google-Smtp-Source: AGHT+IFQFIi4yMa3D9SX8qV5J6pnVJStJ+PWKK4u84QIxh7QlIP4B3Vlw+GnOhoncIt9JMB/TLbU9g== X-Received: by 2002:a0d:dbcc:0:b0:5a8:1a54:ba4b with SMTP id d195-20020a0ddbcc000000b005a81a54ba4bmr6103529ywe.13.1699494959674; Wed, 08 Nov 2023 17:55:59 -0800 (PST) Received: from free.home ([2804:7f1:2080:e9c8:ff5e:88e8:a900:d7b4]) by smtp.gmail.com with ESMTPSA id l17-20020a81d551000000b005b054a1ec5dsm7542148ywj.126.2023.11.08.17.55.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Nov 2023 17:55:59 -0800 (PST) Received: from livre (livre.home [172.31.160.2]) by free.home (8.15.2/8.15.2) with ESMTPS id 3A91torB2231594 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 8 Nov 2023 22:55:50 -0300 From: Alexandre Oliva To: gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org Subject: [PATCH] libsupc++: try cxa_thread_atexit_impl at runtime Organization: Free thinker, does not speak for AdaCore Date: Wed, 08 Nov 2023 22:55:50 -0300 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.84 X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE,WEIRD_QUOTING autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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? 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