public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely@redhat.com>
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]
Date: Mon, 9 Nov 2020 14:31:05 +0000	[thread overview]
Message-ID: <20201109143105.GQ503596@redhat.com> (raw)
In-Reply-To: <20201105180311.GH503596@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1184 bytes --]

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.



[-- Attachment #2: patch.txt --]
[-- Type: text/x-patch, Size: 1853 bytes --]

commit 0af3930a497e022597a08fa1bcef5e453bfa636f
Author: Jonathan Wakely <jwakely@redhat.com>
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)

  reply	other threads:[~2020-11-09 14:31 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-05 18:01 [committed 1/2] libstdc++: Export basic_stringbuf constructor " Jonathan Wakely
2020-11-05 18:03 ` [committed 1/2] libstdc++: Fix multiple definitions of std::exception_ptr functions " Jonathan Wakely
2020-11-09 14:31   ` Jonathan Wakely [this message]
2020-11-06 10:56 ` [committed 1/2] libstdc++: Export basic_stringbuf constructor " Rainer Orth
2020-11-06 20:15   ` Jonathan Wakely

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201109143105.GQ503596@redhat.com \
    --to=jwakely@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=libstdc++@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).