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 [63.128.21.124]) by sourceware.org (Postfix) with ESMTP id C283C3851C3E for ; Mon, 9 Nov 2020 14:31:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org C283C3851C3E Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-314--2Umw-PrPWWMPIVVj4tcdw-1; Mon, 09 Nov 2020 09:31:08 -0500 X-MC-Unique: -2Umw-PrPWWMPIVVj4tcdw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0904C10B9CA0; Mon, 9 Nov 2020 14:31:07 +0000 (UTC) Received: from localhost (unknown [10.33.36.44]) by smtp.corp.redhat.com (Postfix) with ESMTP id AE824100238C; Mon, 9 Nov 2020 14:31:06 +0000 (UTC) Date: Mon, 9 Nov 2020 14:31:05 +0000 From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: Re: [committed 1/2] libstdc++: Fix multiple definitions of std::exception_ptr functions [PR 97729] Message-ID: <20201109143105.GQ503596@redhat.com> References: <20201105180152.GA3511218@redhat.com> <20201105180311.GH503596@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201105180311.GH503596@redhat.com> X-Clacks-Overhead: GNU Terry Pratchett X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: multipart/mixed; boundary="soWJpSPh+l8Y6Fy7" Content-Disposition: inline X-Spam-Status: No, score=-14.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_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libstdc++@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++ mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Nov 2020 14:31:12 -0000 --soWJpSPh+l8Y6Fy7 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline On 05/11/20 18:03 +0000, Jonathan Wakely wrote: >This fixes some multiple definition errors caused by the changes for >PR libstdc++/90295. The previous solution for inlining the members of >std::exception_ptr but still exporting them from the library was to >suppress the 'inline' keyword on those functions when compiling >libsupc++/eh_ptr.cc, so they get defined in that file. That produces ODR >violations though, because there are now both inline and non-inline >definitions in the library, due to the use of std::exception_ptr in >other files sucg as src/c++11/future.cc. > >The new solution is to define all the relevant members as 'inline' >unconditionally, but use __attribute__((used)) to cause definitions to >be emitted in libsupc++/eh_ptr.cc as before. This doesn't quite work >however, because PR c++/67453 means the attribute is ignored on >constructors and destructors. As a workaround, the old solution >(conditionally inline) is still used for those members, but they are >given the always_inline attribute so that they aren't emitted in >src/c++11/future.o as inline definitions. That workaround can be removed now. Tested powerpc64le-linux. Committed to trunk. --soWJpSPh+l8Y6Fy7 Content-Type: text/x-patch; charset=us-ascii Content-Disposition: attachment; filename="patch.txt" commit 0af3930a497e022597a08fa1bcef5e453bfa636f Author: Jonathan Wakely Date: Mon Nov 9 10:16:07 2020 libstdc++: Use 'inline' consistently in std::exception_ptr [PR 97729] With PR c++/67453 fixed we can rely on the 'used' attribute to emit inline constructors and destructors in libsupc++/eh_ptr.cc. This means we don't need to suppress the 'inline' keyword on them in that file, and don't need to force 'always_inline' on them in other files. libstdc++-v3/ChangeLog: PR libstdc++/97729 * libsupc++/exception_ptr.h (exception_ptr::exception_ptr()) (exception_ptr::exception_ptr(const exception_ptr&)) (exception_ptr::~exception_ptr()): Remove 'always_inline' attributes. Use 'inline' unconditionally. diff --git a/libstdc++-v3/libsupc++/exception_ptr.h b/libstdc++-v3/libsupc++/exception_ptr.h index 001343ac0498..6ae4d4ca944d 100644 --- a/libstdc++-v3/libsupc++/exception_ptr.h +++ b/libstdc++-v3/libsupc++/exception_ptr.h @@ -174,19 +174,13 @@ namespace std }; _GLIBCXX_EH_PTR_USED -#ifndef _GLIBCXX_EH_PTR_COMPAT - __attribute__((__always_inline__)) // XXX see PR 97729 inline -#endif exception_ptr::exception_ptr() _GLIBCXX_NOEXCEPT : _M_exception_object(0) { } _GLIBCXX_EH_PTR_USED -#ifndef _GLIBCXX_EH_PTR_COMPAT - __attribute__((__always_inline__)) inline -#endif exception_ptr::exception_ptr(const exception_ptr& __other) _GLIBCXX_NOEXCEPT : _M_exception_object(__other._M_exception_object) { @@ -195,10 +189,7 @@ namespace std } _GLIBCXX_EH_PTR_USED -#ifndef _GLIBCXX_EH_PTR_COMPAT - __attribute__((__always_inline__)) inline -#endif exception_ptr::~exception_ptr() _GLIBCXX_USE_NOEXCEPT { if (_M_exception_object) --soWJpSPh+l8Y6Fy7--