public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Use cxx11 abi in versioned namespace
@ 2022-05-30 20:58 François Dumont
  2022-10-11 17:28 ` François Dumont
  0 siblings, 1 reply; 10+ messages in thread
From: François Dumont @ 2022-05-30 20:58 UTC (permalink / raw)
  To: libstdc++; +Cc: gcc-patches

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

Hi

Here is the patch to use cxx11 abi for the versioned namespace mode.

It is still suffering from a side effect on gdb pretty printers with 3 
errors like:

got: type = 
std::unique_ptr<std::vector<std::unique_ptr<std::list<std::__8::basic_string<char, 
std::__8::char_traits<char>, std::__8::allocator<char> >>[]>>[99]>
FAIL: libstdc++-prettyprinters/80276.cc whatis p4

However once I apply the version bump errors are gone.

Let me know if it is ok to apply all at once or if you prefer to avoid 
the version bump.

François

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

diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
index 138bd58d86c..0fe8ce89986 100644
--- a/libstdc++-v3/acinclude.m4
+++ b/libstdc++-v3/acinclude.m4
@@ -4449,12 +4449,16 @@ 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.
-    enable_libstdcxx_dual_abi="no"
-  fi
-  if test x"$enable_libstdcxx_dual_abi" != xyes; then
+    # gnu-versioned-namespace is incompatible with the dual ABI...
     AC_MSG_NOTICE([dual ABI is disabled])
-    default_libstdcxx_abi="gcc4-compatible"
+    enable_libstdcxx_dual_abi="no"
+    # ... 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 1265190dad9..5f91fd9b560 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 a778a6f402d..6b56e30a568 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 556575363da..54be63c44d7 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 c714d6a544f..ae17cb76c81 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/configure b/libstdc++-v3/configure
index 9b94fd71e42..d3c4106a74a 100755
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -75217,13 +75217,18 @@ fi
 
 
   if test x$enable_symvers = xgnu-versioned-namespace; then
-    # gnu-versioned-namespace is incompatible with the dual ABI.
-    enable_libstdcxx_dual_abi="no"
-  fi
-  if test x"$enable_libstdcxx_dual_abi" != xyes; then
+    # gnu-versioned-namespace is incompatible with the dual ABI...
     { $as_echo "$as_me:${as_lineno-$LINENO}: dual ABI is disabled" >&5
 $as_echo "$as_me: dual ABI is disabled" >&6;}
-    default_libstdcxx_abi="gcc4-compatible"
+    enable_libstdcxx_dual_abi="no"
+    # ... and use the cxx11 one.
+    default_libstdcxx_abi="new"
+  else
+    if test x"$enable_libstdcxx_dual_abi" != xyes; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: dual ABI is disabled" >&5
+$as_echo "$as_me: dual ABI is disabled" >&6;}
+      default_libstdcxx_abi="gcc4-compatible"
+    fi
   fi
 
 
diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config
index 191880fb99d..f899a580b60 100644
--- a/libstdc++-v3/include/bits/c++config
+++ b/libstdc++-v3/include/bits/c++config
@@ -325,26 +325,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 
 
@@ -396,7 +376,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_VERSION_NAMESPACE
   inline namespace __cxx11 __attribute__((__abi_tag__ ("cxx11"))) { }
 # endif
   }
@@ -426,6 +406,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/python/libstdcxx/v6/printers.py b/libstdc++-v3/python/libstdcxx/v6/printers.py
index 17c33c1e54f..f11ac066966 100644
--- a/libstdc++-v3/python/libstdcxx/v6/printers.py
+++ b/libstdc++-v3/python/libstdcxx/v6/printers.py
@@ -942,6 +942,8 @@ class StdStringPrinter:
     def __init__(self, typename, val):
         self.val = val
         self.new_string = typename.find("::__cxx11::basic_string") != -1
+        if not self.new_string and _versioned_namespace:
+            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 b83c222d51d..fcab83ada2d 100644
--- a/libstdc++-v3/src/Makefile.am
+++ b/libstdc++-v3/src/Makefile.am
@@ -82,6 +82,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 = \
@@ -95,6 +98,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/Makefile.in b/libstdc++-v3/src/Makefile.in
index cef290c5d11..946101389c4 100644
--- a/libstdc++-v3/src/Makefile.in
+++ b/libstdc++-v3/src/Makefile.in
@@ -158,10 +158,9 @@ am__objects_2 = compatibility.lo compatibility-debug_list.lo \
 @ENABLE_SYMVERS_GNU_NAMESPACE_FALSE@	compatibility-chrono.lo \
 @ENABLE_SYMVERS_GNU_NAMESPACE_FALSE@	compatibility-condvar.lo \
 @ENABLE_SYMVERS_GNU_NAMESPACE_FALSE@	compatibility-thread-c++0x.lo
-@ENABLE_DUAL_ABI_TRUE@@GLIBCXX_LDBL_ALT128_COMPAT_TRUE@am__objects_4 = compatibility-ldbl-alt128-cxx11.lo
-@GLIBCXX_LDBL_ALT128_COMPAT_TRUE@am__objects_5 =  \
-@GLIBCXX_LDBL_ALT128_COMPAT_TRUE@	compatibility-ldbl-alt128.lo \
-@GLIBCXX_LDBL_ALT128_COMPAT_TRUE@	$(am__objects_4)
+@ENABLE_DUAL_ABI_TRUE@@ENABLE_SYMVERS_GNU_NAMESPACE_FALSE@@GLIBCXX_LDBL_ALT128_COMPAT_TRUE@am__objects_4 = compatibility-ldbl-alt128-cxx11.lo
+@ENABLE_SYMVERS_GNU_NAMESPACE_FALSE@@GLIBCXX_LDBL_ALT128_COMPAT_TRUE@am__objects_5 = compatibility-ldbl-alt128.lo \
+@ENABLE_SYMVERS_GNU_NAMESPACE_FALSE@@GLIBCXX_LDBL_ALT128_COMPAT_TRUE@	$(am__objects_4)
 am__objects_6 = $(am__objects_3) $(am__objects_5)
 am_libstdc___la_OBJECTS = $(am__objects_2) $(am__objects_6)
 libstdc___la_OBJECTS = $(am_libstdc___la_OBJECTS)
@@ -506,14 +505,15 @@ SUBDIRS = c++98 c++11 c++17 c++20 $(filesystem_dir) $(backtrace_dir)
 
 @GLIBCXX_LDBL_COMPAT_FALSE@ldbl_compat_sources = 
 @GLIBCXX_LDBL_COMPAT_TRUE@ldbl_compat_sources = compatibility-ldbl.cc
-@ENABLE_DUAL_ABI_FALSE@@GLIBCXX_LDBL_ALT128_COMPAT_TRUE@ldbl_alt128_compat_cxx11_sources = 
-@ENABLE_DUAL_ABI_TRUE@@GLIBCXX_LDBL_ALT128_COMPAT_TRUE@ldbl_alt128_compat_cxx11_sources = \
-@ENABLE_DUAL_ABI_TRUE@@GLIBCXX_LDBL_ALT128_COMPAT_TRUE@	compatibility-ldbl-alt128-cxx11.cc
-
-@GLIBCXX_LDBL_ALT128_COMPAT_FALSE@ldbl_alt128_compat_sources = 
-@GLIBCXX_LDBL_ALT128_COMPAT_TRUE@ldbl_alt128_compat_sources = \
-@GLIBCXX_LDBL_ALT128_COMPAT_TRUE@	compatibility-ldbl-alt128.cc \
-@GLIBCXX_LDBL_ALT128_COMPAT_TRUE@	${ldbl_alt128_compat_cxx11_sources}
+@ENABLE_SYMVERS_GNU_NAMESPACE_FALSE@@GLIBCXX_LDBL_ALT128_COMPAT_FALSE@ldbl_alt128_compat_sources = 
+@ENABLE_SYMVERS_GNU_NAMESPACE_FALSE@@GLIBCXX_LDBL_ALT128_COMPAT_TRUE@ldbl_alt128_compat_sources = \
+@ENABLE_SYMVERS_GNU_NAMESPACE_FALSE@@GLIBCXX_LDBL_ALT128_COMPAT_TRUE@	compatibility-ldbl-alt128.cc \
+@ENABLE_SYMVERS_GNU_NAMESPACE_FALSE@@GLIBCXX_LDBL_ALT128_COMPAT_TRUE@	${ldbl_alt128_compat_cxx11_sources}
+
+@ENABLE_SYMVERS_GNU_NAMESPACE_TRUE@ldbl_alt128_compat_sources = 
+@ENABLE_DUAL_ABI_FALSE@@ENABLE_SYMVERS_GNU_NAMESPACE_FALSE@@GLIBCXX_LDBL_ALT128_COMPAT_TRUE@ldbl_alt128_compat_cxx11_sources = 
+@ENABLE_DUAL_ABI_TRUE@@ENABLE_SYMVERS_GNU_NAMESPACE_FALSE@@GLIBCXX_LDBL_ALT128_COMPAT_TRUE@ldbl_alt128_compat_cxx11_sources = \
+@ENABLE_DUAL_ABI_TRUE@@ENABLE_SYMVERS_GNU_NAMESPACE_FALSE@@GLIBCXX_LDBL_ALT128_COMPAT_TRUE@	compatibility-ldbl-alt128-cxx11.cc
 
 @ENABLE_SYMVERS_GNU_NAMESPACE_FALSE@cxx0x_compat_sources = \
 @ENABLE_SYMVERS_GNU_NAMESPACE_FALSE@	compatibility-atomic-c++0x.cc \
diff --git a/libstdc++-v3/src/c++11/Makefile.am b/libstdc++-v3/src/c++11/Makefile.am
index ecd46aafc01..b22c54fa057 100644
--- a/libstdc++-v3/src/c++11/Makefile.am
+++ b/libstdc++-v3/src/c++11/Makefile.am
@@ -40,22 +40,22 @@ ctype_members.cc: ${glibcxx_srcdir}/$(CCTYPE_CC)
 	$(LN_S) ${glibcxx_srcdir}/$(CCTYPE_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 = \
 	chrono.cc \
 	codecvt.cc \
 	condition_variable.cc \
+	cow-locale_init.cc \
 	cow-stdexcept.cc \
+	cxx11-hash_tr1.cc \
+	cxx11-ios_failure.cc \
+	cxx11-stdexcept.cc \
 	ctype.cc \
 	debug.cc \
 	functexcept.cc \
@@ -75,19 +75,11 @@ sources = \
 	snprintf_lite.cc \
 	system_error.cc \
 	thread.cc \
-	${cxx11_abi_sources} \
+	${dual_abi_sources} \
 	${host_sources}
 
 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 =
@@ -97,6 +89,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/Makefile.in b/libstdc++-v3/src/c++11/Makefile.in
index 4db28bd8515..fa5b9543f76 100644
--- a/libstdc++-v3/src/c++11/Makefile.in
+++ b/libstdc++-v3/src/c++11/Makefile.in
@@ -122,26 +122,27 @@ CONFIG_CLEAN_FILES =
 CONFIG_CLEAN_VPATH_FILES =
 LTLIBRARIES = $(noinst_LTLIBRARIES)
 libc__11convenience_la_LIBADD =
-@ENABLE_DUAL_ABI_TRUE@am__objects_1 = cow-locale_init.lo \
-@ENABLE_DUAL_ABI_TRUE@	cow-shim_facets.lo cxx11-hash_tr1.lo \
-@ENABLE_DUAL_ABI_TRUE@	cxx11-ios_failure.lo \
-@ENABLE_DUAL_ABI_TRUE@	cxx11-shim_facets.lo cxx11-stdexcept.lo
+@ENABLE_DUAL_ABI_TRUE@am__objects_1 = cow-shim_facets.lo \
+@ENABLE_DUAL_ABI_TRUE@	cxx11-shim_facets.lo
 am__objects_2 = ctype_configure_char.lo ctype_members.lo
 am__objects_3 = chrono.lo codecvt.lo condition_variable.lo \
-	cow-stdexcept.lo ctype.lo debug.lo functexcept.lo \
-	functional.lo futex.lo future.lo hash_c++0x.lo \
+	cow-locale_init.lo cow-stdexcept.lo cxx11-hash_tr1.lo \
+	cxx11-ios_failure.lo cxx11-stdexcept.lo ctype.lo debug.lo \
+	functexcept.lo functional.lo futex.lo future.lo hash_c++0x.lo \
 	hashtable_c++0x.lo ios.lo ios_errcat.lo limits.lo mutex.lo \
 	placeholders.lo random.lo regex.lo shared_ptr.lo \
 	snprintf_lite.lo system_error.lo thread.lo $(am__objects_1) \
 	$(am__objects_2)
-@ENABLE_DUAL_ABI_TRUE@am__objects_4 = cow-fstream-inst.lo \
-@ENABLE_DUAL_ABI_TRUE@	cow-sstream-inst.lo cow-string-inst.lo \
-@ENABLE_DUAL_ABI_TRUE@	cow-string-io-inst.lo \
-@ENABLE_DUAL_ABI_TRUE@	cow-wstring-inst.lo \
-@ENABLE_DUAL_ABI_TRUE@	cow-wstring-io-inst.lo \
-@ENABLE_DUAL_ABI_TRUE@	cxx11-locale-inst.lo \
-@ENABLE_DUAL_ABI_TRUE@	cxx11-wlocale-inst.lo sso_string.lo
+@ENABLE_DUAL_ABI_TRUE@am__objects_4 = sso_string.lo
 @ENABLE_EXTERN_TEMPLATE_TRUE@am__objects_5 = $(am__objects_4) \
+@ENABLE_EXTERN_TEMPLATE_TRUE@	cow-fstream-inst.lo \
+@ENABLE_EXTERN_TEMPLATE_TRUE@	cow-sstream-inst.lo \
+@ENABLE_EXTERN_TEMPLATE_TRUE@	cow-string-inst.lo \
+@ENABLE_EXTERN_TEMPLATE_TRUE@	cow-string-io-inst.lo \
+@ENABLE_EXTERN_TEMPLATE_TRUE@	cow-wstring-inst.lo \
+@ENABLE_EXTERN_TEMPLATE_TRUE@	cow-wstring-io-inst.lo \
+@ENABLE_EXTERN_TEMPLATE_TRUE@	cxx11-locale-inst.lo \
+@ENABLE_EXTERN_TEMPLATE_TRUE@	cxx11-wlocale-inst.lo \
 @ENABLE_EXTERN_TEMPLATE_TRUE@	ext11-inst.lo fstream-inst.lo \
 @ENABLE_EXTERN_TEMPLATE_TRUE@	ios-inst.lo iostream-inst.lo \
 @ENABLE_EXTERN_TEMPLATE_TRUE@	istream-inst.lo locale-inst.lo \
@@ -457,20 +458,20 @@ host_sources = \
 	ctype_configure_char.cc \
 	ctype_members.cc
 
-@ENABLE_DUAL_ABI_FALSE@cxx11_abi_sources = 
-@ENABLE_DUAL_ABI_TRUE@cxx11_abi_sources = \
-@ENABLE_DUAL_ABI_TRUE@	cow-locale_init.cc \
+@ENABLE_DUAL_ABI_FALSE@dual_abi_sources = 
+@ENABLE_DUAL_ABI_TRUE@dual_abi_sources = \
 @ENABLE_DUAL_ABI_TRUE@	cow-shim_facets.cc \
-@ENABLE_DUAL_ABI_TRUE@	cxx11-hash_tr1.cc \
-@ENABLE_DUAL_ABI_TRUE@	cxx11-ios_failure.cc \
-@ENABLE_DUAL_ABI_TRUE@	cxx11-shim_facets.cc \
-@ENABLE_DUAL_ABI_TRUE@	cxx11-stdexcept.cc
+@ENABLE_DUAL_ABI_TRUE@	cxx11-shim_facets.cc
 
 sources = \
 	chrono.cc \
 	codecvt.cc \
 	condition_variable.cc \
+	cow-locale_init.cc \
 	cow-stdexcept.cc \
+	cxx11-hash_tr1.cc \
+	cxx11-ios_failure.cc \
+	cxx11-stdexcept.cc \
 	ctype.cc \
 	debug.cc \
 	functexcept.cc \
@@ -490,19 +491,11 @@ sources = \
 	snprintf_lite.cc \
 	system_error.cc \
 	thread.cc \
-	${cxx11_abi_sources} \
+	${dual_abi_sources} \
 	${host_sources}
 
 @ENABLE_DUAL_ABI_FALSE@extra_string_inst_sources = 
 @ENABLE_DUAL_ABI_TRUE@extra_string_inst_sources = \
-@ENABLE_DUAL_ABI_TRUE@	cow-fstream-inst.cc \
-@ENABLE_DUAL_ABI_TRUE@	cow-sstream-inst.cc \
-@ENABLE_DUAL_ABI_TRUE@	cow-string-inst.cc \
-@ENABLE_DUAL_ABI_TRUE@	cow-string-io-inst.cc \
-@ENABLE_DUAL_ABI_TRUE@	cow-wstring-inst.cc \
-@ENABLE_DUAL_ABI_TRUE@	cow-wstring-io-inst.cc \
-@ENABLE_DUAL_ABI_TRUE@	cxx11-locale-inst.cc \
-@ENABLE_DUAL_ABI_TRUE@	cxx11-wlocale-inst.cc \
 @ENABLE_DUAL_ABI_TRUE@	sso_string.cc
 
 # XTEMPLATE_FLAGS =
@@ -511,6 +504,14 @@ sources = \
 # XTEMPLATE_FLAGS = -fno-implicit-templates
 @ENABLE_EXTERN_TEMPLATE_TRUE@inst_sources = \
 @ENABLE_EXTERN_TEMPLATE_TRUE@	$(extra_string_inst_sources) \
+@ENABLE_EXTERN_TEMPLATE_TRUE@	cow-fstream-inst.cc \
+@ENABLE_EXTERN_TEMPLATE_TRUE@	cow-sstream-inst.cc \
+@ENABLE_EXTERN_TEMPLATE_TRUE@	cow-string-inst.cc \
+@ENABLE_EXTERN_TEMPLATE_TRUE@	cow-string-io-inst.cc \
+@ENABLE_EXTERN_TEMPLATE_TRUE@	cow-wstring-inst.cc \
+@ENABLE_EXTERN_TEMPLATE_TRUE@	cow-wstring-io-inst.cc \
+@ENABLE_EXTERN_TEMPLATE_TRUE@	cxx11-locale-inst.cc \
+@ENABLE_EXTERN_TEMPLATE_TRUE@	cxx11-wlocale-inst.cc \
 @ENABLE_EXTERN_TEMPLATE_TRUE@	ext11-inst.cc \
 @ENABLE_EXTERN_TEMPLATE_TRUE@	fstream-inst.cc \
 @ENABLE_EXTERN_TEMPLATE_TRUE@	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 6b6352c1419..d9657484326 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 4d5c08f20cc..fa27b4142f2 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
@@ -193,3 +190,4 @@ namespace
 
 _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 8839f4a6f75..2db78a43f50 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 9e8787485eb..8b217c45960 100644
--- a/libstdc++-v3/src/c++11/cow-stdexcept.cc
+++ b/libstdc++-v3/src/c++11/cow-stdexcept.cc
@@ -41,7 +41,7 @@ _txnal_logic_error_get_msg(void* e);
 void*
 _txnal_runtime_error_get_msg(void* e);
 
-// All exception classes still use the classic COW std::string.
+// In dual abi 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
@@ -169,6 +169,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
                 "alignof(std::string) has changed");
 #endif
 
+#if ! _GLIBCXX_USE_CXX11_ABI
   // Return error_category::message() as an SSO string
   __sso_string
   error_category::_M_message(int i) const
@@ -176,10 +177,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 +466,4 @@ CTORDTOR(15underflow_error, std::underflow_error, runtime_error)
 
 #endif  // _GLIBCXX_USE_C99_STDINT_TR1
 #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 e5331bb029a..40ebe708971 100644
--- a/libstdc++-v3/src/c++11/cow-string-inst.cc
+++ b/libstdc++-v3/src/c++11/cow-string-inst.cc
@@ -27,11 +27,10 @@
 //
 
 #define _GLIBCXX_USE_CXX11_ABI 0
-#include "string-inst.cc"
+#include <bits/c++config.h>
 
-#if ! _GLIBCXX_USE_DUAL_ABI
-# error This file should not be compiled for this configuration.
-#endif
+#if ! _GLIBCXX_USE_CXX11_ABI
+#include "string-inst.cc"
 
 #ifdef  _GLIBCXX_USE_C99_STDINT_TR1
 #include <random>
@@ -47,3 +46,4 @@ namespace std _GLIBCXX_VISIBILITY(default)
   { _M_init(token.c_str(), token.length()); }
 } // namespace
 #endif
+#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 3f65aeb9873..a3720680907 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 a38c1288ef3..b0eff7ef97d 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 dbd19e0feb0..f0ed5cc6b6b 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 f36541fd4cc..edd89974e1b 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 0a81e15e4c0..db4c623a536 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 5c860054ea6..814cdcc9902 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 236bc40cd55..9faf355977a 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)
 {
@@ -70,9 +68,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   underflow_error::underflow_error(const string& __arg)
   : runtime_error(__arg) { }
 
+# if _GLIBCXX_USE_DUAL_ABI
   // Converting constructor from ABI-tagged std::string to COW string.
   __cow_string::__cow_string(const string& s)
   : __cow_string(s.c_str(), s.length()) { }
+# endif
 
 _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 6d26292075d..7491d5117df 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/fstream-inst.cc b/libstdc++-v3/src/c++11/fstream-inst.cc
index 7bf56c7e864..494c7bb51d0 100644
--- a/libstdc++-v3/src/c++11/fstream-inst.cc
+++ b/libstdc++-v3/src/c++11/fstream-inst.cc
@@ -29,6 +29,7 @@
 #define _GLIBCXX_USE_CXX11_ABI 1
 #include <fstream>
 
+#if _GLIBCXX_USE_CXX11_ABI
 namespace std _GLIBCXX_VISIBILITY(default)
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
@@ -47,3 +48,4 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
+#endif
diff --git a/libstdc++-v3/src/c++11/locale-inst-numeric.h b/libstdc++-v3/src/c++11/locale-inst-numeric.h
index 1417ac25ed4..5b72c30bd5a 100644
--- a/libstdc++-v3/src/c++11/locale-inst-numeric.h
+++ b/libstdc++-v3/src/c++11/locale-inst-numeric.h
@@ -23,12 +23,12 @@
 // <http://www.gnu.org/licenses/>.
 
 #ifndef C
-#define "This file should not be compiled directly, only included"
+# error "This file should not be compiled directly, only included"
 #endif
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
-#if ! _GLIBCXX_USE_CXX11_ABI
+#if ! _GLIBCXX_USE_CXX11_ABI || ! _GLIBCXX_USE_DUAL_ABI
   template const num_get<C>& use_facet<num_get<C> >(const locale&);
   template const num_put<C>& use_facet<num_put<C> >(const locale&);
 
@@ -38,7 +38,7 @@ namespace std _GLIBCXX_VISIBILITY(default)
 
 _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 3aee5df9b04..30847cbef7f 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
@@ -51,7 +60,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
@@ -63,7 +72,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
@@ -72,7 +81,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> >;
@@ -96,13 +105,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
@@ -117,7 +126,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
 _GLIBCXX_END_NAMESPACE_CXX11
 
   // use_facet
-#if ! _GLIBCXX_USE_CXX11_ABI
+#if ! _GLIBCXX_USE_CXX11_ABI || ! _GLIBCXX_USE_DUAL_ABI
   template
     const ctype<C>&
     use_facet<ctype<C> >(const locale&);
@@ -143,7 +152,7 @@ _GLIBCXX_END_NAMESPACE_CXX11
     const moneypunct<C, false>&
     use_facet<moneypunct<C, false> >(const locale&);
 
-#if ! _GLIBCXX_USE_CXX11_ABI
+#if ! _GLIBCXX_USE_CXX11_ABI || ! _GLIBCXX_USE_DUAL_ABI
   template
     const __timepunct<C>&
     use_facet<__timepunct<C> >(const locale&);
@@ -162,7 +171,7 @@ _GLIBCXX_END_NAMESPACE_CXX11
     use_facet<messages<C> >(const locale&);
 
   // has_facet
-#if ! _GLIBCXX_USE_CXX11_ABI
+#if ! _GLIBCXX_USE_CXX11_ABI || ! _GLIBCXX_USE_DUAL_ABI
   template
     bool
     has_facet<ctype<C> >(const locale&);
@@ -184,7 +193,7 @@ _GLIBCXX_END_NAMESPACE_CXX11
     bool
     has_facet<moneypunct<C> >(const locale&);
 
-#if ! _GLIBCXX_USE_CXX11_ABI
+#if ! _GLIBCXX_USE_CXX11_ABI || ! _GLIBCXX_USE_DUAL_ABI
   template
     bool
     has_facet<__timepunct<C> >(const locale&);
@@ -203,7 +212,7 @@ _GLIBCXX_END_NAMESPACE_CXX11
     has_facet<messages<C> >(const locale&);
 
 
-#if ! _GLIBCXX_USE_CXX11_ABI
+#if ! _GLIBCXX_USE_CXX11_ABI || ! _GLIBCXX_USE_DUAL_ABI
   // locale functions.
   template
     C*
@@ -228,7 +237,11 @@ _GLIBCXX_END_NAMESPACE_CXX11
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
 
+#if ! _GLIBCXX_INLINE_VERSION
 // XXX GLIBCXX_ABI Deprecated
-#if defined _GLIBCXX_LONG_DOUBLE_COMPAT && ! _GLIBCXX_USE_CXX11_ABI
-#include "compatibility-ldbl-facets-aliases.h"
-#endif // _GLIBCXX_LONG_DOUBLE_COMPAT
+# if defined _GLIBCXX_LONG_DOUBLE_COMPAT && ! _GLIBCXX_USE_CXX11_ABI
+#  include "compatibility-ldbl-facets-aliases.h"
+# endif // _GLIBCXX_LONG_DOUBLE_COMPAT
+#endif
+
+#endif //  _GLIBCXX_BUILD_CXX11_ABI == _GLIBCXX_USE_CXX11_ABI
diff --git a/libstdc++-v3/src/c++11/wlocale-inst.cc b/libstdc++-v3/src/c++11/wlocale-inst.cc
index 0855f67707c..0338a9554a2 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 b96588bd95c..9bbe8c00a73 100644
--- a/libstdc++-v3/src/c++98/Makefile.am
+++ b/libstdc++-v3/src/c++98/Makefile.am
@@ -90,13 +90,6 @@ c++locale.cc: ${glibcxx_srcdir}/$(CLOCALE_CC)
 basic_file.cc: ${glibcxx_srcdir}/$(BASIC_FILE_CC)
 	$(LN_S) ${glibcxx_srcdir}/$(BASIC_FILE_CC) ./$@ || true
 
-if ENABLE_DUAL_ABI
-cxx11_abi_sources = \
-	cow-istream-string.cc
-else
-cxx11_abi_sources =
-endif
-
 if ENABLE_EXTERN_TEMPLATE
 # XTEMPLATE_FLAGS = -fno-implicit-templates
 inst_sources = \
@@ -118,6 +111,7 @@ sources = \
 	mt_allocator.cc \
 	codecvt.cc \
 	complex_io.cc \
+	cow-istream-string.cc \
 	globals_io.cc \
 	hash_tr1.cc \
 	hashtable_tr1.cc \
@@ -142,7 +136,6 @@ sources = \
 	istream-string.cc \
 	streambuf.cc \
 	valarray.cc \
-	${cxx11_abi_sources} \
 	${host_sources} \
 	${host_sources_extra}
 
diff --git a/libstdc++-v3/src/c++98/Makefile.in b/libstdc++-v3/src/c++98/Makefile.in
index 90eff5da986..aafc04efe89 100644
--- a/libstdc++-v3/src/c++98/Makefile.in
+++ b/libstdc++-v3/src/c++98/Makefile.in
@@ -122,30 +122,29 @@ CONFIG_CLEAN_FILES =
 CONFIG_CLEAN_VPATH_FILES =
 LTLIBRARIES = $(noinst_LTLIBRARIES)
 libc__98convenience_la_LIBADD =
-@ENABLE_DUAL_ABI_TRUE@am__objects_1 = cow-istream-string.lo
-@ENABLE_DUAL_ABI_TRUE@am__objects_2 = collate_members_cow.lo \
+@ENABLE_DUAL_ABI_TRUE@am__objects_1 = collate_members_cow.lo \
 @ENABLE_DUAL_ABI_TRUE@	messages_members_cow.lo \
 @ENABLE_DUAL_ABI_TRUE@	monetary_members_cow.lo \
 @ENABLE_DUAL_ABI_TRUE@	numeric_members_cow.lo
-am__objects_3 = $(am__objects_2) codecvt_members.lo collate_members.lo \
+am__objects_2 = $(am__objects_1) codecvt_members.lo collate_members.lo \
 	messages_members.lo monetary_members.lo numeric_members.lo \
 	time_members.lo
-@ENABLE_EXTERN_TEMPLATE_TRUE@am__objects_4 = allocator-inst.lo \
+@ENABLE_EXTERN_TEMPLATE_TRUE@am__objects_3 = allocator-inst.lo \
 @ENABLE_EXTERN_TEMPLATE_TRUE@	concept-inst.lo ext-inst.lo \
 @ENABLE_EXTERN_TEMPLATE_TRUE@	misc-inst.lo
-am__objects_5 = parallel_settings.lo
-am__objects_6 = basic_file.lo c++locale.lo $(am__objects_4) \
-	$(am__objects_5)
-am__objects_7 = bitmap_allocator.lo pool_allocator.lo mt_allocator.lo \
-	codecvt.lo complex_io.lo globals_io.lo hash_tr1.lo \
-	hashtable_tr1.lo ios_failure.lo ios_init.lo ios_locale.lo \
-	list.lo list-aux.lo list-aux-2.lo list_associated.lo \
-	list_associated-2.lo locale.lo locale_init.lo locale_facets.lo \
-	localename.lo math_stubs_float.lo math_stubs_long_double.lo \
-	stdexcept.lo strstream.lo tree.lo istream.lo istream-string.lo \
-	streambuf.lo valarray.lo $(am__objects_1) $(am__objects_3) \
-	$(am__objects_6)
-am_libc__98convenience_la_OBJECTS = $(am__objects_7)
+am__objects_4 = parallel_settings.lo
+am__objects_5 = basic_file.lo c++locale.lo $(am__objects_3) \
+	$(am__objects_4)
+am__objects_6 = bitmap_allocator.lo pool_allocator.lo mt_allocator.lo \
+	codecvt.lo complex_io.lo cow-istream-string.lo globals_io.lo \
+	hash_tr1.lo hashtable_tr1.lo ios_failure.lo ios_init.lo \
+	ios_locale.lo list.lo list-aux.lo list-aux-2.lo \
+	list_associated.lo list_associated-2.lo locale.lo \
+	locale_init.lo locale_facets.lo localename.lo \
+	math_stubs_float.lo math_stubs_long_double.lo stdexcept.lo \
+	strstream.lo tree.lo istream.lo istream-string.lo streambuf.lo \
+	valarray.lo $(am__objects_2) $(am__objects_5)
+am_libc__98convenience_la_OBJECTS = $(am__objects_6)
 libc__98convenience_la_OBJECTS = $(am_libc__98convenience_la_OBJECTS)
 AM_V_lt = $(am__v_lt_@AM_V@)
 am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
@@ -470,10 +469,6 @@ host_sources_extra = \
 	basic_file.cc c++locale.cc \
 	${inst_sources} ${parallel_sources}
 
-@ENABLE_DUAL_ABI_FALSE@cxx11_abi_sources = 
-@ENABLE_DUAL_ABI_TRUE@cxx11_abi_sources = \
-@ENABLE_DUAL_ABI_TRUE@	cow-istream-string.cc
-
 # XTEMPLATE_FLAGS =
 @ENABLE_EXTERN_TEMPLATE_FALSE@inst_sources = 
 
@@ -493,6 +488,7 @@ sources = \
 	mt_allocator.cc \
 	codecvt.cc \
 	complex_io.cc \
+	cow-istream-string.cc \
 	globals_io.cc \
 	hash_tr1.cc \
 	hashtable_tr1.cc \
@@ -517,7 +513,6 @@ sources = \
 	istream-string.cc \
 	streambuf.cc \
 	valarray.cc \
-	${cxx11_abi_sources} \
 	${host_sources} \
 	${host_sources_extra}
 
diff --git a/libstdc++-v3/src/c++98/cow-istream-string.cc b/libstdc++-v3/src/c++98/cow-istream-string.cc
index d90ec2a0cf3..ff406830c61 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 caa424e423f..7256d2529cf 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 523d1f6a4e9..7fea41af56c 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
-
-#ifdef _GLIBCXX_USE_NLS
-# include <libintl.h>
-# define _(msgid)   gettext (msgid)
-#else
-# define _(msgid)   (msgid)
-#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
+#  include <libintl.h>
+#  define _(msgid)   gettext (msgid)
+# else
+#  define _(msgid)   (msgid)
+# 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,11 +56,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   const char*
   ios_base::failure::what() const throw()
   { return _M_msg.c_str(); }
+# endif
 
-#if _GLIBCXX_USE_DUAL_ABI
+# if _GLIBCXX_USE_DUAL_ABI
   // When the dual ABI is enabled __throw_ios_failure() is defined in
   // src/c++11/cxx11-ios_failure.cc
-#if __cpp_rtti
+#  if __cpp_rtti
   // If RTTI is enabled the exception type thrown will use these functions to
   // construct/destroy a gcc4-compatible ios::failure object in a buffer,
   // and to catch that object via a handler of the gcc4-compatible type.
@@ -80,9 +83,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   typedef char S[1 / (sizeof(ios::failure) <= sizeof(runtime_error))];
   typedef char A[1 / (__alignof(ios::failure) <= __alignof(runtime_error))];
   }
-#endif // __cpp_rtti
+#  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_DUAL_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 19f5f0c1a47..034cd951d6d 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 1293a37e642..4b351b2e8ef 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 0a24b054ca0..786f0ff0523 100644
--- a/libstdc++-v3/src/c++98/stdexcept.cc
+++ b/libstdc++-v3/src/c++98/stdexcept.cc
@@ -26,7 +26,7 @@
 // ISO C++ 14882: 19.1  Exception classes
 //
 
-// All exception classes still use the classic COW std::string.
+// In dual abi all exception classes still use the classic COW std::string.
 #define _GLIBCXX_USE_CXX11_ABI 0
 #include <string>
 #include <stdexcept>
@@ -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 { }
 

[-- Attachment #3: bump_versioned_ns.patch --]
[-- Type: text/x-patch, Size: 8372 bytes --]

diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
index 0fe8ce89986..f182d2c01e9 100644
--- a/libstdc++-v3/acinclude.m4
+++ b/libstdc++-v3/acinclude.m4
@@ -3834,7 +3834,7 @@ case $enable_symvers in
 	      [Define to use GNU versioning in the shared library.])
     ;;
   gnu-versioned-namespace)
-    libtool_VERSION=8:0:0
+    libtool_VERSION=9:0:0
     SYMVER_FILE=config/abi/pre/gnu-versioned-namespace.ver
     AC_DEFINE(_GLIBCXX_SYMVER_GNU_NAMESPACE, 1,
 	      [Define to use GNU namespace versioning in the shared library.])
diff --git a/libstdc++-v3/config/abi/pre/gnu-versioned-namespace.ver b/libstdc++-v3/config/abi/pre/gnu-versioned-namespace.ver
index b37199ece72..3272c83cca4 100644
--- a/libstdc++-v3/config/abi/pre/gnu-versioned-namespace.ver
+++ b/libstdc++-v3/config/abi/pre/gnu-versioned-namespace.ver
@@ -19,7 +19,7 @@
 ## with this library; see the file COPYING3.  If not see
 ## <http://www.gnu.org/licenses/>.
 
-GLIBCXX_8.0 {
+GLIBCXX_9.0 {
 
   global:
 
@@ -27,7 +27,7 @@ GLIBCXX_8.0 {
     extern "C++"
     {
       std::*;
-      std::__8::*;
+      std::__9::*;
     };
 
     # operator new(size_t)
@@ -59,7 +59,7 @@ GLIBCXX_8.0 {
     # vtable
     _ZTVSt*;
     _ZTVNSt*;
-    _ZTVN9__gnu_cxx3__818stdio_sync_filebufI[cw]NSt3__811char_traitsI[cw]EEEE;
+    _ZTVN9__gnu_cxx3__918stdio_sync_filebufI[cw]NSt3__911char_traitsI[cw]EEEE;
 
     # thunk
     _ZTv0_n12_NS*;
@@ -74,54 +74,54 @@ GLIBCXX_8.0 {
     _ZTSNSt*;
 
     # locale
-    _ZNSt3__89has_facetINS_*;
+    _ZNSt3__99has_facetINS_*;
 
     # hash
-    _ZNSt8__detail3__812__prime_listE;
-    _ZNSt3tr18__detail3__812__prime_listE;
+    _ZNSt8__detail3__912__prime_listE;
+    _ZNSt3tr18__detail3__912__prime_listE;
 
     # thread/mutex/condition_variable/future
     __once_proxy;
 
     # std::__detail::_List_node_base
-    _ZNSt8__detail3__815_List_node_base7_M_hook*;
-    _ZNSt8__detail3__815_List_node_base9_M_unhookEv;
-    _ZNSt8__detail3__815_List_node_base10_M_reverseEv;
-    _ZNSt8__detail3__815_List_node_base11_M_transfer*;
-    _ZNSt8__detail3__815_List_node_base4swapER*;
+    _ZNSt8__detail3__915_List_node_base7_M_hook*;
+    _ZNSt8__detail3__915_List_node_base9_M_unhookEv;
+    _ZNSt8__detail3__915_List_node_base10_M_reverseEv;
+    _ZNSt8__detail3__915_List_node_base11_M_transfer*;
+    _ZNSt8__detail3__915_List_node_base4swapER*;
 
     # std::__convert_to_v
-    _ZNSt3__814__convert_to_v*;
+    _ZNSt3__914__convert_to_v*;
 
     # std::__copy_streambufs
-    _ZNSt3__817__copy_streambufsI*;
-    _ZNSt3__821__copy_streambufs_eofI*;
+    _ZNSt3__917__copy_streambufsI*;
+    _ZNSt3__921__copy_streambufs_eofI*;
 
     # std::__istream_extract(wistream&, wchar_t*, streamsize)
-    _ZNSt3__817__istream_extractIwNS_11char_traitsIwEEEEvRNS_13basic_istreamIT_T0_EEPS4_[ilx];
+    _ZNSt3__917__istream_extractIwNS_11char_traitsIwEEEEvRNS_13basic_istreamIT_T0_EEPS4_[ilx];
 
     # __gnu_cxx::__atomic_add
     # __gnu_cxx::__exchange_and_add
-    _ZN9__gnu_cxx3__812__atomic_addEPV[il][il];
-    _ZN9__gnu_cxx3__818__exchange_and_addEPV[li][il];
+    _ZN9__gnu_cxx3__912__atomic_addEPV[il][il];
+    _ZN9__gnu_cxx3__918__exchange_and_addEPV[li][il];
 
     # __gnu_cxx::__pool
-    _ZN9__gnu_cxx3__86__poolILb[01]EE13_M_initializeEv;
-    _ZN9__gnu_cxx3__86__poolILb[01]EE16_M_reserve_blockE[jmy][jmy];
-    _ZN9__gnu_cxx3__86__poolILb[01]EE16_M_reclaim_blockEPc[jmy];
-    _ZN9__gnu_cxx3__86__poolILb[01]EE10_M_destroyEv;
-    _ZN9__gnu_cxx3__86__poolILb1EE16_M_get_thread_idEv;
+    _ZN9__gnu_cxx3__96__poolILb[01]EE13_M_initializeEv;
+    _ZN9__gnu_cxx3__96__poolILb[01]EE16_M_reserve_blockE[jmy][jmy];
+    _ZN9__gnu_cxx3__96__poolILb[01]EE16_M_reclaim_blockEPc[jmy];
+    _ZN9__gnu_cxx3__96__poolILb[01]EE10_M_destroyEv;
+    _ZN9__gnu_cxx3__96__poolILb1EE16_M_get_thread_idEv;
 
-    _ZN9__gnu_cxx3__817__pool_alloc_base9_M_refillE[jmy];
-    _ZN9__gnu_cxx3__817__pool_alloc_base16_M_get_free_listE[jmy];
-    _ZN9__gnu_cxx3__817__pool_alloc_base12_M_get_mutexEv;
+    _ZN9__gnu_cxx3__917__pool_alloc_base9_M_refillE[jmy];
+    _ZN9__gnu_cxx3__917__pool_alloc_base16_M_get_free_listE[jmy];
+    _ZN9__gnu_cxx3__917__pool_alloc_base12_M_get_mutexEv;
 
-    _ZN9__gnu_cxx3__89free_list6_M_getE[jmy];
-    _ZN9__gnu_cxx3__89free_list8_M_clearEv;
+    _ZN9__gnu_cxx3__99free_list6_M_getE[jmy];
+    _ZN9__gnu_cxx3__99free_list8_M_clearEv;
 
     # __gnu_cxx::stdio_sync_filebuf
-    _ZTVN9__gnu_cxx3__818stdio_sync_filebufI[cw]St3__811char_traitsI[cw]EEE;
-    _ZN9__gnu_cxx3__818stdio_sync_filebufI[cw]NSt3__811char_traitsI[cw]EEE[5-9]*;
+    _ZTVN9__gnu_cxx3__918stdio_sync_filebufI[cw]St3__911char_traitsI[cw]EEE;
+    _ZN9__gnu_cxx3__918stdio_sync_filebufI[cw]NSt3__911char_traitsI[cw]EEE[5-9]*;
 
     # debug mode
     _ZN11__gnu_debug19_Safe_sequence_base12_M_get_mutexEv;
@@ -247,7 +247,7 @@ CXXABI_2.0 {
     _ZSt15_Fnv_hash_bytesPKv*;
 
     # __gnu_cxx::_verbose_terminate_handler()
-    _ZN9__gnu_cxx3__827__verbose_terminate_handlerEv;
+    _ZN9__gnu_cxx3__927__verbose_terminate_handlerEv;
 
     # *_type_info classes, ctor and dtor
     _ZN10__cxxabiv117__array_type_info*;
diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
index d3c4106a74a..a0ffdca4d1a 100755
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -74998,7 +74998,7 @@ $as_echo "#define _GLIBCXX_SYMVER_GNU 1" >>confdefs.h
 
     ;;
   gnu-versioned-namespace)
-    libtool_VERSION=8:0:0
+    libtool_VERSION=9:0:0
     SYMVER_FILE=config/abi/pre/gnu-versioned-namespace.ver
 
 $as_echo "#define _GLIBCXX_SYMVER_GNU_NAMESPACE 1" >>confdefs.h
diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config
index f899a580b60..5e0a9a0c63c 100644
--- a/libstdc++-v3/include/bits/c++config
+++ b/libstdc++-v3/include/bits/c++config
@@ -330,7 +330,7 @@ namespace std
 
 #if _GLIBCXX_INLINE_VERSION
 // Inline namespace for symbol versioning of (nearly) everything in std.
-# define _GLIBCXX_BEGIN_NAMESPACE_VERSION namespace __8 {
+# define _GLIBCXX_BEGIN_NAMESPACE_VERSION namespace __9 {
 # define _GLIBCXX_END_NAMESPACE_VERSION }
 // Unused when everything in std is versioned anyway.
 # define _GLIBCXX_BEGIN_INLINE_ABI_NAMESPACE(X)
diff --git a/libstdc++-v3/python/libstdcxx/v6/printers.py b/libstdc++-v3/python/libstdcxx/v6/printers.py
index f11ac066966..45490785296 100644
--- a/libstdc++-v3/python/libstdcxx/v6/printers.py
+++ b/libstdc++-v3/python/libstdcxx/v6/printers.py
@@ -100,7 +100,7 @@ def find_type(orig, name):
         else:
             raise ValueError("Cannot find type %s::%s" % (str(orig), name))
 
-_versioned_namespace = '__8::'
+_versioned_namespace = '__9::'
 
 def lookup_templ_spec(templ, *args):
     """
diff --git a/libstdc++-v3/testsuite/23_containers/map/48101_neg.cc b/libstdc++-v3/testsuite/23_containers/map/48101_neg.cc
index cc7ad160162..53aceb633c1 100644
--- a/libstdc++-v3/testsuite/23_containers/map/48101_neg.cc
+++ b/libstdc++-v3/testsuite/23_containers/map/48101_neg.cc
@@ -29,8 +29,8 @@ test01()
   c2.find(2); // { dg-error "here" }
 }
 
-// { dg-error "_Compare = std::(__8::)?less<int.>" "" { target *-*-* } 0 }
-// { dg-error "_Compare = std::(__8::)?allocator<int>" "" { target *-*-* } 0 }
+// { dg-error "_Compare = std::(__9::)?less<int.>" "" { target *-*-* } 0 }
+// { dg-error "_Compare = std::(__9::)?allocator<int>" "" { target *-*-* } 0 }
 // { dg-error "comparison object must be invocable" "" { target *-*-* } 0 }
 // { dg-prune-output "no match for call" }
 // { dg-prune-output "invalid conversion" }
diff --git a/libstdc++-v3/testsuite/23_containers/multimap/48101_neg.cc b/libstdc++-v3/testsuite/23_containers/multimap/48101_neg.cc
index 8bb69ec3e9d..cbb9583a548 100644
--- a/libstdc++-v3/testsuite/23_containers/multimap/48101_neg.cc
+++ b/libstdc++-v3/testsuite/23_containers/multimap/48101_neg.cc
@@ -29,8 +29,8 @@ test01()
   c2.find(2); // { dg-error "here" }
 }
 
-// { dg-error "_Compare = std::(__8::)?less<int.>" "" { target *-*-* } 0 }
-// { dg-error "_Compare = std::(__8::)?allocator<int>" "" { target *-*-* } 0 }
+// { dg-error "_Compare = std::(__9::)?less<int.>" "" { target *-*-* } 0 }
+// { dg-error "_Compare = std::(__9::)?allocator<int>" "" { target *-*-* } 0 }
 // { dg-error "comparison object must be invocable" "" { target *-*-* } 0 }
 // { dg-prune-output "no match for call" }
 // { dg-prune-output "invalid conversion" }

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Use cxx11 abi in versioned namespace
  2022-05-30 20:58 [PATCH] Use cxx11 abi in versioned namespace François Dumont
@ 2022-10-11 17:28 ` François Dumont
  2022-12-05 21:13   ` François Dumont
  0 siblings, 1 reply; 10+ messages in thread
From: François Dumont @ 2022-10-11 17:28 UTC (permalink / raw)
  To: libstdc++; +Cc: gcc-patches

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

Hi

     Now that pretty printer is fixed (once patch validated) I'd like to 
propose this patch again.

     Note that I'am adding a check on pretty printer with a std::any on 
a std::wstring. I did so because of the FIXME in printers.py which is 
dealing with 'std::string' explicitely. Looks like in my case, where 
there is no 'std::string' but just a 'std::__8::string' we do not need 
the workaround.

     Once again I am attaching also the version namespace bump patch as 
I think that adopting the cxx11 abi in this mode is a good enough reason 
to bump it. If you agress let me know if I should squash the commits 
before pushing.

     libstdc++: [_GLIBCXX_INLINE_VERSION] Use cxx11 abi

     Use cxx11 abi when activating versioned namespace mode.

     libstdcxx-v3/ChangeLog:

             * acinclude.m4 [GLIBCXX_ENABLE_LIBSTDCXX_DUAL_ABI]: Default 
to "new" libstdcxx abi.
             * config/locale/dragonfly/monetary_members.cc 
[!_GLIBCXX_USE_DUAL_ABI]: Define money_base
             members.
             * config/locale/generic/monetary_members.cc 
[!_GLIBCXX_USE_DUAL_ABI]: Likewise.
             * config/locale/gnu/monetary_members.cc 
[!_GLIBCXX_USE_DUAL_ABI]: Likewise.
             * config/locale/gnu/numeric_members.cc
             [!_GLIBCXX_USE_DUAL_ABI](__narrow_multibyte_chars): Define.
             * configure: Regenerate.
             * include/bits/c++config
             [_GLIBCXX_INLINE_VERSION](_GLIBCXX_NAMESPACE_CXX11, 
_GLIBCXX_BEGIN_NAMESPACE_CXX11): Define
             empty.
[_GLIBCXX_INLINE_VERSION](_GLIBCXX_END_NAMESPACE_CXX11, 
_GLIBCXX_DEFAULT_ABI_TAG): Likewise.
             * python/libstdcxx/v6/printers.py
             (StdStringPrinter::__init__): Set self.new_string to True 
when std::__8::basic_string type is
             found.
             * src/Makefile.am 
[ENABLE_SYMVERS_GNU_NAMESPACE](ldbl_alt128_compat_sources): Define empty.
             * src/Makefile.in: Regenerate.
             * src/c++11/Makefile.am (cxx11_abi_sources): Rename into...
             (dual_abi_sources): ...this, new. Also move several sources 
to...
             (sources): ...this.
             (extra_string_inst_sources): Move several sources to...
             (inst_sources): ...this.
             * src/c++11/Makefile.in: Regenerate.
             * src/c++11/cow-fstream-inst.cc [_GLIBCXX_USE_CXX11_ABI]: 
Skip definitions.
             * src/c++11/cow-locale_init.cc [_GLIBCXX_USE_CXX11_ABI]: 
Skip definitions.
             * src/c++11/cow-sstream-inst.cc [_GLIBCXX_USE_CXX11_ABI]: 
Skip definitions.
             * src/c++11/cow-stdexcept.cc 
[_GLIBCXX_USE_CXX11_ABI](error_category::_M_message):
             Skip definition.
             [_GLIBCXX_USE_CXX11_ABI]: Skip Transaction Memory TS 
definitions.
             * src/c++11/cow-string-inst.cc [_GLIBCXX_USE_CXX11_ABI]: 
Skip definitions.
             * src/c++11/cow-string-io-inst.cc [_GLIBCXX_USE_CXX11_ABI]: 
Skip definitions.
             * src/c++11/cow-wstring-inst.cc [_GLIBCXX_USE_CXX11_ABI]: 
Skip definitions.
             * src/c++11/cow-wstring-io-inst.cc 
[_GLIBCXX_USE_CXX11_ABI]: Skip definitions.
             * src/c++11/cxx11-hash_tr1.cc [!_GLIBCXX_USE_CXX11_ABI]: 
Skip definitions.
             * src/c++11/cxx11-ios_failure.cc [!_GLIBCXX_USE_CXX11_ABI]: 
Skip definitions.
             [!_GLIBCXX_USE_DUAL_ABI] (__ios_failure): Remove.
             * src/c++11/cxx11-locale-inst.cc: Cleanup, just include 
locale-inst.cc.
             * src/c++11/cxx11-stdexcept.cc [!_GLIBCXX_USE_CXX11_ABI]: 
Skip definitions.
             [!_GLIBCXX_USE_DUAL_ABI](__cow_string): Remove.
             * src/c++11/cxx11-wlocale-inst.cc 
[!_GLIBCXX_USE_CXX11_ABI]: Skip definitions.
             * src/c++11/fstream-inst.cc [!_GLIBCXX_USE_CXX11_ABI]: Skip 
definitions
             * src/c++11/locale-inst-numeric.h
[!_GLIBCXX_USE_DUAL_ABI](std::use_facet<num_get<>>, 
std::use_facet<num_put<>>): Instantiate.
[!_GLIBCXX_USE_DUAL_ABI](std::has_facet<num_get<>>, 
std::has_facet<num_put<>>): Instantiate.
             [!_GLIBCXX_USE_DUAL_ABI](std::num_get<C, 
istreambuf_iterator<C>>): Instantiate.
             [!_GLIBCXX_USE_DUAL_ABI](std::num_put<C, 
ostreambuf_iterator<C>>): Instantiate.
             * src/c++11/locale-inst.cc [!_GLIBCXX_USE_DUAL_ABI]: Build 
only when configured
             _GLIBCXX_USE_CXX11_ABI is equal to currently built abi.
             [!_GLIBCXX_USE_DUAL_ABI](__moneypunct_cache<C, false>): 
Instantiate.
             [!_GLIBCXX_USE_DUAL_ABI](__moneypunct_cache<C, true>): 
Instantiate.
             [!_GLIBCXX_USE_DUAL_ABI](__numpunct_cache<C>): Instantiate.
             [!_GLIBCXX_USE_DUAL_ABI](__timepunct<C>): Instantiate.
             [!_GLIBCXX_USE_DUAL_ABI](__timepunct_cache<C>): Instantiate.
             [!_GLIBCXX_USE_DUAL_ABI](time_put<C, 
ostreambuf_iterator<C>>): Instantiate.
             [!_GLIBCXX_USE_DUAL_ABI](time_put_byname<C, 
ostreambuf_iterator<C>>): Instantiate.
[!_GLIBCXX_USE_DUAL_ABI](__ctype_abstract_base<C>): Instantiate.
             [!_GLIBCXX_USE_DUAL_ABI](ctype_byname<C>): Instantiate.
             [!_GLIBCXX_USE_DUAL_ABI](__codecvt_abstract_base<C, char, 
mbstate_t>): Instantiate.
             [!_GLIBCXX_USE_DUAL_ABI](codecvt_byname<C, char, 
mbstate_t>): Instantiate.
[!_GLIBCXX_USE_DUAL_ABI](use_facet<ctype<C>>(const locale&)): Instantiate.
             [!_GLIBCXX_USE_DUAL_ABI](use_facet<codecvt<C, char, 
mbstate_t>>(const locale&)): Instantiate.
[!_GLIBCXX_USE_DUAL_ABI](use_facet<__timepunct<C>>(const locale&)): 
Instantiate.
[!_GLIBCXX_USE_DUAL_ABI](use_facet<time_put<C>>(const locale&)): 
Instantiate.
[!_GLIBCXX_USE_DUAL_ABI](has_facet<ctype<C>>(const locale&)): Instantiate.
             [!_GLIBCXX_USE_DUAL_ABI](has_facet<codecvt<C, char, 
mbstate_t>>(const locale&)): Instantiate.
[!_GLIBCXX_USE_DUAL_ABI](has_facet<__timepunct<C>>(const locale&)): 
Instantiate.
[!_GLIBCXX_USE_DUAL_ABI](has_facet<time_put<C>>(const locale&)): 
Instantiate.
             [!_GLIBCXX_USE_DUAL_ABI](__add_grouping<C>): Define.
             [!_GLIBCXX_USE_DUAL_ABI](__pad<C, char_traits<C>>): 
Instantiate.
             [!_GLIBCXX_USE_DUAL_ABI](__int_to_char(C*, unsigned long, 
const C*, ios_base::fmtflags, bool)):
             Define.
             [!_GLIBCXX_USE_DUAL_ABI](__int_to_char(C*, unsigned long 
long, const C*, ios_base::fmtflags, bool)):
             Define.
             * src/c++11/cxx11-wlocale-inst.cc 
[!_GLIBCXX_USE_CXX11_ABI]: Skip definitions.
             * src/c++98/Makefile.am (cxx11_abi_sources): Remove, unique 
cow-istream-string.cc entry move to...
             (inst_sources): ...this.
             * src/c++98/Makefile.in: Regenerate.
             * src/c++98/cow-istream-string.cc: Include <bits/c++config.h>.
             [_GLIBCXX_USE_CXX11_ABI]: Skip definitions.
             * src/c++98/hash_tr1.cc [_GLIBCXX_USE_CXX11_ABI]: Skip 
definitions.
             * src/c++98/ios_failure.cc 
[_GLIBCXX_USE_CXX11_ABI][_GLIBCXX_USE_DUAL_ABI]: Skip definitions.
             * src/c++98/istream-string.cc [!_GLIBCXX_USE_DUAL_ABI]: 
Build only when configured
             _GLIBCXX_USE_CXX11_ABI is equal to currently built abi.
             * src/c++98/locale_facets.cc 
[_GLIBCXX_USE_CXX11_ABI](__verify_grouping): Remove.
             * src/c++98/stdexcept.cc
             [_GLIBCXX_USE_CXX11_ABI](logic_error(const string&): Remove.
             [_GLIBCXX_USE_CXX11_ABI](domain_error(const string&): Remove.
             [_GLIBCXX_USE_CXX11_ABI](invalid_argument(const string&): 
Remove.
             [_GLIBCXX_USE_CXX11_ABI](length_error(const string&): Remove.
             [_GLIBCXX_USE_CXX11_ABI](out_of_range(const string&): Remove.
             [_GLIBCXX_USE_CXX11_ABI](runtime_error(const string&): Remove.
             [_GLIBCXX_USE_CXX11_ABI](range_error(const string&): Remove.
             [_GLIBCXX_USE_CXX11_ABI](overflow_error(const string&): Remove.
             [_GLIBCXX_USE_CXX11_ABI](underflow_error(const string&): 
Remove.
             * testsuite/libstdc++-prettyprinters/cxx17.cc: Add std::any 
check with std::wstring.

François

On 30/05/22 22:58, François Dumont wrote:
> Hi
>
> Here is the patch to use cxx11 abi for the versioned namespace mode.
>
> It is still suffering from a side effect on gdb pretty printers with 3 
> errors like:
>
> got: type = 
> std::unique_ptr<std::vector<std::unique_ptr<std::list<std::__8::basic_string<char, 
> std::__8::char_traits<char>, std::__8::allocator<char> >>[]>>[99]>
> FAIL: libstdc++-prettyprinters/80276.cc whatis p4
>
> However once I apply the version bump errors are gone.
>
> Let me know if it is ok to apply all at once or if you prefer to avoid 
> the version bump.
>
> François


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

diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
index 1b404d7df22..0c4348a277a 100644
--- a/libstdc++-v3/acinclude.m4
+++ b/libstdc++-v3/acinclude.m4
@@ -4449,12 +4449,16 @@ 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.
-    enable_libstdcxx_dual_abi="no"
-  fi
-  if test x"$enable_libstdcxx_dual_abi" != xyes; then
+    # gnu-versioned-namespace is incompatible with the dual ABI...
     AC_MSG_NOTICE([dual ABI is disabled])
-    default_libstdcxx_abi="gcc4-compatible"
+    enable_libstdcxx_dual_abi="no"
+    # ... 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 1265190dad9..5f91fd9b560 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 a778a6f402d..6b56e30a568 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 556575363da..54be63c44d7 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 c714d6a544f..ae17cb76c81 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/configure b/libstdc++-v3/configure
index 4f2c12f6b69..1fd4f166e59 100755
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -69276,13 +69276,18 @@ fi
 
 
   if test x$enable_symvers = xgnu-versioned-namespace; then
-    # gnu-versioned-namespace is incompatible with the dual ABI.
-    enable_libstdcxx_dual_abi="no"
-  fi
-  if test x"$enable_libstdcxx_dual_abi" != xyes; then
+    # gnu-versioned-namespace is incompatible with the dual ABI...
     { $as_echo "$as_me:${as_lineno-$LINENO}: dual ABI is disabled" >&5
 $as_echo "$as_me: dual ABI is disabled" >&6;}
-    default_libstdcxx_abi="gcc4-compatible"
+    enable_libstdcxx_dual_abi="no"
+    # ... and use the cxx11 one.
+    default_libstdcxx_abi="new"
+  else
+    if test x"$enable_libstdcxx_dual_abi" != xyes; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: dual ABI is disabled" >&5
+$as_echo "$as_me: dual ABI is disabled" >&6;}
+      default_libstdcxx_abi="gcc4-compatible"
+    fi
   fi
 
 
diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config
index 191880fb99d..f899a580b60 100644
--- a/libstdc++-v3/include/bits/c++config
+++ b/libstdc++-v3/include/bits/c++config
@@ -325,26 +325,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 
 
@@ -396,7 +376,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_VERSION_NAMESPACE
   inline namespace __cxx11 __attribute__((__abi_tag__ ("cxx11"))) { }
 # endif
   }
@@ -426,6 +406,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/python/libstdcxx/v6/printers.py b/libstdc++-v3/python/libstdcxx/v6/printers.py
index 52339b247d8..55e5c211c8f 100644
--- a/libstdc++-v3/python/libstdcxx/v6/printers.py
+++ b/libstdc++-v3/python/libstdcxx/v6/printers.py
@@ -942,6 +942,8 @@ class StdStringPrinter:
     def __init__(self, typename, val):
         self.val = val
         self.new_string = typename.find("::__cxx11::basic_string") != -1
+        if not self.new_string and _versioned_namespace:
+            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 b83c222d51d..fcab83ada2d 100644
--- a/libstdc++-v3/src/Makefile.am
+++ b/libstdc++-v3/src/Makefile.am
@@ -82,6 +82,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 = \
@@ -95,6 +98,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/Makefile.in b/libstdc++-v3/src/Makefile.in
index cef290c5d11..946101389c4 100644
--- a/libstdc++-v3/src/Makefile.in
+++ b/libstdc++-v3/src/Makefile.in
@@ -158,10 +158,9 @@ am__objects_2 = compatibility.lo compatibility-debug_list.lo \
 @ENABLE_SYMVERS_GNU_NAMESPACE_FALSE@	compatibility-chrono.lo \
 @ENABLE_SYMVERS_GNU_NAMESPACE_FALSE@	compatibility-condvar.lo \
 @ENABLE_SYMVERS_GNU_NAMESPACE_FALSE@	compatibility-thread-c++0x.lo
-@ENABLE_DUAL_ABI_TRUE@@GLIBCXX_LDBL_ALT128_COMPAT_TRUE@am__objects_4 = compatibility-ldbl-alt128-cxx11.lo
-@GLIBCXX_LDBL_ALT128_COMPAT_TRUE@am__objects_5 =  \
-@GLIBCXX_LDBL_ALT128_COMPAT_TRUE@	compatibility-ldbl-alt128.lo \
-@GLIBCXX_LDBL_ALT128_COMPAT_TRUE@	$(am__objects_4)
+@ENABLE_DUAL_ABI_TRUE@@ENABLE_SYMVERS_GNU_NAMESPACE_FALSE@@GLIBCXX_LDBL_ALT128_COMPAT_TRUE@am__objects_4 = compatibility-ldbl-alt128-cxx11.lo
+@ENABLE_SYMVERS_GNU_NAMESPACE_FALSE@@GLIBCXX_LDBL_ALT128_COMPAT_TRUE@am__objects_5 = compatibility-ldbl-alt128.lo \
+@ENABLE_SYMVERS_GNU_NAMESPACE_FALSE@@GLIBCXX_LDBL_ALT128_COMPAT_TRUE@	$(am__objects_4)
 am__objects_6 = $(am__objects_3) $(am__objects_5)
 am_libstdc___la_OBJECTS = $(am__objects_2) $(am__objects_6)
 libstdc___la_OBJECTS = $(am_libstdc___la_OBJECTS)
@@ -506,14 +505,15 @@ SUBDIRS = c++98 c++11 c++17 c++20 $(filesystem_dir) $(backtrace_dir)
 
 @GLIBCXX_LDBL_COMPAT_FALSE@ldbl_compat_sources = 
 @GLIBCXX_LDBL_COMPAT_TRUE@ldbl_compat_sources = compatibility-ldbl.cc
-@ENABLE_DUAL_ABI_FALSE@@GLIBCXX_LDBL_ALT128_COMPAT_TRUE@ldbl_alt128_compat_cxx11_sources = 
-@ENABLE_DUAL_ABI_TRUE@@GLIBCXX_LDBL_ALT128_COMPAT_TRUE@ldbl_alt128_compat_cxx11_sources = \
-@ENABLE_DUAL_ABI_TRUE@@GLIBCXX_LDBL_ALT128_COMPAT_TRUE@	compatibility-ldbl-alt128-cxx11.cc
-
-@GLIBCXX_LDBL_ALT128_COMPAT_FALSE@ldbl_alt128_compat_sources = 
-@GLIBCXX_LDBL_ALT128_COMPAT_TRUE@ldbl_alt128_compat_sources = \
-@GLIBCXX_LDBL_ALT128_COMPAT_TRUE@	compatibility-ldbl-alt128.cc \
-@GLIBCXX_LDBL_ALT128_COMPAT_TRUE@	${ldbl_alt128_compat_cxx11_sources}
+@ENABLE_SYMVERS_GNU_NAMESPACE_FALSE@@GLIBCXX_LDBL_ALT128_COMPAT_FALSE@ldbl_alt128_compat_sources = 
+@ENABLE_SYMVERS_GNU_NAMESPACE_FALSE@@GLIBCXX_LDBL_ALT128_COMPAT_TRUE@ldbl_alt128_compat_sources = \
+@ENABLE_SYMVERS_GNU_NAMESPACE_FALSE@@GLIBCXX_LDBL_ALT128_COMPAT_TRUE@	compatibility-ldbl-alt128.cc \
+@ENABLE_SYMVERS_GNU_NAMESPACE_FALSE@@GLIBCXX_LDBL_ALT128_COMPAT_TRUE@	${ldbl_alt128_compat_cxx11_sources}
+
+@ENABLE_SYMVERS_GNU_NAMESPACE_TRUE@ldbl_alt128_compat_sources = 
+@ENABLE_DUAL_ABI_FALSE@@ENABLE_SYMVERS_GNU_NAMESPACE_FALSE@@GLIBCXX_LDBL_ALT128_COMPAT_TRUE@ldbl_alt128_compat_cxx11_sources = 
+@ENABLE_DUAL_ABI_TRUE@@ENABLE_SYMVERS_GNU_NAMESPACE_FALSE@@GLIBCXX_LDBL_ALT128_COMPAT_TRUE@ldbl_alt128_compat_cxx11_sources = \
+@ENABLE_DUAL_ABI_TRUE@@ENABLE_SYMVERS_GNU_NAMESPACE_FALSE@@GLIBCXX_LDBL_ALT128_COMPAT_TRUE@	compatibility-ldbl-alt128-cxx11.cc
 
 @ENABLE_SYMVERS_GNU_NAMESPACE_FALSE@cxx0x_compat_sources = \
 @ENABLE_SYMVERS_GNU_NAMESPACE_FALSE@	compatibility-atomic-c++0x.cc \
diff --git a/libstdc++-v3/src/c++11/Makefile.am b/libstdc++-v3/src/c++11/Makefile.am
index ecd46aafc01..b22c54fa057 100644
--- a/libstdc++-v3/src/c++11/Makefile.am
+++ b/libstdc++-v3/src/c++11/Makefile.am
@@ -40,22 +40,22 @@ ctype_members.cc: ${glibcxx_srcdir}/$(CCTYPE_CC)
 	$(LN_S) ${glibcxx_srcdir}/$(CCTYPE_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 = \
 	chrono.cc \
 	codecvt.cc \
 	condition_variable.cc \
+	cow-locale_init.cc \
 	cow-stdexcept.cc \
+	cxx11-hash_tr1.cc \
+	cxx11-ios_failure.cc \
+	cxx11-stdexcept.cc \
 	ctype.cc \
 	debug.cc \
 	functexcept.cc \
@@ -75,19 +75,11 @@ sources = \
 	snprintf_lite.cc \
 	system_error.cc \
 	thread.cc \
-	${cxx11_abi_sources} \
+	${dual_abi_sources} \
 	${host_sources}
 
 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 =
@@ -97,6 +89,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/Makefile.in b/libstdc++-v3/src/c++11/Makefile.in
index 4db28bd8515..fa5b9543f76 100644
--- a/libstdc++-v3/src/c++11/Makefile.in
+++ b/libstdc++-v3/src/c++11/Makefile.in
@@ -122,26 +122,27 @@ CONFIG_CLEAN_FILES =
 CONFIG_CLEAN_VPATH_FILES =
 LTLIBRARIES = $(noinst_LTLIBRARIES)
 libc__11convenience_la_LIBADD =
-@ENABLE_DUAL_ABI_TRUE@am__objects_1 = cow-locale_init.lo \
-@ENABLE_DUAL_ABI_TRUE@	cow-shim_facets.lo cxx11-hash_tr1.lo \
-@ENABLE_DUAL_ABI_TRUE@	cxx11-ios_failure.lo \
-@ENABLE_DUAL_ABI_TRUE@	cxx11-shim_facets.lo cxx11-stdexcept.lo
+@ENABLE_DUAL_ABI_TRUE@am__objects_1 = cow-shim_facets.lo \
+@ENABLE_DUAL_ABI_TRUE@	cxx11-shim_facets.lo
 am__objects_2 = ctype_configure_char.lo ctype_members.lo
 am__objects_3 = chrono.lo codecvt.lo condition_variable.lo \
-	cow-stdexcept.lo ctype.lo debug.lo functexcept.lo \
-	functional.lo futex.lo future.lo hash_c++0x.lo \
+	cow-locale_init.lo cow-stdexcept.lo cxx11-hash_tr1.lo \
+	cxx11-ios_failure.lo cxx11-stdexcept.lo ctype.lo debug.lo \
+	functexcept.lo functional.lo futex.lo future.lo hash_c++0x.lo \
 	hashtable_c++0x.lo ios.lo ios_errcat.lo limits.lo mutex.lo \
 	placeholders.lo random.lo regex.lo shared_ptr.lo \
 	snprintf_lite.lo system_error.lo thread.lo $(am__objects_1) \
 	$(am__objects_2)
-@ENABLE_DUAL_ABI_TRUE@am__objects_4 = cow-fstream-inst.lo \
-@ENABLE_DUAL_ABI_TRUE@	cow-sstream-inst.lo cow-string-inst.lo \
-@ENABLE_DUAL_ABI_TRUE@	cow-string-io-inst.lo \
-@ENABLE_DUAL_ABI_TRUE@	cow-wstring-inst.lo \
-@ENABLE_DUAL_ABI_TRUE@	cow-wstring-io-inst.lo \
-@ENABLE_DUAL_ABI_TRUE@	cxx11-locale-inst.lo \
-@ENABLE_DUAL_ABI_TRUE@	cxx11-wlocale-inst.lo sso_string.lo
+@ENABLE_DUAL_ABI_TRUE@am__objects_4 = sso_string.lo
 @ENABLE_EXTERN_TEMPLATE_TRUE@am__objects_5 = $(am__objects_4) \
+@ENABLE_EXTERN_TEMPLATE_TRUE@	cow-fstream-inst.lo \
+@ENABLE_EXTERN_TEMPLATE_TRUE@	cow-sstream-inst.lo \
+@ENABLE_EXTERN_TEMPLATE_TRUE@	cow-string-inst.lo \
+@ENABLE_EXTERN_TEMPLATE_TRUE@	cow-string-io-inst.lo \
+@ENABLE_EXTERN_TEMPLATE_TRUE@	cow-wstring-inst.lo \
+@ENABLE_EXTERN_TEMPLATE_TRUE@	cow-wstring-io-inst.lo \
+@ENABLE_EXTERN_TEMPLATE_TRUE@	cxx11-locale-inst.lo \
+@ENABLE_EXTERN_TEMPLATE_TRUE@	cxx11-wlocale-inst.lo \
 @ENABLE_EXTERN_TEMPLATE_TRUE@	ext11-inst.lo fstream-inst.lo \
 @ENABLE_EXTERN_TEMPLATE_TRUE@	ios-inst.lo iostream-inst.lo \
 @ENABLE_EXTERN_TEMPLATE_TRUE@	istream-inst.lo locale-inst.lo \
@@ -457,20 +458,20 @@ host_sources = \
 	ctype_configure_char.cc \
 	ctype_members.cc
 
-@ENABLE_DUAL_ABI_FALSE@cxx11_abi_sources = 
-@ENABLE_DUAL_ABI_TRUE@cxx11_abi_sources = \
-@ENABLE_DUAL_ABI_TRUE@	cow-locale_init.cc \
+@ENABLE_DUAL_ABI_FALSE@dual_abi_sources = 
+@ENABLE_DUAL_ABI_TRUE@dual_abi_sources = \
 @ENABLE_DUAL_ABI_TRUE@	cow-shim_facets.cc \
-@ENABLE_DUAL_ABI_TRUE@	cxx11-hash_tr1.cc \
-@ENABLE_DUAL_ABI_TRUE@	cxx11-ios_failure.cc \
-@ENABLE_DUAL_ABI_TRUE@	cxx11-shim_facets.cc \
-@ENABLE_DUAL_ABI_TRUE@	cxx11-stdexcept.cc
+@ENABLE_DUAL_ABI_TRUE@	cxx11-shim_facets.cc
 
 sources = \
 	chrono.cc \
 	codecvt.cc \
 	condition_variable.cc \
+	cow-locale_init.cc \
 	cow-stdexcept.cc \
+	cxx11-hash_tr1.cc \
+	cxx11-ios_failure.cc \
+	cxx11-stdexcept.cc \
 	ctype.cc \
 	debug.cc \
 	functexcept.cc \
@@ -490,19 +491,11 @@ sources = \
 	snprintf_lite.cc \
 	system_error.cc \
 	thread.cc \
-	${cxx11_abi_sources} \
+	${dual_abi_sources} \
 	${host_sources}
 
 @ENABLE_DUAL_ABI_FALSE@extra_string_inst_sources = 
 @ENABLE_DUAL_ABI_TRUE@extra_string_inst_sources = \
-@ENABLE_DUAL_ABI_TRUE@	cow-fstream-inst.cc \
-@ENABLE_DUAL_ABI_TRUE@	cow-sstream-inst.cc \
-@ENABLE_DUAL_ABI_TRUE@	cow-string-inst.cc \
-@ENABLE_DUAL_ABI_TRUE@	cow-string-io-inst.cc \
-@ENABLE_DUAL_ABI_TRUE@	cow-wstring-inst.cc \
-@ENABLE_DUAL_ABI_TRUE@	cow-wstring-io-inst.cc \
-@ENABLE_DUAL_ABI_TRUE@	cxx11-locale-inst.cc \
-@ENABLE_DUAL_ABI_TRUE@	cxx11-wlocale-inst.cc \
 @ENABLE_DUAL_ABI_TRUE@	sso_string.cc
 
 # XTEMPLATE_FLAGS =
@@ -511,6 +504,14 @@ sources = \
 # XTEMPLATE_FLAGS = -fno-implicit-templates
 @ENABLE_EXTERN_TEMPLATE_TRUE@inst_sources = \
 @ENABLE_EXTERN_TEMPLATE_TRUE@	$(extra_string_inst_sources) \
+@ENABLE_EXTERN_TEMPLATE_TRUE@	cow-fstream-inst.cc \
+@ENABLE_EXTERN_TEMPLATE_TRUE@	cow-sstream-inst.cc \
+@ENABLE_EXTERN_TEMPLATE_TRUE@	cow-string-inst.cc \
+@ENABLE_EXTERN_TEMPLATE_TRUE@	cow-string-io-inst.cc \
+@ENABLE_EXTERN_TEMPLATE_TRUE@	cow-wstring-inst.cc \
+@ENABLE_EXTERN_TEMPLATE_TRUE@	cow-wstring-io-inst.cc \
+@ENABLE_EXTERN_TEMPLATE_TRUE@	cxx11-locale-inst.cc \
+@ENABLE_EXTERN_TEMPLATE_TRUE@	cxx11-wlocale-inst.cc \
 @ENABLE_EXTERN_TEMPLATE_TRUE@	ext11-inst.cc \
 @ENABLE_EXTERN_TEMPLATE_TRUE@	fstream-inst.cc \
 @ENABLE_EXTERN_TEMPLATE_TRUE@	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 6b6352c1419..d9657484326 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 4d5c08f20cc..fa27b4142f2 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
@@ -193,3 +190,4 @@ namespace
 
 _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 8839f4a6f75..2db78a43f50 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 9e8787485eb..8b217c45960 100644
--- a/libstdc++-v3/src/c++11/cow-stdexcept.cc
+++ b/libstdc++-v3/src/c++11/cow-stdexcept.cc
@@ -41,7 +41,7 @@ _txnal_logic_error_get_msg(void* e);
 void*
 _txnal_runtime_error_get_msg(void* e);
 
-// All exception classes still use the classic COW std::string.
+// In dual abi 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
@@ -169,6 +169,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
                 "alignof(std::string) has changed");
 #endif
 
+#if ! _GLIBCXX_USE_CXX11_ABI
   // Return error_category::message() as an SSO string
   __sso_string
   error_category::_M_message(int i) const
@@ -176,10 +177,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 +466,4 @@ CTORDTOR(15underflow_error, std::underflow_error, runtime_error)
 
 #endif  // _GLIBCXX_USE_C99_STDINT_TR1
 #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 e5331bb029a..40ebe708971 100644
--- a/libstdc++-v3/src/c++11/cow-string-inst.cc
+++ b/libstdc++-v3/src/c++11/cow-string-inst.cc
@@ -27,11 +27,10 @@
 //
 
 #define _GLIBCXX_USE_CXX11_ABI 0
-#include "string-inst.cc"
+#include <bits/c++config.h>
 
-#if ! _GLIBCXX_USE_DUAL_ABI
-# error This file should not be compiled for this configuration.
-#endif
+#if ! _GLIBCXX_USE_CXX11_ABI
+#include "string-inst.cc"
 
 #ifdef  _GLIBCXX_USE_C99_STDINT_TR1
 #include <random>
@@ -47,3 +46,4 @@ namespace std _GLIBCXX_VISIBILITY(default)
   { _M_init(token.c_str(), token.length()); }
 } // namespace
 #endif
+#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 3f65aeb9873..a3720680907 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 a38c1288ef3..b0eff7ef97d 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 dbd19e0feb0..f0ed5cc6b6b 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 f36541fd4cc..edd89974e1b 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 0a81e15e4c0..db4c623a536 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 5c860054ea6..814cdcc9902 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 236bc40cd55..9faf355977a 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)
 {
@@ -70,9 +68,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   underflow_error::underflow_error(const string& __arg)
   : runtime_error(__arg) { }
 
+# if _GLIBCXX_USE_DUAL_ABI
   // Converting constructor from ABI-tagged std::string to COW string.
   __cow_string::__cow_string(const string& s)
   : __cow_string(s.c_str(), s.length()) { }
+# endif
 
 _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 6d26292075d..7491d5117df 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/fstream-inst.cc b/libstdc++-v3/src/c++11/fstream-inst.cc
index 7bf56c7e864..494c7bb51d0 100644
--- a/libstdc++-v3/src/c++11/fstream-inst.cc
+++ b/libstdc++-v3/src/c++11/fstream-inst.cc
@@ -29,6 +29,7 @@
 #define _GLIBCXX_USE_CXX11_ABI 1
 #include <fstream>
 
+#if _GLIBCXX_USE_CXX11_ABI
 namespace std _GLIBCXX_VISIBILITY(default)
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
@@ -47,3 +48,4 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
+#endif
diff --git a/libstdc++-v3/src/c++11/locale-inst-numeric.h b/libstdc++-v3/src/c++11/locale-inst-numeric.h
index 1417ac25ed4..5b72c30bd5a 100644
--- a/libstdc++-v3/src/c++11/locale-inst-numeric.h
+++ b/libstdc++-v3/src/c++11/locale-inst-numeric.h
@@ -23,12 +23,12 @@
 // <http://www.gnu.org/licenses/>.
 
 #ifndef C
-#define "This file should not be compiled directly, only included"
+# error "This file should not be compiled directly, only included"
 #endif
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
-#if ! _GLIBCXX_USE_CXX11_ABI
+#if ! _GLIBCXX_USE_CXX11_ABI || ! _GLIBCXX_USE_DUAL_ABI
   template const num_get<C>& use_facet<num_get<C> >(const locale&);
   template const num_put<C>& use_facet<num_put<C> >(const locale&);
 
@@ -38,7 +38,7 @@ namespace std _GLIBCXX_VISIBILITY(default)
 
 _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 3aee5df9b04..30847cbef7f 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
@@ -51,7 +60,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
@@ -63,7 +72,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
@@ -72,7 +81,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> >;
@@ -96,13 +105,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
@@ -117,7 +126,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
 _GLIBCXX_END_NAMESPACE_CXX11
 
   // use_facet
-#if ! _GLIBCXX_USE_CXX11_ABI
+#if ! _GLIBCXX_USE_CXX11_ABI || ! _GLIBCXX_USE_DUAL_ABI
   template
     const ctype<C>&
     use_facet<ctype<C> >(const locale&);
@@ -143,7 +152,7 @@ _GLIBCXX_END_NAMESPACE_CXX11
     const moneypunct<C, false>&
     use_facet<moneypunct<C, false> >(const locale&);
 
-#if ! _GLIBCXX_USE_CXX11_ABI
+#if ! _GLIBCXX_USE_CXX11_ABI || ! _GLIBCXX_USE_DUAL_ABI
   template
     const __timepunct<C>&
     use_facet<__timepunct<C> >(const locale&);
@@ -162,7 +171,7 @@ _GLIBCXX_END_NAMESPACE_CXX11
     use_facet<messages<C> >(const locale&);
 
   // has_facet
-#if ! _GLIBCXX_USE_CXX11_ABI
+#if ! _GLIBCXX_USE_CXX11_ABI || ! _GLIBCXX_USE_DUAL_ABI
   template
     bool
     has_facet<ctype<C> >(const locale&);
@@ -184,7 +193,7 @@ _GLIBCXX_END_NAMESPACE_CXX11
     bool
     has_facet<moneypunct<C> >(const locale&);
 
-#if ! _GLIBCXX_USE_CXX11_ABI
+#if ! _GLIBCXX_USE_CXX11_ABI || ! _GLIBCXX_USE_DUAL_ABI
   template
     bool
     has_facet<__timepunct<C> >(const locale&);
@@ -203,7 +212,7 @@ _GLIBCXX_END_NAMESPACE_CXX11
     has_facet<messages<C> >(const locale&);
 
 
-#if ! _GLIBCXX_USE_CXX11_ABI
+#if ! _GLIBCXX_USE_CXX11_ABI || ! _GLIBCXX_USE_DUAL_ABI
   // locale functions.
   template
     C*
@@ -228,7 +237,11 @@ _GLIBCXX_END_NAMESPACE_CXX11
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
 
+#if ! _GLIBCXX_INLINE_VERSION
 // XXX GLIBCXX_ABI Deprecated
-#if defined _GLIBCXX_LONG_DOUBLE_COMPAT && ! _GLIBCXX_USE_CXX11_ABI
-#include "compatibility-ldbl-facets-aliases.h"
-#endif // _GLIBCXX_LONG_DOUBLE_COMPAT
+# if defined _GLIBCXX_LONG_DOUBLE_COMPAT && ! _GLIBCXX_USE_CXX11_ABI
+#  include "compatibility-ldbl-facets-aliases.h"
+# endif // _GLIBCXX_LONG_DOUBLE_COMPAT
+#endif
+
+#endif //  _GLIBCXX_BUILD_CXX11_ABI == _GLIBCXX_USE_CXX11_ABI
diff --git a/libstdc++-v3/src/c++11/wlocale-inst.cc b/libstdc++-v3/src/c++11/wlocale-inst.cc
index 0855f67707c..0338a9554a2 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 b96588bd95c..9bbe8c00a73 100644
--- a/libstdc++-v3/src/c++98/Makefile.am
+++ b/libstdc++-v3/src/c++98/Makefile.am
@@ -90,13 +90,6 @@ c++locale.cc: ${glibcxx_srcdir}/$(CLOCALE_CC)
 basic_file.cc: ${glibcxx_srcdir}/$(BASIC_FILE_CC)
 	$(LN_S) ${glibcxx_srcdir}/$(BASIC_FILE_CC) ./$@ || true
 
-if ENABLE_DUAL_ABI
-cxx11_abi_sources = \
-	cow-istream-string.cc
-else
-cxx11_abi_sources =
-endif
-
 if ENABLE_EXTERN_TEMPLATE
 # XTEMPLATE_FLAGS = -fno-implicit-templates
 inst_sources = \
@@ -118,6 +111,7 @@ sources = \
 	mt_allocator.cc \
 	codecvt.cc \
 	complex_io.cc \
+	cow-istream-string.cc \
 	globals_io.cc \
 	hash_tr1.cc \
 	hashtable_tr1.cc \
@@ -142,7 +136,6 @@ sources = \
 	istream-string.cc \
 	streambuf.cc \
 	valarray.cc \
-	${cxx11_abi_sources} \
 	${host_sources} \
 	${host_sources_extra}
 
diff --git a/libstdc++-v3/src/c++98/Makefile.in b/libstdc++-v3/src/c++98/Makefile.in
index 90eff5da986..aafc04efe89 100644
--- a/libstdc++-v3/src/c++98/Makefile.in
+++ b/libstdc++-v3/src/c++98/Makefile.in
@@ -122,30 +122,29 @@ CONFIG_CLEAN_FILES =
 CONFIG_CLEAN_VPATH_FILES =
 LTLIBRARIES = $(noinst_LTLIBRARIES)
 libc__98convenience_la_LIBADD =
-@ENABLE_DUAL_ABI_TRUE@am__objects_1 = cow-istream-string.lo
-@ENABLE_DUAL_ABI_TRUE@am__objects_2 = collate_members_cow.lo \
+@ENABLE_DUAL_ABI_TRUE@am__objects_1 = collate_members_cow.lo \
 @ENABLE_DUAL_ABI_TRUE@	messages_members_cow.lo \
 @ENABLE_DUAL_ABI_TRUE@	monetary_members_cow.lo \
 @ENABLE_DUAL_ABI_TRUE@	numeric_members_cow.lo
-am__objects_3 = $(am__objects_2) codecvt_members.lo collate_members.lo \
+am__objects_2 = $(am__objects_1) codecvt_members.lo collate_members.lo \
 	messages_members.lo monetary_members.lo numeric_members.lo \
 	time_members.lo
-@ENABLE_EXTERN_TEMPLATE_TRUE@am__objects_4 = allocator-inst.lo \
+@ENABLE_EXTERN_TEMPLATE_TRUE@am__objects_3 = allocator-inst.lo \
 @ENABLE_EXTERN_TEMPLATE_TRUE@	concept-inst.lo ext-inst.lo \
 @ENABLE_EXTERN_TEMPLATE_TRUE@	misc-inst.lo
-am__objects_5 = parallel_settings.lo
-am__objects_6 = basic_file.lo c++locale.lo $(am__objects_4) \
-	$(am__objects_5)
-am__objects_7 = bitmap_allocator.lo pool_allocator.lo mt_allocator.lo \
-	codecvt.lo complex_io.lo globals_io.lo hash_tr1.lo \
-	hashtable_tr1.lo ios_failure.lo ios_init.lo ios_locale.lo \
-	list.lo list-aux.lo list-aux-2.lo list_associated.lo \
-	list_associated-2.lo locale.lo locale_init.lo locale_facets.lo \
-	localename.lo math_stubs_float.lo math_stubs_long_double.lo \
-	stdexcept.lo strstream.lo tree.lo istream.lo istream-string.lo \
-	streambuf.lo valarray.lo $(am__objects_1) $(am__objects_3) \
-	$(am__objects_6)
-am_libc__98convenience_la_OBJECTS = $(am__objects_7)
+am__objects_4 = parallel_settings.lo
+am__objects_5 = basic_file.lo c++locale.lo $(am__objects_3) \
+	$(am__objects_4)
+am__objects_6 = bitmap_allocator.lo pool_allocator.lo mt_allocator.lo \
+	codecvt.lo complex_io.lo cow-istream-string.lo globals_io.lo \
+	hash_tr1.lo hashtable_tr1.lo ios_failure.lo ios_init.lo \
+	ios_locale.lo list.lo list-aux.lo list-aux-2.lo \
+	list_associated.lo list_associated-2.lo locale.lo \
+	locale_init.lo locale_facets.lo localename.lo \
+	math_stubs_float.lo math_stubs_long_double.lo stdexcept.lo \
+	strstream.lo tree.lo istream.lo istream-string.lo streambuf.lo \
+	valarray.lo $(am__objects_2) $(am__objects_5)
+am_libc__98convenience_la_OBJECTS = $(am__objects_6)
 libc__98convenience_la_OBJECTS = $(am_libc__98convenience_la_OBJECTS)
 AM_V_lt = $(am__v_lt_@AM_V@)
 am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
@@ -470,10 +469,6 @@ host_sources_extra = \
 	basic_file.cc c++locale.cc \
 	${inst_sources} ${parallel_sources}
 
-@ENABLE_DUAL_ABI_FALSE@cxx11_abi_sources = 
-@ENABLE_DUAL_ABI_TRUE@cxx11_abi_sources = \
-@ENABLE_DUAL_ABI_TRUE@	cow-istream-string.cc
-
 # XTEMPLATE_FLAGS =
 @ENABLE_EXTERN_TEMPLATE_FALSE@inst_sources = 
 
@@ -493,6 +488,7 @@ sources = \
 	mt_allocator.cc \
 	codecvt.cc \
 	complex_io.cc \
+	cow-istream-string.cc \
 	globals_io.cc \
 	hash_tr1.cc \
 	hashtable_tr1.cc \
@@ -517,7 +513,6 @@ sources = \
 	istream-string.cc \
 	streambuf.cc \
 	valarray.cc \
-	${cxx11_abi_sources} \
 	${host_sources} \
 	${host_sources_extra}
 
diff --git a/libstdc++-v3/src/c++98/cow-istream-string.cc b/libstdc++-v3/src/c++98/cow-istream-string.cc
index d90ec2a0cf3..ff406830c61 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 caa424e423f..7256d2529cf 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 523d1f6a4e9..e650ded371e 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
-
-#ifdef _GLIBCXX_USE_NLS
-# include <libintl.h>
-# define _(msgid)   gettext (msgid)
-#else
-# define _(msgid)   (msgid)
-#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
+#  include <libintl.h>
+#  define _(msgid)   gettext (msgid)
+# else
+#  define _(msgid)   (msgid)
+# 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,11 +56,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   const char*
   ios_base::failure::what() const throw()
   { return _M_msg.c_str(); }
+# endif
 
-#if _GLIBCXX_USE_DUAL_ABI
+# if _GLIBCXX_USE_DUAL_ABI
   // When the dual ABI is enabled __throw_ios_failure() is defined in
   // src/c++11/cxx11-ios_failure.cc
-#if __cpp_rtti
+#  if __cpp_rtti
   // If RTTI is enabled the exception type thrown will use these functions to
   // construct/destroy a gcc4-compatible ios::failure object in a buffer,
   // and to catch that object via a handler of the gcc4-compatible type.
@@ -80,9 +83,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   typedef char S[1 / (sizeof(ios::failure) <= sizeof(runtime_error))];
   typedef char A[1 / (__alignof(ios::failure) <= __alignof(runtime_error))];
   }
-#endif // __cpp_rtti
+#  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_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 19f5f0c1a47..034cd951d6d 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 1293a37e642..4b351b2e8ef 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 0a24b054ca0..786f0ff0523 100644
--- a/libstdc++-v3/src/c++98/stdexcept.cc
+++ b/libstdc++-v3/src/c++98/stdexcept.cc
@@ -26,7 +26,7 @@
 // ISO C++ 14882: 19.1  Exception classes
 //
 
-// All exception classes still use the classic COW std::string.
+// In dual abi all exception classes still use the classic COW std::string.
 #define _GLIBCXX_USE_CXX11_ABI 0
 #include <string>
 #include <stdexcept>
@@ -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 { }
 
diff --git a/libstdc++-v3/testsuite/libstdc++-prettyprinters/cxx17.cc b/libstdc++-v3/testsuite/libstdc++-prettyprinters/cxx17.cc
index cf699d22e78..beff378520c 100644
--- a/libstdc++-v3/testsuite/libstdc++-prettyprinters/cxx17.cc
+++ b/libstdc++-v3/testsuite/libstdc++-prettyprinters/cxx17.cc
@@ -62,6 +62,8 @@ main()
 // { dg-final { regexp-test om {std::optional<std::(__debug::)?map<int, double>> containing std::(__debug::)?map with 3 elements = {\[1\] = 2, \[3\] = 4, \[5\] = 6}} } }
   optional<std::string> os{ "stringy" };
 // { dg-final { note-test os {std::optional<std::string> = {[contained value] = "stringy"}} } }
+  optional<std::wstring> ows{ L"stringy" };
+// { dg-final { note-test ows {std::optional<std::wstring> = {[contained value] = L"stringy"}} } }
 
   any a;
 // { dg-final { note-test a {std::any [no contained value]} } }
@@ -73,6 +75,8 @@ main()
 // { dg-final { note-test ap {std::any containing void * = {[contained value] = 0x0}} } }
   any as = *os;
 // { dg-final { note-test as {std::any containing std::string = {[contained value] = "stringy"}} } }
+  any aws = *ows;
+// { dg-final { note-test aws {std::any containing std::wstring = {[contained value] = L"stringy"}} } }
   any as2("stringiest");
 // { dg-final { regexp-test as2 {std::any containing const char \* = {\[contained value\] = 0x[[:xdigit:]]+ "stringiest"}} } }
   any am = *om;

[-- Attachment #3: version_namespace_bump.patch --]
[-- Type: text/x-patch, Size: 8359 bytes --]

diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
index 0c4348a277a..9b72faef82e 100644
--- a/libstdc++-v3/acinclude.m4
+++ b/libstdc++-v3/acinclude.m4
@@ -3834,7 +3834,7 @@ case $enable_symvers in
 	      [Define to use GNU versioning in the shared library.])
     ;;
   gnu-versioned-namespace)
-    libtool_VERSION=8:0:0
+    libtool_VERSION=9:0:0
     SYMVER_FILE=config/abi/pre/gnu-versioned-namespace.ver
     AC_DEFINE(_GLIBCXX_SYMVER_GNU_NAMESPACE, 1,
 	      [Define to use GNU namespace versioning in the shared library.])
diff --git a/libstdc++-v3/config/abi/pre/gnu-versioned-namespace.ver b/libstdc++-v3/config/abi/pre/gnu-versioned-namespace.ver
index 06ccaa80a58..d82077a3cfa 100644
--- a/libstdc++-v3/config/abi/pre/gnu-versioned-namespace.ver
+++ b/libstdc++-v3/config/abi/pre/gnu-versioned-namespace.ver
@@ -19,7 +19,7 @@
 ## with this library; see the file COPYING3.  If not see
 ## <http://www.gnu.org/licenses/>.
 
-GLIBCXX_8.0 {
+GLIBCXX_9.0 {
 
   global:
 
@@ -27,7 +27,7 @@ GLIBCXX_8.0 {
     extern "C++"
     {
       std::*;
-      std::__8::*;
+      std::__9::*;
     };
 
     # operator new(size_t)
@@ -59,7 +59,7 @@ GLIBCXX_8.0 {
     # vtable
     _ZTVSt*;
     _ZTVNSt*;
-    _ZTVN9__gnu_cxx3__818stdio_sync_filebufI[cw]NSt3__811char_traitsI[cw]EEEE;
+    _ZTVN9__gnu_cxx3__918stdio_sync_filebufI[cw]NSt3__911char_traitsI[cw]EEEE;
 
     # thunk
     _ZTv0_n12_NS*;
@@ -74,43 +74,43 @@ GLIBCXX_8.0 {
     _ZTSNSt*;
 
     # locale
-    _ZNSt3__89has_facetINS_*;
+    _ZNSt3__99has_facetINS_*;
 
     # thread/mutex/condition_variable/future
     __once_proxy;
 
     # std::__convert_to_v
-    _ZNSt3__814__convert_to_v*;
+    _ZNSt3__914__convert_to_v*;
 
     # std::__copy_streambufs
-    _ZNSt3__817__copy_streambufsI*;
-    _ZNSt3__821__copy_streambufs_eofI*;
+    _ZNSt3__917__copy_streambufsI*;
+    _ZNSt3__921__copy_streambufs_eofI*;
 
     # std::__istream_extract(wistream&, wchar_t*, streamsize)
-    _ZNSt3__817__istream_extractIwNS_11char_traitsIwEEEEvRNS_13basic_istreamIT_T0_EEPS4_[ilx];
+    _ZNSt3__917__istream_extractIwNS_11char_traitsIwEEEEvRNS_13basic_istreamIT_T0_EEPS4_[ilx];
 
     # __gnu_cxx::__atomic_add
     # __gnu_cxx::__exchange_and_add
-    _ZN9__gnu_cxx3__812__atomic_addEPV[il][il];
-    _ZN9__gnu_cxx3__818__exchange_and_addEPV[li][il];
+    _ZN9__gnu_cxx3__912__atomic_addEPV[il][il];
+    _ZN9__gnu_cxx3__918__exchange_and_addEPV[li][il];
 
     # __gnu_cxx::__pool
-    _ZN9__gnu_cxx3__86__poolILb[01]EE13_M_initializeEv;
-    _ZN9__gnu_cxx3__86__poolILb[01]EE16_M_reserve_blockE[jmy][jmy];
-    _ZN9__gnu_cxx3__86__poolILb[01]EE16_M_reclaim_blockEPc[jmy];
-    _ZN9__gnu_cxx3__86__poolILb[01]EE10_M_destroyEv;
-    _ZN9__gnu_cxx3__86__poolILb1EE16_M_get_thread_idEv;
+    _ZN9__gnu_cxx3__96__poolILb[01]EE13_M_initializeEv;
+    _ZN9__gnu_cxx3__96__poolILb[01]EE16_M_reserve_blockE[jmy][jmy];
+    _ZN9__gnu_cxx3__96__poolILb[01]EE16_M_reclaim_blockEPc[jmy];
+    _ZN9__gnu_cxx3__96__poolILb[01]EE10_M_destroyEv;
+    _ZN9__gnu_cxx3__96__poolILb1EE16_M_get_thread_idEv;
 
-    _ZN9__gnu_cxx3__817__pool_alloc_base9_M_refillE[jmy];
-    _ZN9__gnu_cxx3__817__pool_alloc_base16_M_get_free_listE[jmy];
-    _ZN9__gnu_cxx3__817__pool_alloc_base12_M_get_mutexEv;
+    _ZN9__gnu_cxx3__917__pool_alloc_base9_M_refillE[jmy];
+    _ZN9__gnu_cxx3__917__pool_alloc_base16_M_get_free_listE[jmy];
+    _ZN9__gnu_cxx3__917__pool_alloc_base12_M_get_mutexEv;
 
-    _ZN9__gnu_cxx3__89free_list6_M_getE[jmy];
-    _ZN9__gnu_cxx3__89free_list8_M_clearEv;
+    _ZN9__gnu_cxx3__99free_list6_M_getE[jmy];
+    _ZN9__gnu_cxx3__99free_list8_M_clearEv;
 
     # __gnu_cxx::stdio_sync_filebuf
-    _ZTVN9__gnu_cxx3__818stdio_sync_filebufI[cw]St3__811char_traitsI[cw]EEE;
-    _ZN9__gnu_cxx3__818stdio_sync_filebufI[cw]NSt3__811char_traitsI[cw]EEE[5-9]*;
+    _ZTVN9__gnu_cxx3__918stdio_sync_filebufI[cw]St3__911char_traitsI[cw]EEE;
+    _ZN9__gnu_cxx3__918stdio_sync_filebufI[cw]NSt3__911char_traitsI[cw]EEE[5-9]*;
 
     # debug mode
     _ZN11__gnu_debug19_Safe_sequence_base12_M_get_mutexEv;
@@ -236,7 +236,7 @@ CXXABI_2.0 {
     _ZSt15_Fnv_hash_bytesPKv*;
 
     # __gnu_cxx::_verbose_terminate_handler()
-    _ZN9__gnu_cxx3__827__verbose_terminate_handlerEv;
+    _ZN9__gnu_cxx3__927__verbose_terminate_handlerEv;
 
     # *_type_info classes, ctor and dtor
     _ZN10__cxxabiv117__array_type_info*;
diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
index 1fd4f166e59..2737ce3a72c 100755
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -69057,7 +69057,7 @@ $as_echo "#define _GLIBCXX_SYMVER_GNU 1" >>confdefs.h
 
     ;;
   gnu-versioned-namespace)
-    libtool_VERSION=8:0:0
+    libtool_VERSION=9:0:0
     SYMVER_FILE=config/abi/pre/gnu-versioned-namespace.ver
 
 $as_echo "#define _GLIBCXX_SYMVER_GNU_NAMESPACE 1" >>confdefs.h
diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config
index f899a580b60..5e0a9a0c63c 100644
--- a/libstdc++-v3/include/bits/c++config
+++ b/libstdc++-v3/include/bits/c++config
@@ -330,7 +330,7 @@ namespace std
 
 #if _GLIBCXX_INLINE_VERSION
 // Inline namespace for symbol versioning of (nearly) everything in std.
-# define _GLIBCXX_BEGIN_NAMESPACE_VERSION namespace __8 {
+# define _GLIBCXX_BEGIN_NAMESPACE_VERSION namespace __9 {
 # define _GLIBCXX_END_NAMESPACE_VERSION }
 // Unused when everything in std is versioned anyway.
 # define _GLIBCXX_BEGIN_INLINE_ABI_NAMESPACE(X)
diff --git a/libstdc++-v3/python/libstdcxx/v6/printers.py b/libstdc++-v3/python/libstdcxx/v6/printers.py
index 55e5c211c8f..4e314dbd96a 100644
--- a/libstdc++-v3/python/libstdcxx/v6/printers.py
+++ b/libstdc++-v3/python/libstdcxx/v6/printers.py
@@ -100,7 +100,7 @@ def find_type(orig, name):
         else:
             raise ValueError("Cannot find type %s::%s" % (str(orig), name))
 
-_versioned_namespace = '__8::'
+_versioned_namespace = '__9::'
 
 def lookup_templ_spec(templ, *args):
     """
diff --git a/libstdc++-v3/testsuite/20_util/is_complete_or_unbounded/memoization_neg.cc b/libstdc++-v3/testsuite/20_util/is_complete_or_unbounded/memoization_neg.cc
index bc66c13feee..759925cca7c 100644
--- a/libstdc++-v3/testsuite/20_util/is_complete_or_unbounded/memoization_neg.cc
+++ b/libstdc++-v3/testsuite/20_util/is_complete_or_unbounded/memoization_neg.cc
@@ -1,6 +1,6 @@
 // { dg-do compile { target c++11 } }
 // { dg-prune-output "must be a complete" }
-// { dg-prune-output "'value' is not a member of 'std::(__8::)?is_move_cons" }
+// { dg-prune-output "'value' is not a member of 'std::(__9::)?is_move_cons" }
 // { dg-prune-output "invalid use of incomplete type" }
 
 // Copyright (C) 2019-2022 Free Software Foundation, Inc.
diff --git a/libstdc++-v3/testsuite/23_containers/map/48101_neg.cc b/libstdc++-v3/testsuite/23_containers/map/48101_neg.cc
index cc7ad160162..53aceb633c1 100644
--- a/libstdc++-v3/testsuite/23_containers/map/48101_neg.cc
+++ b/libstdc++-v3/testsuite/23_containers/map/48101_neg.cc
@@ -29,8 +29,8 @@ test01()
   c2.find(2); // { dg-error "here" }
 }
 
-// { dg-error "_Compare = std::(__8::)?less<int.>" "" { target *-*-* } 0 }
-// { dg-error "_Compare = std::(__8::)?allocator<int>" "" { target *-*-* } 0 }
+// { dg-error "_Compare = std::(__9::)?less<int.>" "" { target *-*-* } 0 }
+// { dg-error "_Compare = std::(__9::)?allocator<int>" "" { target *-*-* } 0 }
 // { dg-error "comparison object must be invocable" "" { target *-*-* } 0 }
 // { dg-prune-output "no match for call" }
 // { dg-prune-output "invalid conversion" }
diff --git a/libstdc++-v3/testsuite/23_containers/multimap/48101_neg.cc b/libstdc++-v3/testsuite/23_containers/multimap/48101_neg.cc
index 8bb69ec3e9d..cbb9583a548 100644
--- a/libstdc++-v3/testsuite/23_containers/multimap/48101_neg.cc
+++ b/libstdc++-v3/testsuite/23_containers/multimap/48101_neg.cc
@@ -29,8 +29,8 @@ test01()
   c2.find(2); // { dg-error "here" }
 }
 
-// { dg-error "_Compare = std::(__8::)?less<int.>" "" { target *-*-* } 0 }
-// { dg-error "_Compare = std::(__8::)?allocator<int>" "" { target *-*-* } 0 }
+// { dg-error "_Compare = std::(__9::)?less<int.>" "" { target *-*-* } 0 }
+// { dg-error "_Compare = std::(__9::)?allocator<int>" "" { target *-*-* } 0 }
 // { dg-error "comparison object must be invocable" "" { target *-*-* } 0 }
 // { dg-prune-output "no match for call" }
 // { dg-prune-output "invalid conversion" }

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Use cxx11 abi in versioned namespace
  2022-10-11 17:28 ` François Dumont
@ 2022-12-05 21:13   ` François Dumont
  2023-01-13 16:33     ` Jonathan Wakely
  0 siblings, 1 reply; 10+ messages in thread
From: François Dumont @ 2022-12-05 21:13 UTC (permalink / raw)
  To: libstdc++; +Cc: gcc-patches

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

I just rebased this patch.

All good apart from the to_chars/from_chars symbols issue.

François


On 11/10/22 19:28, François Dumont wrote:
> Hi
>
>     Now that pretty printer is fixed (once patch validated) I'd like 
> to propose this patch again.
>
>     Note that I'am adding a check on pretty printer with a std::any on 
> a std::wstring. I did so because of the FIXME in printers.py which is 
> dealing with 'std::string' explicitely. Looks like in my case, where 
> there is no 'std::string' but just a 'std::__8::string' we do not need 
> the workaround.
>
>     Once again I am attaching also the version namespace bump patch as 
> I think that adopting the cxx11 abi in this mode is a good enough 
> reason to bump it. If you agress let me know if I should squash the 
> commits before pushing.
>
>     libstdc++: [_GLIBCXX_INLINE_VERSION] Use cxx11 abi
>
>     Use cxx11 abi when activating versioned namespace mode.
>
>     libstdcxx-v3/ChangeLog:
>
>             * acinclude.m4 [GLIBCXX_ENABLE_LIBSTDCXX_DUAL_ABI]: 
> Default to "new" libstdcxx abi.
>             * config/locale/dragonfly/monetary_members.cc 
> [!_GLIBCXX_USE_DUAL_ABI]: Define money_base
>             members.
>             * config/locale/generic/monetary_members.cc 
> [!_GLIBCXX_USE_DUAL_ABI]: Likewise.
>             * config/locale/gnu/monetary_members.cc 
> [!_GLIBCXX_USE_DUAL_ABI]: Likewise.
>             * config/locale/gnu/numeric_members.cc
>             [!_GLIBCXX_USE_DUAL_ABI](__narrow_multibyte_chars): Define.
>             * configure: Regenerate.
>             * include/bits/c++config
>             [_GLIBCXX_INLINE_VERSION](_GLIBCXX_NAMESPACE_CXX11, 
> _GLIBCXX_BEGIN_NAMESPACE_CXX11): Define
>             empty.
> [_GLIBCXX_INLINE_VERSION](_GLIBCXX_END_NAMESPACE_CXX11, 
> _GLIBCXX_DEFAULT_ABI_TAG): Likewise.
>             * python/libstdcxx/v6/printers.py
>             (StdStringPrinter::__init__): Set self.new_string to True 
> when std::__8::basic_string type is
>             found.
>             * src/Makefile.am 
> [ENABLE_SYMVERS_GNU_NAMESPACE](ldbl_alt128_compat_sources): Define empty.
>             * src/Makefile.in: Regenerate.
>             * src/c++11/Makefile.am (cxx11_abi_sources): Rename into...
>             (dual_abi_sources): ...this, new. Also move several 
> sources to...
>             (sources): ...this.
>             (extra_string_inst_sources): Move several sources to...
>             (inst_sources): ...this.
>             * src/c++11/Makefile.in: Regenerate.
>             * src/c++11/cow-fstream-inst.cc [_GLIBCXX_USE_CXX11_ABI]: 
> Skip definitions.
>             * src/c++11/cow-locale_init.cc [_GLIBCXX_USE_CXX11_ABI]: 
> Skip definitions.
>             * src/c++11/cow-sstream-inst.cc [_GLIBCXX_USE_CXX11_ABI]: 
> Skip definitions.
>             * src/c++11/cow-stdexcept.cc 
> [_GLIBCXX_USE_CXX11_ABI](error_category::_M_message):
>             Skip definition.
>             [_GLIBCXX_USE_CXX11_ABI]: Skip Transaction Memory TS 
> definitions.
>             * src/c++11/cow-string-inst.cc [_GLIBCXX_USE_CXX11_ABI]: 
> Skip definitions.
>             * src/c++11/cow-string-io-inst.cc 
> [_GLIBCXX_USE_CXX11_ABI]: Skip definitions.
>             * src/c++11/cow-wstring-inst.cc [_GLIBCXX_USE_CXX11_ABI]: 
> Skip definitions.
>             * src/c++11/cow-wstring-io-inst.cc 
> [_GLIBCXX_USE_CXX11_ABI]: Skip definitions.
>             * src/c++11/cxx11-hash_tr1.cc [!_GLIBCXX_USE_CXX11_ABI]: 
> Skip definitions.
>             * src/c++11/cxx11-ios_failure.cc 
> [!_GLIBCXX_USE_CXX11_ABI]: Skip definitions.
>             [!_GLIBCXX_USE_DUAL_ABI] (__ios_failure): Remove.
>             * src/c++11/cxx11-locale-inst.cc: Cleanup, just include 
> locale-inst.cc.
>             * src/c++11/cxx11-stdexcept.cc [!_GLIBCXX_USE_CXX11_ABI]: 
> Skip definitions.
>             [!_GLIBCXX_USE_DUAL_ABI](__cow_string): Remove.
>             * src/c++11/cxx11-wlocale-inst.cc 
> [!_GLIBCXX_USE_CXX11_ABI]: Skip definitions.
>             * src/c++11/fstream-inst.cc [!_GLIBCXX_USE_CXX11_ABI]: 
> Skip definitions
>             * src/c++11/locale-inst-numeric.h
> [!_GLIBCXX_USE_DUAL_ABI](std::use_facet<num_get<>>, 
> std::use_facet<num_put<>>): Instantiate.
> [!_GLIBCXX_USE_DUAL_ABI](std::has_facet<num_get<>>, 
> std::has_facet<num_put<>>): Instantiate.
>             [!_GLIBCXX_USE_DUAL_ABI](std::num_get<C, 
> istreambuf_iterator<C>>): Instantiate.
>             [!_GLIBCXX_USE_DUAL_ABI](std::num_put<C, 
> ostreambuf_iterator<C>>): Instantiate.
>             * src/c++11/locale-inst.cc [!_GLIBCXX_USE_DUAL_ABI]: Build 
> only when configured
>             _GLIBCXX_USE_CXX11_ABI is equal to currently built abi.
>             [!_GLIBCXX_USE_DUAL_ABI](__moneypunct_cache<C, false>): 
> Instantiate.
>             [!_GLIBCXX_USE_DUAL_ABI](__moneypunct_cache<C, true>): 
> Instantiate.
>             [!_GLIBCXX_USE_DUAL_ABI](__numpunct_cache<C>): Instantiate.
>             [!_GLIBCXX_USE_DUAL_ABI](__timepunct<C>): Instantiate.
>             [!_GLIBCXX_USE_DUAL_ABI](__timepunct_cache<C>): Instantiate.
>             [!_GLIBCXX_USE_DUAL_ABI](time_put<C, 
> ostreambuf_iterator<C>>): Instantiate.
>             [!_GLIBCXX_USE_DUAL_ABI](time_put_byname<C, 
> ostreambuf_iterator<C>>): Instantiate.
> [!_GLIBCXX_USE_DUAL_ABI](__ctype_abstract_base<C>): Instantiate.
>             [!_GLIBCXX_USE_DUAL_ABI](ctype_byname<C>): Instantiate.
>             [!_GLIBCXX_USE_DUAL_ABI](__codecvt_abstract_base<C, char, 
> mbstate_t>): Instantiate.
>             [!_GLIBCXX_USE_DUAL_ABI](codecvt_byname<C, char, 
> mbstate_t>): Instantiate.
> [!_GLIBCXX_USE_DUAL_ABI](use_facet<ctype<C>>(const locale&)): 
> Instantiate.
>             [!_GLIBCXX_USE_DUAL_ABI](use_facet<codecvt<C, char, 
> mbstate_t>>(const locale&)): Instantiate.
> [!_GLIBCXX_USE_DUAL_ABI](use_facet<__timepunct<C>>(const locale&)): 
> Instantiate.
> [!_GLIBCXX_USE_DUAL_ABI](use_facet<time_put<C>>(const locale&)): 
> Instantiate.
> [!_GLIBCXX_USE_DUAL_ABI](has_facet<ctype<C>>(const locale&)): 
> Instantiate.
>             [!_GLIBCXX_USE_DUAL_ABI](has_facet<codecvt<C, char, 
> mbstate_t>>(const locale&)): Instantiate.
> [!_GLIBCXX_USE_DUAL_ABI](has_facet<__timepunct<C>>(const locale&)): 
> Instantiate.
> [!_GLIBCXX_USE_DUAL_ABI](has_facet<time_put<C>>(const locale&)): 
> Instantiate.
>             [!_GLIBCXX_USE_DUAL_ABI](__add_grouping<C>): Define.
>             [!_GLIBCXX_USE_DUAL_ABI](__pad<C, char_traits<C>>): 
> Instantiate.
>             [!_GLIBCXX_USE_DUAL_ABI](__int_to_char(C*, unsigned long, 
> const C*, ios_base::fmtflags, bool)):
>             Define.
>             [!_GLIBCXX_USE_DUAL_ABI](__int_to_char(C*, unsigned long 
> long, const C*, ios_base::fmtflags, bool)):
>             Define.
>             * src/c++11/cxx11-wlocale-inst.cc 
> [!_GLIBCXX_USE_CXX11_ABI]: Skip definitions.
>             * src/c++98/Makefile.am (cxx11_abi_sources): Remove, 
> unique cow-istream-string.cc entry move to...
>             (inst_sources): ...this.
>             * src/c++98/Makefile.in: Regenerate.
>             * src/c++98/cow-istream-string.cc: Include 
> <bits/c++config.h>.
>             [_GLIBCXX_USE_CXX11_ABI]: Skip definitions.
>             * src/c++98/hash_tr1.cc [_GLIBCXX_USE_CXX11_ABI]: Skip 
> definitions.
>             * src/c++98/ios_failure.cc 
> [_GLIBCXX_USE_CXX11_ABI][_GLIBCXX_USE_DUAL_ABI]: Skip definitions.
>             * src/c++98/istream-string.cc [!_GLIBCXX_USE_DUAL_ABI]: 
> Build only when configured
>             _GLIBCXX_USE_CXX11_ABI is equal to currently built abi.
>             * src/c++98/locale_facets.cc 
> [_GLIBCXX_USE_CXX11_ABI](__verify_grouping): Remove.
>             * src/c++98/stdexcept.cc
>             [_GLIBCXX_USE_CXX11_ABI](logic_error(const string&): Remove.
>             [_GLIBCXX_USE_CXX11_ABI](domain_error(const string&): Remove.
>             [_GLIBCXX_USE_CXX11_ABI](invalid_argument(const string&): 
> Remove.
>             [_GLIBCXX_USE_CXX11_ABI](length_error(const string&): Remove.
>             [_GLIBCXX_USE_CXX11_ABI](out_of_range(const string&): Remove.
>             [_GLIBCXX_USE_CXX11_ABI](runtime_error(const string&): 
> Remove.
>             [_GLIBCXX_USE_CXX11_ABI](range_error(const string&): Remove.
>             [_GLIBCXX_USE_CXX11_ABI](overflow_error(const string&): 
> Remove.
>             [_GLIBCXX_USE_CXX11_ABI](underflow_error(const string&): 
> Remove.
>             * testsuite/libstdc++-prettyprinters/cxx17.cc: Add 
> std::any check with std::wstring.
>
> François
>
> On 30/05/22 22:58, François Dumont wrote:
>> Hi
>>
>> Here is the patch to use cxx11 abi for the versioned namespace mode.
>>
>> It is still suffering from a side effect on gdb pretty printers with 
>> 3 errors like:
>>
>> got: type = 
>> std::unique_ptr<std::vector<std::unique_ptr<std::list<std::__8::basic_string<char, 
>> std::__8::char_traits<char>, std::__8::allocator<char> >>[]>>[99]>
>> FAIL: libstdc++-prettyprinters/80276.cc whatis p4
>>
>> However once I apply the version bump errors are gone.
>>
>> Let me know if it is ok to apply all at once or if you prefer to 
>> avoid the version bump.
>>
>> François
>

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

diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
index b957c728ba1..eb5cffcac78 100644
--- a/libstdc++-v3/acinclude.m4
+++ b/libstdc++-v3/acinclude.m4
@@ -4472,12 +4472,16 @@ 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.
-    enable_libstdcxx_dual_abi="no"
-  fi
-  if test x"$enable_libstdcxx_dual_abi" != xyes; then
+    # gnu-versioned-namespace is incompatible with the dual ABI...
     AC_MSG_NOTICE([dual ABI is disabled])
-    default_libstdcxx_abi="gcc4-compatible"
+    enable_libstdcxx_dual_abi="no"
+    # ... 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 1265190dad9..5f91fd9b560 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 a778a6f402d..6b56e30a568 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 556575363da..54be63c44d7 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 c714d6a544f..ae17cb76c81 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/configure b/libstdc++-v3/configure
index 1f7017c08a4..b47a379e201 100755
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -68903,13 +68903,18 @@ fi
 
 
   if test x$enable_symvers = xgnu-versioned-namespace; then
-    # gnu-versioned-namespace is incompatible with the dual ABI.
-    enable_libstdcxx_dual_abi="no"
-  fi
-  if test x"$enable_libstdcxx_dual_abi" != xyes; then
+    # gnu-versioned-namespace is incompatible with the dual ABI...
     { $as_echo "$as_me:${as_lineno-$LINENO}: dual ABI is disabled" >&5
 $as_echo "$as_me: dual ABI is disabled" >&6;}
-    default_libstdcxx_abi="gcc4-compatible"
+    enable_libstdcxx_dual_abi="no"
+    # ... and use the cxx11 one.
+    default_libstdcxx_abi="new"
+  else
+    if test x"$enable_libstdcxx_dual_abi" != xyes; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: dual ABI is disabled" >&5
+$as_echo "$as_me: dual ABI is disabled" >&6;}
+      default_libstdcxx_abi="gcc4-compatible"
+    fi
   fi
 
 
diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config
index 50406066afe..2e9ff1a5ba2 100644
--- a/libstdc++-v3/include/bits/c++config
+++ b/libstdc++-v3/include/bits/c++config
@@ -325,26 +325,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 
 
@@ -396,7 +376,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_VERSION_NAMESPACE
   inline namespace __cxx11 __attribute__((__abi_tag__ ("cxx11"))) { }
 # endif
   }
@@ -426,6 +406,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/python/libstdcxx/v6/printers.py b/libstdc++-v3/python/libstdcxx/v6/printers.py
index 1abf0a4bce3..5fe08ee0adc 100644
--- a/libstdc++-v3/python/libstdcxx/v6/printers.py
+++ b/libstdc++-v3/python/libstdcxx/v6/printers.py
@@ -947,6 +947,8 @@ class StdStringPrinter:
     def __init__(self, typename, val):
         self.val = val
         self.new_string = typename.find("::__cxx11::basic_string") != -1
+        if not self.new_string and _versioned_namespace:
+            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 38943f36fb4..dc1ac826ffe 100644
--- a/libstdc++-v3/src/Makefile.am
+++ b/libstdc++-v3/src/Makefile.am
@@ -81,6 +81,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 = \
@@ -94,6 +97,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/Makefile.in b/libstdc++-v3/src/Makefile.in
index c556d0dee1b..744e5ff36cc 100644
--- a/libstdc++-v3/src/Makefile.in
+++ b/libstdc++-v3/src/Makefile.in
@@ -157,10 +157,9 @@ am__objects_2 = compatibility.lo compatibility-debug_list.lo \
 @ENABLE_SYMVERS_GNU_NAMESPACE_FALSE@	compatibility-chrono.lo \
 @ENABLE_SYMVERS_GNU_NAMESPACE_FALSE@	compatibility-condvar.lo \
 @ENABLE_SYMVERS_GNU_NAMESPACE_FALSE@	compatibility-thread-c++0x.lo
-@ENABLE_DUAL_ABI_TRUE@@GLIBCXX_LDBL_ALT128_COMPAT_TRUE@am__objects_4 = compatibility-ldbl-alt128-cxx11.lo
-@GLIBCXX_LDBL_ALT128_COMPAT_TRUE@am__objects_5 =  \
-@GLIBCXX_LDBL_ALT128_COMPAT_TRUE@	compatibility-ldbl-alt128.lo \
-@GLIBCXX_LDBL_ALT128_COMPAT_TRUE@	$(am__objects_4)
+@ENABLE_DUAL_ABI_TRUE@@ENABLE_SYMVERS_GNU_NAMESPACE_FALSE@@GLIBCXX_LDBL_ALT128_COMPAT_TRUE@am__objects_4 = compatibility-ldbl-alt128-cxx11.lo
+@ENABLE_SYMVERS_GNU_NAMESPACE_FALSE@@GLIBCXX_LDBL_ALT128_COMPAT_TRUE@am__objects_5 = compatibility-ldbl-alt128.lo \
+@ENABLE_SYMVERS_GNU_NAMESPACE_FALSE@@GLIBCXX_LDBL_ALT128_COMPAT_TRUE@	$(am__objects_4)
 am__objects_6 = $(am__objects_3) $(am__objects_5)
 am_libstdc___la_OBJECTS = $(am__objects_2) $(am__objects_6)
 libstdc___la_OBJECTS = $(am_libstdc___la_OBJECTS)
@@ -505,14 +504,15 @@ SUBDIRS = c++98 c++11 c++17 c++20 $(filesystem_dir) $(backtrace_dir) experimenta
 
 @GLIBCXX_LDBL_COMPAT_FALSE@ldbl_compat_sources = 
 @GLIBCXX_LDBL_COMPAT_TRUE@ldbl_compat_sources = compatibility-ldbl.cc
-@ENABLE_DUAL_ABI_FALSE@@GLIBCXX_LDBL_ALT128_COMPAT_TRUE@ldbl_alt128_compat_cxx11_sources = 
-@ENABLE_DUAL_ABI_TRUE@@GLIBCXX_LDBL_ALT128_COMPAT_TRUE@ldbl_alt128_compat_cxx11_sources = \
-@ENABLE_DUAL_ABI_TRUE@@GLIBCXX_LDBL_ALT128_COMPAT_TRUE@	compatibility-ldbl-alt128-cxx11.cc
-
-@GLIBCXX_LDBL_ALT128_COMPAT_FALSE@ldbl_alt128_compat_sources = 
-@GLIBCXX_LDBL_ALT128_COMPAT_TRUE@ldbl_alt128_compat_sources = \
-@GLIBCXX_LDBL_ALT128_COMPAT_TRUE@	compatibility-ldbl-alt128.cc \
-@GLIBCXX_LDBL_ALT128_COMPAT_TRUE@	${ldbl_alt128_compat_cxx11_sources}
+@ENABLE_SYMVERS_GNU_NAMESPACE_FALSE@@GLIBCXX_LDBL_ALT128_COMPAT_FALSE@ldbl_alt128_compat_sources = 
+@ENABLE_SYMVERS_GNU_NAMESPACE_FALSE@@GLIBCXX_LDBL_ALT128_COMPAT_TRUE@ldbl_alt128_compat_sources = \
+@ENABLE_SYMVERS_GNU_NAMESPACE_FALSE@@GLIBCXX_LDBL_ALT128_COMPAT_TRUE@	compatibility-ldbl-alt128.cc \
+@ENABLE_SYMVERS_GNU_NAMESPACE_FALSE@@GLIBCXX_LDBL_ALT128_COMPAT_TRUE@	${ldbl_alt128_compat_cxx11_sources}
+
+@ENABLE_SYMVERS_GNU_NAMESPACE_TRUE@ldbl_alt128_compat_sources = 
+@ENABLE_DUAL_ABI_FALSE@@ENABLE_SYMVERS_GNU_NAMESPACE_FALSE@@GLIBCXX_LDBL_ALT128_COMPAT_TRUE@ldbl_alt128_compat_cxx11_sources = 
+@ENABLE_DUAL_ABI_TRUE@@ENABLE_SYMVERS_GNU_NAMESPACE_FALSE@@GLIBCXX_LDBL_ALT128_COMPAT_TRUE@ldbl_alt128_compat_cxx11_sources = \
+@ENABLE_DUAL_ABI_TRUE@@ENABLE_SYMVERS_GNU_NAMESPACE_FALSE@@GLIBCXX_LDBL_ALT128_COMPAT_TRUE@	compatibility-ldbl-alt128-cxx11.cc
 
 @ENABLE_SYMVERS_GNU_NAMESPACE_FALSE@cxx0x_compat_sources = \
 @ENABLE_SYMVERS_GNU_NAMESPACE_FALSE@	compatibility-atomic-c++0x.cc \
diff --git a/libstdc++-v3/src/c++11/Makefile.am b/libstdc++-v3/src/c++11/Makefile.am
index ecd46aafc01..b22c54fa057 100644
--- a/libstdc++-v3/src/c++11/Makefile.am
+++ b/libstdc++-v3/src/c++11/Makefile.am
@@ -40,22 +40,22 @@ ctype_members.cc: ${glibcxx_srcdir}/$(CCTYPE_CC)
 	$(LN_S) ${glibcxx_srcdir}/$(CCTYPE_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 = \
 	chrono.cc \
 	codecvt.cc \
 	condition_variable.cc \
+	cow-locale_init.cc \
 	cow-stdexcept.cc \
+	cxx11-hash_tr1.cc \
+	cxx11-ios_failure.cc \
+	cxx11-stdexcept.cc \
 	ctype.cc \
 	debug.cc \
 	functexcept.cc \
@@ -75,19 +75,11 @@ sources = \
 	snprintf_lite.cc \
 	system_error.cc \
 	thread.cc \
-	${cxx11_abi_sources} \
+	${dual_abi_sources} \
 	${host_sources}
 
 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 =
@@ -97,6 +89,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/Makefile.in b/libstdc++-v3/src/c++11/Makefile.in
index 77e11a9fd1d..d11b01109c2 100644
--- a/libstdc++-v3/src/c++11/Makefile.in
+++ b/libstdc++-v3/src/c++11/Makefile.in
@@ -121,26 +121,27 @@ CONFIG_CLEAN_FILES =
 CONFIG_CLEAN_VPATH_FILES =
 LTLIBRARIES = $(noinst_LTLIBRARIES)
 libc__11convenience_la_LIBADD =
-@ENABLE_DUAL_ABI_TRUE@am__objects_1 = cow-locale_init.lo \
-@ENABLE_DUAL_ABI_TRUE@	cow-shim_facets.lo cxx11-hash_tr1.lo \
-@ENABLE_DUAL_ABI_TRUE@	cxx11-ios_failure.lo \
-@ENABLE_DUAL_ABI_TRUE@	cxx11-shim_facets.lo cxx11-stdexcept.lo
+@ENABLE_DUAL_ABI_TRUE@am__objects_1 = cow-shim_facets.lo \
+@ENABLE_DUAL_ABI_TRUE@	cxx11-shim_facets.lo
 am__objects_2 = ctype_configure_char.lo ctype_members.lo
 am__objects_3 = chrono.lo codecvt.lo condition_variable.lo \
-	cow-stdexcept.lo ctype.lo debug.lo functexcept.lo \
-	functional.lo futex.lo future.lo hash_c++0x.lo \
+	cow-locale_init.lo cow-stdexcept.lo cxx11-hash_tr1.lo \
+	cxx11-ios_failure.lo cxx11-stdexcept.lo ctype.lo debug.lo \
+	functexcept.lo functional.lo futex.lo future.lo hash_c++0x.lo \
 	hashtable_c++0x.lo ios.lo ios_errcat.lo limits.lo mutex.lo \
 	placeholders.lo random.lo regex.lo shared_ptr.lo \
 	snprintf_lite.lo system_error.lo thread.lo $(am__objects_1) \
 	$(am__objects_2)
-@ENABLE_DUAL_ABI_TRUE@am__objects_4 = cow-fstream-inst.lo \
-@ENABLE_DUAL_ABI_TRUE@	cow-sstream-inst.lo cow-string-inst.lo \
-@ENABLE_DUAL_ABI_TRUE@	cow-string-io-inst.lo \
-@ENABLE_DUAL_ABI_TRUE@	cow-wstring-inst.lo \
-@ENABLE_DUAL_ABI_TRUE@	cow-wstring-io-inst.lo \
-@ENABLE_DUAL_ABI_TRUE@	cxx11-locale-inst.lo \
-@ENABLE_DUAL_ABI_TRUE@	cxx11-wlocale-inst.lo sso_string.lo
+@ENABLE_DUAL_ABI_TRUE@am__objects_4 = sso_string.lo
 @ENABLE_EXTERN_TEMPLATE_TRUE@am__objects_5 = $(am__objects_4) \
+@ENABLE_EXTERN_TEMPLATE_TRUE@	cow-fstream-inst.lo \
+@ENABLE_EXTERN_TEMPLATE_TRUE@	cow-sstream-inst.lo \
+@ENABLE_EXTERN_TEMPLATE_TRUE@	cow-string-inst.lo \
+@ENABLE_EXTERN_TEMPLATE_TRUE@	cow-string-io-inst.lo \
+@ENABLE_EXTERN_TEMPLATE_TRUE@	cow-wstring-inst.lo \
+@ENABLE_EXTERN_TEMPLATE_TRUE@	cow-wstring-io-inst.lo \
+@ENABLE_EXTERN_TEMPLATE_TRUE@	cxx11-locale-inst.lo \
+@ENABLE_EXTERN_TEMPLATE_TRUE@	cxx11-wlocale-inst.lo \
 @ENABLE_EXTERN_TEMPLATE_TRUE@	ext11-inst.lo fstream-inst.lo \
 @ENABLE_EXTERN_TEMPLATE_TRUE@	ios-inst.lo iostream-inst.lo \
 @ENABLE_EXTERN_TEMPLATE_TRUE@	istream-inst.lo locale-inst.lo \
@@ -457,20 +458,20 @@ host_sources = \
 	ctype_configure_char.cc \
 	ctype_members.cc
 
-@ENABLE_DUAL_ABI_FALSE@cxx11_abi_sources = 
-@ENABLE_DUAL_ABI_TRUE@cxx11_abi_sources = \
-@ENABLE_DUAL_ABI_TRUE@	cow-locale_init.cc \
+@ENABLE_DUAL_ABI_FALSE@dual_abi_sources = 
+@ENABLE_DUAL_ABI_TRUE@dual_abi_sources = \
 @ENABLE_DUAL_ABI_TRUE@	cow-shim_facets.cc \
-@ENABLE_DUAL_ABI_TRUE@	cxx11-hash_tr1.cc \
-@ENABLE_DUAL_ABI_TRUE@	cxx11-ios_failure.cc \
-@ENABLE_DUAL_ABI_TRUE@	cxx11-shim_facets.cc \
-@ENABLE_DUAL_ABI_TRUE@	cxx11-stdexcept.cc
+@ENABLE_DUAL_ABI_TRUE@	cxx11-shim_facets.cc
 
 sources = \
 	chrono.cc \
 	codecvt.cc \
 	condition_variable.cc \
+	cow-locale_init.cc \
 	cow-stdexcept.cc \
+	cxx11-hash_tr1.cc \
+	cxx11-ios_failure.cc \
+	cxx11-stdexcept.cc \
 	ctype.cc \
 	debug.cc \
 	functexcept.cc \
@@ -490,19 +491,11 @@ sources = \
 	snprintf_lite.cc \
 	system_error.cc \
 	thread.cc \
-	${cxx11_abi_sources} \
+	${dual_abi_sources} \
 	${host_sources}
 
 @ENABLE_DUAL_ABI_FALSE@extra_string_inst_sources = 
 @ENABLE_DUAL_ABI_TRUE@extra_string_inst_sources = \
-@ENABLE_DUAL_ABI_TRUE@	cow-fstream-inst.cc \
-@ENABLE_DUAL_ABI_TRUE@	cow-sstream-inst.cc \
-@ENABLE_DUAL_ABI_TRUE@	cow-string-inst.cc \
-@ENABLE_DUAL_ABI_TRUE@	cow-string-io-inst.cc \
-@ENABLE_DUAL_ABI_TRUE@	cow-wstring-inst.cc \
-@ENABLE_DUAL_ABI_TRUE@	cow-wstring-io-inst.cc \
-@ENABLE_DUAL_ABI_TRUE@	cxx11-locale-inst.cc \
-@ENABLE_DUAL_ABI_TRUE@	cxx11-wlocale-inst.cc \
 @ENABLE_DUAL_ABI_TRUE@	sso_string.cc
 
 # XTEMPLATE_FLAGS =
@@ -511,6 +504,14 @@ sources = \
 # XTEMPLATE_FLAGS = -fno-implicit-templates
 @ENABLE_EXTERN_TEMPLATE_TRUE@inst_sources = \
 @ENABLE_EXTERN_TEMPLATE_TRUE@	$(extra_string_inst_sources) \
+@ENABLE_EXTERN_TEMPLATE_TRUE@	cow-fstream-inst.cc \
+@ENABLE_EXTERN_TEMPLATE_TRUE@	cow-sstream-inst.cc \
+@ENABLE_EXTERN_TEMPLATE_TRUE@	cow-string-inst.cc \
+@ENABLE_EXTERN_TEMPLATE_TRUE@	cow-string-io-inst.cc \
+@ENABLE_EXTERN_TEMPLATE_TRUE@	cow-wstring-inst.cc \
+@ENABLE_EXTERN_TEMPLATE_TRUE@	cow-wstring-io-inst.cc \
+@ENABLE_EXTERN_TEMPLATE_TRUE@	cxx11-locale-inst.cc \
+@ENABLE_EXTERN_TEMPLATE_TRUE@	cxx11-wlocale-inst.cc \
 @ENABLE_EXTERN_TEMPLATE_TRUE@	ext11-inst.cc \
 @ENABLE_EXTERN_TEMPLATE_TRUE@	fstream-inst.cc \
 @ENABLE_EXTERN_TEMPLATE_TRUE@	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 6b6352c1419..d9657484326 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 4d5c08f20cc..fa27b4142f2 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
@@ -193,3 +190,4 @@ namespace
 
 _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 8839f4a6f75..2db78a43f50 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 9e8787485eb..8b217c45960 100644
--- a/libstdc++-v3/src/c++11/cow-stdexcept.cc
+++ b/libstdc++-v3/src/c++11/cow-stdexcept.cc
@@ -41,7 +41,7 @@ _txnal_logic_error_get_msg(void* e);
 void*
 _txnal_runtime_error_get_msg(void* e);
 
-// All exception classes still use the classic COW std::string.
+// In dual abi 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
@@ -169,6 +169,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
                 "alignof(std::string) has changed");
 #endif
 
+#if ! _GLIBCXX_USE_CXX11_ABI
   // Return error_category::message() as an SSO string
   __sso_string
   error_category::_M_message(int i) const
@@ -176,10 +177,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 +466,4 @@ CTORDTOR(15underflow_error, std::underflow_error, runtime_error)
 
 #endif  // _GLIBCXX_USE_C99_STDINT_TR1
 #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 e5331bb029a..40ebe708971 100644
--- a/libstdc++-v3/src/c++11/cow-string-inst.cc
+++ b/libstdc++-v3/src/c++11/cow-string-inst.cc
@@ -27,11 +27,10 @@
 //
 
 #define _GLIBCXX_USE_CXX11_ABI 0
-#include "string-inst.cc"
+#include <bits/c++config.h>
 
-#if ! _GLIBCXX_USE_DUAL_ABI
-# error This file should not be compiled for this configuration.
-#endif
+#if ! _GLIBCXX_USE_CXX11_ABI
+#include "string-inst.cc"
 
 #ifdef  _GLIBCXX_USE_C99_STDINT_TR1
 #include <random>
@@ -47,3 +46,4 @@ namespace std _GLIBCXX_VISIBILITY(default)
   { _M_init(token.c_str(), token.length()); }
 } // namespace
 #endif
+#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 3f65aeb9873..a3720680907 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 a38c1288ef3..b0eff7ef97d 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 dbd19e0feb0..f0ed5cc6b6b 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 f36541fd4cc..edd89974e1b 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 0a81e15e4c0..db4c623a536 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 5c860054ea6..814cdcc9902 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 236bc40cd55..9faf355977a 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)
 {
@@ -70,9 +68,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   underflow_error::underflow_error(const string& __arg)
   : runtime_error(__arg) { }
 
+# if _GLIBCXX_USE_DUAL_ABI
   // Converting constructor from ABI-tagged std::string to COW string.
   __cow_string::__cow_string(const string& s)
   : __cow_string(s.c_str(), s.length()) { }
+# endif
 
 _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 6d26292075d..7491d5117df 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/fstream-inst.cc b/libstdc++-v3/src/c++11/fstream-inst.cc
index 7bf56c7e864..494c7bb51d0 100644
--- a/libstdc++-v3/src/c++11/fstream-inst.cc
+++ b/libstdc++-v3/src/c++11/fstream-inst.cc
@@ -29,6 +29,7 @@
 #define _GLIBCXX_USE_CXX11_ABI 1
 #include <fstream>
 
+#if _GLIBCXX_USE_CXX11_ABI
 namespace std _GLIBCXX_VISIBILITY(default)
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
@@ -47,3 +48,4 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
+#endif
diff --git a/libstdc++-v3/src/c++11/locale-inst-numeric.h b/libstdc++-v3/src/c++11/locale-inst-numeric.h
index 18514e892af..741e6f5ca26 100644
--- a/libstdc++-v3/src/c++11/locale-inst-numeric.h
+++ b/libstdc++-v3/src/c++11/locale-inst-numeric.h
@@ -23,14 +23,14 @@
 // <http://www.gnu.org/licenses/>.
 
 #ifndef C
-#define "This file should not be compiled directly, only included"
+# error "This file should not be compiled directly, only included"
 #endif
 
 #include "facet_inst_macros.h"
 
 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 6767da74b74..15235c2c155 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*
@@ -159,7 +168,11 @@ INSTANTIATE_FACET_ACCESSORS(messages<C>);
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
 
+#if ! _GLIBCXX_INLINE_VERSION
 // XXX GLIBCXX_ABI Deprecated
-#if defined _GLIBCXX_LONG_DOUBLE_COMPAT && ! _GLIBCXX_USE_CXX11_ABI
-#include "compatibility-ldbl-facets-aliases.h"
-#endif // _GLIBCXX_LONG_DOUBLE_COMPAT
+# if defined _GLIBCXX_LONG_DOUBLE_COMPAT && ! _GLIBCXX_USE_CXX11_ABI
+#  include "compatibility-ldbl-facets-aliases.h"
+# endif // _GLIBCXX_LONG_DOUBLE_COMPAT
+#endif
+
+#endif //  _GLIBCXX_BUILD_CXX11_ABI == _GLIBCXX_USE_CXX11_ABI
diff --git a/libstdc++-v3/src/c++11/wlocale-inst.cc b/libstdc++-v3/src/c++11/wlocale-inst.cc
index 0855f67707c..0338a9554a2 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 b96588bd95c..9bbe8c00a73 100644
--- a/libstdc++-v3/src/c++98/Makefile.am
+++ b/libstdc++-v3/src/c++98/Makefile.am
@@ -90,13 +90,6 @@ c++locale.cc: ${glibcxx_srcdir}/$(CLOCALE_CC)
 basic_file.cc: ${glibcxx_srcdir}/$(BASIC_FILE_CC)
 	$(LN_S) ${glibcxx_srcdir}/$(BASIC_FILE_CC) ./$@ || true
 
-if ENABLE_DUAL_ABI
-cxx11_abi_sources = \
-	cow-istream-string.cc
-else
-cxx11_abi_sources =
-endif
-
 if ENABLE_EXTERN_TEMPLATE
 # XTEMPLATE_FLAGS = -fno-implicit-templates
 inst_sources = \
@@ -118,6 +111,7 @@ sources = \
 	mt_allocator.cc \
 	codecvt.cc \
 	complex_io.cc \
+	cow-istream-string.cc \
 	globals_io.cc \
 	hash_tr1.cc \
 	hashtable_tr1.cc \
@@ -142,7 +136,6 @@ sources = \
 	istream-string.cc \
 	streambuf.cc \
 	valarray.cc \
-	${cxx11_abi_sources} \
 	${host_sources} \
 	${host_sources_extra}
 
diff --git a/libstdc++-v3/src/c++98/Makefile.in b/libstdc++-v3/src/c++98/Makefile.in
index bd63782a12d..e4e22db69df 100644
--- a/libstdc++-v3/src/c++98/Makefile.in
+++ b/libstdc++-v3/src/c++98/Makefile.in
@@ -121,30 +121,29 @@ CONFIG_CLEAN_FILES =
 CONFIG_CLEAN_VPATH_FILES =
 LTLIBRARIES = $(noinst_LTLIBRARIES)
 libc__98convenience_la_LIBADD =
-@ENABLE_DUAL_ABI_TRUE@am__objects_1 = cow-istream-string.lo
-@ENABLE_DUAL_ABI_TRUE@am__objects_2 = collate_members_cow.lo \
+@ENABLE_DUAL_ABI_TRUE@am__objects_1 = collate_members_cow.lo \
 @ENABLE_DUAL_ABI_TRUE@	messages_members_cow.lo \
 @ENABLE_DUAL_ABI_TRUE@	monetary_members_cow.lo \
 @ENABLE_DUAL_ABI_TRUE@	numeric_members_cow.lo
-am__objects_3 = $(am__objects_2) codecvt_members.lo collate_members.lo \
+am__objects_2 = $(am__objects_1) codecvt_members.lo collate_members.lo \
 	messages_members.lo monetary_members.lo numeric_members.lo \
 	time_members.lo
-@ENABLE_EXTERN_TEMPLATE_TRUE@am__objects_4 = allocator-inst.lo \
+@ENABLE_EXTERN_TEMPLATE_TRUE@am__objects_3 = allocator-inst.lo \
 @ENABLE_EXTERN_TEMPLATE_TRUE@	concept-inst.lo ext-inst.lo \
 @ENABLE_EXTERN_TEMPLATE_TRUE@	misc-inst.lo
-am__objects_5 = parallel_settings.lo
-am__objects_6 = basic_file.lo c++locale.lo $(am__objects_4) \
-	$(am__objects_5)
-am__objects_7 = bitmap_allocator.lo pool_allocator.lo mt_allocator.lo \
-	codecvt.lo complex_io.lo globals_io.lo hash_tr1.lo \
-	hashtable_tr1.lo ios_failure.lo ios_init.lo ios_locale.lo \
-	list.lo list-aux.lo list-aux-2.lo list_associated.lo \
-	list_associated-2.lo locale.lo locale_init.lo locale_facets.lo \
-	localename.lo math_stubs_float.lo math_stubs_long_double.lo \
-	stdexcept.lo strstream.lo tree.lo istream.lo istream-string.lo \
-	streambuf.lo valarray.lo $(am__objects_1) $(am__objects_3) \
-	$(am__objects_6)
-am_libc__98convenience_la_OBJECTS = $(am__objects_7)
+am__objects_4 = parallel_settings.lo
+am__objects_5 = basic_file.lo c++locale.lo $(am__objects_3) \
+	$(am__objects_4)
+am__objects_6 = bitmap_allocator.lo pool_allocator.lo mt_allocator.lo \
+	codecvt.lo complex_io.lo cow-istream-string.lo globals_io.lo \
+	hash_tr1.lo hashtable_tr1.lo ios_failure.lo ios_init.lo \
+	ios_locale.lo list.lo list-aux.lo list-aux-2.lo \
+	list_associated.lo list_associated-2.lo locale.lo \
+	locale_init.lo locale_facets.lo localename.lo \
+	math_stubs_float.lo math_stubs_long_double.lo stdexcept.lo \
+	strstream.lo tree.lo istream.lo istream-string.lo streambuf.lo \
+	valarray.lo $(am__objects_2) $(am__objects_5)
+am_libc__98convenience_la_OBJECTS = $(am__objects_6)
 libc__98convenience_la_OBJECTS = $(am_libc__98convenience_la_OBJECTS)
 AM_V_lt = $(am__v_lt_@AM_V@)
 am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
@@ -470,10 +469,6 @@ host_sources_extra = \
 	basic_file.cc c++locale.cc \
 	${inst_sources} ${parallel_sources}
 
-@ENABLE_DUAL_ABI_FALSE@cxx11_abi_sources = 
-@ENABLE_DUAL_ABI_TRUE@cxx11_abi_sources = \
-@ENABLE_DUAL_ABI_TRUE@	cow-istream-string.cc
-
 # XTEMPLATE_FLAGS =
 @ENABLE_EXTERN_TEMPLATE_FALSE@inst_sources = 
 
@@ -493,6 +488,7 @@ sources = \
 	mt_allocator.cc \
 	codecvt.cc \
 	complex_io.cc \
+	cow-istream-string.cc \
 	globals_io.cc \
 	hash_tr1.cc \
 	hashtable_tr1.cc \
@@ -517,7 +513,6 @@ sources = \
 	istream-string.cc \
 	streambuf.cc \
 	valarray.cc \
-	${cxx11_abi_sources} \
 	${host_sources} \
 	${host_sources_extra}
 
diff --git a/libstdc++-v3/src/c++98/cow-istream-string.cc b/libstdc++-v3/src/c++98/cow-istream-string.cc
index d90ec2a0cf3..ff406830c61 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 caa424e423f..7256d2529cf 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 523d1f6a4e9..e650ded371e 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
-
-#ifdef _GLIBCXX_USE_NLS
-# include <libintl.h>
-# define _(msgid)   gettext (msgid)
-#else
-# define _(msgid)   (msgid)
-#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
+#  include <libintl.h>
+#  define _(msgid)   gettext (msgid)
+# else
+#  define _(msgid)   (msgid)
+# 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,11 +56,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   const char*
   ios_base::failure::what() const throw()
   { return _M_msg.c_str(); }
+# endif
 
-#if _GLIBCXX_USE_DUAL_ABI
+# if _GLIBCXX_USE_DUAL_ABI
   // When the dual ABI is enabled __throw_ios_failure() is defined in
   // src/c++11/cxx11-ios_failure.cc
-#if __cpp_rtti
+#  if __cpp_rtti
   // If RTTI is enabled the exception type thrown will use these functions to
   // construct/destroy a gcc4-compatible ios::failure object in a buffer,
   // and to catch that object via a handler of the gcc4-compatible type.
@@ -80,9 +83,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   typedef char S[1 / (sizeof(ios::failure) <= sizeof(runtime_error))];
   typedef char A[1 / (__alignof(ios::failure) <= __alignof(runtime_error))];
   }
-#endif // __cpp_rtti
+#  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_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 19f5f0c1a47..034cd951d6d 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 1293a37e642..4b351b2e8ef 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 0a24b054ca0..786f0ff0523 100644
--- a/libstdc++-v3/src/c++98/stdexcept.cc
+++ b/libstdc++-v3/src/c++98/stdexcept.cc
@@ -26,7 +26,7 @@
 // ISO C++ 14882: 19.1  Exception classes
 //
 
-// All exception classes still use the classic COW std::string.
+// In dual abi all exception classes still use the classic COW std::string.
 #define _GLIBCXX_USE_CXX11_ABI 0
 #include <string>
 #include <stdexcept>
@@ -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 { }
 
diff --git a/libstdc++-v3/testsuite/20_util/bind/ref_neg.cc b/libstdc++-v3/testsuite/20_util/bind/ref_neg.cc
index a78935775c2..830b30eae6c 100644
--- a/libstdc++-v3/testsuite/20_util/bind/ref_neg.cc
+++ b/libstdc++-v3/testsuite/20_util/bind/ref_neg.cc
@@ -50,7 +50,7 @@ void test02()
 
 // Ignore the reasons for deduction/substitution failure in the headers.
 // Arrange for the match to work on installed trees as well as build trees.
-// { dg-prune-output "no type named 'type' in 'struct std::result_of" }
+// { dg-prune-output "no type named 'type' in 'struct std::(__8::)?result_of" }
 
 int main()
 {
diff --git a/libstdc++-v3/testsuite/libstdc++-prettyprinters/cxx17.cc b/libstdc++-v3/testsuite/libstdc++-prettyprinters/cxx17.cc
index cf699d22e78..beff378520c 100644
--- a/libstdc++-v3/testsuite/libstdc++-prettyprinters/cxx17.cc
+++ b/libstdc++-v3/testsuite/libstdc++-prettyprinters/cxx17.cc
@@ -62,6 +62,8 @@ main()
 // { dg-final { regexp-test om {std::optional<std::(__debug::)?map<int, double>> containing std::(__debug::)?map with 3 elements = {\[1\] = 2, \[3\] = 4, \[5\] = 6}} } }
   optional<std::string> os{ "stringy" };
 // { dg-final { note-test os {std::optional<std::string> = {[contained value] = "stringy"}} } }
+  optional<std::wstring> ows{ L"stringy" };
+// { dg-final { note-test ows {std::optional<std::wstring> = {[contained value] = L"stringy"}} } }
 
   any a;
 // { dg-final { note-test a {std::any [no contained value]} } }
@@ -73,6 +75,8 @@ main()
 // { dg-final { note-test ap {std::any containing void * = {[contained value] = 0x0}} } }
   any as = *os;
 // { dg-final { note-test as {std::any containing std::string = {[contained value] = "stringy"}} } }
+  any aws = *ows;
+// { dg-final { note-test aws {std::any containing std::wstring = {[contained value] = L"stringy"}} } }
   any as2("stringiest");
 // { dg-final { regexp-test as2 {std::any containing const char \* = {\[contained value\] = 0x[[:xdigit:]]+ "stringiest"}} } }
   any am = *om;

[-- Attachment #3: version_namespace_bump.patch --]
[-- Type: text/x-patch, Size: 9394 bytes --]

diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
index eb5cffcac78..367181d76c5 100644
--- a/libstdc++-v3/acinclude.m4
+++ b/libstdc++-v3/acinclude.m4
@@ -3857,7 +3857,7 @@ case $enable_symvers in
 	      [Define to use GNU versioning in the shared library.])
     ;;
   gnu-versioned-namespace)
-    libtool_VERSION=8:0:0
+    libtool_VERSION=9:0:0
     SYMVER_FILE=config/abi/pre/gnu-versioned-namespace.ver
     AC_DEFINE(_GLIBCXX_SYMVER_GNU_NAMESPACE, 1,
 	      [Define to use GNU namespace versioning in the shared library.])
diff --git a/libstdc++-v3/config/abi/pre/gnu-versioned-namespace.ver b/libstdc++-v3/config/abi/pre/gnu-versioned-namespace.ver
index 06ccaa80a58..d82077a3cfa 100644
--- a/libstdc++-v3/config/abi/pre/gnu-versioned-namespace.ver
+++ b/libstdc++-v3/config/abi/pre/gnu-versioned-namespace.ver
@@ -19,7 +19,7 @@
 ## with this library; see the file COPYING3.  If not see
 ## <http://www.gnu.org/licenses/>.
 
-GLIBCXX_8.0 {
+GLIBCXX_9.0 {
 
   global:
 
@@ -27,7 +27,7 @@ GLIBCXX_8.0 {
     extern "C++"
     {
       std::*;
-      std::__8::*;
+      std::__9::*;
     };
 
     # operator new(size_t)
@@ -59,7 +59,7 @@ GLIBCXX_8.0 {
     # vtable
     _ZTVSt*;
     _ZTVNSt*;
-    _ZTVN9__gnu_cxx3__818stdio_sync_filebufI[cw]NSt3__811char_traitsI[cw]EEEE;
+    _ZTVN9__gnu_cxx3__918stdio_sync_filebufI[cw]NSt3__911char_traitsI[cw]EEEE;
 
     # thunk
     _ZTv0_n12_NS*;
@@ -74,43 +74,43 @@ GLIBCXX_8.0 {
     _ZTSNSt*;
 
     # locale
-    _ZNSt3__89has_facetINS_*;
+    _ZNSt3__99has_facetINS_*;
 
     # thread/mutex/condition_variable/future
     __once_proxy;
 
     # std::__convert_to_v
-    _ZNSt3__814__convert_to_v*;
+    _ZNSt3__914__convert_to_v*;
 
     # std::__copy_streambufs
-    _ZNSt3__817__copy_streambufsI*;
-    _ZNSt3__821__copy_streambufs_eofI*;
+    _ZNSt3__917__copy_streambufsI*;
+    _ZNSt3__921__copy_streambufs_eofI*;
 
     # std::__istream_extract(wistream&, wchar_t*, streamsize)
-    _ZNSt3__817__istream_extractIwNS_11char_traitsIwEEEEvRNS_13basic_istreamIT_T0_EEPS4_[ilx];
+    _ZNSt3__917__istream_extractIwNS_11char_traitsIwEEEEvRNS_13basic_istreamIT_T0_EEPS4_[ilx];
 
     # __gnu_cxx::__atomic_add
     # __gnu_cxx::__exchange_and_add
-    _ZN9__gnu_cxx3__812__atomic_addEPV[il][il];
-    _ZN9__gnu_cxx3__818__exchange_and_addEPV[li][il];
+    _ZN9__gnu_cxx3__912__atomic_addEPV[il][il];
+    _ZN9__gnu_cxx3__918__exchange_and_addEPV[li][il];
 
     # __gnu_cxx::__pool
-    _ZN9__gnu_cxx3__86__poolILb[01]EE13_M_initializeEv;
-    _ZN9__gnu_cxx3__86__poolILb[01]EE16_M_reserve_blockE[jmy][jmy];
-    _ZN9__gnu_cxx3__86__poolILb[01]EE16_M_reclaim_blockEPc[jmy];
-    _ZN9__gnu_cxx3__86__poolILb[01]EE10_M_destroyEv;
-    _ZN9__gnu_cxx3__86__poolILb1EE16_M_get_thread_idEv;
+    _ZN9__gnu_cxx3__96__poolILb[01]EE13_M_initializeEv;
+    _ZN9__gnu_cxx3__96__poolILb[01]EE16_M_reserve_blockE[jmy][jmy];
+    _ZN9__gnu_cxx3__96__poolILb[01]EE16_M_reclaim_blockEPc[jmy];
+    _ZN9__gnu_cxx3__96__poolILb[01]EE10_M_destroyEv;
+    _ZN9__gnu_cxx3__96__poolILb1EE16_M_get_thread_idEv;
 
-    _ZN9__gnu_cxx3__817__pool_alloc_base9_M_refillE[jmy];
-    _ZN9__gnu_cxx3__817__pool_alloc_base16_M_get_free_listE[jmy];
-    _ZN9__gnu_cxx3__817__pool_alloc_base12_M_get_mutexEv;
+    _ZN9__gnu_cxx3__917__pool_alloc_base9_M_refillE[jmy];
+    _ZN9__gnu_cxx3__917__pool_alloc_base16_M_get_free_listE[jmy];
+    _ZN9__gnu_cxx3__917__pool_alloc_base12_M_get_mutexEv;
 
-    _ZN9__gnu_cxx3__89free_list6_M_getE[jmy];
-    _ZN9__gnu_cxx3__89free_list8_M_clearEv;
+    _ZN9__gnu_cxx3__99free_list6_M_getE[jmy];
+    _ZN9__gnu_cxx3__99free_list8_M_clearEv;
 
     # __gnu_cxx::stdio_sync_filebuf
-    _ZTVN9__gnu_cxx3__818stdio_sync_filebufI[cw]St3__811char_traitsI[cw]EEE;
-    _ZN9__gnu_cxx3__818stdio_sync_filebufI[cw]NSt3__811char_traitsI[cw]EEE[5-9]*;
+    _ZTVN9__gnu_cxx3__918stdio_sync_filebufI[cw]St3__911char_traitsI[cw]EEE;
+    _ZN9__gnu_cxx3__918stdio_sync_filebufI[cw]NSt3__911char_traitsI[cw]EEE[5-9]*;
 
     # debug mode
     _ZN11__gnu_debug19_Safe_sequence_base12_M_get_mutexEv;
@@ -236,7 +236,7 @@ CXXABI_2.0 {
     _ZSt15_Fnv_hash_bytesPKv*;
 
     # __gnu_cxx::_verbose_terminate_handler()
-    _ZN9__gnu_cxx3__827__verbose_terminate_handlerEv;
+    _ZN9__gnu_cxx3__927__verbose_terminate_handlerEv;
 
     # *_type_info classes, ctor and dtor
     _ZN10__cxxabiv117__array_type_info*;
diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
index b47a379e201..9779ce0222b 100755
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -68684,7 +68684,7 @@ $as_echo "#define _GLIBCXX_SYMVER_GNU 1" >>confdefs.h
 
     ;;
   gnu-versioned-namespace)
-    libtool_VERSION=8:0:0
+    libtool_VERSION=9:0:0
     SYMVER_FILE=config/abi/pre/gnu-versioned-namespace.ver
 
 $as_echo "#define _GLIBCXX_SYMVER_GNU_NAMESPACE 1" >>confdefs.h
diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config
index 2e9ff1a5ba2..04ba2240f9e 100644
--- a/libstdc++-v3/include/bits/c++config
+++ b/libstdc++-v3/include/bits/c++config
@@ -330,7 +330,7 @@ namespace std
 
 #if _GLIBCXX_INLINE_VERSION
 // Inline namespace for symbol versioning of (nearly) everything in std.
-# define _GLIBCXX_BEGIN_NAMESPACE_VERSION namespace __8 {
+# define _GLIBCXX_BEGIN_NAMESPACE_VERSION namespace __9 {
 # define _GLIBCXX_END_NAMESPACE_VERSION }
 // Unused when everything in std is versioned anyway.
 # define _GLIBCXX_BEGIN_INLINE_ABI_NAMESPACE(X)
diff --git a/libstdc++-v3/python/libstdcxx/v6/printers.py b/libstdc++-v3/python/libstdcxx/v6/printers.py
index 5fe08ee0adc..fcedff08d5c 100644
--- a/libstdc++-v3/python/libstdcxx/v6/printers.py
+++ b/libstdc++-v3/python/libstdcxx/v6/printers.py
@@ -100,7 +100,7 @@ def find_type(orig, name):
         else:
             raise ValueError("Cannot find type %s::%s" % (str(orig), name))
 
-_versioned_namespace = '__8::'
+_versioned_namespace = '__9::'
 
 def lookup_templ_spec(templ, *args):
     """
diff --git a/libstdc++-v3/testsuite/20_util/bind/ref_neg.cc b/libstdc++-v3/testsuite/20_util/bind/ref_neg.cc
index 830b30eae6c..a78935775c2 100644
--- a/libstdc++-v3/testsuite/20_util/bind/ref_neg.cc
+++ b/libstdc++-v3/testsuite/20_util/bind/ref_neg.cc
@@ -50,7 +50,7 @@ void test02()
 
 // Ignore the reasons for deduction/substitution failure in the headers.
 // Arrange for the match to work on installed trees as well as build trees.
-// { dg-prune-output "no type named 'type' in 'struct std::(__8::)?result_of" }
+// { dg-prune-output "no type named 'type' in 'struct std::result_of" }
 
 int main()
 {
diff --git a/libstdc++-v3/testsuite/20_util/function/cons/70692.cc b/libstdc++-v3/testsuite/20_util/function/cons/70692.cc
index b15208a2531..26324d3f078 100644
--- a/libstdc++-v3/testsuite/20_util/function/cons/70692.cc
+++ b/libstdc++-v3/testsuite/20_util/function/cons/70692.cc
@@ -11,4 +11,4 @@ int main()
   std::function<const int&()> ff(f);  // { dg-error "no matching function" }
   std::function<long&&()> f2(f);      // { dg-error "no matching function" }
 }
-// { dg-error "std::(__8::)?enable_if" "" { target *-*-* } 0 }
+// { dg-error "std::(__9::)?enable_if" "" { target *-*-* } 0 }
diff --git a/libstdc++-v3/testsuite/23_containers/map/48101_neg.cc b/libstdc++-v3/testsuite/23_containers/map/48101_neg.cc
index cc7ad160162..53aceb633c1 100644
--- a/libstdc++-v3/testsuite/23_containers/map/48101_neg.cc
+++ b/libstdc++-v3/testsuite/23_containers/map/48101_neg.cc
@@ -29,8 +29,8 @@ test01()
   c2.find(2); // { dg-error "here" }
 }
 
-// { dg-error "_Compare = std::(__8::)?less<int.>" "" { target *-*-* } 0 }
-// { dg-error "_Compare = std::(__8::)?allocator<int>" "" { target *-*-* } 0 }
+// { dg-error "_Compare = std::(__9::)?less<int.>" "" { target *-*-* } 0 }
+// { dg-error "_Compare = std::(__9::)?allocator<int>" "" { target *-*-* } 0 }
 // { dg-error "comparison object must be invocable" "" { target *-*-* } 0 }
 // { dg-prune-output "no match for call" }
 // { dg-prune-output "invalid conversion" }
diff --git a/libstdc++-v3/testsuite/23_containers/multimap/48101_neg.cc b/libstdc++-v3/testsuite/23_containers/multimap/48101_neg.cc
index 8bb69ec3e9d..cbb9583a548 100644
--- a/libstdc++-v3/testsuite/23_containers/multimap/48101_neg.cc
+++ b/libstdc++-v3/testsuite/23_containers/multimap/48101_neg.cc
@@ -29,8 +29,8 @@ test01()
   c2.find(2); // { dg-error "here" }
 }
 
-// { dg-error "_Compare = std::(__8::)?less<int.>" "" { target *-*-* } 0 }
-// { dg-error "_Compare = std::(__8::)?allocator<int>" "" { target *-*-* } 0 }
+// { dg-error "_Compare = std::(__9::)?less<int.>" "" { target *-*-* } 0 }
+// { dg-error "_Compare = std::(__9::)?allocator<int>" "" { target *-*-* } 0 }
 // { dg-error "comparison object must be invocable" "" { target *-*-* } 0 }
 // { dg-prune-output "no match for call" }
 // { dg-prune-output "invalid conversion" }
diff --git a/libstdc++-v3/testsuite/lib/prune.exp b/libstdc++-v3/testsuite/lib/prune.exp
index 74842ae680c..70b86eb3473 100644
--- a/libstdc++-v3/testsuite/lib/prune.exp
+++ b/libstdc++-v3/testsuite/lib/prune.exp
@@ -37,7 +37,7 @@ proc libstdc++-dg-prune { system text } {
       return "::unsupported::hosted C++ headers not supported"
     }
 
-    regsub -all "std::__8::" $text "std::" text
+    regsub -all "std::__9::" $text "std::" text
 
     # Ignore caret diagnostics. Unfortunately dejaGNU trims leading
     # spaces, so one cannot rely on them being present.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Use cxx11 abi in versioned namespace
  2022-12-05 21:13   ` François Dumont
@ 2023-01-13 16:33     ` Jonathan Wakely
  2023-01-13 17:06       ` Jonathan Wakely
  2023-01-16 17:47       ` François Dumont
  0 siblings, 2 replies; 10+ messages in thread
From: Jonathan Wakely @ 2023-01-13 16:33 UTC (permalink / raw)
  To: François Dumont; +Cc: libstdc++, gcc-patches

On Mon, 5 Dec 2022 at 21:14, François Dumont via Libstdc++
<libstdc++@gcc.gnu.org> wrote:
>
> I just rebased this patch.
>
> All good apart from the to_chars/from_chars symbols issue.
>
> François
>
>
> On 11/10/22 19:28, François Dumont wrote:
> > Hi
> >
> >     Now that pretty printer is fixed (once patch validated) I'd like
> > to propose this patch again.
> >
> >     Note that I'am adding a check on pretty printer with a std::any on
> > a std::wstring. I did so because of the FIXME in printers.py which is
> > dealing with 'std::string' explicitely. Looks like in my case, where
> > there is no 'std::string' but just a 'std::__8::string' we do not need
> > the workaround.
> >
> >     Once again I am attaching also the version namespace bump patch as
> > I think that adopting the cxx11 abi in this mode is a good enough
> > reason to bump it. If you agress let me know if I should squash the
> > commits before pushing.

Yes, I think this change would justify bumping the version.

> >
> >     libstdc++: [_GLIBCXX_INLINE_VERSION] Use cxx11 abi
> >
> >     Use cxx11 abi when activating versioned namespace mode.
> >
> >     libstdcxx-v3/ChangeLog:
> >
> >             * acinclude.m4 [GLIBCXX_ENABLE_LIBSTDCXX_DUAL_ABI]:
> > Default to "new" libstdcxx abi.
> >             * config/locale/dragonfly/monetary_members.cc
> > [!_GLIBCXX_USE_DUAL_ABI]: Define money_base
> >             members.
> >             * config/locale/generic/monetary_members.cc
> > [!_GLIBCXX_USE_DUAL_ABI]: Likewise.
> >             * config/locale/gnu/monetary_members.cc
> > [!_GLIBCXX_USE_DUAL_ABI]: Likewise.
> >             * config/locale/gnu/numeric_members.cc
> >             [!_GLIBCXX_USE_DUAL_ABI](__narrow_multibyte_chars): Define.
> >             * configure: Regenerate.
> >             * include/bits/c++config
> >             [_GLIBCXX_INLINE_VERSION](_GLIBCXX_NAMESPACE_CXX11,
> > _GLIBCXX_BEGIN_NAMESPACE_CXX11): Define
> >             empty.
> > [_GLIBCXX_INLINE_VERSION](_GLIBCXX_END_NAMESPACE_CXX11,
> > _GLIBCXX_DEFAULT_ABI_TAG): Likewise.
> >             * python/libstdcxx/v6/printers.py
> >             (StdStringPrinter::__init__): Set self.new_string to True
> > when std::__8::basic_string type is
> >             found.
> >             * src/Makefile.am
> > [ENABLE_SYMVERS_GNU_NAMESPACE](ldbl_alt128_compat_sources): Define empty.
> >             * src/Makefile.in: Regenerate.
> >             * src/c++11/Makefile.am (cxx11_abi_sources): Rename into...
> >             (dual_abi_sources): ...this, new. Also move several
> > sources to...
> >             (sources): ...this.
> >             (extra_string_inst_sources): Move several sources to...
> >             (inst_sources): ...this.

I don't understand this part. Moving those files to sources and
inst_sources will mean they are always compiled, right? But we don't
want them compiled for --disable-libstdcxx-dual-abi

In those files you've changed the #if conditions so they are empty if
the dual ABI is disabled, but why do they need to be compiled at all?
This isn't clear from the patch or the description or the changelog.


> >             * src/c++11/Makefile.in: Regenerate.
> >             * src/c++11/cow-fstream-inst.cc [_GLIBCXX_USE_CXX11_ABI]:
> > Skip definitions.
> >             * src/c++11/cow-locale_init.cc [_GLIBCXX_USE_CXX11_ABI]:
> > Skip definitions.
> >             * src/c++11/cow-sstream-inst.cc [_GLIBCXX_USE_CXX11_ABI]:
> > Skip definitions.
> >             * src/c++11/cow-stdexcept.cc
> > [_GLIBCXX_USE_CXX11_ABI](error_category::_M_message):
> >             Skip definition.
> >             [_GLIBCXX_USE_CXX11_ABI]: Skip Transaction Memory TS
> > definitions.
> >             * src/c++11/cow-string-inst.cc [_GLIBCXX_USE_CXX11_ABI]:
> > Skip definitions.
> >             * src/c++11/cow-string-io-inst.cc
> > [_GLIBCXX_USE_CXX11_ABI]: Skip definitions.
> >             * src/c++11/cow-wstring-inst.cc [_GLIBCXX_USE_CXX11_ABI]:
> > Skip definitions.
> >             * src/c++11/cow-wstring-io-inst.cc
> > [_GLIBCXX_USE_CXX11_ABI]: Skip definitions.
> >             * src/c++11/cxx11-hash_tr1.cc [!_GLIBCXX_USE_CXX11_ABI]:
> > Skip definitions.
> >             * src/c++11/cxx11-ios_failure.cc
> > [!_GLIBCXX_USE_CXX11_ABI]: Skip definitions.
> >             [!_GLIBCXX_USE_DUAL_ABI] (__ios_failure): Remove.

For this file I think your changes make sense, because the definitions
of the gcc4-compatible and cxx11 ABI are different, we're not just
compiling it twice.


> >             * src/c++11/cxx11-locale-inst.cc: Cleanup, just include
> > locale-inst.cc.
> >             * src/c++11/cxx11-stdexcept.cc [!_GLIBCXX_USE_CXX11_ABI]:
> > Skip definitions.
> >             [!_GLIBCXX_USE_DUAL_ABI](__cow_string): Remove.
> >             * src/c++11/cxx11-wlocale-inst.cc
> > [!_GLIBCXX_USE_CXX11_ABI]: Skip definitions.
> >             * src/c++11/fstream-inst.cc [!_GLIBCXX_USE_CXX11_ABI]:
> > Skip definitions
> >             * src/c++11/locale-inst-numeric.h
> > [!_GLIBCXX_USE_DUAL_ABI](std::use_facet<num_get<>>,
> > std::use_facet<num_put<>>): Instantiate.
> > [!_GLIBCXX_USE_DUAL_ABI](std::has_facet<num_get<>>,
> > std::has_facet<num_put<>>): Instantiate.
> >             [!_GLIBCXX_USE_DUAL_ABI](std::num_get<C,
> > istreambuf_iterator<C>>): Instantiate.
> >             [!_GLIBCXX_USE_DUAL_ABI](std::num_put<C,
> > ostreambuf_iterator<C>>): Instantiate.
> >             * src/c++11/locale-inst.cc [!_GLIBCXX_USE_DUAL_ABI]: Build
> > only when configured
> >             _GLIBCXX_USE_CXX11_ABI is equal to currently built abi.
> >             [!_GLIBCXX_USE_DUAL_ABI](__moneypunct_cache<C, false>):
> > Instantiate.
> >             [!_GLIBCXX_USE_DUAL_ABI](__moneypunct_cache<C, true>):
> > Instantiate.
> >             [!_GLIBCXX_USE_DUAL_ABI](__numpunct_cache<C>): Instantiate.
> >             [!_GLIBCXX_USE_DUAL_ABI](__timepunct<C>): Instantiate.
> >             [!_GLIBCXX_USE_DUAL_ABI](__timepunct_cache<C>): Instantiate.
> >             [!_GLIBCXX_USE_DUAL_ABI](time_put<C,
> > ostreambuf_iterator<C>>): Instantiate.
> >             [!_GLIBCXX_USE_DUAL_ABI](time_put_byname<C,
> > ostreambuf_iterator<C>>): Instantiate.
> > [!_GLIBCXX_USE_DUAL_ABI](__ctype_abstract_base<C>): Instantiate.
> >             [!_GLIBCXX_USE_DUAL_ABI](ctype_byname<C>): Instantiate.
> >             [!_GLIBCXX_USE_DUAL_ABI](__codecvt_abstract_base<C, char,
> > mbstate_t>): Instantiate.
> >             [!_GLIBCXX_USE_DUAL_ABI](codecvt_byname<C, char,
> > mbstate_t>): Instantiate.
> > [!_GLIBCXX_USE_DUAL_ABI](use_facet<ctype<C>>(const locale&)):
> > Instantiate.
> >             [!_GLIBCXX_USE_DUAL_ABI](use_facet<codecvt<C, char,
> > mbstate_t>>(const locale&)): Instantiate.
> > [!_GLIBCXX_USE_DUAL_ABI](use_facet<__timepunct<C>>(const locale&)):
> > Instantiate.
> > [!_GLIBCXX_USE_DUAL_ABI](use_facet<time_put<C>>(const locale&)):
> > Instantiate.
> > [!_GLIBCXX_USE_DUAL_ABI](has_facet<ctype<C>>(const locale&)):
> > Instantiate.
> >             [!_GLIBCXX_USE_DUAL_ABI](has_facet<codecvt<C, char,
> > mbstate_t>>(const locale&)): Instantiate.
> > [!_GLIBCXX_USE_DUAL_ABI](has_facet<__timepunct<C>>(const locale&)):
> > Instantiate.
> > [!_GLIBCXX_USE_DUAL_ABI](has_facet<time_put<C>>(const locale&)):
> > Instantiate.
> >             [!_GLIBCXX_USE_DUAL_ABI](__add_grouping<C>): Define.
> >             [!_GLIBCXX_USE_DUAL_ABI](__pad<C, char_traits<C>>):
> > Instantiate.
> >             [!_GLIBCXX_USE_DUAL_ABI](__int_to_char(C*, unsigned long,
> > const C*, ios_base::fmtflags, bool)):
> >             Define.
> >             [!_GLIBCXX_USE_DUAL_ABI](__int_to_char(C*, unsigned long
> > long, const C*, ios_base::fmtflags, bool)):
> >             Define.
> >             * src/c++11/cxx11-wlocale-inst.cc
> > [!_GLIBCXX_USE_CXX11_ABI]: Skip definitions.
> >             * src/c++98/Makefile.am (cxx11_abi_sources): Remove,
> > unique cow-istream-string.cc entry move to...
> >             (inst_sources): ...this.

Why?

> >             * src/c++98/Makefile.in: Regenerate.
> >             * src/c++98/cow-istream-string.cc: Include
> > <bits/c++config.h>.
> >             [_GLIBCXX_USE_CXX11_ABI]: Skip definitions.

This file doesn't need to be compiled when the dual abi is disabled.

> >             * src/c++98/hash_tr1.cc [_GLIBCXX_USE_CXX11_ABI]: Skip
> > definitions.
> >             * src/c++98/ios_failure.cc
> > [_GLIBCXX_USE_CXX11_ABI][_GLIBCXX_USE_DUAL_ABI]: Skip definitions.
> >             * src/c++98/istream-string.cc [!_GLIBCXX_USE_DUAL_ABI]:
> > Build only when configured
> >             _GLIBCXX_USE_CXX11_ABI is equal to currently built abi.
> >             * src/c++98/locale_facets.cc
> > [_GLIBCXX_USE_CXX11_ABI](__verify_grouping): Remove.
> >             * src/c++98/stdexcept.cc
> >             [_GLIBCXX_USE_CXX11_ABI](logic_error(const string&): Remove.
> >             [_GLIBCXX_USE_CXX11_ABI](domain_error(const string&): Remove.
> >             [_GLIBCXX_USE_CXX11_ABI](invalid_argument(const string&):
> > Remove.
> >             [_GLIBCXX_USE_CXX11_ABI](length_error(const string&): Remove.
> >             [_GLIBCXX_USE_CXX11_ABI](out_of_range(const string&): Remove.
> >             [_GLIBCXX_USE_CXX11_ABI](runtime_error(const string&):
> > Remove.
> >             [_GLIBCXX_USE_CXX11_ABI](range_error(const string&): Remove.
> >             [_GLIBCXX_USE_CXX11_ABI](overflow_error(const string&):
> > Remove.
> >             [_GLIBCXX_USE_CXX11_ABI](underflow_error(const string&):
> > Remove.
> >             * testsuite/libstdc++-prettyprinters/cxx17.cc: Add
> > std::any check with std::wstring.
> >
> > François
> >
> > On 30/05/22 22:58, François Dumont wrote:
> >> Hi
> >>
> >> Here is the patch to use cxx11 abi for the versioned namespace mode.
> >>
> >> It is still suffering from a side effect on gdb pretty printers with
> >> 3 errors like:
> >>
> >> got: type =
> >> std::unique_ptr<std::vector<std::unique_ptr<std::list<std::__8::basic_string<char,
> >> std::__8::char_traits<char>, std::__8::allocator<char> >>[]>>[99]>
> >> FAIL: libstdc++-prettyprinters/80276.cc whatis p4
> >>
> >> However once I apply the version bump errors are gone.
> >>
> >> Let me know if it is ok to apply all at once or if you prefer to
> >> avoid the version bump.
> >>
> >> François
> >


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Use cxx11 abi in versioned namespace
  2023-01-13 16:33     ` Jonathan Wakely
@ 2023-01-13 17:06       ` Jonathan Wakely
  2023-01-13 17:15         ` Jonathan Wakely
  2023-01-16 17:52         ` François Dumont
  2023-01-16 17:47       ` François Dumont
  1 sibling, 2 replies; 10+ messages in thread
From: Jonathan Wakely @ 2023-01-13 17:06 UTC (permalink / raw)
  To: François Dumont; +Cc: libstdc++, gcc-patches

On Fri, 13 Jan 2023 at 16:33, Jonathan Wakely <jwakely@redhat.com> wrote:
>
> On Mon, 5 Dec 2022 at 21:14, François Dumont via Libstdc++
> <libstdc++@gcc.gnu.org> wrote:
> >
> > I just rebased this patch.
> >
> > All good apart from the to_chars/from_chars symbols issue.
> >
> > François
> >
> >
> > On 11/10/22 19:28, François Dumont wrote:
> > > Hi
> > >
> > >     Now that pretty printer is fixed (once patch validated) I'd like
> > > to propose this patch again.
> > >
> > >     Note that I'am adding a check on pretty printer with a std::any on
> > > a std::wstring. I did so because of the FIXME in printers.py which is
> > > dealing with 'std::string' explicitely. Looks like in my case, where
> > > there is no 'std::string' but just a 'std::__8::string' we do not need
> > > the workaround.
> > >
> > >     Once again I am attaching also the version namespace bump patch as
> > > I think that adopting the cxx11 abi in this mode is a good enough
> > > reason to bump it. If you agress let me know if I should squash the
> > > commits before pushing.
>
> Yes, I think this change would justify bumping the version.
>
> > >
> > >     libstdc++: [_GLIBCXX_INLINE_VERSION] Use cxx11 abi
> > >
> > >     Use cxx11 abi when activating versioned namespace mode.
> > >
> > >     libstdcxx-v3/ChangeLog:
> > >
> > >             * acinclude.m4 [GLIBCXX_ENABLE_LIBSTDCXX_DUAL_ABI]:
> > > Default to "new" libstdcxx abi.
> > >             * config/locale/dragonfly/monetary_members.cc
> > > [!_GLIBCXX_USE_DUAL_ABI]: Define money_base
> > >             members.
> > >             * config/locale/generic/monetary_members.cc
> > > [!_GLIBCXX_USE_DUAL_ABI]: Likewise.
> > >             * config/locale/gnu/monetary_members.cc
> > > [!_GLIBCXX_USE_DUAL_ABI]: Likewise.
> > >             * config/locale/gnu/numeric_members.cc
> > >             [!_GLIBCXX_USE_DUAL_ABI](__narrow_multibyte_chars): Define.
> > >             * configure: Regenerate.
> > >             * include/bits/c++config
> > >             [_GLIBCXX_INLINE_VERSION](_GLIBCXX_NAMESPACE_CXX11,
> > > _GLIBCXX_BEGIN_NAMESPACE_CXX11): Define
> > >             empty.
> > > [_GLIBCXX_INLINE_VERSION](_GLIBCXX_END_NAMESPACE_CXX11,
> > > _GLIBCXX_DEFAULT_ABI_TAG): Likewise.
> > >             * python/libstdcxx/v6/printers.py
> > >             (StdStringPrinter::__init__): Set self.new_string to True
> > > when std::__8::basic_string type is
> > >             found.
> > >             * src/Makefile.am
> > > [ENABLE_SYMVERS_GNU_NAMESPACE](ldbl_alt128_compat_sources): Define empty.
> > >             * src/Makefile.in: Regenerate.
> > >             * src/c++11/Makefile.am (cxx11_abi_sources): Rename into...
> > >             (dual_abi_sources): ...this, new. Also move several
> > > sources to...
> > >             (sources): ...this.
> > >             (extra_string_inst_sources): Move several sources to...
> > >             (inst_sources): ...this.
>
> I don't understand this part. Moving those files to sources and
> inst_sources will mean they are always compiled, right? But we don't
> want them compiled for --disable-libstdcxx-dual-abi
>
> In those files you've changed the #if conditions so they are empty if
> the dual ABI is disabled, but why do they need to be compiled at all?
> This isn't clear from the patch or the description or the changelog.
>
>
> > >             * src/c++11/Makefile.in: Regenerate.
> > >             * src/c++11/cow-fstream-inst.cc [_GLIBCXX_USE_CXX11_ABI]:
> > > Skip definitions.
> > >             * src/c++11/cow-locale_init.cc [_GLIBCXX_USE_CXX11_ABI]:
> > > Skip definitions.
> > >             * src/c++11/cow-sstream-inst.cc [_GLIBCXX_USE_CXX11_ABI]:
> > > Skip definitions.
> > >             * src/c++11/cow-stdexcept.cc
> > > [_GLIBCXX_USE_CXX11_ABI](error_category::_M_message):
> > >             Skip definition.
> > >             [_GLIBCXX_USE_CXX11_ABI]: Skip Transaction Memory TS
> > > definitions.
> > >             * src/c++11/cow-string-inst.cc [_GLIBCXX_USE_CXX11_ABI]:
> > > Skip definitions.
> > >             * src/c++11/cow-string-io-inst.cc
> > > [_GLIBCXX_USE_CXX11_ABI]: Skip definitions.
> > >             * src/c++11/cow-wstring-inst.cc [_GLIBCXX_USE_CXX11_ABI]:
> > > Skip definitions.
> > >             * src/c++11/cow-wstring-io-inst.cc
> > > [_GLIBCXX_USE_CXX11_ABI]: Skip definitions.
> > >             * src/c++11/cxx11-hash_tr1.cc [!_GLIBCXX_USE_CXX11_ABI]:
> > > Skip definitions.
> > >             * src/c++11/cxx11-ios_failure.cc
> > > [!_GLIBCXX_USE_CXX11_ABI]: Skip definitions.
> > >             [!_GLIBCXX_USE_DUAL_ABI] (__ios_failure): Remove.
>
> For this file I think your changes make sense, because the definitions
> of the gcc4-compatible and cxx11 ABI are different, we're not just
> compiling it twice.
>
>
> > >             * src/c++11/cxx11-locale-inst.cc: Cleanup, just include
> > > locale-inst.cc.
> > >             * src/c++11/cxx11-stdexcept.cc [!_GLIBCXX_USE_CXX11_ABI]:
> > > Skip definitions.
> > >             [!_GLIBCXX_USE_DUAL_ABI](__cow_string): Remove.
> > >             * src/c++11/cxx11-wlocale-inst.cc
> > > [!_GLIBCXX_USE_CXX11_ABI]: Skip definitions.
> > >             * src/c++11/fstream-inst.cc [!_GLIBCXX_USE_CXX11_ABI]:
> > > Skip definitions
> > >             * src/c++11/locale-inst-numeric.h
> > > [!_GLIBCXX_USE_DUAL_ABI](std::use_facet<num_get<>>,
> > > std::use_facet<num_put<>>): Instantiate.
> > > [!_GLIBCXX_USE_DUAL_ABI](std::has_facet<num_get<>>,
> > > std::has_facet<num_put<>>): Instantiate.
> > >             [!_GLIBCXX_USE_DUAL_ABI](std::num_get<C,
> > > istreambuf_iterator<C>>): Instantiate.
> > >             [!_GLIBCXX_USE_DUAL_ABI](std::num_put<C,
> > > ostreambuf_iterator<C>>): Instantiate.
> > >             * src/c++11/locale-inst.cc [!_GLIBCXX_USE_DUAL_ABI]: Build
> > > only when configured
> > >             _GLIBCXX_USE_CXX11_ABI is equal to currently built abi.
> > >             [!_GLIBCXX_USE_DUAL_ABI](__moneypunct_cache<C, false>):
> > > Instantiate.
> > >             [!_GLIBCXX_USE_DUAL_ABI](__moneypunct_cache<C, true>):
> > > Instantiate.
> > >             [!_GLIBCXX_USE_DUAL_ABI](__numpunct_cache<C>): Instantiate.
> > >             [!_GLIBCXX_USE_DUAL_ABI](__timepunct<C>): Instantiate.
> > >             [!_GLIBCXX_USE_DUAL_ABI](__timepunct_cache<C>): Instantiate.
> > >             [!_GLIBCXX_USE_DUAL_ABI](time_put<C,
> > > ostreambuf_iterator<C>>): Instantiate.
> > >             [!_GLIBCXX_USE_DUAL_ABI](time_put_byname<C,
> > > ostreambuf_iterator<C>>): Instantiate.
> > > [!_GLIBCXX_USE_DUAL_ABI](__ctype_abstract_base<C>): Instantiate.
> > >             [!_GLIBCXX_USE_DUAL_ABI](ctype_byname<C>): Instantiate.
> > >             [!_GLIBCXX_USE_DUAL_ABI](__codecvt_abstract_base<C, char,
> > > mbstate_t>): Instantiate.
> > >             [!_GLIBCXX_USE_DUAL_ABI](codecvt_byname<C, char,
> > > mbstate_t>): Instantiate.
> > > [!_GLIBCXX_USE_DUAL_ABI](use_facet<ctype<C>>(const locale&)):
> > > Instantiate.
> > >             [!_GLIBCXX_USE_DUAL_ABI](use_facet<codecvt<C, char,
> > > mbstate_t>>(const locale&)): Instantiate.
> > > [!_GLIBCXX_USE_DUAL_ABI](use_facet<__timepunct<C>>(const locale&)):
> > > Instantiate.
> > > [!_GLIBCXX_USE_DUAL_ABI](use_facet<time_put<C>>(const locale&)):
> > > Instantiate.
> > > [!_GLIBCXX_USE_DUAL_ABI](has_facet<ctype<C>>(const locale&)):
> > > Instantiate.
> > >             [!_GLIBCXX_USE_DUAL_ABI](has_facet<codecvt<C, char,
> > > mbstate_t>>(const locale&)): Instantiate.
> > > [!_GLIBCXX_USE_DUAL_ABI](has_facet<__timepunct<C>>(const locale&)):
> > > Instantiate.
> > > [!_GLIBCXX_USE_DUAL_ABI](has_facet<time_put<C>>(const locale&)):
> > > Instantiate.
> > >             [!_GLIBCXX_USE_DUAL_ABI](__add_grouping<C>): Define.
> > >             [!_GLIBCXX_USE_DUAL_ABI](__pad<C, char_traits<C>>):
> > > Instantiate.
> > >             [!_GLIBCXX_USE_DUAL_ABI](__int_to_char(C*, unsigned long,
> > > const C*, ios_base::fmtflags, bool)):
> > >             Define.
> > >             [!_GLIBCXX_USE_DUAL_ABI](__int_to_char(C*, unsigned long
> > > long, const C*, ios_base::fmtflags, bool)):
> > >             Define.
> > >             * src/c++11/cxx11-wlocale-inst.cc
> > > [!_GLIBCXX_USE_CXX11_ABI]: Skip definitions.
> > >             * src/c++98/Makefile.am (cxx11_abi_sources): Remove,
> > > unique cow-istream-string.cc entry move to...
> > >             (inst_sources): ...this.
>
> Why?

I know all this ENABLE_DUAL_ABI stuff is a horrible mess, and I should
really try to clean it up, and it's impressive you made this work at
all. But I think the solution you've found makes the mess even worse,
unfortunately.

Another problem is here:

--- a/libstdc++-v3/src/c++98/stdexcept.cc
+++ b/libstdc++-v3/src/c++98/stdexcept.cc
@@ -26,7 +26,7 @@
 // ISO C++ 14882: 19.1  Exception classes
 //

-// All exception classes still use the classic COW std::string.
+// In dual abi all exception classes still use the classic COW std::string.
 #define _GLIBCXX_USE_CXX11_ABI 0

Exceptions must have a non-throwing copy constructor, which is why
they still need to use a reference-counted string. If we disable the
dual ABI and only build the cxx11 string, we need to figure out a way
to compile enough of the COW string to keep exceptions working.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Use cxx11 abi in versioned namespace
  2023-01-13 17:06       ` Jonathan Wakely
@ 2023-01-13 17:15         ` Jonathan Wakely
  2023-01-16 17:53           ` François Dumont
  2023-01-16 17:52         ` François Dumont
  1 sibling, 1 reply; 10+ messages in thread
From: Jonathan Wakely @ 2023-01-13 17:15 UTC (permalink / raw)
  To: François Dumont; +Cc: libstdc++, gcc-patches

@@ -396,7 +376,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_VERSION_NAMESPACE

This should be INLINE not VERSION, right?


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Use cxx11 abi in versioned namespace
  2023-01-13 16:33     ` Jonathan Wakely
  2023-01-13 17:06       ` Jonathan Wakely
@ 2023-01-16 17:47       ` François Dumont
  2023-01-16 17:54         ` Jonathan Wakely
  1 sibling, 1 reply; 10+ messages in thread
From: François Dumont @ 2023-01-16 17:47 UTC (permalink / raw)
  To: Jonathan Wakely; +Cc: libstdc++, gcc-patches

On 13/01/23 17:33, Jonathan Wakely wrote:
> On Mon, 5 Dec 2022 at 21:14, François Dumont via Libstdc++
> <libstdc++@gcc.gnu.org>  wrote:
>> I just rebased this patch.
>>
>> All good apart from the to_chars/from_chars symbols issue.
>>
>> François
>>
>>
>> On 11/10/22 19:28, François Dumont wrote:
>>> Hi
>>>
>>>      Now that pretty printer is fixed (once patch validated) I'd like
>>> to propose this patch again.
>>>
>>>      Note that I'am adding a check on pretty printer with a std::any on
>>> a std::wstring. I did so because of the FIXME in printers.py which is
>>> dealing with 'std::string' explicitely. Looks like in my case, where
>>> there is no 'std::string' but just a 'std::__8::string' we do not need
>>> the workaround.
>>>
>>>      Once again I am attaching also the version namespace bump patch as
>>> I think that adopting the cxx11 abi in this mode is a good enough
>>> reason to bump it. If you agress let me know if I should squash the
>>> commits before pushing.
> Yes, I think this change would justify bumping the version.
>
>>>      libstdc++: [_GLIBCXX_INLINE_VERSION] Use cxx11 abi
>>>
>>>      Use cxx11 abi when activating versioned namespace mode.
>>>
>>>      libstdcxx-v3/ChangeLog:
>>>
>>>              * acinclude.m4 [GLIBCXX_ENABLE_LIBSTDCXX_DUAL_ABI]:
>>> Default to "new" libstdcxx abi.
>>>              * config/locale/dragonfly/monetary_members.cc
>>> [!_GLIBCXX_USE_DUAL_ABI]: Define money_base
>>>              members.
>>>              * config/locale/generic/monetary_members.cc
>>> [!_GLIBCXX_USE_DUAL_ABI]: Likewise.
>>>              * config/locale/gnu/monetary_members.cc
>>> [!_GLIBCXX_USE_DUAL_ABI]: Likewise.
>>>              * config/locale/gnu/numeric_members.cc
>>>              [!_GLIBCXX_USE_DUAL_ABI](__narrow_multibyte_chars): Define.
>>>              * configure: Regenerate.
>>>              * include/bits/c++config
>>>              [_GLIBCXX_INLINE_VERSION](_GLIBCXX_NAMESPACE_CXX11,
>>> _GLIBCXX_BEGIN_NAMESPACE_CXX11): Define
>>>              empty.
>>> [_GLIBCXX_INLINE_VERSION](_GLIBCXX_END_NAMESPACE_CXX11,
>>> _GLIBCXX_DEFAULT_ABI_TAG): Likewise.
>>>              * python/libstdcxx/v6/printers.py
>>>              (StdStringPrinter::__init__): Set self.new_string to True
>>> when std::__8::basic_string type is
>>>              found.
>>>              * src/Makefile.am
>>> [ENABLE_SYMVERS_GNU_NAMESPACE](ldbl_alt128_compat_sources): Define empty.
>>>              * src/Makefile.in: Regenerate.
>>>              * src/c++11/Makefile.am (cxx11_abi_sources): Rename into...
>>>              (dual_abi_sources): ...this, new. Also move several
>>> sources to...
>>>              (sources): ...this.
>>>              (extra_string_inst_sources): Move several sources to...
>>>              (inst_sources): ...this.
> I don't understand this part. Moving those files to sources and
> inst_sources will mean they are always compiled, right? But we don't
> want them compiled for --disable-libstdcxx-dual-abi
>
> In those files you've changed the #if conditions so they are empty if
> the dual ABI is disabled, but why do they need to be compiled at all?
> This isn't clear from the patch or the description or the changelog.

--disable-libstdcxx-dual-abi means use cow string implementation. With 
this patch I am introducing somehow another disable-dual-abi mode but 
this time to use cxx11 string implementation.

At Makefile.am level it was difficult to match both cases so I'm doing 
it at compilation time with most of time the condition:

#if ! _GLIBCXX_USE_CXX11_ABI || ! _GLIBCXX_USE_DUAL_ABI

I'll make it clearer at ChangeLog level.

>>>              * src/c++11/Makefile.in: Regenerate.
>>>              * src/c++11/cow-fstream-inst.cc [_GLIBCXX_USE_CXX11_ABI]:
>>> Skip definitions.
>>>              * src/c++11/cow-locale_init.cc [_GLIBCXX_USE_CXX11_ABI]:
>>> Skip definitions.
>>>              * src/c++11/cow-sstream-inst.cc [_GLIBCXX_USE_CXX11_ABI]:
>>> Skip definitions.
>>>              * src/c++11/cow-stdexcept.cc
>>> [_GLIBCXX_USE_CXX11_ABI](error_category::_M_message):
>>>              Skip definition.
>>>              [_GLIBCXX_USE_CXX11_ABI]: Skip Transaction Memory TS
>>> definitions.
>>>              * src/c++11/cow-string-inst.cc [_GLIBCXX_USE_CXX11_ABI]:
>>> Skip definitions.
>>>              * src/c++11/cow-string-io-inst.cc
>>> [_GLIBCXX_USE_CXX11_ABI]: Skip definitions.
>>>              * src/c++11/cow-wstring-inst.cc [_GLIBCXX_USE_CXX11_ABI]:
>>> Skip definitions.
>>>              * src/c++11/cow-wstring-io-inst.cc
>>> [_GLIBCXX_USE_CXX11_ABI]: Skip definitions.
>>>              * src/c++11/cxx11-hash_tr1.cc [!_GLIBCXX_USE_CXX11_ABI]:
>>> Skip definitions.
>>>              * src/c++11/cxx11-ios_failure.cc
>>> [!_GLIBCXX_USE_CXX11_ABI]: Skip definitions.
>>>              [!_GLIBCXX_USE_DUAL_ABI] (__ios_failure): Remove.
> For this file I think your changes make sense, because the definitions
> of the gcc4-compatible and cxx11 ABI are different, we're not just
> compiling it twice.
>
>
>>>              * src/c++11/cxx11-locale-inst.cc: Cleanup, just include
>>> locale-inst.cc.
>>>              * src/c++11/cxx11-stdexcept.cc [!_GLIBCXX_USE_CXX11_ABI]:
>>> Skip definitions.
>>>              [!_GLIBCXX_USE_DUAL_ABI](__cow_string): Remove.
>>>              * src/c++11/cxx11-wlocale-inst.cc
>>> [!_GLIBCXX_USE_CXX11_ABI]: Skip definitions.
>>>              * src/c++11/fstream-inst.cc [!_GLIBCXX_USE_CXX11_ABI]:
>>> Skip definitions
>>>              * src/c++11/locale-inst-numeric.h
>>> [!_GLIBCXX_USE_DUAL_ABI](std::use_facet<num_get<>>,
>>> std::use_facet<num_put<>>): Instantiate.
>>> [!_GLIBCXX_USE_DUAL_ABI](std::has_facet<num_get<>>,
>>> std::has_facet<num_put<>>): Instantiate.
>>>              [!_GLIBCXX_USE_DUAL_ABI](std::num_get<C,
>>> istreambuf_iterator<C>>): Instantiate.
>>>              [!_GLIBCXX_USE_DUAL_ABI](std::num_put<C,
>>> ostreambuf_iterator<C>>): Instantiate.
>>>              * src/c++11/locale-inst.cc [!_GLIBCXX_USE_DUAL_ABI]: Build
>>> only when configured
>>>              _GLIBCXX_USE_CXX11_ABI is equal to currently built abi.
>>>              [!_GLIBCXX_USE_DUAL_ABI](__moneypunct_cache<C, false>):
>>> Instantiate.
>>>              [!_GLIBCXX_USE_DUAL_ABI](__moneypunct_cache<C, true>):
>>> Instantiate.
>>>              [!_GLIBCXX_USE_DUAL_ABI](__numpunct_cache<C>): Instantiate.
>>>              [!_GLIBCXX_USE_DUAL_ABI](__timepunct<C>): Instantiate.
>>>              [!_GLIBCXX_USE_DUAL_ABI](__timepunct_cache<C>): Instantiate.
>>>              [!_GLIBCXX_USE_DUAL_ABI](time_put<C,
>>> ostreambuf_iterator<C>>): Instantiate.
>>>              [!_GLIBCXX_USE_DUAL_ABI](time_put_byname<C,
>>> ostreambuf_iterator<C>>): Instantiate.
>>> [!_GLIBCXX_USE_DUAL_ABI](__ctype_abstract_base<C>): Instantiate.
>>>              [!_GLIBCXX_USE_DUAL_ABI](ctype_byname<C>): Instantiate.
>>>              [!_GLIBCXX_USE_DUAL_ABI](__codecvt_abstract_base<C, char,
>>> mbstate_t>): Instantiate.
>>>              [!_GLIBCXX_USE_DUAL_ABI](codecvt_byname<C, char,
>>> mbstate_t>): Instantiate.
>>> [!_GLIBCXX_USE_DUAL_ABI](use_facet<ctype<C>>(const locale&)):
>>> Instantiate.
>>>              [!_GLIBCXX_USE_DUAL_ABI](use_facet<codecvt<C, char,
>>> mbstate_t>>(const locale&)): Instantiate.
>>> [!_GLIBCXX_USE_DUAL_ABI](use_facet<__timepunct<C>>(const locale&)):
>>> Instantiate.
>>> [!_GLIBCXX_USE_DUAL_ABI](use_facet<time_put<C>>(const locale&)):
>>> Instantiate.
>>> [!_GLIBCXX_USE_DUAL_ABI](has_facet<ctype<C>>(const locale&)):
>>> Instantiate.
>>>              [!_GLIBCXX_USE_DUAL_ABI](has_facet<codecvt<C, char,
>>> mbstate_t>>(const locale&)): Instantiate.
>>> [!_GLIBCXX_USE_DUAL_ABI](has_facet<__timepunct<C>>(const locale&)):
>>> Instantiate.
>>> [!_GLIBCXX_USE_DUAL_ABI](has_facet<time_put<C>>(const locale&)):
>>> Instantiate.
>>>              [!_GLIBCXX_USE_DUAL_ABI](__add_grouping<C>): Define.
>>>              [!_GLIBCXX_USE_DUAL_ABI](__pad<C, char_traits<C>>):
>>> Instantiate.
>>>              [!_GLIBCXX_USE_DUAL_ABI](__int_to_char(C*, unsigned long,
>>> const C*, ios_base::fmtflags, bool)):
>>>              Define.
>>>              [!_GLIBCXX_USE_DUAL_ABI](__int_to_char(C*, unsigned long
>>> long, const C*, ios_base::fmtflags, bool)):
>>>              Define.
>>>              * src/c++11/cxx11-wlocale-inst.cc
>>> [!_GLIBCXX_USE_CXX11_ABI]: Skip definitions.
>>>              * src/c++98/Makefile.am (cxx11_abi_sources): Remove,
>>> unique cow-istream-string.cc entry move to...
>>>              (inst_sources): ...this.
> Why?
>
>>>              * src/c++98/Makefile.in: Regenerate.
>>>              * src/c++98/cow-istream-string.cc: Include
>>> <bits/c++config.h>.
>>>              [_GLIBCXX_USE_CXX11_ABI]: Skip definitions.
> This file doesn't need to be compiled when the dual abi is disabled.

It depends if it is disabled because of --disable-libstdcxx-dual-abi or 
because of --enable-symvers=gnu-versioned-namespace.


>>>              * src/c++98/hash_tr1.cc [_GLIBCXX_USE_CXX11_ABI]: Skip
>>> definitions.
>>>              * src/c++98/ios_failure.cc
>>> [_GLIBCXX_USE_CXX11_ABI][_GLIBCXX_USE_DUAL_ABI]: Skip definitions.
>>>              * src/c++98/istream-string.cc [!_GLIBCXX_USE_DUAL_ABI]:
>>> Build only when configured
>>>              _GLIBCXX_USE_CXX11_ABI is equal to currently built abi.
>>>              * src/c++98/locale_facets.cc
>>> [_GLIBCXX_USE_CXX11_ABI](__verify_grouping): Remove.
>>>              * src/c++98/stdexcept.cc
>>>              [_GLIBCXX_USE_CXX11_ABI](logic_error(const string&): Remove.
>>>              [_GLIBCXX_USE_CXX11_ABI](domain_error(const string&): Remove.
>>>              [_GLIBCXX_USE_CXX11_ABI](invalid_argument(const string&):
>>> Remove.
>>>              [_GLIBCXX_USE_CXX11_ABI](length_error(const string&): Remove.
>>>              [_GLIBCXX_USE_CXX11_ABI](out_of_range(const string&): Remove.
>>>              [_GLIBCXX_USE_CXX11_ABI](runtime_error(const string&):
>>> Remove.
>>>              [_GLIBCXX_USE_CXX11_ABI](range_error(const string&): Remove.
>>>              [_GLIBCXX_USE_CXX11_ABI](overflow_error(const string&):
>>> Remove.
>>>              [_GLIBCXX_USE_CXX11_ABI](underflow_error(const string&):
>>> Remove.
>>>              * testsuite/libstdc++-prettyprinters/cxx17.cc: Add
>>> std::any check with std::wstring.
>>>
>>> François
>>>
>>> On 30/05/22 22:58, François Dumont wrote:
>>>> Hi
>>>>
>>>> Here is the patch to use cxx11 abi for the versioned namespace mode.
>>>>
>>>> It is still suffering from a side effect on gdb pretty printers with
>>>> 3 errors like:
>>>>
>>>> got: type =
>>>> std::unique_ptr<std::vector<std::unique_ptr<std::list<std::__8::basic_string<char,
>>>> std::__8::char_traits<char>, std::__8::allocator<char> >>[]>>[99]>
>>>> FAIL: libstdc++-prettyprinters/80276.cc whatis p4
>>>>
>>>> However once I apply the version bump errors are gone.
>>>>
>>>> Let me know if it is ok to apply all at once or if you prefer to
>>>> avoid the version bump.
>>>>
>>>> François



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Use cxx11 abi in versioned namespace
  2023-01-13 17:06       ` Jonathan Wakely
  2023-01-13 17:15         ` Jonathan Wakely
@ 2023-01-16 17:52         ` François Dumont
  1 sibling, 0 replies; 10+ messages in thread
From: François Dumont @ 2023-01-16 17:52 UTC (permalink / raw)
  To: Jonathan Wakely; +Cc: libstdc++, gcc-patches

On 13/01/23 18:06, Jonathan Wakely wrote:
> On Fri, 13 Jan 2023 at 16:33, Jonathan Wakely <jwakely@redhat.com> wrote:
>> On Mon, 5 Dec 2022 at 21:14, François Dumont via Libstdc++
>> <libstdc++@gcc.gnu.org> wrote:
>>> I just rebased this patch.
>>>
>>> All good apart from the to_chars/from_chars symbols issue.
>>>
>>> François
>>>
>>>
>>> On 11/10/22 19:28, François Dumont wrote:
>>>> Hi
>>>>
>>>>      Now that pretty printer is fixed (once patch validated) I'd like
>>>> to propose this patch again.
>>>>
>>>>      Note that I'am adding a check on pretty printer with a std::any on
>>>> a std::wstring. I did so because of the FIXME in printers.py which is
>>>> dealing with 'std::string' explicitely. Looks like in my case, where
>>>> there is no 'std::string' but just a 'std::__8::string' we do not need
>>>> the workaround.
>>>>
>>>>      Once again I am attaching also the version namespace bump patch as
>>>> I think that adopting the cxx11 abi in this mode is a good enough
>>>> reason to bump it. If you agress let me know if I should squash the
>>>> commits before pushing.
>> Yes, I think this change would justify bumping the version.
>>
>>>>      libstdc++: [_GLIBCXX_INLINE_VERSION] Use cxx11 abi
>>>>
>>>>      Use cxx11 abi when activating versioned namespace mode.
>>>>
>>>>      libstdcxx-v3/ChangeLog:
>>>>
>>>>              * acinclude.m4 [GLIBCXX_ENABLE_LIBSTDCXX_DUAL_ABI]:
>>>> Default to "new" libstdcxx abi.
>>>>              * config/locale/dragonfly/monetary_members.cc
>>>> [!_GLIBCXX_USE_DUAL_ABI]: Define money_base
>>>>              members.
>>>>              * config/locale/generic/monetary_members.cc
>>>> [!_GLIBCXX_USE_DUAL_ABI]: Likewise.
>>>>              * config/locale/gnu/monetary_members.cc
>>>> [!_GLIBCXX_USE_DUAL_ABI]: Likewise.
>>>>              * config/locale/gnu/numeric_members.cc
>>>>              [!_GLIBCXX_USE_DUAL_ABI](__narrow_multibyte_chars): Define.
>>>>              * configure: Regenerate.
>>>>              * include/bits/c++config
>>>>              [_GLIBCXX_INLINE_VERSION](_GLIBCXX_NAMESPACE_CXX11,
>>>> _GLIBCXX_BEGIN_NAMESPACE_CXX11): Define
>>>>              empty.
>>>> [_GLIBCXX_INLINE_VERSION](_GLIBCXX_END_NAMESPACE_CXX11,
>>>> _GLIBCXX_DEFAULT_ABI_TAG): Likewise.
>>>>              * python/libstdcxx/v6/printers.py
>>>>              (StdStringPrinter::__init__): Set self.new_string to True
>>>> when std::__8::basic_string type is
>>>>              found.
>>>>              * src/Makefile.am
>>>> [ENABLE_SYMVERS_GNU_NAMESPACE](ldbl_alt128_compat_sources): Define empty.
>>>>              * src/Makefile.in: Regenerate.
>>>>              * src/c++11/Makefile.am (cxx11_abi_sources): Rename into...
>>>>              (dual_abi_sources): ...this, new. Also move several
>>>> sources to...
>>>>              (sources): ...this.
>>>>              (extra_string_inst_sources): Move several sources to...
>>>>              (inst_sources): ...this.
>> I don't understand this part. Moving those files to sources and
>> inst_sources will mean they are always compiled, right? But we don't
>> want them compiled for --disable-libstdcxx-dual-abi
>>
>> In those files you've changed the #if conditions so they are empty if
>> the dual ABI is disabled, but why do they need to be compiled at all?
>> This isn't clear from the patch or the description or the changelog.
>>
>>
>>>>              * src/c++11/Makefile.in: Regenerate.
>>>>              * src/c++11/cow-fstream-inst.cc [_GLIBCXX_USE_CXX11_ABI]:
>>>> Skip definitions.
>>>>              * src/c++11/cow-locale_init.cc [_GLIBCXX_USE_CXX11_ABI]:
>>>> Skip definitions.
>>>>              * src/c++11/cow-sstream-inst.cc [_GLIBCXX_USE_CXX11_ABI]:
>>>> Skip definitions.
>>>>              * src/c++11/cow-stdexcept.cc
>>>> [_GLIBCXX_USE_CXX11_ABI](error_category::_M_message):
>>>>              Skip definition.
>>>>              [_GLIBCXX_USE_CXX11_ABI]: Skip Transaction Memory TS
>>>> definitions.
>>>>              * src/c++11/cow-string-inst.cc [_GLIBCXX_USE_CXX11_ABI]:
>>>> Skip definitions.
>>>>              * src/c++11/cow-string-io-inst.cc
>>>> [_GLIBCXX_USE_CXX11_ABI]: Skip definitions.
>>>>              * src/c++11/cow-wstring-inst.cc [_GLIBCXX_USE_CXX11_ABI]:
>>>> Skip definitions.
>>>>              * src/c++11/cow-wstring-io-inst.cc
>>>> [_GLIBCXX_USE_CXX11_ABI]: Skip definitions.
>>>>              * src/c++11/cxx11-hash_tr1.cc [!_GLIBCXX_USE_CXX11_ABI]:
>>>> Skip definitions.
>>>>              * src/c++11/cxx11-ios_failure.cc
>>>> [!_GLIBCXX_USE_CXX11_ABI]: Skip definitions.
>>>>              [!_GLIBCXX_USE_DUAL_ABI] (__ios_failure): Remove.
>> For this file I think your changes make sense, because the definitions
>> of the gcc4-compatible and cxx11 ABI are different, we're not just
>> compiling it twice.
>>
>>
>>>>              * src/c++11/cxx11-locale-inst.cc: Cleanup, just include
>>>> locale-inst.cc.
>>>>              * src/c++11/cxx11-stdexcept.cc [!_GLIBCXX_USE_CXX11_ABI]:
>>>> Skip definitions.
>>>>              [!_GLIBCXX_USE_DUAL_ABI](__cow_string): Remove.
>>>>              * src/c++11/cxx11-wlocale-inst.cc
>>>> [!_GLIBCXX_USE_CXX11_ABI]: Skip definitions.
>>>>              * src/c++11/fstream-inst.cc [!_GLIBCXX_USE_CXX11_ABI]:
>>>> Skip definitions
>>>>              * src/c++11/locale-inst-numeric.h
>>>> [!_GLIBCXX_USE_DUAL_ABI](std::use_facet<num_get<>>,
>>>> std::use_facet<num_put<>>): Instantiate.
>>>> [!_GLIBCXX_USE_DUAL_ABI](std::has_facet<num_get<>>,
>>>> std::has_facet<num_put<>>): Instantiate.
>>>>              [!_GLIBCXX_USE_DUAL_ABI](std::num_get<C,
>>>> istreambuf_iterator<C>>): Instantiate.
>>>>              [!_GLIBCXX_USE_DUAL_ABI](std::num_put<C,
>>>> ostreambuf_iterator<C>>): Instantiate.
>>>>              * src/c++11/locale-inst.cc [!_GLIBCXX_USE_DUAL_ABI]: Build
>>>> only when configured
>>>>              _GLIBCXX_USE_CXX11_ABI is equal to currently built abi.
>>>>              [!_GLIBCXX_USE_DUAL_ABI](__moneypunct_cache<C, false>):
>>>> Instantiate.
>>>>              [!_GLIBCXX_USE_DUAL_ABI](__moneypunct_cache<C, true>):
>>>> Instantiate.
>>>>              [!_GLIBCXX_USE_DUAL_ABI](__numpunct_cache<C>): Instantiate.
>>>>              [!_GLIBCXX_USE_DUAL_ABI](__timepunct<C>): Instantiate.
>>>>              [!_GLIBCXX_USE_DUAL_ABI](__timepunct_cache<C>): Instantiate.
>>>>              [!_GLIBCXX_USE_DUAL_ABI](time_put<C,
>>>> ostreambuf_iterator<C>>): Instantiate.
>>>>              [!_GLIBCXX_USE_DUAL_ABI](time_put_byname<C,
>>>> ostreambuf_iterator<C>>): Instantiate.
>>>> [!_GLIBCXX_USE_DUAL_ABI](__ctype_abstract_base<C>): Instantiate.
>>>>              [!_GLIBCXX_USE_DUAL_ABI](ctype_byname<C>): Instantiate.
>>>>              [!_GLIBCXX_USE_DUAL_ABI](__codecvt_abstract_base<C, char,
>>>> mbstate_t>): Instantiate.
>>>>              [!_GLIBCXX_USE_DUAL_ABI](codecvt_byname<C, char,
>>>> mbstate_t>): Instantiate.
>>>> [!_GLIBCXX_USE_DUAL_ABI](use_facet<ctype<C>>(const locale&)):
>>>> Instantiate.
>>>>              [!_GLIBCXX_USE_DUAL_ABI](use_facet<codecvt<C, char,
>>>> mbstate_t>>(const locale&)): Instantiate.
>>>> [!_GLIBCXX_USE_DUAL_ABI](use_facet<__timepunct<C>>(const locale&)):
>>>> Instantiate.
>>>> [!_GLIBCXX_USE_DUAL_ABI](use_facet<time_put<C>>(const locale&)):
>>>> Instantiate.
>>>> [!_GLIBCXX_USE_DUAL_ABI](has_facet<ctype<C>>(const locale&)):
>>>> Instantiate.
>>>>              [!_GLIBCXX_USE_DUAL_ABI](has_facet<codecvt<C, char,
>>>> mbstate_t>>(const locale&)): Instantiate.
>>>> [!_GLIBCXX_USE_DUAL_ABI](has_facet<__timepunct<C>>(const locale&)):
>>>> Instantiate.
>>>> [!_GLIBCXX_USE_DUAL_ABI](has_facet<time_put<C>>(const locale&)):
>>>> Instantiate.
>>>>              [!_GLIBCXX_USE_DUAL_ABI](__add_grouping<C>): Define.
>>>>              [!_GLIBCXX_USE_DUAL_ABI](__pad<C, char_traits<C>>):
>>>> Instantiate.
>>>>              [!_GLIBCXX_USE_DUAL_ABI](__int_to_char(C*, unsigned long,
>>>> const C*, ios_base::fmtflags, bool)):
>>>>              Define.
>>>>              [!_GLIBCXX_USE_DUAL_ABI](__int_to_char(C*, unsigned long
>>>> long, const C*, ios_base::fmtflags, bool)):
>>>>              Define.
>>>>              * src/c++11/cxx11-wlocale-inst.cc
>>>> [!_GLIBCXX_USE_CXX11_ABI]: Skip definitions.
>>>>              * src/c++98/Makefile.am (cxx11_abi_sources): Remove,
>>>> unique cow-istream-string.cc entry move to...
>>>>              (inst_sources): ...this.
>> Why?
> I know all this ENABLE_DUAL_ABI stuff is a horrible mess, and I should
> really try to clean it up, and it's impressive you made this work at
> all. But I think the solution you've found makes the mess even worse,
> unfortunately.
>
> Another problem is here:
>
> --- a/libstdc++-v3/src/c++98/stdexcept.cc
> +++ b/libstdc++-v3/src/c++98/stdexcept.cc
> @@ -26,7 +26,7 @@
>   // ISO C++ 14882: 19.1  Exception classes
>   //
>
> -// All exception classes still use the classic COW std::string.
> +// In dual abi all exception classes still use the classic COW std::string.
>   #define _GLIBCXX_USE_CXX11_ABI 0
>
> Exceptions must have a non-throwing copy constructor, which is why
> they still need to use a reference-counted string. If we disable the
> dual ABI and only build the cxx11 string, we need to figure out a way
> to compile enough of the COW string to keep exceptions working.
>
Ouch, I did not know.

Maybe there should be a static_assert about this constraint, you would 
have saved a patch review.

This is going to give me a big headache to find a solution to this problem !


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Use cxx11 abi in versioned namespace
  2023-01-13 17:15         ` Jonathan Wakely
@ 2023-01-16 17:53           ` François Dumont
  0 siblings, 0 replies; 10+ messages in thread
From: François Dumont @ 2023-01-16 17:53 UTC (permalink / raw)
  To: Jonathan Wakely; +Cc: libstdc++, gcc-patches

On 13/01/23 18:15, Jonathan Wakely wrote:
> @@ -396,7 +376,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_VERSION_NAMESPACE
>
> This should be INLINE not VERSION, right?
>
Indeed, I haven't tested the _GLIBCXX_DEBUG mode.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Use cxx11 abi in versioned namespace
  2023-01-16 17:47       ` François Dumont
@ 2023-01-16 17:54         ` Jonathan Wakely
  0 siblings, 0 replies; 10+ messages in thread
From: Jonathan Wakely @ 2023-01-16 17:54 UTC (permalink / raw)
  To: François Dumont; +Cc: libstdc++, gcc-patches

On Mon, 16 Jan 2023 at 17:47, François Dumont <frs.dumont@gmail.com> wrote:
>
> On 13/01/23 17:33, Jonathan Wakely wrote:
> > On Mon, 5 Dec 2022 at 21:14, François Dumont via Libstdc++
> > <libstdc++@gcc.gnu.org>  wrote:
> >> I just rebased this patch.
> >>
> >> All good apart from the to_chars/from_chars symbols issue.
> >>
> >> François
> >>
> >>
> >> On 11/10/22 19:28, François Dumont wrote:
> >>> Hi
> >>>
> >>>      Now that pretty printer is fixed (once patch validated) I'd like
> >>> to propose this patch again.
> >>>
> >>>      Note that I'am adding a check on pretty printer with a std::any on
> >>> a std::wstring. I did so because of the FIXME in printers.py which is
> >>> dealing with 'std::string' explicitely. Looks like in my case, where
> >>> there is no 'std::string' but just a 'std::__8::string' we do not need
> >>> the workaround.
> >>>
> >>>      Once again I am attaching also the version namespace bump patch as
> >>> I think that adopting the cxx11 abi in this mode is a good enough
> >>> reason to bump it. If you agress let me know if I should squash the
> >>> commits before pushing.
> > Yes, I think this change would justify bumping the version.
> >
> >>>      libstdc++: [_GLIBCXX_INLINE_VERSION] Use cxx11 abi
> >>>
> >>>      Use cxx11 abi when activating versioned namespace mode.
> >>>
> >>>      libstdcxx-v3/ChangeLog:
> >>>
> >>>              * acinclude.m4 [GLIBCXX_ENABLE_LIBSTDCXX_DUAL_ABI]:
> >>> Default to "new" libstdcxx abi.
> >>>              * config/locale/dragonfly/monetary_members.cc
> >>> [!_GLIBCXX_USE_DUAL_ABI]: Define money_base
> >>>              members.
> >>>              * config/locale/generic/monetary_members.cc
> >>> [!_GLIBCXX_USE_DUAL_ABI]: Likewise.
> >>>              * config/locale/gnu/monetary_members.cc
> >>> [!_GLIBCXX_USE_DUAL_ABI]: Likewise.
> >>>              * config/locale/gnu/numeric_members.cc
> >>>              [!_GLIBCXX_USE_DUAL_ABI](__narrow_multibyte_chars): Define.
> >>>              * configure: Regenerate.
> >>>              * include/bits/c++config
> >>>              [_GLIBCXX_INLINE_VERSION](_GLIBCXX_NAMESPACE_CXX11,
> >>> _GLIBCXX_BEGIN_NAMESPACE_CXX11): Define
> >>>              empty.
> >>> [_GLIBCXX_INLINE_VERSION](_GLIBCXX_END_NAMESPACE_CXX11,
> >>> _GLIBCXX_DEFAULT_ABI_TAG): Likewise.
> >>>              * python/libstdcxx/v6/printers.py
> >>>              (StdStringPrinter::__init__): Set self.new_string to True
> >>> when std::__8::basic_string type is
> >>>              found.
> >>>              * src/Makefile.am
> >>> [ENABLE_SYMVERS_GNU_NAMESPACE](ldbl_alt128_compat_sources): Define empty.
> >>>              * src/Makefile.in: Regenerate.
> >>>              * src/c++11/Makefile.am (cxx11_abi_sources): Rename into...
> >>>              (dual_abi_sources): ...this, new. Also move several
> >>> sources to...
> >>>              (sources): ...this.
> >>>              (extra_string_inst_sources): Move several sources to...
> >>>              (inst_sources): ...this.
> > I don't understand this part. Moving those files to sources and
> > inst_sources will mean they are always compiled, right? But we don't
> > want them compiled for --disable-libstdcxx-dual-abi
> >
> > In those files you've changed the #if conditions so they are empty if
> > the dual ABI is disabled, but why do they need to be compiled at all?
> > This isn't clear from the patch or the description or the changelog.
>
> --disable-libstdcxx-dual-abi means use cow string implementation. With
> this patch I am introducing somehow another disable-dual-abi mode but
> this time to use cxx11 string implementation.

Oh right, I misremembered. I thought you could choose the ABI when
disabling dual-abi.



>
> At Makefile.am level it was difficult to match both cases so I'm doing
> it at compilation time with most of time the condition:
>
> #if ! _GLIBCXX_USE_CXX11_ABI || ! _GLIBCXX_USE_DUAL_ABI
>
> I'll make it clearer at ChangeLog level.
>
> >>>              * src/c++11/Makefile.in: Regenerate.
> >>>              * src/c++11/cow-fstream-inst.cc [_GLIBCXX_USE_CXX11_ABI]:
> >>> Skip definitions.
> >>>              * src/c++11/cow-locale_init.cc [_GLIBCXX_USE_CXX11_ABI]:
> >>> Skip definitions.
> >>>              * src/c++11/cow-sstream-inst.cc [_GLIBCXX_USE_CXX11_ABI]:
> >>> Skip definitions.
> >>>              * src/c++11/cow-stdexcept.cc
> >>> [_GLIBCXX_USE_CXX11_ABI](error_category::_M_message):
> >>>              Skip definition.
> >>>              [_GLIBCXX_USE_CXX11_ABI]: Skip Transaction Memory TS
> >>> definitions.
> >>>              * src/c++11/cow-string-inst.cc [_GLIBCXX_USE_CXX11_ABI]:
> >>> Skip definitions.
> >>>              * src/c++11/cow-string-io-inst.cc
> >>> [_GLIBCXX_USE_CXX11_ABI]: Skip definitions.
> >>>              * src/c++11/cow-wstring-inst.cc [_GLIBCXX_USE_CXX11_ABI]:
> >>> Skip definitions.
> >>>              * src/c++11/cow-wstring-io-inst.cc
> >>> [_GLIBCXX_USE_CXX11_ABI]: Skip definitions.
> >>>              * src/c++11/cxx11-hash_tr1.cc [!_GLIBCXX_USE_CXX11_ABI]:
> >>> Skip definitions.
> >>>              * src/c++11/cxx11-ios_failure.cc
> >>> [!_GLIBCXX_USE_CXX11_ABI]: Skip definitions.
> >>>              [!_GLIBCXX_USE_DUAL_ABI] (__ios_failure): Remove.
> > For this file I think your changes make sense, because the definitions
> > of the gcc4-compatible and cxx11 ABI are different, we're not just
> > compiling it twice.
> >
> >
> >>>              * src/c++11/cxx11-locale-inst.cc: Cleanup, just include
> >>> locale-inst.cc.
> >>>              * src/c++11/cxx11-stdexcept.cc [!_GLIBCXX_USE_CXX11_ABI]:
> >>> Skip definitions.
> >>>              [!_GLIBCXX_USE_DUAL_ABI](__cow_string): Remove.
> >>>              * src/c++11/cxx11-wlocale-inst.cc
> >>> [!_GLIBCXX_USE_CXX11_ABI]: Skip definitions.
> >>>              * src/c++11/fstream-inst.cc [!_GLIBCXX_USE_CXX11_ABI]:
> >>> Skip definitions
> >>>              * src/c++11/locale-inst-numeric.h
> >>> [!_GLIBCXX_USE_DUAL_ABI](std::use_facet<num_get<>>,
> >>> std::use_facet<num_put<>>): Instantiate.
> >>> [!_GLIBCXX_USE_DUAL_ABI](std::has_facet<num_get<>>,
> >>> std::has_facet<num_put<>>): Instantiate.
> >>>              [!_GLIBCXX_USE_DUAL_ABI](std::num_get<C,
> >>> istreambuf_iterator<C>>): Instantiate.
> >>>              [!_GLIBCXX_USE_DUAL_ABI](std::num_put<C,
> >>> ostreambuf_iterator<C>>): Instantiate.
> >>>              * src/c++11/locale-inst.cc [!_GLIBCXX_USE_DUAL_ABI]: Build
> >>> only when configured
> >>>              _GLIBCXX_USE_CXX11_ABI is equal to currently built abi.
> >>>              [!_GLIBCXX_USE_DUAL_ABI](__moneypunct_cache<C, false>):
> >>> Instantiate.
> >>>              [!_GLIBCXX_USE_DUAL_ABI](__moneypunct_cache<C, true>):
> >>> Instantiate.
> >>>              [!_GLIBCXX_USE_DUAL_ABI](__numpunct_cache<C>): Instantiate.
> >>>              [!_GLIBCXX_USE_DUAL_ABI](__timepunct<C>): Instantiate.
> >>>              [!_GLIBCXX_USE_DUAL_ABI](__timepunct_cache<C>): Instantiate.
> >>>              [!_GLIBCXX_USE_DUAL_ABI](time_put<C,
> >>> ostreambuf_iterator<C>>): Instantiate.
> >>>              [!_GLIBCXX_USE_DUAL_ABI](time_put_byname<C,
> >>> ostreambuf_iterator<C>>): Instantiate.
> >>> [!_GLIBCXX_USE_DUAL_ABI](__ctype_abstract_base<C>): Instantiate.
> >>>              [!_GLIBCXX_USE_DUAL_ABI](ctype_byname<C>): Instantiate.
> >>>              [!_GLIBCXX_USE_DUAL_ABI](__codecvt_abstract_base<C, char,
> >>> mbstate_t>): Instantiate.
> >>>              [!_GLIBCXX_USE_DUAL_ABI](codecvt_byname<C, char,
> >>> mbstate_t>): Instantiate.
> >>> [!_GLIBCXX_USE_DUAL_ABI](use_facet<ctype<C>>(const locale&)):
> >>> Instantiate.
> >>>              [!_GLIBCXX_USE_DUAL_ABI](use_facet<codecvt<C, char,
> >>> mbstate_t>>(const locale&)): Instantiate.
> >>> [!_GLIBCXX_USE_DUAL_ABI](use_facet<__timepunct<C>>(const locale&)):
> >>> Instantiate.
> >>> [!_GLIBCXX_USE_DUAL_ABI](use_facet<time_put<C>>(const locale&)):
> >>> Instantiate.
> >>> [!_GLIBCXX_USE_DUAL_ABI](has_facet<ctype<C>>(const locale&)):
> >>> Instantiate.
> >>>              [!_GLIBCXX_USE_DUAL_ABI](has_facet<codecvt<C, char,
> >>> mbstate_t>>(const locale&)): Instantiate.
> >>> [!_GLIBCXX_USE_DUAL_ABI](has_facet<__timepunct<C>>(const locale&)):
> >>> Instantiate.
> >>> [!_GLIBCXX_USE_DUAL_ABI](has_facet<time_put<C>>(const locale&)):
> >>> Instantiate.
> >>>              [!_GLIBCXX_USE_DUAL_ABI](__add_grouping<C>): Define.
> >>>              [!_GLIBCXX_USE_DUAL_ABI](__pad<C, char_traits<C>>):
> >>> Instantiate.
> >>>              [!_GLIBCXX_USE_DUAL_ABI](__int_to_char(C*, unsigned long,
> >>> const C*, ios_base::fmtflags, bool)):
> >>>              Define.
> >>>              [!_GLIBCXX_USE_DUAL_ABI](__int_to_char(C*, unsigned long
> >>> long, const C*, ios_base::fmtflags, bool)):
> >>>              Define.
> >>>              * src/c++11/cxx11-wlocale-inst.cc
> >>> [!_GLIBCXX_USE_CXX11_ABI]: Skip definitions.
> >>>              * src/c++98/Makefile.am (cxx11_abi_sources): Remove,
> >>> unique cow-istream-string.cc entry move to...
> >>>              (inst_sources): ...this.
> > Why?
> >
> >>>              * src/c++98/Makefile.in: Regenerate.
> >>>              * src/c++98/cow-istream-string.cc: Include
> >>> <bits/c++config.h>.
> >>>              [_GLIBCXX_USE_CXX11_ABI]: Skip definitions.
> > This file doesn't need to be compiled when the dual abi is disabled.
>
> It depends if it is disabled because of --disable-libstdcxx-dual-abi or
> because of --enable-symvers=gnu-versioned-namespace.
>
>
> >>>              * src/c++98/hash_tr1.cc [_GLIBCXX_USE_CXX11_ABI]: Skip
> >>> definitions.
> >>>              * src/c++98/ios_failure.cc
> >>> [_GLIBCXX_USE_CXX11_ABI][_GLIBCXX_USE_DUAL_ABI]: Skip definitions.
> >>>              * src/c++98/istream-string.cc [!_GLIBCXX_USE_DUAL_ABI]:
> >>> Build only when configured
> >>>              _GLIBCXX_USE_CXX11_ABI is equal to currently built abi.
> >>>              * src/c++98/locale_facets.cc
> >>> [_GLIBCXX_USE_CXX11_ABI](__verify_grouping): Remove.
> >>>              * src/c++98/stdexcept.cc
> >>>              [_GLIBCXX_USE_CXX11_ABI](logic_error(const string&): Remove.
> >>>              [_GLIBCXX_USE_CXX11_ABI](domain_error(const string&): Remove.
> >>>              [_GLIBCXX_USE_CXX11_ABI](invalid_argument(const string&):
> >>> Remove.
> >>>              [_GLIBCXX_USE_CXX11_ABI](length_error(const string&): Remove.
> >>>              [_GLIBCXX_USE_CXX11_ABI](out_of_range(const string&): Remove.
> >>>              [_GLIBCXX_USE_CXX11_ABI](runtime_error(const string&):
> >>> Remove.
> >>>              [_GLIBCXX_USE_CXX11_ABI](range_error(const string&): Remove.
> >>>              [_GLIBCXX_USE_CXX11_ABI](overflow_error(const string&):
> >>> Remove.
> >>>              [_GLIBCXX_USE_CXX11_ABI](underflow_error(const string&):
> >>> Remove.
> >>>              * testsuite/libstdc++-prettyprinters/cxx17.cc: Add
> >>> std::any check with std::wstring.
> >>>
> >>> François
> >>>
> >>> On 30/05/22 22:58, François Dumont wrote:
> >>>> Hi
> >>>>
> >>>> Here is the patch to use cxx11 abi for the versioned namespace mode.
> >>>>
> >>>> It is still suffering from a side effect on gdb pretty printers with
> >>>> 3 errors like:
> >>>>
> >>>> got: type =
> >>>> std::unique_ptr<std::vector<std::unique_ptr<std::list<std::__8::basic_string<char,
> >>>> std::__8::char_traits<char>, std::__8::allocator<char> >>[]>>[99]>
> >>>> FAIL: libstdc++-prettyprinters/80276.cc whatis p4
> >>>>
> >>>> However once I apply the version bump errors are gone.
> >>>>
> >>>> Let me know if it is ok to apply all at once or if you prefer to
> >>>> avoid the version bump.
> >>>>
> >>>> François
>
>


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2023-01-16 17:54 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-30 20:58 [PATCH] Use cxx11 abi in versioned namespace François Dumont
2022-10-11 17:28 ` François Dumont
2022-12-05 21:13   ` François Dumont
2023-01-13 16:33     ` Jonathan Wakely
2023-01-13 17:06       ` Jonathan Wakely
2023-01-13 17:15         ` Jonathan Wakely
2023-01-16 17:53           ` François Dumont
2023-01-16 17:52         ` François Dumont
2023-01-16 17:47       ` François Dumont
2023-01-16 17:54         ` 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).