* [PATCH] Fix version namespace build
@ 2021-02-09 21:05 François Dumont
2021-02-11 15:23 ` Jonathan Wakely
0 siblings, 1 reply; 3+ messages in thread
From: François Dumont @ 2021-02-09 21:05 UTC (permalink / raw)
To: libstdc++, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 469 bytes --]
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 ?
François
[-- Attachment #2: version_ns.patch --]
[-- Type: text/x-patch, Size: 1052 bytes --]
diff --git a/libstdc++-v3/libsupc++/eh_ptr.cc b/libstdc++-v3/libsupc++/eh_ptr.cc
index 5d8ac1d879a..80999f52795 100644
--- a/libstdc++-v3/libsupc++/eh_ptr.cc
+++ b/libstdc++-v3/libsupc++/eh_ptr.cc
@@ -72,9 +72,12 @@ std::__exception_ptr::exception_ptr::exception_ptr(void* obj) noexcept
: _M_exception_object(obj) { _M_addref(); }
+#ifdef _GLIBCXX_EH_PTR_COMPAT
+
std::__exception_ptr::exception_ptr::exception_ptr(__safe_bool) noexcept
: _M_exception_object(nullptr) { }
+#endif
void
std::__exception_ptr::exception_ptr::_M_addref() noexcept
@@ -112,6 +115,7 @@ std::__exception_ptr::exception_ptr::_M_get() const noexcept
{ return _M_exception_object; }
+#ifdef _GLIBCXX_EH_PTR_COMPAT
// Retained for compatibility with CXXABI_1.3.
void
@@ -130,6 +134,8 @@ std::__exception_ptr::exception_ptr::operator __safe_bool() const noexcept
return _M_exception_object ? &exception_ptr::_M_safe_bool_dummy : nullptr;
}
+#endif
+
const std::type_info*
std::__exception_ptr::exception_ptr::__cxa_exception_type() const noexcept
{
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Fix version namespace build
2021-02-09 21:05 [PATCH] Fix version namespace build François Dumont
@ 2021-02-11 15:23 ` Jonathan Wakely
2021-02-11 17:29 ` Jonathan Wakely
0 siblings, 1 reply; 3+ messages in thread
From: Jonathan Wakely @ 2021-02-11 15:23 UTC (permalink / raw)
To: François Dumont; +Cc: libstdc++, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 1690 bytes --]
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 <bits/c++config.h>
#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 <exception>
#include <bits/exception_ptr.h>
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?
[-- Attachment #2: patch.txt --]
[-- Type: text/x-patch, Size: 1657 bytes --]
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 <bits/c++config.h>
#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 <exception>
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 <typeinfo>
#include <new>
-#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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Fix version namespace build
2021-02-11 15:23 ` Jonathan Wakely
@ 2021-02-11 17:29 ` Jonathan Wakely
0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Wakely @ 2021-02-11 17:29 UTC (permalink / raw)
To: François Dumont; +Cc: libstdc++, gcc-patches
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 <bits/c++config.h>
> #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 <exception>
> #include <bits/exception_ptr.h>
>
>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 <bits/c++config.h>
> #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 <exception>
>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 <typeinfo>
> #include <new>
>
>-#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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-02-11 17:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-09 21:05 [PATCH] Fix version namespace build François Dumont
2021-02-11 15:23 ` Jonathan Wakely
2021-02-11 17:29 ` Jonathan Wakely
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).