From patchwork Mon Jan 9 13:05:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 90439 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp71071qgi; Mon, 9 Jan 2017 05:06:26 -0800 (PST) X-Received: by 10.99.113.82 with SMTP id b18mr146591020pgn.118.1483967186225; Mon, 09 Jan 2017 05:06:26 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id n8si88577514pgc.160.2017.01.09.05.06.25 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Jan 2017 05:06:26 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-445679-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-return-445679-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-445679-patch=linaro.org@gcc.gnu.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:references:mime-version:content-type :in-reply-to; q=dns; s=default; b=GdUbXcE8WhLOcEyFL4sLY7Bt3vTPxe gWpAjjGUp92Y3iWqbAtNAXOPuGIiC5LJlSURqlKfFs00LkgOYI1V6mrTYcmDiPBr D8ZGu6esxEZYXMWuP8KswCmsi/8pOyEJvHMB0wc7ikFFp3eh9qMsNHDxPEidhHMs W44/Bw3X/vxes= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:references:mime-version:content-type :in-reply-to; s=default; bh=D30HRTZOdihlJHEbYWCl/H7AXuo=; b=WrEn WKxFnRFSPRNHKD18FtBu6yIslR8d9U2cJoL51VN83B8GrxiIONMro2w7HlGVlLoc XySPhIPnXuWxZKKJy59+9i3AAQyEkdQTJXDgH6ZRBcKqF/sO3EsERwcyMQo1iC3s FXkq+bDTadOiUeKWFZPOW0ih14rjkpI+Ydv4GXw= Received: (qmail 80071 invoked by alias); 9 Jan 2017 13:06:10 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 79959 invoked by uid 89); 9 Jan 2017 13:06:09 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-5.1 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=destruction, our X-Spam-User: qpsmtpd, 2 recipients X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 09 Jan 2017 13:05:59 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 18EAC81F01; Mon, 9 Jan 2017 13:05:59 +0000 (UTC) Received: from localhost (ovpn-116-26.ams2.redhat.com [10.36.116.26]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v09D5vfp017006; Mon, 9 Jan 2017 08:05:58 -0500 Date: Mon, 9 Jan 2017 13:05:56 +0000 From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: Re: [PATCH] PR78968 add configure check for __cxa_thread_atexit in libc Message-ID: <20170109130556.GH13348@redhat.com> References: <20170104154256.GA12632@redhat.com> <20170106170622.GF2966@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20170106170622.GF2966@redhat.com> X-Clacks-Overhead: GNU Terry Pratchett User-Agent: Mutt/1.7.1 (2016-10-04) On 06/01/17 17:06 +0000, Jonathan Wakely wrote: >On 04/01/17 15:42 +0000, Jonathan Wakely wrote: >>FreeBSD 11 adds __cxa_thread_atexit to libc, so we should use that >>instead of defining our own inferior version. This also avoids >>multiple definitions of the symbol. >> >> PR libstdc++/78968 >> * config.h.in: Regenerate. >> * configure: Likewise. >> * configure.ac: Check for __cxa_thread_atexit. >> * libsupc++/atexit_thread.cc [_GLIBCXX_HAVE___CXA_THREAD_ATEXIT]: >> Don't define __cxa_thread_atexit if libc provides it. >> >>Tested powerpc64le-linux, committed to trunk. > >This adds the check for freebsd cross-compilers. Tested by building >x86_64-unknown-freebsd11.0 on x86_64-uknown-linux-gnu. > >Committed to trunk. And this adjusts the testsuite so that the test which depends on correct thread_local destruction order runs for FreeBSD. Tested x86_64-linux and x86_64-freebsd11. Committed to trunk. commit 9d592302e39c785eb27beb982768816ad60d6bc8 Author: Jonathan Wakely Date: Mon Jan 9 11:42:21 2017 +0000 Define testsuite macro for correct thread_local destructors * testsuite/30_threads/condition_variable/members/3.cc: Use new macro to detect correct thread_local destructors. * testsuite/util/testsuite_hooks.h (CORRECT_THREAD_LOCAL_DTORS): Define. diff --git a/libstdc++-v3/testsuite/30_threads/condition_variable/members/3.cc b/libstdc++-v3/testsuite/30_threads/condition_variable/members/3.cc index 3f6885d..cedb2ab 100644 --- a/libstdc++-v3/testsuite/30_threads/condition_variable/members/3.cc +++ b/libstdc++-v3/testsuite/30_threads/condition_variable/members/3.cc @@ -24,6 +24,7 @@ #include #include #include +#include std::mutex mx; std::condition_variable cv; @@ -40,12 +41,12 @@ void func() { std::unique_lock lock{mx}; std::notify_all_at_thread_exit(cv, std::move(lock)); -#if _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL +#if CORRECT_THREAD_LOCAL_DTORS // Correct order of thread_local destruction needs __cxa_thread_atexit_impl - static thread_local Inc inc; -#else - Inc inc; + // or similar support from libc. + static thread_local #endif + Inc inc; } int main() diff --git a/libstdc++-v3/testsuite/util/testsuite_hooks.h b/libstdc++-v3/testsuite/util/testsuite_hooks.h index 6baff15..6f064a4 100644 --- a/libstdc++-v3/testsuite/util/testsuite_hooks.h +++ b/libstdc++-v3/testsuite/util/testsuite_hooks.h @@ -81,6 +81,12 @@ # define THROW(X) noexcept(false) #endif +#if _GLIBCXX_HAVE___CXA_THREAD_ATEXIT || _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL +// Correct order of thread_local destruction needs __cxa_thread_atexit_impl +// or similar support from libc. +# define CORRECT_THREAD_LOCAL_DTORS 1 +#endif + namespace __gnu_test { // All macros are defined in GLIBCXX_CONFIGURE_TESTSUITE and imported