]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Move __glibcxx_assert_fail to its own file
authorJonathan Wakely <jwakely@redhat.com>
Mon, 11 Sep 2023 14:58:48 +0000 (15:58 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Mon, 11 Sep 2023 16:07:24 +0000 (17:07 +0100)
This avoids a dependency on the other symbols in src/c++11/debug.o when
linking statically to libstdc++.a without using -Wl,--gc-sections.

libstdc++-v3/ChangeLog:

* src/c++11/Makefile.am: Add new file.
* src/c++11/Makefile.in: Regenerate.
* src/c++11/debug.cc (__glibcxx_assert_fail): Move to ...
* src/c++11/assert_fail.cc: New file.

libstdc++-v3/src/c++11/Makefile.am
libstdc++-v3/src/c++11/Makefile.in
libstdc++-v3/src/c++11/assert_fail.cc [new file with mode: 0644]
libstdc++-v3/src/c++11/debug.cc

index 682be1669a41e1ae06cb74d119612f5b39f95470..e7495dcccef7eb632f0967287e1ba6c9c88ac786 100644 (file)
@@ -56,6 +56,7 @@ sources_freestanding = \
        placeholders.cc
 
 sources = \
+       assert_fail.cc \
        chrono.cc \
        codecvt.cc \
        condition_variable.cc \
index e7a09fe324697309faf9df8f109eb3882455515f..a10e05977bcb29c71c8a82c93ab025c5e1d15c16 100644 (file)
@@ -127,9 +127,9 @@ am__objects_1 = limits.lo placeholders.lo
 @ENABLE_DUAL_ABI_TRUE@ cxx11-ios_failure.lo \
 @ENABLE_DUAL_ABI_TRUE@ cxx11-shim_facets.lo cxx11-stdexcept.lo
 am__objects_3 = ctype_configure_char.lo ctype_members.lo
-am__objects_4 = 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 \
+am__objects_4 = 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 mutex.lo random.lo \
        regex.lo shared_ptr.lo snprintf_lite.lo system_error.lo \
        thread.lo $(am__objects_2) $(am__objects_3)
@@ -475,6 +475,7 @@ sources_freestanding = \
        placeholders.cc
 
 sources = \
+       assert_fail.cc \
        chrono.cc \
        codecvt.cc \
        condition_variable.cc \
diff --git a/libstdc++-v3/src/c++11/assert_fail.cc b/libstdc++-v3/src/c++11/assert_fail.cc
new file mode 100644 (file)
index 0000000..540e953
--- /dev/null
@@ -0,0 +1,44 @@
+// Debugging mode support code -*- C++ -*-
+
+// Copyright (C) 2021-2023 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/>.
+
+#include <cstdio>      // for std::fprintf, stderr
+#include <cstdlib>     // for std::abort
+
+#ifdef _GLIBCXX_VERBOSE_ASSERT
+namespace std
+{
+  [[__noreturn__]]
+  void
+  __glibcxx_assert_fail(const char* file, int line,
+                       const char* function, const char* condition) noexcept
+  {
+    if (file && function && condition)
+      fprintf(stderr, "%s:%d: %s: Assertion '%s' failed.\n",
+             file, line, function, condition);
+    else if (function)
+      fprintf(stderr, "%s: Undefined behavior detected.\n", function);
+    abort();
+  }
+}
+#endif
index 926e8be6122a3d5f3ce7b669bc4474a2c2f626fe..f40e995e0f306bda28ac9398effca42e4913b476 100644 (file)
 
 #include "mutex_pool.h"
 
-#ifdef _GLIBCXX_VERBOSE_ASSERT
-namespace std
-{
-  [[__noreturn__]]
-  void
-  __glibcxx_assert_fail(const char* file, int line,
-                       const char* function, const char* condition) noexcept
-  {
-    if (file && function && condition)
-      fprintf(stderr, "%s:%d: %s: Assertion '%s' failed.\n",
-             file, line, function, condition);
-    else if (function)
-      fprintf(stderr, "%s: Undefined behavior detected.\n", function);
-    abort();
-  }
-}
-#endif
-
 using namespace std;
 
 namespace