As described in PR 117630 the cow-stdexcept.cc file pulls in symbols
from system_error.cc, which are not actually needed there. Moving the
definition of error_category::_M_message to a separate file should solve
it.

libstdc++-v3/ChangeLog:

        PR libstdc++/117630
        * src/c++11/Makefile.am: Add new file.
        * src/c++11/Makefile.in: Regnerate.
        * src/c++11/cow-stdexcept.cc (error_category::_M_message): Move
        member function definition to ...
        * src/c++11/cow-system_error.cc: New file.
---

I plan to push this when testing finishes.

 libstdc++-v3/src/c++11/Makefile.am         |  1 +
 libstdc++-v3/src/c++11/Makefile.in         | 13 +++---
 libstdc++-v3/src/c++11/cow-stdexcept.cc    |  9 ----
 libstdc++-v3/src/c++11/cow-system_error.cc | 48 ++++++++++++++++++++++
 4 files changed, 56 insertions(+), 15 deletions(-)
 create mode 100644 libstdc++-v3/src/c++11/cow-system_error.cc

diff --git a/libstdc++-v3/src/c++11/Makefile.am 
b/libstdc++-v3/src/c++11/Makefile.am
index 89e20ca3b06..a501607c474 100644
--- a/libstdc++-v3/src/c++11/Makefile.am
+++ b/libstdc++-v3/src/c++11/Makefile.am
@@ -69,6 +69,7 @@ sources = \
        codecvt.cc \
        condition_variable.cc \
        cow-stdexcept.cc \
+       cow-system_error.cc \
        ctype.cc \
        debug.cc \
        functexcept.cc \
diff --git a/libstdc++-v3/src/c++11/Makefile.in 
b/libstdc++-v3/src/c++11/Makefile.in
index 4be021e8025..770e948a98a 100644
--- a/libstdc++-v3/src/c++11/Makefile.in
+++ b/libstdc++-v3/src/c++11/Makefile.in
@@ -129,12 +129,12 @@ am__objects_1 = limits.lo placeholders.lo
 am__objects_3 = ctype_configure_char.lo ctype_members.lo
 am__objects_4 = basic_file.lo
 am__objects_5 = assert_fail.lo 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 \
-       hashtable_c++0x.lo ios.lo ios_errcat.lo locale_init.lo \
-       localename.lo mutex.lo random.lo regex.lo shared_ptr.lo \
-       snprintf_lite.lo system_error.lo thread.lo $(am__objects_2) \
-       $(am__objects_3) $(am__objects_4)
+       condition_variable.lo cow-stdexcept.lo cow-system_error.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 locale_init.lo localename.lo mutex.lo random.lo \
+       regex.lo shared_ptr.lo snprintf_lite.lo system_error.lo \
+       thread.lo $(am__objects_2) $(am__objects_3) $(am__objects_4)
 @ENABLE_DUAL_ABI_TRUE@am__objects_6 = 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 \
@@ -488,6 +488,7 @@ sources = \
        codecvt.cc \
        condition_variable.cc \
        cow-stdexcept.cc \
+       cow-system_error.cc \
        ctype.cc \
        debug.cc \
        functexcept.cc \
diff --git a/libstdc++-v3/src/c++11/cow-stdexcept.cc 
b/libstdc++-v3/src/c++11/cow-stdexcept.cc
index 6af88f23fca..ada16eb8e9e 100644
--- a/libstdc++-v3/src/c++11/cow-stdexcept.cc
+++ b/libstdc++-v3/src/c++11/cow-stdexcept.cc
@@ -46,7 +46,6 @@ _txnal_runtime_error_get_msg(void* e);
 #define _GLIBCXX_DEFINE_STDEXCEPT_COPY_OPS 1
 #define __cow_string __cow_stringxxx
 #include <stdexcept>
-#include <system_error>
 #undef __cow_string
 
 namespace std _GLIBCXX_VISIBILITY(default)
@@ -169,14 +168,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
                 "alignof(std::string) has changed");
 #endif
 
-  // Return error_category::message() as an SSO string
-  __sso_string
-  error_category::_M_message(int i) const
-  {
-    string msg = this->message(i);
-    return {msg.c_str(), msg.length()};
-  }
-
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
 
diff --git a/libstdc++-v3/src/c++11/cow-system_error.cc 
b/libstdc++-v3/src/c++11/cow-system_error.cc
new file mode 100644
index 00000000000..56824c190e7
--- /dev/null
+++ b/libstdc++-v3/src/c++11/cow-system_error.cc
@@ -0,0 +1,48 @@
+// Dual ABI Support for <system_error> -*- C++ -*-
+
+// Copyright (C) 2014-2024 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// Under Section 7 of GPL version 3, you are granted additional
+// permissions described in the GCC Runtime Library Exception, version
+// 3.1, as published by the Free Software Foundation.
+
+// You should have received a copy of the GNU General Public License and
+// a copy of the GCC Runtime Library Exception along with this program;
+// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+// <http://www.gnu.org/licenses/>.
+
+//
+// ISO C++ 14882: 19.1  Exception classes
+//
+
+// All exception classes still use the classic COW std::string.
+#define _GLIBCXX_USE_CXX11_ABI 0
+#define __cow_string __cow_stringxxx
+#include <system_error>
+#undef __cow_string
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+  // Return error_category::message() as an SSO string
+  __sso_string
+  error_category::_M_message(int i) const
+  {
+    string msg = this->message(i);
+    return {msg.c_str(), msg.length()};
+  }
+
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace
-- 
2.47.0

Reply via email to