From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yw1-x112e.google.com (mail-yw1-x112e.google.com [IPv6:2607:f8b0:4864:20::112e]) by sourceware.org (Postfix) with ESMTPS id 4B278385B512 for ; Thu, 9 Nov 2023 01:56:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4B278385B512 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 4B278385B512 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::112e ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699494966; cv=none; b=Q619krera6SYLdDy5RHycOLMGxbufijtziuwzoPCPaF659v1XBCFWKzdh7w0gMGWk/y8gSeOR+pepAe/nZ9shKFPaLmh5Nh0PHr27Ffm/tn78ue4VxyH9vKTNJgGdRW9NNhgR8gtQiHgzNPhGfbwMZr6uV1LRru72SHN00Q9p+c= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699494966; c=relaxed/simple; bh=j4GV4/seTg+Y+1bx18kPxhDNx9A7gNcADzfO+cv/3b4=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=jHJ/sO8VKFl53cyrevjJDqrBrgwFb3kxUSg9COpMnIGew5SWWHvowboTGHBCDw0asSCzZeSN6Fcr33+g7g0qjJO4ts0WjG6e7rDXJw8EmOIl0ac9oQE5y5cU1Y3qLeVujQdCofkTTkc3L7ctSHHr5CO91zLYdkz0k/GlxCdUryc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-yw1-x112e.google.com with SMTP id 00721157ae682-5a877e0f0d8so13802367b3.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=wfRrLzzvazBQL9AYf0NLjuT5dcZ5+0DiFF/RZebyx7iAo2aAGmogAf6wacDFcTCfDw bvzBC6jedvPqbJ2e9zz7tVmmfKKd1RLdL7GLES4ml97UINep03F9gIrccYszogWugHxp TtIfu61Kf/56wAVfIEpYHk5I3flBHfjszkGG3fSm7SI8frn9sQC0I6RQQGktInvmXYgd VGdv5gN5pHlSgVxKRKTyxLP4/HAxAguginBAoaBWtQkrqCiMF9kUk0Rnkx42FVTYxqbM iZcooNtxgjjmqxe6z7iBnacDk15MSyqz2xdtB5UcVu/DuJCe0WbQdP6ISs35s0JHvbho YR1g== X-Gm-Message-State: AOJu0YxpkXkDObq4lZslPptPubiYqGU0+Gvo1iCDsVJzGamWeSpMES4P kqvDxiLMm4NrvgYihG3suWU//mcFfNTBUHQwBdaS1w== 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=-13.4 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=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: 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