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 AC695383F865 for ; Thu, 11 Feb 2021 17:29:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org AC695383F865 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-264-Pdoq5XedO9a7n54MoRcCuQ-1; Thu, 11 Feb 2021 12:29:24 -0500 X-MC-Unique: Pdoq5XedO9a7n54MoRcCuQ-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 9DDA11020C20; Thu, 11 Feb 2021 17:29:23 +0000 (UTC) Received: from localhost (unknown [10.33.36.155]) by smtp.corp.redhat.com (Postfix) with ESMTP id 41E6E10021AA; Thu, 11 Feb 2021 17:29:23 +0000 (UTC) Date: Thu, 11 Feb 2021 17:29:22 +0000 From: Jonathan Wakely To: =?iso-8859-1?Q?Fran=E7ois?= Dumont Cc: "libstdc++@gcc.gnu.org" , gcc-patches Subject: Re: [PATCH] Fix version namespace build Message-ID: <20210211172922.GE3008@redhat.com> References: MIME-Version: 1.0 In-Reply-To: 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: text/plain; charset=iso-8859-1; format=flowed Content-Disposition: inline Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-13.6 required=5.0 tests=BAYES_00, BODY_8BITS, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=unavailable 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: Thu, 11 Feb 2021 17:29:28 -0000 On 11/02/21 15:23 +0000, Jonathan Wakely wrote: >On 09/02/21 22:05 +0100, François Dumont via Libstdc++ wrote: >>    libstdc++: Fix versioned namespace build >> >>    libstdc++-v3/ChangeLog: >> >>            * libsupc++/eh_ptr.cc (exception_ptr(__safe_bool)): Define if >>            _GLIBCXX_EH_PTR_COMPAT is defined. >>            (exception_ptr::_M_safe_bool_dummy()): Likewise. >>            (exception_ptr::operator!()): Likewise. >>            (exception_ptr::opeerator __safe_bool()): Likewise. >> >>Ok to commit ? > >No, this is not correct. Those functions are declared in the >header if included from C++98 code: > >#if (__cplusplus < 201103L) || defined (_GLIBCXX_EH_PTR_COMPAT) > typedef void (exception_ptr::*__safe_bool)(); > > // For construction from nullptr or 0. > exception_ptr(__safe_bool) _GLIBCXX_USE_NOEXCEPT; >#endif > >With your change, C++98 code that calls those functions will be unable >to link to libstdc++.so.8 because the functions won't be defined in >the library. > >The simplest fix would be to revert this change: > >--- a/libstdc++-v3/libsupc++/eh_ptr.cc >+++ b/libstdc++-v3/libsupc++/eh_ptr.cc >@@ -25,7 +25,12 @@ > #include > #include "eh_atomics.h" > >+#if ! _GLIBCXX_INLINE_VERSION >+// This macro causes exception_ptr to declare an older API (with corresponding >+// definitions in this file) and to mark some inline functions as "used" so >+// that definitions will be emitted in this translation unit. > #define _GLIBCXX_EH_PTR_COMPAT >+#endif > > #include > #include > >But that leaves the unwanted operator== definitions in libstdc++.so.8 >so the attached patch (only tested with unversioned namespace) is >probably what we want to do. Does it fix the problem? I've now tested the patch below and committed it. >diff --git a/libstdc++-v3/libsupc++/eh_ptr.cc b/libstdc++-v3/libsupc++/eh_ptr.cc >index 5d8ac1d879a..5c4685606fe 100644 >--- a/libstdc++-v3/libsupc++/eh_ptr.cc >+++ b/libstdc++-v3/libsupc++/eh_ptr.cc >@@ -25,11 +25,15 @@ > #include > #include "eh_atomics.h" > >-#if ! _GLIBCXX_INLINE_VERSION > // This macro causes exception_ptr to declare an older API (with corresponding >-// definitions in this file) and to mark some inline functions as "used" so >-// that definitions will be emitted in this translation unit. >+// definitions in this file). > #define _GLIBCXX_EH_PTR_COMPAT >+ >+#if ! _GLIBCXX_INLINE_VERSION >+// This macro causes some inline functions in exception_ptr to be marked >+// as "used" so that definitions will be emitted in this translation unit. >+// We need this because those functions were not inline in previous releases. >+#define _GLIBCXX_EH_PTR_RELOPS_COMPAT > #endif > > #include >diff --git a/libstdc++-v3/libsupc++/exception_ptr.h b/libstdc++-v3/libsupc++/exception_ptr.h >index 6d41b34fabe..9943668d9b3 100644 >--- a/libstdc++-v3/libsupc++/exception_ptr.h >+++ b/libstdc++-v3/libsupc++/exception_ptr.h >@@ -39,7 +39,7 @@ > #include > #include > >-#ifdef _GLIBCXX_EH_PTR_COMPAT >+#ifdef _GLIBCXX_EH_PTR_RELOPS_COMPAT > # define _GLIBCXX_EH_PTR_USED __attribute__((__used__)) > #else > # define _GLIBCXX_EH_PTR_USED >@@ -153,7 +153,7 @@ namespace std > #endif > > #if __cpp_impl_three_way_comparison >= 201907L \ >- && ! defined _GLIBCXX_EH_PTR_COMPAT >+ && ! defined _GLIBCXX_EH_PTR_RELOPS_COMPAT > friend bool > operator==(const exception_ptr&, const exception_ptr&) noexcept = default; > #else