From patchwork Mon Sep 11 16:07:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 1832351 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=sxbJawzj; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Rks8S6kpCz1yhZ for ; Tue, 12 Sep 2023 02:08:40 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CAF423858002 for ; Mon, 11 Sep 2023 16:08:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CAF423858002 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1694448517; bh=dZXGOKgFVscVhNTxiBekRNVXvCWBVfvv2RmquoKVtgU=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=sxbJawzjUiqqjRUmlZ7GqOvmJoHfctTLujgFHUlq7qOPcWz8xcB3K3DFH5hqMwJnU T5MtvRvsmu9aVAQyszPJTP7pMS0ZG34LsCTd2ca2vYUvboB25XEoArmbSJlaAh8ofE NhLW4P1wRp5l07KIB+Iv+Iy5sBrV8z7mVuLCPdx8= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 360663858D3C for ; Mon, 11 Sep 2023 16:08:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 360663858D3C Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-9-eaJCPAVaOWK55OwRWwnpAQ-1; Mon, 11 Sep 2023 12:08:12 -0400 X-MC-Unique: eaJCPAVaOWK55OwRWwnpAQ-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 08D183810D3A; Mon, 11 Sep 2023 16:08:12 +0000 (UTC) Received: from localhost (unknown [10.42.28.190]) by smtp.corp.redhat.com (Postfix) with ESMTP id B9E7D1006B5C; Mon, 11 Sep 2023 16:08:11 +0000 (UTC) To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Move __glibcxx_assert_fail to its own file Date: Mon, 11 Sep 2023 17:07:36 +0100 Message-ID: <20230911160811.1912603-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jonathan Wakely via Gcc-patches From: Jonathan Wakely Reply-To: Jonathan Wakely Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Tested aarch64-linux. Pushed to trunk. Maybe worth backporting too. -- >8 -- 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 | 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(-) create mode 100644 libstdc++-v3/src/c++11/assert_fail.cc diff --git a/libstdc++-v3/src/c++11/Makefile.am b/libstdc++-v3/src/c++11/Makefile.am index 682be1669a4..e7495dcccef 100644 --- a/libstdc++-v3/src/c++11/Makefile.am +++ b/libstdc++-v3/src/c++11/Makefile.am @@ -56,6 +56,7 @@ sources_freestanding = \ placeholders.cc 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 e7a09fe3246..a10e05977bc 100644 --- a/libstdc++-v3/src/c++11/Makefile.in +++ b/libstdc++-v3/src/c++11/Makefile.in @@ -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 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 926e8be6122..f40e995e0f3 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