From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2181) id 83268385829B; Mon, 18 Mar 2024 14:08:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 83268385829B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1710770915; bh=yVg5lTgNHNF86AZy/yWpH959lbmSpZdwnJKaGMTCLF4=; h=From:To:Subject:Date:From; b=EAntAFIzwdQseEvEWp9Jzcd3yS3FcFsqC2SmbxQGAjOuZdgfcjfj7Ltkn/XiD9qoT o6la1Z39SoDPW/HW5B/nV9gMEYN5BQ5c49mzv4YjmPYzy8pMSzHv1WiskOYz1GDiMO AA9+wCrTlbV6pp9gl4mSX+XofWFtiasXZ6QgWopk= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jonathan Wakely To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r12-10280] libstdc++: Move __glibcxx_assert_fail to its own file X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/heads/releases/gcc-12 X-Git-Oldrev: 2d604183c99ef0cea5d7540a7a466fb1d1453a58 X-Git-Newrev: 413b91e1faacf5fd5d5ffe099898f46750c7f601 Message-Id: <20240318140835.83268385829B@sourceware.org> Date: Mon, 18 Mar 2024 14:08:35 +0000 (GMT) List-Id: https://gcc.gnu.org/g:413b91e1faacf5fd5d5ffe099898f46750c7f601 commit r12-10280-g413b91e1faacf5fd5d5ffe099898f46750c7f601 Author: Jonathan Wakely Date: Mon Sep 11 15:58:48 2023 +0100 libstdc++: Move __glibcxx_assert_fail to its own file 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. (cherry picked from commit c7db9000fa7caceadb4e72dcc6226abebf7a6239) Diff: --- libstdc++-v3/src/c++11/Makefile.am | 1 + libstdc++-v3/src/c++11/Makefile.in | 7 +++--- libstdc++-v3/src/c++11/assert_fail.cc | 44 +++++++++++++++++++++++++++++++++++ libstdc++-v3/src/c++11/debug.cc | 18 -------------- 4 files changed, 49 insertions(+), 21 deletions(-) diff --git a/libstdc++-v3/src/c++11/Makefile.am b/libstdc++-v3/src/c++11/Makefile.am index 222e2a8c618..2198db1617d 100644 --- a/libstdc++-v3/src/c++11/Makefile.am +++ b/libstdc++-v3/src/c++11/Makefile.am @@ -52,6 +52,7 @@ cxx11_abi_sources = endif sources = \ + assert_fail.cc \ chrono.cc \ codecvt.cc \ condition_variable.cc \ diff --git a/libstdc++-v3/src/c++11/Makefile.in b/libstdc++-v3/src/c++11/Makefile.in index 892c505eddc..8005fa6253c 100644 --- a/libstdc++-v3/src/c++11/Makefile.in +++ b/libstdc++-v3/src/c++11/Makefile.in @@ -127,9 +127,9 @@ libc__11convenience_la_LIBADD = @ENABLE_DUAL_ABI_TRUE@ cxx11-ios_failure.lo \ @ENABLE_DUAL_ABI_TRUE@ cxx11-shim_facets.lo cxx11-stdexcept.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 \ +am__objects_3 = 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 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) @@ -466,6 +466,7 @@ host_sources = \ @ENABLE_DUAL_ABI_TRUE@ cxx11-stdexcept.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 index 00000000000..540e953da2e --- /dev/null +++ b/libstdc++-v3/src/c++11/assert_fail.cc @@ -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 +// . + +#include // for std::fprintf, stderr +#include // 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 diff --git a/libstdc++-v3/src/c++11/debug.cc b/libstdc++-v3/src/c++11/debug.cc index 1bfc6ccc581..88dca83ce1a 100644 --- a/libstdc++-v3/src/c++11/debug.cc +++ b/libstdc++-v3/src/c++11/debug.cc @@ -45,24 +45,6 @@ #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