* [committed] libstdc++: Use Clang attribute instead of __constinit
@ 2022-01-20 12:31 Jonathan Wakely
0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2022-01-20 12:31 UTC (permalink / raw)
To: libstdc++, gcc-patches
Tested powerpc64le-linux, pushed to trunk.
Clang doesn't support the __constinit extension that we use pre-C++20,
but it does have its own equivalent attribute that can be used instead.
This makes it a little easier to use Clang to build libstdc++ (which
isn't supported. but is sometimes attempted for esoteric targets).
libstdc++-v3/ChangeLog:
* src/c++11/cxx11-ios_failure.cc (__constinit): Define as
equivalent attribute for Clang.
* src/c++11/future.cc (__constinit): Likewise.
* src/c++11/system_error.cc (__constinit): Likewise.
* src/c++17/memory_resource.cc (__constinit): Likewise.
---
libstdc++-v3/src/c++11/cxx11-ios_failure.cc | 4 ++++
libstdc++-v3/src/c++11/future.cc | 4 ++++
libstdc++-v3/src/c++11/system_error.cc | 4 ++++
libstdc++-v3/src/c++17/memory_resource.cc | 4 ++++
4 files changed, 16 insertions(+)
diff --git a/libstdc++-v3/src/c++11/cxx11-ios_failure.cc b/libstdc++-v3/src/c++11/cxx11-ios_failure.cc
index ba4b1413bf9..14a7f9cfcb1 100644
--- a/libstdc++-v3/src/c++11/cxx11-ios_failure.cc
+++ b/libstdc++-v3/src/c++11/cxx11-ios_failure.cc
@@ -42,6 +42,10 @@
# error This file should not be compiled for this configuration.
#endif
+#if __has_cpp_attribute(clang::require_constant_initialization)
+# define __constinit [[clang::require_constant_initialization]]
+#endif
+
namespace
{
struct io_error_category final : std::error_category
diff --git a/libstdc++-v3/src/c++11/future.cc b/libstdc++-v3/src/c++11/future.cc
index 488ff17a1e6..c52c057ba1d 100644
--- a/libstdc++-v3/src/c++11/future.cc
+++ b/libstdc++-v3/src/c++11/future.cc
@@ -25,6 +25,10 @@
#include <future>
#include <bits/functexcept.h>
+#if __has_cpp_attribute(clang::require_constant_initialization)
+# define __constinit [[clang::require_constant_initialization]]
+#endif
+
namespace
{
struct future_error_category final : public std::error_category
diff --git a/libstdc++-v3/src/c++11/system_error.cc b/libstdc++-v3/src/c++11/system_error.cc
index 789f2b45382..7b1a5a20637 100644
--- a/libstdc++-v3/src/c++11/system_error.cc
+++ b/libstdc++-v3/src/c++11/system_error.cc
@@ -37,6 +37,10 @@
#include <windows.h>
#endif
+#if __has_cpp_attribute(clang::require_constant_initialization)
+# define __constinit [[clang::require_constant_initialization]]
+#endif
+
namespace
{
using std::string;
diff --git a/libstdc++-v3/src/c++17/memory_resource.cc b/libstdc++-v3/src/c++17/memory_resource.cc
index 5cdb35df2cd..bb6334c9694 100644
--- a/libstdc++-v3/src/c++17/memory_resource.cc
+++ b/libstdc++-v3/src/c++17/memory_resource.cc
@@ -32,6 +32,10 @@
# include <bits/move.h> // std::__exchange
#endif
+#if __has_cpp_attribute(clang::require_constant_initialization)
+# define __constinit [[clang::require_constant_initialization]]
+#endif
+
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
--
2.31.1
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-01-20 12:31 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-20 12:31 [committed] libstdc++: Use Clang attribute instead of __constinit 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).