public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
From: "François Dumont" <frs.dumont@gmail.com>
To: Jonathan Wakely <jwakely@redhat.com>
Cc: Jonathan Wakely <jwakely.gcc@gmail.com>,
	libstdc++ <libstdc++@gcc.gnu.org>
Subject: Re: [PATCH] sso-string@gnu-versioned-namespace [PR83077]
Date: Wed, 28 Feb 2024 19:37:27 +0100	[thread overview]
Message-ID: <a201a021-f9c1-4c8b-bcf9-1ee5f764fbcc@gmail.com> (raw)
In-Reply-To: <CACb0b4nmVG9xFSAnueH+BK7P8Ug3vu-0h0oy1npOQ5sjifockw@mail.gmail.com>

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

Another version with the major enhancement that COW string is not 
explicitly instantiated anymore. That's ~100ko saved in resulting lib, 
not too bad.

Note that this patch is also smaller cause I removed the regenerated 
parts from it. We got time but can you confirmed that when approved I'll 
also have to commit the regenerated files ?

François


On 17/08/2023 19:22, Jonathan Wakely wrote:
> On Sun, 13 Aug 2023 at 14:27, François Dumont via Libstdc++
> <libstdc++@gcc.gnu.org> wrote:
>> Here is the fixed patch tested in all 3 modes:
>>
>> - _GLIBCXX_USE_DUAL_ABI
>>
>> - !_GLIBCXX_USE_DUAL_ABI && !_GLIBCXX_USE_CXX11_ABI
>>
>> - !_GLIBCXX_USE_DUAL_ABI && _GLIBCXX_USE_CXX11_ABI
>>
>> I don't know what you have in mind for the change below but I wanted to
>> let you know that I tried to put COW std::basic_string into a nested
>> __cow namespace when _GLIBCXX_USE_CXX11_ABI. But it had more impact on
>> string-inst.cc so I preferred the macro substitution approach.
> I was thinking of implementing the necessary special members functions
> of __cow_string directly, so they are ABI compatible with the COW
> std::basic_string but don't actually reuse the code. That would mean
> we don't need to compile and instantiate the whole COW string just to
> use a few members from it. But that can be done later, the macro
> approach seems OK for now.
>
>> There are some test failing when !_GLIBCXX_USE_CXX11_ABI that are
>> unrelated with my changes. I'll propose fixes in coming days.
> Which tests? I run the entire testsuite with
> -D_GLIBCXX_USE_CXX11_ABI=0 several times per day and I'm not seeing
> failures.
>
> I'll review the patch ASAP, thanks for working on it.
>

[-- Attachment #2: gnu_versioned_ns_cxx11_patch.txt --]
[-- Type: text/plain, Size: 41240 bytes --]

diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
index f72bd0f45b8..28d24577c57 100644
--- a/libstdc++-v3/acinclude.m4
+++ b/libstdc++-v3/acinclude.m4
@@ -4875,13 +4875,17 @@ dnl
 AC_DEFUN([GLIBCXX_ENABLE_LIBSTDCXX_DUAL_ABI], [
   GLIBCXX_ENABLE(libstdcxx-dual-abi,$1,,[support two versions of std::string])
   if test x$enable_symvers = xgnu-versioned-namespace; then
-    # gnu-versioned-namespace is incompatible with the dual ABI.
+    # gnu-versioned-namespace is incompatible with the dual ABI...
+    AC_MSG_NOTICE([dual ABI is disabled])
     enable_libstdcxx_dual_abi="no"
-  fi
+    # ... and use the cxx11 one.
+    default_libstdcxx_abi="new"
+  else
     if test x"$enable_libstdcxx_dual_abi" != xyes; then
       AC_MSG_NOTICE([dual ABI is disabled])
       default_libstdcxx_abi="gcc4-compatible"
     fi
+  fi
   GLIBCXX_CONDITIONAL(ENABLE_DUAL_ABI, test $enable_libstdcxx_dual_abi = yes)
 ])
 
diff --git a/libstdc++-v3/config/locale/dragonfly/monetary_members.cc b/libstdc++-v3/config/locale/dragonfly/monetary_members.cc
index 6e48e45b3e7..0b0c4277718 100644
--- a/libstdc++-v3/config/locale/dragonfly/monetary_members.cc
+++ b/libstdc++-v3/config/locale/dragonfly/monetary_members.cc
@@ -39,7 +39,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
 // This file might be compiled twice, but we only want to define the members
 // of money_base once.
-#if ! _GLIBCXX_USE_CXX11_ABI
+#if ! _GLIBCXX_USE_CXX11_ABI || ! _GLIBCXX_USE_DUAL_ABI
 
   // Construct and return valid pattern consisting of some combination of:
   // space none symbol sign value
@@ -207,7 +207,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       }
     return __ret;
   }
-#endif
+#endif // ! _GLIBCXX_USE_CXX11_ABI || ! _GLIBCXX_USE_DUAL_ABI
 
   template<>
     void
diff --git a/libstdc++-v3/config/locale/generic/monetary_members.cc b/libstdc++-v3/config/locale/generic/monetary_members.cc
index 0192cb882ef..e725e8790d5 100644
--- a/libstdc++-v3/config/locale/generic/monetary_members.cc
+++ b/libstdc++-v3/config/locale/generic/monetary_members.cc
@@ -36,7 +36,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
 // This file might be compiled twice, but we only want to define the members
 // of money_base once.
-#if ! _GLIBCXX_USE_CXX11_ABI
+#if ! _GLIBCXX_USE_CXX11_ABI || ! _GLIBCXX_USE_DUAL_ABI
 
   // Construct and return valid pattern consisting of some combination of:
   // space none symbol sign value
diff --git a/libstdc++-v3/config/locale/gnu/monetary_members.cc b/libstdc++-v3/config/locale/gnu/monetary_members.cc
index 75af8e3ce42..46b2f1fc8d1 100644
--- a/libstdc++-v3/config/locale/gnu/monetary_members.cc
+++ b/libstdc++-v3/config/locale/gnu/monetary_members.cc
@@ -37,7 +37,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
 // This file might be compiled twice, but we only want to define the members
 // of money_base once.
-#if ! _GLIBCXX_USE_CXX11_ABI
+#if ! _GLIBCXX_USE_CXX11_ABI || ! _GLIBCXX_USE_DUAL_ABI
 
   // Construct and return valid pattern consisting of some combination of:
   // space none symbol sign value
@@ -205,7 +205,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       }
     return __ret;
   }
-#endif
+#endif // ! _GLIBCXX_USE_CXX11_ABI || ! _GLIBCXX_USE_DUAL_ABI
 
   extern char __narrow_multibyte_chars(const char* s, __locale_t cloc);
 
diff --git a/libstdc++-v3/config/locale/gnu/numeric_members.cc b/libstdc++-v3/config/locale/gnu/numeric_members.cc
index 3d1a88ae832..e98f548a1c4 100644
--- a/libstdc++-v3/config/locale/gnu/numeric_members.cc
+++ b/libstdc++-v3/config/locale/gnu/numeric_members.cc
@@ -39,7 +39,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   extern char __narrow_multibyte_chars(const char* s, __locale_t cloc);
 
 // This file might be compiled twice, but we only want to define this once.
-#if ! _GLIBCXX_USE_CXX11_ABI
+#if ! _GLIBCXX_USE_CXX11_ABI || ! _GLIBCXX_USE_DUAL_ABI
   char
   __narrow_multibyte_chars(const char* s, __locale_t cloc)
   {
@@ -84,7 +84,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       }
     return '\0';
   }
-#endif
+#endif // ! _GLIBCXX_USE_CXX11_ABI || ! _GLIBCXX_USE_DUAL_ABI
 
   template<>
     void
diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config
index b57e3f338e9..142ae2ff520 100644
--- a/libstdc++-v3/include/bits/c++config
+++ b/libstdc++-v3/include/bits/c++config
@@ -337,26 +337,6 @@ namespace std
 #define _GLIBCXX_USE_CXX11_ABI
 #endif
 
-#if _GLIBCXX_USE_CXX11_ABI
-namespace std
-{
-  inline namespace __cxx11 __attribute__((__abi_tag__ ("cxx11"))) { }
-}
-namespace __gnu_cxx
-{
-  inline namespace __cxx11 __attribute__((__abi_tag__ ("cxx11"))) { }
-}
-# define _GLIBCXX_NAMESPACE_CXX11 __cxx11::
-# define _GLIBCXX_BEGIN_NAMESPACE_CXX11 namespace __cxx11 {
-# define _GLIBCXX_END_NAMESPACE_CXX11 }
-# define _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_ABI_TAG_CXX11
-#else
-# define _GLIBCXX_NAMESPACE_CXX11
-# define _GLIBCXX_BEGIN_NAMESPACE_CXX11
-# define _GLIBCXX_END_NAMESPACE_CXX11
-# define _GLIBCXX_DEFAULT_ABI_TAG
-#endif
-
 // Non-zero if inline namespaces are used for versioning the entire library.
 #define _GLIBCXX_INLINE_VERSION 
 
@@ -415,7 +395,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   // Non-inline namespace for components replaced by alternates in active mode.
   namespace __cxx1998
   {
-# if _GLIBCXX_USE_CXX11_ABI
+# if _GLIBCXX_USE_CXX11_ABI && ! _GLIBCXX_INLINE_VERSION
   inline namespace __cxx11 __attribute__((__abi_tag__ ("cxx11"))) { }
 # endif
   }
@@ -445,6 +425,26 @@ _GLIBCXX_END_NAMESPACE_VERSION
 # endif
 #endif
 
+#if _GLIBCXX_USE_CXX11_ABI && ! _GLIBCXX_INLINE_VERSION
+namespace std
+{
+  inline namespace __cxx11 __attribute__((__abi_tag__ ("cxx11"))) { }
+}
+namespace __gnu_cxx
+{
+  inline namespace __cxx11 __attribute__((__abi_tag__ ("cxx11"))) { }
+}
+# define _GLIBCXX_NAMESPACE_CXX11 __cxx11::
+# define _GLIBCXX_BEGIN_NAMESPACE_CXX11 namespace __cxx11 {
+# define _GLIBCXX_END_NAMESPACE_CXX11 }
+# define _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_ABI_TAG_CXX11
+#else
+# define _GLIBCXX_NAMESPACE_CXX11
+# define _GLIBCXX_BEGIN_NAMESPACE_CXX11
+# define _GLIBCXX_END_NAMESPACE_CXX11
+# define _GLIBCXX_DEFAULT_ABI_TAG
+#endif
+
 // Macros for namespace scope. Either namespace std:: or the name
 // of some nested namespace within it corresponding to the active mode.
 // _GLIBCXX_STD_A
diff --git a/libstdc++-v3/include/bits/cow_string.h b/libstdc++-v3/include/bits/cow_string.h
index 5d81bfc1230..c62d1180e23 100644
--- a/libstdc++-v3/include/bits/cow_string.h
+++ b/libstdc++-v3/include/bits/cow_string.h
@@ -32,13 +32,14 @@
 #ifndef _COW_STRING_H
 #define _COW_STRING_H 1
 
-#if ! _GLIBCXX_USE_CXX11_ABI
-
 #include <ext/atomicity.h> // _Atomic_word, __is_single_threaded
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
-_GLIBCXX_BEGIN_NAMESPACE_VERSION
+#if _GLIBCXX_USE_CXX11_ABI
+  namespace __detail
+  {
+#endif
 
   /**
    *  @class basic_string basic_string.h <string>
@@ -3515,6 +3516,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       _M_rep()->_M_set_length_and_sharable(__new_size);
     }
 
+
   template<typename _CharT, typename _Traits, typename _Alloc>
     void
     basic_string<_CharT, _Traits, _Alloc>::
@@ -3797,8 +3799,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     }
 #endif // C++11
 
-
-_GLIBCXX_END_NAMESPACE_VERSION
+#if _GLIBCXX_USE_CXX11_ABI
+} // namespace __detail
+#endif
 } // namespace std
-#endif  // ! _GLIBCXX_USE_CXX11_ABI
 #endif  // _COW_STRING_H
diff --git a/libstdc++-v3/include/std/stdexcept b/libstdc++-v3/include/std/stdexcept
index b55c19bbfe2..b637e33ee7e 100644
--- a/libstdc++-v3/include/std/stdexcept
+++ b/libstdc++-v3/include/std/stdexcept
@@ -42,8 +42,8 @@ namespace std _GLIBCXX_VISIBILITY(default)
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
-#if _GLIBCXX_USE_DUAL_ABI
-#if _GLIBCXX_USE_CXX11_ABI
+#if _GLIBCXX_USE_DUAL_ABI || _GLIBCXX_USE_CXX11_ABI
+#if ! _GLIBCXX_DEFINE_STDEXCEPT_INSTANTIATIONS
   // Emulates an old COW string when the new std::string is in use.
   struct __cow_string
   {
@@ -62,12 +62,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     __cow_string(__cow_string&&) noexcept;
     __cow_string& operator=(__cow_string&&) noexcept;
 #endif
+    const char* c_str() const _GLIBCXX_NOEXCEPT;
   };
-
-  typedef basic_string<char> __sso_string;
-#else // _GLIBCXX_USE_CXX11_ABI
+#endif // ! _GLIBCXX_DEFINE_STDEXCEPT_INSTANTIATIONS
+#else
   typedef basic_string<char> __cow_string;
+#endif
 
+#if _GLIBCXX_USE_DUAL_ABI && ! _GLIBCXX_USE_CXX11_ABI
   // Emulates a new SSO string when the old std::string is in use.
   struct __sso_string
   {
@@ -94,10 +96,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     __sso_string& operator=(__sso_string&&) noexcept;
 #endif
   };
-#endif // _GLIBCXX_USE_CXX11_ABI
-#else  // _GLIBCXX_USE_DUAL_ABI
+#else
   typedef basic_string<char> __sso_string;
-  typedef basic_string<char> __cow_string;
 #endif
 
   /**
@@ -127,7 +127,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     logic_error& operator=(logic_error&&) noexcept;
 #endif
 
-#if _GLIBCXX_USE_CXX11_ABI || _GLIBCXX_DEFINE_STDEXCEPT_COPY_OPS
+#if _GLIBCXX_USE_CXX11_ABI || _GLIBCXX_DEFINE_STDEXCEPT_INSTANTIATIONS
     logic_error(const logic_error&) _GLIBCXX_NOTHROW;
     logic_error& operator=(const logic_error&) _GLIBCXX_NOTHROW;
 #elif __cplusplus >= 201103L
@@ -233,7 +233,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     runtime_error& operator=(runtime_error&&) noexcept;
 #endif
 
-#if _GLIBCXX_USE_CXX11_ABI || _GLIBCXX_DEFINE_STDEXCEPT_COPY_OPS
+#if _GLIBCXX_USE_CXX11_ABI || _GLIBCXX_DEFINE_STDEXCEPT_INSTANTIATIONS
     runtime_error(const runtime_error&) _GLIBCXX_NOTHROW;
     runtime_error& operator=(const runtime_error&) _GLIBCXX_NOTHROW;
 #elif __cplusplus >= 201103L
diff --git a/libstdc++-v3/python/libstdcxx/v6/printers.py b/libstdc++-v3/python/libstdcxx/v6/printers.py
index a6c2ed4599f..3870f9d10fc 100644
--- a/libstdc++-v3/python/libstdcxx/v6/printers.py
+++ b/libstdc++-v3/python/libstdcxx/v6/printers.py
@@ -1029,6 +1029,8 @@ class StdStringPrinter(printer_base):
     def __init__(self, typename, val):
         self._val = val
         self._new_string = typename.find("::__cxx11::basic_string") != -1
+        if not self._new_string:
+            self._new_string = typename.find("::" + _versioned_namespace + "basic_string") != -1
 
     def to_string(self):
         # Make sure &string works, too.
diff --git a/libstdc++-v3/src/Makefile.am b/libstdc++-v3/src/Makefile.am
index 37ba1491dea..59d3dd44e48 100644
--- a/libstdc++-v3/src/Makefile.am
+++ b/libstdc++-v3/src/Makefile.am
@@ -92,6 +92,9 @@ else
 ldbl_compat_sources =
 endif
 
+if ENABLE_SYMVERS_GNU_NAMESPACE
+ldbl_alt128_compat_sources =
+else
 if GLIBCXX_LDBL_ALT128_COMPAT
 if ENABLE_DUAL_ABI
 ldbl_alt128_compat_cxx11_sources = \
@@ -105,6 +108,7 @@ ldbl_alt128_compat_sources = \
 else
 ldbl_alt128_compat_sources =
 endif
+endif
 
 if ENABLE_SYMVERS_GNU_NAMESPACE
 cxx0x_compat_sources =
diff --git a/libstdc++-v3/src/c++11/Makefile.am b/libstdc++-v3/src/c++11/Makefile.am
index 89e20ca3b06..44bb79e3d17 100644
--- a/libstdc++-v3/src/c++11/Makefile.am
+++ b/libstdc++-v3/src/c++11/Makefile.am
@@ -48,15 +48,11 @@ basic_file.cc: ${glibcxx_srcdir}/$(BASIC_FILE_CC)
 	$(LN_S) ${glibcxx_srcdir}/$(BASIC_FILE_CC) ./$@ || true
 
 if ENABLE_DUAL_ABI
-cxx11_abi_sources = \
-	cow-locale_init.cc \
+dual_abi_sources = \
 	cow-shim_facets.cc \
-	cxx11-hash_tr1.cc \
-	cxx11-ios_failure.cc \
-	cxx11-shim_facets.cc \
-	cxx11-stdexcept.cc
+	cxx11-shim_facets.cc
 else
-cxx11_abi_sources =
+dual_abi_sources =
 endif
 
 sources_freestanding = \
@@ -68,8 +64,12 @@ sources = \
 	chrono.cc \
 	codecvt.cc \
 	condition_variable.cc \
+	cow-locale_init.cc \
 	cow-stdexcept.cc \
 	ctype.cc \
+	cxx11-hash_tr1.cc \
+	cxx11-ios_failure.cc \
+	cxx11-stdexcept.cc \
 	debug.cc \
 	functexcept.cc \
 	functional.cc \
@@ -88,20 +88,12 @@ sources = \
 	snprintf_lite.cc \
 	system_error.cc \
 	thread.cc \
-	${cxx11_abi_sources} \
+	${dual_abi_sources} \
 	${host_sources} \
 	${host_sources_extra}
 
 if ENABLE_DUAL_ABI
 extra_string_inst_sources = \
-	cow-fstream-inst.cc \
-	cow-sstream-inst.cc \
-	cow-string-inst.cc \
-	cow-string-io-inst.cc \
-	cow-wstring-inst.cc \
-	cow-wstring-io-inst.cc \
-	cxx11-locale-inst.cc \
-	cxx11-wlocale-inst.cc \
 	sso_string.cc
 else
 extra_string_inst_sources =
@@ -111,6 +103,14 @@ if ENABLE_EXTERN_TEMPLATE
 # XTEMPLATE_FLAGS = -fno-implicit-templates
 inst_sources = \
 	$(extra_string_inst_sources) \
+	cow-fstream-inst.cc \
+	cow-sstream-inst.cc \
+	cow-string-inst.cc \
+	cow-string-io-inst.cc \
+	cow-wstring-inst.cc \
+	cow-wstring-io-inst.cc \
+	cxx11-locale-inst.cc \
+	cxx11-wlocale-inst.cc \
 	ext11-inst.cc \
 	fstream-inst.cc \
 	ios-inst.cc \
diff --git a/libstdc++-v3/src/c++11/cow-fstream-inst.cc b/libstdc++-v3/src/c++11/cow-fstream-inst.cc
index bbed5a4b893..00892d704ed 100644
--- a/libstdc++-v3/src/c++11/cow-fstream-inst.cc
+++ b/libstdc++-v3/src/c++11/cow-fstream-inst.cc
@@ -29,10 +29,7 @@
 #define _GLIBCXX_USE_CXX11_ABI 0
 #include <fstream>
 
-#if ! _GLIBCXX_USE_DUAL_ABI
-# error This file should not be compiled for this configuration.
-#endif
-
+#if ! _GLIBCXX_USE_CXX11_ABI
 namespace std _GLIBCXX_VISIBILITY(default)
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
@@ -76,3 +73,4 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
+#endif
diff --git a/libstdc++-v3/src/c++11/cow-locale_init.cc b/libstdc++-v3/src/c++11/cow-locale_init.cc
index c1ea3f4f5c4..d1d947c12a5 100644
--- a/libstdc++-v3/src/c++11/cow-locale_init.cc
+++ b/libstdc++-v3/src/c++11/cow-locale_init.cc
@@ -24,10 +24,7 @@
 #define _GLIBCXX_USE_CXX11_ABI 0
 #include <locale>
 
-#if ! _GLIBCXX_USE_DUAL_ABI
-# error This file should not be compiled for this configuration.
-#endif
-
+#if ! _GLIBCXX_USE_CXX11_ABI
 namespace std _GLIBCXX_VISIBILITY(default)
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
@@ -166,6 +163,7 @@ namespace
 #endif
   }
 
+#if _GLIBCXX_USE_DUAL_ABI
 // TODO should be in another file
   string
   locale::name() const
@@ -191,6 +189,8 @@ namespace
       }
     return __ret;
   }
+#endif
 
 _GLIBCXX_END_NAMESPACE_VERSION
 }
+#endif // ! _GLIBCXX_USE_CXX11_ABI
diff --git a/libstdc++-v3/src/c++11/cow-sstream-inst.cc b/libstdc++-v3/src/c++11/cow-sstream-inst.cc
index f142376c9b6..710a36097e1 100644
--- a/libstdc++-v3/src/c++11/cow-sstream-inst.cc
+++ b/libstdc++-v3/src/c++11/cow-sstream-inst.cc
@@ -27,8 +27,8 @@
 //
 
 #define _GLIBCXX_USE_CXX11_ABI 0
-#include "sstream-inst.cc"
+#include <bits/c++config.h>
 
-#if ! _GLIBCXX_USE_DUAL_ABI
-# error This file should not be compiled for this configuration.
+#if ! _GLIBCXX_USE_CXX11_ABI
+# include "sstream-inst.cc"
 #endif
diff --git a/libstdc++-v3/src/c++11/cow-stdexcept.cc b/libstdc++-v3/src/c++11/cow-stdexcept.cc
index 6af88f23fca..6d1ee5f361f 100644
--- a/libstdc++-v3/src/c++11/cow-stdexcept.cc
+++ b/libstdc++-v3/src/c++11/cow-stdexcept.cc
@@ -43,11 +43,52 @@ _txnal_runtime_error_get_msg(void* e);
 
 // All exception classes still use the classic COW std::string.
 #define _GLIBCXX_USE_CXX11_ABI 0
-#define _GLIBCXX_DEFINE_STDEXCEPT_COPY_OPS 1
-#define __cow_string __cow_stringxxx
+#include <string>
+
+#if _GLIBCXX_USE_DUAL_ABI || _GLIBCXX_USE_CXX11_ABI
+# if _GLIBCXX_USE_CXX11_ABI
+#  include <bits/cow_string.h>
+# endif
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+# if _GLIBCXX_USE_CXX11_ABI
+  typedef std::__detail::basic_string<char, std::char_traits<char>,
+				      std::allocator<char>> cowstr;
+# else
+  typedef std::string cowstr;
+# endif
+
+  // Redefine __cow_string so that we can define and export its members
+  // in terms of the COW std::string.
+  struct __cow_string
+  {
+    union {
+      const char* _M_p;
+      char _M_bytes[sizeof(_M_p)];
+      cowstr _M_str;
+    };
+
+    __cow_string();
+    __cow_string(const std::string& s);
+    __cow_string(const char*);
+    __cow_string(const char*, size_t);
+    __cow_string(const __cow_string&) noexcept;
+    __cow_string& operator=(const __cow_string&) noexcept;
+    ~__cow_string();
+    __cow_string(__cow_string&&) noexcept;
+    __cow_string& operator=(__cow_string&&) noexcept;
+    const char* c_str() const noexcept;
+  };
+_GLIBCXX_END_NAMESPACE_VERSION
+}
+#endif
+
+#define _GLIBCXX_DEFINE_STDEXCEPT_INSTANTIATIONS 1
 #include <stdexcept>
 #include <system_error>
-#undef __cow_string
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
@@ -114,30 +155,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   // Converting constructor from COW std::string to SSO string.
   __sso_string::__sso_string(const string& s)
   : __sso_string(s.c_str(), s.length()) { }
+#endif
 
-  // Redefine __cow_string so that we can define and export its members
-  // in terms of the COW std::string.
-  struct __cow_string
-  {
-    union {
-      const char* _M_p;
-      char _M_bytes[sizeof(_M_p)];
-      std::string _M_str;
-    };
-
-    __cow_string();
-    __cow_string(const std::string& s);
-    __cow_string(const char*, size_t n);
-    __cow_string(const __cow_string&) noexcept;
-    __cow_string& operator=(const __cow_string&) noexcept;
-    ~__cow_string();
-    __cow_string(__cow_string&&) noexcept;
-    __cow_string& operator=(__cow_string&&) noexcept;
-  };
-
+#if _GLIBCXX_USE_DUAL_ABI || _GLIBCXX_USE_CXX11_ABI
   __cow_string::__cow_string() : _M_str() { }
 
+#if !_GLIBCXX_USE_CXX11_ABI
   __cow_string::__cow_string(const std::string& s) : _M_str(s) { }
+#endif
+
+  __cow_string::__cow_string(const char* s) : _M_str(s) { }
 
   __cow_string::__cow_string(const char* s, size_t n) : _M_str(s, n) { }
 
@@ -151,7 +178,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     return *this;
   }
 
-  __cow_string::~__cow_string() { _M_str.~basic_string(); }
+  __cow_string::~__cow_string() { _M_str.~cowstr(); }
 
   __cow_string::__cow_string(__cow_string&& s) noexcept
   : _M_str(std::move(s._M_str)) { }
@@ -163,12 +190,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     return *this;
   }
 
-  static_assert(sizeof(__cow_string) == sizeof(std::string),
+  const char*
+  __cow_string::c_str() const noexcept
+  { return _M_str.c_str(); }
+
+  static_assert(sizeof(__cow_string) == sizeof(cowstr),
                 "sizeof(std::string) has changed");
-  static_assert(alignof(__cow_string) == alignof(std::string),
+  static_assert(alignof(__cow_string) == alignof(cowstr),
                 "alignof(std::string) has changed");
-#endif
+#endif // _GLIBCXX_USE_CXX11_ABI
 
+#if ! _GLIBCXX_USE_CXX11_ABI
   // Return error_category::message() as an SSO string
   __sso_string
   error_category::_M_message(int i) const
@@ -176,10 +208,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     string msg = this->message(i);
     return {msg.c_str(), msg.length()};
   }
+#endif
 
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
 
+#if ! _GLIBCXX_USE_CXX11_ABI
 // Support for the Transactional Memory TS (N4514).
 //
 // logic_error and runtime_error both carry a message in the form of a COW
@@ -463,3 +497,4 @@ CTORDTOR(15underflow_error, std::underflow_error, runtime_error)
 
 #endif  // _GLIBCXX_USE_C99_STDINT
 #endif  // _GLIBCXX_USE_WEAK_REF
+#endif  // ! _GLIBCXX_USE_CXX11_ABI
diff --git a/libstdc++-v3/src/c++11/cow-string-inst.cc b/libstdc++-v3/src/c++11/cow-string-inst.cc
index 14a9a99b460..858e81b976f 100644
--- a/libstdc++-v3/src/c++11/cow-string-inst.cc
+++ b/libstdc++-v3/src/c++11/cow-string-inst.cc
@@ -29,10 +29,7 @@
 #define _GLIBCXX_USE_CXX11_ABI 0
 #include "string-inst.cc"
 
-#if ! _GLIBCXX_USE_DUAL_ABI
-# error This file should not be compiled for this configuration.
-#endif
-
+#if _GLIBCXX_USE_DUAL_ABI && ! _GLIBCXX_USE_CXX11_ABI
 #include <random>
 
 namespace std _GLIBCXX_VISIBILITY(default)
@@ -45,3 +42,4 @@ namespace std _GLIBCXX_VISIBILITY(default)
   random_device::_M_init_pretr1(const std::string& token)
   { _M_init(token.c_str(), token.length()); }
 } // namespace
+#endif
diff --git a/libstdc++-v3/src/c++11/cow-string-io-inst.cc b/libstdc++-v3/src/c++11/cow-string-io-inst.cc
index a167894b157..6be7387c1a9 100644
--- a/libstdc++-v3/src/c++11/cow-string-io-inst.cc
+++ b/libstdc++-v3/src/c++11/cow-string-io-inst.cc
@@ -30,10 +30,7 @@
 #include <istream>
 #include <ostream>
 
-#if ! _GLIBCXX_USE_DUAL_ABI
-# error This file should not be compiled for this configuration.
-#endif
-
+#if ! _GLIBCXX_USE_CXX11_ABI
 namespace std _GLIBCXX_VISIBILITY(default)
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
@@ -57,3 +54,4 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
+#endif
diff --git a/libstdc++-v3/src/c++11/cow-wstring-inst.cc b/libstdc++-v3/src/c++11/cow-wstring-inst.cc
index 2aabc05214f..985b4df710f 100644
--- a/libstdc++-v3/src/c++11/cow-wstring-inst.cc
+++ b/libstdc++-v3/src/c++11/cow-wstring-inst.cc
@@ -29,12 +29,9 @@
 #define _GLIBCXX_USE_CXX11_ABI 0
 #include <bits/c++config.h>
 
+#if ! _GLIBCXX_USE_CXX11_ABI
 #ifdef _GLIBCXX_USE_WCHAR_T
 #define C wchar_t
 #include "string-inst.cc"
-
-#if ! _GLIBCXX_USE_DUAL_ABI
-# error This file should not be compiled for this configuration.
 #endif
-
 #endif
diff --git a/libstdc++-v3/src/c++11/cow-wstring-io-inst.cc b/libstdc++-v3/src/c++11/cow-wstring-io-inst.cc
index 41ef96ba85b..671fa13f039 100644
--- a/libstdc++-v3/src/c++11/cow-wstring-io-inst.cc
+++ b/libstdc++-v3/src/c++11/cow-wstring-io-inst.cc
@@ -29,14 +29,11 @@
 #define _GLIBCXX_USE_CXX11_ABI 0
 #include <bits/c++config.h>
 
+#if ! _GLIBCXX_USE_CXX11_ABI
 #ifdef _GLIBCXX_USE_WCHAR_T
 #include <ostream>
 #include <istream>
 
-#if ! _GLIBCXX_USE_DUAL_ABI
-# error This file should not be compiled for this configuration.
-#endif
-
 namespace std _GLIBCXX_VISIBILITY(default)
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
@@ -61,3 +58,4 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
 #endif
+#endif
diff --git a/libstdc++-v3/src/c++11/cxx11-hash_tr1.cc b/libstdc++-v3/src/c++11/cxx11-hash_tr1.cc
index 010d9dbdb97..a90f0d9a425 100644
--- a/libstdc++-v3/src/c++11/cxx11-hash_tr1.cc
+++ b/libstdc++-v3/src/c++11/cxx11-hash_tr1.cc
@@ -25,9 +25,7 @@
 #define _GLIBCXX_USE_CXX11_ABI 1
 #include <string>
 
-#if ! _GLIBCXX_USE_DUAL_ABI
-# error This file should not be compiled for this configuration.
-#endif
+#if _GLIBCXX_USE_CXX11_ABI
 
 #include <tr1/functional>
 namespace std _GLIBCXX_VISIBILITY(default)
@@ -57,3 +55,5 @@ namespace std _GLIBCXX_VISIBILITY(default)
 #endif
   }
 }
+
+#endif // _GLIBCXX_USE_CXX11_ABI
diff --git a/libstdc++-v3/src/c++11/cxx11-ios_failure.cc b/libstdc++-v3/src/c++11/cxx11-ios_failure.cc
index bd3fd556bd4..7095bf96865 100644
--- a/libstdc++-v3/src/c++11/cxx11-ios_failure.cc
+++ b/libstdc++-v3/src/c++11/cxx11-ios_failure.cc
@@ -38,9 +38,7 @@
 # define _(msgid)   (msgid)
 #endif
 
-#if ! _GLIBCXX_USE_DUAL_ABI
-# error This file should not be compiled for this configuration.
-#endif
+#if _GLIBCXX_USE_CXX11_ABI
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
@@ -62,7 +60,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   ios_base::failure::what() const throw()
   { return runtime_error::what(); }
 
-#if __cpp_rtti
+#if _GLIBCXX_USE_DUAL_ABI && __cpp_rtti
   // These functions are defined in src/c++98/ios_failure.cc
   extern void __construct_ios_failure(void*, const char*);
   extern void __destroy_ios_failure(void*);
@@ -118,7 +116,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     // Otherwise proceed as normal to see if the handler matches.
     return __class_type_info::__do_upcast(dst_type, obj_ptr);
   }
-#else // ! __cpp_rtti
+#else // ! _GLIBCXX_USE_DUAL_ABI || ! __cpp_rtti
   using __ios_failure = ios::failure;
 #endif
 
@@ -136,3 +134,5 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
+
+#endif // _GLIBCXX_USE_CXX11_ABI
diff --git a/libstdc++-v3/src/c++11/cxx11-locale-inst.cc b/libstdc++-v3/src/c++11/cxx11-locale-inst.cc
index 13036ae9f6e..37042354e4f 100644
--- a/libstdc++-v3/src/c++11/cxx11-locale-inst.cc
+++ b/libstdc++-v3/src/c++11/cxx11-locale-inst.cc
@@ -27,11 +27,5 @@
 // Facet instantiations using new ABI strings.
 
 #define _GLIBCXX_USE_CXX11_ABI 1
-#include <bits/c++config.h>
-#if ! _GLIBCXX_USE_DUAL_ABI
-# error This file should not be compiled for this configuration.
-#endif
 
-#define C char
-#define C_is_char
-# include "locale-inst.cc"
+#include "locale-inst.cc"
diff --git a/libstdc++-v3/src/c++11/cxx11-stdexcept.cc b/libstdc++-v3/src/c++11/cxx11-stdexcept.cc
index 07368c7c3f2..1843fd67191 100644
--- a/libstdc++-v3/src/c++11/cxx11-stdexcept.cc
+++ b/libstdc++-v3/src/c++11/cxx11-stdexcept.cc
@@ -29,9 +29,7 @@
 #define _GLIBCXX_USE_CXX11_ABI 1
 #include <stdexcept>
 
-#if ! _GLIBCXX_USE_DUAL_ABI
-# error This file should not be compiled for this configuration.
-#endif
+#if _GLIBCXX_USE_CXX11_ABI
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
@@ -76,3 +74,5 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
+
+#endif // _GLIBCXX_USE_CXX11_ABI
diff --git a/libstdc++-v3/src/c++11/cxx11-wlocale-inst.cc b/libstdc++-v3/src/c++11/cxx11-wlocale-inst.cc
index 80b0339a1c4..210c00177d1 100644
--- a/libstdc++-v3/src/c++11/cxx11-wlocale-inst.cc
+++ b/libstdc++-v3/src/c++11/cxx11-wlocale-inst.cc
@@ -28,11 +28,10 @@
 
 #define _GLIBCXX_USE_CXX11_ABI 1
 #include <bits/c++config.h>
-#if ! _GLIBCXX_USE_DUAL_ABI
-# error This file should not be compiled for this configuration.
-#endif
 
-#ifdef _GLIBCXX_USE_WCHAR_T
-#define C wchar_t
-#include "locale-inst.cc"
+#if _GLIBCXX_USE_CXX11_ABI
+# ifdef _GLIBCXX_USE_WCHAR_T
+#  define C wchar_t
+#  include "locale-inst.cc"
+# endif
 #endif
diff --git a/libstdc++-v3/src/c++11/locale-inst-numeric.h b/libstdc++-v3/src/c++11/locale-inst-numeric.h
index b15ad2e895c..2e8270e27b3 100644
--- a/libstdc++-v3/src/c++11/locale-inst-numeric.h
+++ b/libstdc++-v3/src/c++11/locale-inst-numeric.h
@@ -30,7 +30,7 @@
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
-#if ! _GLIBCXX_USE_CXX11_ABI
+#if ! _GLIBCXX_USE_CXX11_ABI || ! _GLIBCXX_USE_DUAL_ABI
 // use_facet and has_facet instantiations
 INSTANTIATE_FACET_ACCESSORS(num_get<C>);
 INSTANTIATE_FACET_ACCESSORS(num_put<C>);
@@ -38,7 +38,7 @@ INSTANTIATE_FACET_ACCESSORS(num_put<C>);
 
 _GLIBCXX_BEGIN_NAMESPACE_LDBL
 
-#if ! _GLIBCXX_USE_CXX11_ABI
+#if ! _GLIBCXX_USE_CXX11_ABI || ! _GLIBCXX_USE_DUAL_ABI
   template class num_get<C, istreambuf_iterator<C> >;
   template class num_put<C, ostreambuf_iterator<C> >;
 #endif
@@ -88,7 +88,7 @@ _GLIBCXX_BEGIN_NAMESPACE_LDBL
 		   unsigned long long&) const;
 #endif
 
-#if ! _GLIBCXX_USE_CXX11_ABI
+#if ! _GLIBCXX_USE_CXX11_ABI || ! _GLIBCXX_USE_DUAL_ABI
   // num_put member function templates
   template
     ostreambuf_iterator<C>
diff --git a/libstdc++-v3/src/c++11/locale-inst.cc b/libstdc++-v3/src/c++11/locale-inst.cc
index a84fd9c732a..ce5eead599b 100644
--- a/libstdc++-v3/src/c++11/locale-inst.cc
+++ b/libstdc++-v3/src/c++11/locale-inst.cc
@@ -35,8 +35,17 @@
 # define _GLIBCXX_USE_CXX11_ABI 0
 #endif
 
-#include <locale>
+#if _GLIBCXX_USE_CXX11_ABI
+# define _GLIBCXX_BUILD_CXX11_ABI 1
+#else
+# define _GLIBCXX_BUILD_CXX11_ABI 0
+#endif
+
+#include <bits/c++config.h>
 
+#if _GLIBCXX_BUILD_CXX11_ABI == _GLIBCXX_USE_CXX11_ABI
+
+#include <locale>
 // Instantiation configuration.
 #ifndef C
 # define C char
@@ -52,7 +61,7 @@ namespace std _GLIBCXX_VISIBILITY(default)
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   // moneypunct, money_get, and money_put
-#if ! _GLIBCXX_USE_CXX11_ABI
+#if ! _GLIBCXX_USE_CXX11_ABI || ! _GLIBCXX_USE_DUAL_ABI
   template struct __moneypunct_cache<C, false>;
   template struct __moneypunct_cache<C, true>;
 #endif
@@ -64,7 +73,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
 _GLIBCXX_END_NAMESPACE_CXX11
 
   // numpunct, numpunct_byname, num_get, and num_put
-#if ! _GLIBCXX_USE_CXX11_ABI
+#if ! _GLIBCXX_USE_CXX11_ABI || ! _GLIBCXX_USE_DUAL_ABI
   template struct __numpunct_cache<C>;
 #endif
 _GLIBCXX_BEGIN_NAMESPACE_CXX11
@@ -73,7 +82,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
 _GLIBCXX_END_NAMESPACE_CXX11
 
   // time_get and time_put
-#if ! _GLIBCXX_USE_CXX11_ABI
+#if ! _GLIBCXX_USE_CXX11_ABI || ! _GLIBCXX_USE_DUAL_ABI
   template class __timepunct<C>;
   template struct __timepunct_cache<C>;
   template class time_put<C, ostreambuf_iterator<C> >;
@@ -97,13 +106,13 @@ _GLIBCXX_END_NAMESPACE_CXX11
   ctype_byname<C>::ctype_byname(const string& __s, size_t __refs)
   : ctype_byname(__s.c_str(), __refs) { }
 
-#if ! _GLIBCXX_USE_CXX11_ABI
+#if ! _GLIBCXX_USE_CXX11_ABI || ! _GLIBCXX_USE_DUAL_ABI
   inline template class __ctype_abstract_base<C>;
   template class ctype_byname<C>;
 #endif
 
   // codecvt
-#if ! _GLIBCXX_USE_CXX11_ABI
+#if ! _GLIBCXX_USE_CXX11_ABI || ! _GLIBCXX_USE_DUAL_ABI
   inline template class __codecvt_abstract_base<C, char, mbstate_t>;
   template class codecvt_byname<C, char, mbstate_t>;
 #else
@@ -118,7 +127,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
 _GLIBCXX_END_NAMESPACE_CXX11
 
 // use_facet and has_facet instantiations
-#if ! _GLIBCXX_USE_CXX11_ABI
+#if ! _GLIBCXX_USE_CXX11_ABI || ! _GLIBCXX_USE_DUAL_ABI
 INSTANTIATE_FACET_ACCESSORS(ctype<C>);
 INSTANTIATE_FACET_ACCESSORS(codecvt<C, char, mbstate_t>);
 #endif
@@ -127,14 +136,14 @@ INSTANTIATE_FACET_ACCESSORS(numpunct<C>);
 INSTANTIATE_FACET_ACCESSORS(moneypunct<C, false>);
 // No explicit instantiation of has_facet<moneypunct<C, true>> for some reason.
 INSTANTIATE_USE_FACET      (moneypunct<C, true>);
-#if ! _GLIBCXX_USE_CXX11_ABI
+#if ! _GLIBCXX_USE_CXX11_ABI || ! _GLIBCXX_USE_DUAL_ABI
 INSTANTIATE_FACET_ACCESSORS(__timepunct<C>);
 INSTANTIATE_FACET_ACCESSORS(time_put<C>);
 #endif
 INSTANTIATE_FACET_ACCESSORS(time_get<C>);
 INSTANTIATE_FACET_ACCESSORS(messages<C>);
 
-#if ! _GLIBCXX_USE_CXX11_ABI
+#if ! _GLIBCXX_USE_CXX11_ABI || ! _GLIBCXX_USE_DUAL_ABI
   // locale functions.
   template
     C*
@@ -163,3 +172,5 @@ _GLIBCXX_END_NAMESPACE_VERSION
 #if defined _GLIBCXX_LONG_DOUBLE_COMPAT && ! _GLIBCXX_USE_CXX11_ABI
 #include "compatibility-ldbl-facets-aliases.h"
 #endif // _GLIBCXX_LONG_DOUBLE_COMPAT
+
+#endif //  _GLIBCXX_BUILD_CXX11_ABI == _GLIBCXX_USE_CXX11_ABI
diff --git a/libstdc++-v3/src/c++11/string-inst.cc b/libstdc++-v3/src/c++11/string-inst.cc
index ec5ba41ebcd..f35b7f8433d 100644
--- a/libstdc++-v3/src/c++11/string-inst.cc
+++ b/libstdc++-v3/src/c++11/string-inst.cc
@@ -35,6 +35,12 @@
 # define _GLIBCXX_USE_CXX11_ABI 1
 #endif
 
+#if _GLIBCXX_USE_CXX11_ABI
+# define _GLIBCXX_BUILD_CXX11_ABI 1
+#else
+# define _GLIBCXX_BUILD_CXX11_ABI 0
+#endif
+
 // Prevent the basic_string(const _CharT*, const _Alloc&) and
 // basic_string(size_type, _CharT, const _Alloc&) constructors from being
 // replaced by constrained function templates, so that we instantiate the
@@ -45,14 +51,38 @@
 
 #include <string>
 
+#if _GLIBCXX_USE_DUAL_ABI || _GLIBCXX_USE_CXX11_ABI
+#include <stdexcept>
+
+#if _GLIBCXX_USE_CXX11_ABI
+# include <bits/cow_string.h>
+typedef std::__detail::basic_string<char, std::char_traits<char>,
+				    std::allocator<char>> cowstr;
+#else
+typedef std::string cowstr;
+#endif
+
+static_assert(sizeof(std::__cow_string) == sizeof(cowstr),
+	      "sizeof(std::string) has changed");
+static_assert(alignof(std::__cow_string) == alignof(cowstr),
+	      "alignof(std::string) has changed");
+#endif // _GLIBCXX_USE_DUAL_ABI || _GLIBCXX_USE_CXX11_ABI
+
+#if _GLIBCXX_USE_CXX11_ABI && ! _GLIBCXX_BUILD_CXX11_ABI
+# include <bits/cow_string.h>
+#endif
+
 // Instantiation configuration.
 #ifndef C
 # define C char
 #endif
 
+#if _GLIBCXX_USE_CXX11_ABI == _GLIBCXX_BUILD_CXX11_ABI
 namespace std _GLIBCXX_VISIBILITY(default)
 {
+#if _GLIBCXX_USE_CXX11_ABI
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
+#endif
 
   typedef basic_string<C> S;
 
@@ -108,7 +138,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 		    forward_iterator_tag);
 #endif
 
+#if _GLIBCXX_USE_CXX11_ABI
 _GLIBCXX_END_NAMESPACE_VERSION
+#endif
 } // namespace
 
 namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
@@ -121,3 +153,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
+#elif ! _GLIBCXX_BUILD_CXX11_ABI
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+  namespace __detail
+  {
+    template basic_string<C, std::char_traits<C>, std::allocator<C>>::size_type
+      basic_string<C, std::char_traits<C>, std::allocator<C>>::_Rep::_S_empty_rep_storage[];
+  }
+}
+#endif
diff --git a/libstdc++-v3/src/c++11/wlocale-inst.cc b/libstdc++-v3/src/c++11/wlocale-inst.cc
index 284d566a99a..d9c8e878aa8 100644
--- a/libstdc++-v3/src/c++11/wlocale-inst.cc
+++ b/libstdc++-v3/src/c++11/wlocale-inst.cc
@@ -30,7 +30,9 @@
 #define _GLIBCXX_USE_CXX11_ABI 0
 #include <bits/c++config.h>
 
-#ifdef _GLIBCXX_USE_WCHAR_T
-#define C wchar_t
-#include "locale-inst.cc"
-#endif // _GLIBCXX_USE_WCHAR_T
+#if ! _GLIBCXX_USE_CXX11_ABI
+# ifdef _GLIBCXX_USE_WCHAR_T
+#  define C wchar_t
+#  include "locale-inst.cc"
+# endif // _GLIBCXX_USE_WCHAR_T
+#endif
diff --git a/libstdc++-v3/src/c++98/Makefile.am b/libstdc++-v3/src/c++98/Makefile.am
index d12fdf0f121..a2dff992a6b 100644
--- a/libstdc++-v3/src/c++98/Makefile.am
+++ b/libstdc++-v3/src/c++98/Makefile.am
@@ -86,12 +86,8 @@ host_sources_extra = \
 c++locale.cc: ${glibcxx_srcdir}/$(CLOCALE_CC)
 	$(LN_S) ${glibcxx_srcdir}/$(CLOCALE_CC) ./$@ || true
 
-if ENABLE_DUAL_ABI
-cxx11_abi_sources = \
-	cow-istream-string.cc
-else
-cxx11_abi_sources =
-endif
+basic_file.cc: ${glibcxx_srcdir}/$(BASIC_FILE_CC)
+	$(LN_S) ${glibcxx_srcdir}/$(BASIC_FILE_CC) ./$@ || true
 
 if ENABLE_EXTERN_TEMPLATE
 # XTEMPLATE_FLAGS = -fno-implicit-templates
@@ -114,6 +110,7 @@ sources = \
 	mt_allocator.cc \
 	codecvt.cc \
 	complex_io.cc \
+	cow-istream-string.cc \
 	globals_io.cc \
 	hash_tr1.cc \
 	hashtable_tr1.cc \
@@ -136,7 +133,6 @@ sources = \
 	istream-string.cc \
 	streambuf.cc \
 	valarray.cc \
-	${cxx11_abi_sources} \
 	${host_sources} \
 	${host_sources_extra} \
 	${inst_sources} \
diff --git a/libstdc++-v3/src/c++98/compatibility.cc b/libstdc++-v3/src/c++98/compatibility.cc
index 3f0973e741f..586a7b4cb83 100644
--- a/libstdc++-v3/src/c++98/compatibility.cc
+++ b/libstdc++-v3/src/c++98/compatibility.cc
@@ -25,7 +25,8 @@
 #define _GLIBCXX_USE_CXX11_ABI 0
 #include <bits/c++config.h>
 
-#if defined(_GLIBCXX_SYMVER_GNU) && defined(_GLIBCXX_SHARED) \
+#if ! _GLIBCXX_USE_CXX11_ABI \
+    && defined(_GLIBCXX_SYMVER_GNU) && defined(_GLIBCXX_SHARED)	\
     && defined(_GLIBCXX_HAVE_AS_SYMVER_DIRECTIVE)\
     && defined(_GLIBCXX_HAVE_SYMVER_SYMBOL_RENAMING_RUNTIME_SUPPORT)
 #define istreambuf_iterator istreambuf_iteratorXX
@@ -220,7 +221,8 @@ _GLIBCXX_END_NAMESPACE_VERSION
 
 // NB: These symbols renames should go into the shared library only,
 // and only those shared libraries that support versioning.
-#if defined(_GLIBCXX_SYMVER_GNU) && defined(_GLIBCXX_SHARED) \
+#if ! _GLIBCXX_USE_CXX11_ABI \
+    && defined(_GLIBCXX_SYMVER_GNU) && defined(_GLIBCXX_SHARED)	\
     && defined(_GLIBCXX_HAVE_AS_SYMVER_DIRECTIVE) \
     && defined(_GLIBCXX_HAVE_SYMVER_SYMBOL_RENAMING_RUNTIME_SUPPORT)
 
@@ -525,7 +527,7 @@ _GLIBCXX_MATHL_WRAPPER1 (tan, GLIBCXX_3.4);
 #endif
 #endif // _GLIBCXX_LONG_DOUBLE_COMPAT
 
-#endif
+#endif // ! _GLIBCXX_USE_CXX11_ABI
 
 #ifdef _GLIBCXX_LONG_DOUBLE_COMPAT
 extern void *_ZTVN10__cxxabiv123__fundamental_type_infoE[];
diff --git a/libstdc++-v3/src/c++98/cow-istream-string.cc b/libstdc++-v3/src/c++98/cow-istream-string.cc
index a36b84ff333..1c601b7e4ad 100644
--- a/libstdc++-v3/src/c++98/cow-istream-string.cc
+++ b/libstdc++-v3/src/c++98/cow-istream-string.cc
@@ -27,4 +27,8 @@
 //
 
 #define _GLIBCXX_USE_CXX11_ABI 0
-#include "istream-string.cc"
+#include <bits/c++config.h>
+
+#if ! _GLIBCXX_USE_CXX11_ABI
+# include "istream-string.cc"
+#endif
diff --git a/libstdc++-v3/src/c++98/hash_tr1.cc b/libstdc++-v3/src/c++98/hash_tr1.cc
index ee313ce5d62..d85c28c55a7 100644
--- a/libstdc++-v3/src/c++98/hash_tr1.cc
+++ b/libstdc++-v3/src/c++98/hash_tr1.cc
@@ -28,6 +28,7 @@
 
 #include "hash-long-double-tr1-aux.cc"
 
+#if ! _GLIBCXX_USE_CXX11_ABI
 namespace std _GLIBCXX_VISIBILITY(default)
 {
   namespace tr1
@@ -57,3 +58,4 @@ namespace std _GLIBCXX_VISIBILITY(default)
 #endif
   }
 }
+#endif // ! _GLIBCXX_USE_CXX11_ABI
diff --git a/libstdc++-v3/src/c++98/ios_failure.cc b/libstdc++-v3/src/c++98/ios_failure.cc
index 0467109c96f..ad0cd6097ec 100644
--- a/libstdc++-v3/src/c++98/ios_failure.cc
+++ b/libstdc++-v3/src/c++98/ios_failure.cc
@@ -29,22 +29,24 @@
 #define _GLIBCXX_USE_CXX11_ABI 0
 #include <ios>
 
-#if _GLIBCXX_USE_DUAL_ABI && __cpp_rtti
-#include <cxxabi.h>
-#include <typeinfo>
-#endif
+#if ! _GLIBCXX_USE_CXX11_ABI || ! _GLIBCXX_USE_DUAL_ABI
+# if _GLIBCXX_USE_DUAL_ABI && __cpp_rtti
+#  include <cxxabi.h>
+#  include <typeinfo>
+# endif
 
-#ifdef _GLIBCXX_USE_NLS
+# ifdef _GLIBCXX_USE_NLS
 #  include <libintl.h>
 #  define _(msgid)   gettext (msgid)
-#else
+# else
 #  define _(msgid)   (msgid)
-#endif
+# endif
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
+#if ! _GLIBCXX_USE_CXX11_ABI
   ios_base::failure::failure(const string& __str) throw()
   : _M_msg(__str) { }
 
@@ -54,6 +56,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   const char*
   ios_base::failure::what() const throw()
   { return _M_msg.c_str(); }
+#endif
 
 #if _GLIBCXX_USE_DUAL_ABI
   // When the dual ABI is enabled __throw_ios_failure() is defined in
@@ -82,7 +85,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   }
 #endif // __cpp_rtti
 
-#else // ! _GLIBCXX_USE_DUAL_ABI
+#elif ! _GLIBCXX_USE_CXX11_ABI
 
   void
   __throw_ios_failure(const char* __s __attribute__((unused)))
@@ -92,7 +95,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   __throw_ios_failure(const char* str, int)
   { __throw_ios_failure(str); }
 
-#endif // _GLIBCXX_USE_DUAL_ABI
+#endif // ! _GLIBCXX_USE_CXX11_ABI
 
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
+
+#endif // ! _GLIBCXX_USE_CXX11_ABI || ! _GLIBCXX_USE_DUAL_ABI
diff --git a/libstdc++-v3/src/c++98/istream-string.cc b/libstdc++-v3/src/c++98/istream-string.cc
index 7b3e9e865ce..f1e71ffc853 100644
--- a/libstdc++-v3/src/c++98/istream-string.cc
+++ b/libstdc++-v3/src/c++98/istream-string.cc
@@ -31,6 +31,16 @@
 // by another file which defines _GLIBCXX_USE_CXX11_ABI=0.
 # define _GLIBCXX_USE_CXX11_ABI 1
 #endif
+
+#if _GLIBCXX_USE_CXX11_ABI
+# define _GLIBCXX_BUILD_CXX11_ABI 1
+#else
+# define _GLIBCXX_BUILD_CXX11_ABI 0
+#endif
+
+#include <bits/c++config.h>
+
+#if _GLIBCXX_BUILD_CXX11_ABI == _GLIBCXX_USE_CXX11_ABI
 #include <istream>
 #include <string>
 
@@ -289,3 +299,4 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
+#endif // _GLIBCXX_BUILD_CXX11_ABI == _GLIBCXX_USE_CXX11_ABI
diff --git a/libstdc++-v3/src/c++98/locale_facets.cc b/libstdc++-v3/src/c++98/locale_facets.cc
index fa469b1b872..4406b7e2e3c 100644
--- a/libstdc++-v3/src/c++98/locale_facets.cc
+++ b/libstdc++-v3/src/c++98/locale_facets.cc
@@ -125,6 +125,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     return __test;
   }
 
+#if ! _GLIBCXX_USE_CXX11_ABI
   bool
   __verify_grouping(const char* __grouping, size_t __grouping_size,
 		    const string& __grouping_tmp) throw()
@@ -133,6 +134,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
                                   __grouping_tmp.c_str(),
                                   __grouping_tmp.size());
   }
+#endif
 
   namespace
   {
diff --git a/libstdc++-v3/src/c++98/stdexcept.cc b/libstdc++-v3/src/c++98/stdexcept.cc
index df5bf9ca0ca..a773a28e9bb 100644
--- a/libstdc++-v3/src/c++98/stdexcept.cc
+++ b/libstdc++-v3/src/c++98/stdexcept.cc
@@ -35,8 +35,10 @@ namespace std _GLIBCXX_VISIBILITY(default)
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
+#if ! _GLIBCXX_USE_CXX11_ABI
   logic_error::logic_error(const string& __arg)
   : exception(), _M_msg(__arg) { }
+#endif
 
   logic_error::~logic_error() _GLIBCXX_USE_NOEXCEPT { }
 
@@ -44,28 +46,38 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   logic_error::what() const _GLIBCXX_USE_NOEXCEPT
   { return _M_msg.c_str(); }
 
+#if ! _GLIBCXX_USE_CXX11_ABI
   domain_error::domain_error(const string& __arg)
   : logic_error(__arg) { }
+#endif
 
   domain_error::~domain_error() _GLIBCXX_USE_NOEXCEPT { }
 
+#if ! _GLIBCXX_USE_CXX11_ABI
   invalid_argument::invalid_argument(const string& __arg)
   : logic_error(__arg) { }
+#endif
 
   invalid_argument::~invalid_argument() _GLIBCXX_USE_NOEXCEPT { }
 
+#if ! _GLIBCXX_USE_CXX11_ABI
   length_error::length_error(const string& __arg)
   : logic_error(__arg) { }
+#endif
 
   length_error::~length_error() _GLIBCXX_USE_NOEXCEPT { }
 
+#if ! _GLIBCXX_USE_CXX11_ABI
   out_of_range::out_of_range(const string& __arg)
   : logic_error(__arg) { }
+#endif
 
   out_of_range::~out_of_range() _GLIBCXX_USE_NOEXCEPT { }
 
+#if ! _GLIBCXX_USE_CXX11_ABI
   runtime_error::runtime_error(const string& __arg)
   : exception(), _M_msg(__arg) { }
+#endif
 
   runtime_error::~runtime_error() _GLIBCXX_USE_NOEXCEPT { }
 
@@ -73,18 +85,24 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   runtime_error::what() const _GLIBCXX_USE_NOEXCEPT
   { return _M_msg.c_str(); }
 
+#if ! _GLIBCXX_USE_CXX11_ABI
   range_error::range_error(const string& __arg)
   : runtime_error(__arg) { }
+#endif
 
   range_error::~range_error() _GLIBCXX_USE_NOEXCEPT { }
 
+#if ! _GLIBCXX_USE_CXX11_ABI
   overflow_error::overflow_error(const string& __arg)
   : runtime_error(__arg) { }
+#endif
 
   overflow_error::~overflow_error() _GLIBCXX_USE_NOEXCEPT { }
 
+#if ! _GLIBCXX_USE_CXX11_ABI
   underflow_error::underflow_error(const string& __arg)
   : runtime_error(__arg) { }
+#endif
 
   underflow_error::~underflow_error() _GLIBCXX_USE_NOEXCEPT { }
 

      parent reply	other threads:[~2024-02-28 18:37 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-10  5:13 François Dumont
2023-08-11  5:43 ` François Dumont
2023-08-11  7:51   ` Jonathan Wakely
2023-08-13 13:27     ` François Dumont
2023-08-13 19:51       ` François Dumont
2023-08-17 17:17         ` François Dumont
2023-08-24 17:33           ` François Dumont
2023-08-17 17:22       ` Jonathan Wakely
2023-08-17 17:40         ` François Dumont
2023-08-17 18:59           ` Jonathan Wakely
2023-08-17 19:37             ` Jonathan Wakely
2023-08-17 19:44               ` Jonathan Wakely
2023-08-17 23:31                 ` Jonathan Wakely
2023-08-19 19:44                 ` François Dumont
2023-10-07 12:25         ` François Dumont
2023-10-07 19:32           ` François Dumont
2023-10-09 14:42             ` Iain Sandoe
2023-10-09 16:27               ` Iain Sandoe
2023-10-09 17:38               ` François Dumont
2023-10-24  4:55             ` François Dumont
2024-02-28 18:37         ` François Dumont [this message]

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=a201a021-f9c1-4c8b-bcf9-1ee5f764fbcc@gmail.com \
    --to=frs.dumont@gmail.com \
    --cc=jwakely.gcc@gmail.com \
    --cc=jwakely@redhat.com \
    --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).