From patchwork Tue Apr 4 23:09:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Arsen_Arsenovi=C4=87?= X-Patchwork-Id: 79411 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp212280vqo; Tue, 4 Apr 2023 16:13:15 -0700 (PDT) X-Google-Smtp-Source: AKy350aVH2Wj6W9rUR8u+mSiZ0y87f9Hq8g+6BWwMXvWKm9XZA4kTAIKamvwRadbsrG8QjrTqcNt X-Received: by 2002:a17:906:d055:b0:933:4d37:82b2 with SMTP id bo21-20020a170906d05500b009334d3782b2mr1004472ejb.57.1680649995065; Tue, 04 Apr 2023 16:13:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680649995; cv=none; d=google.com; s=arc-20160816; b=zs7xvtCgc9M3G8VrsI7in8NCwH/3gq2gxD7s3UXIzBsWf7Bsv3Gm9zPvS/uFWJeGW3 9H1ypacJa5MlyHlpHBd2xaUOJhlqWOTwvWE4wwo7lhjBfCf6LGm/Q+aq/Ux8EhWfAsGY aegdKav/8HcpFatjmp8+SC0WRdAnjKX1R6YLTx1vc6kjA+s6/t8h2Hqb94vAaV4GpRzd jqKhFGkRjYtnZJ5Z9/ojNUMWfhF1c4k5tDCGvudqF5ziwIi/EUczRXgT1jx848gfUJ4X PBroLxViBJLuM5OR2Dj4HBH3rL0JiGX1hm0S0OqCUF4qCfbjI2q3OF4qyfsTdkeuqs0D 9VZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=QC2YlU4U8EExSN20/p1p+EbFMl3wxwTImZYBdo8bKcQ=; b=dSuAr0vZbVrimgnIQ7YKEgXpxJV3WMRH8DdeXx/p2KWp2rwm3YiWW/pjJ0AgpovXRI VZbLR07UsReC92HuyG2N6SAEFsZyC0ljsu2gpPloafx91RXSMERec3wP+x8xice1qqEh S3LwH+IcLJc3cJHxaiFUXjlZc6hKMiXkqzt+PwgzWQO92knQFkBYHpDMdudqc4suTE7j stvYPiZgMvIxStT25UpI1++oUY1pCM5JFdmGqs1+b+WhqVoyVYwbmCKx/gySbttndmFe oloLtmNkkxahks8w0xyOqRvtC3BdxXrxxf+DylqowwFz4MqpdEUVF+0Vo8NIiUuRFwtu BWDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=K4eQyRXd; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id lu12-20020a170906facc00b0093a35a98aeasi2894859ejb.946.2023.04.04.16.13.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Apr 2023 16:13:15 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=K4eQyRXd; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CAF1D3850400 for ; Tue, 4 Apr 2023 23:12:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CAF1D3850400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1680649934; bh=QC2YlU4U8EExSN20/p1p+EbFMl3wxwTImZYBdo8bKcQ=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=K4eQyRXd64qJxVaSSADNVknB7cfl+dQ/iQdtdk1j8hE1Z976JIwaxFpjxt5MQvnKW Je+wWk7JEjHnUHV2FYA3W4IBrONYYPa8DmRVaQrOrRJIlQQs1FycWjW8PpzlhJ3u36 f9Rnj7hPo4P6KXNs3Y5HppGqRJc1D4y+Qmp5AL0M= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mout-p-202.mailbox.org (mout-p-202.mailbox.org [IPv6:2001:67c:2050:0:465::202]) by sourceware.org (Postfix) with ESMTPS id A57B63858C54; Tue, 4 Apr 2023 23:10:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A57B63858C54 Received: from smtp202.mailbox.org (unknown [10.196.197.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-202.mailbox.org (Postfix) with ESMTPS id 4Prk5S0x94z9sWK; Wed, 5 Apr 2023 01:10:52 +0200 (CEST) To: gcc-patches@gcc.gnu.org Cc: libstdc++@gcc.gnu.org, =?utf-8?q?Arsen_Arsenovi=C4=87?= Subject: [PATCH 3/4] libstdc++: Downgrade DEBUG to ASSERTIONS when !HOSTED Date: Wed, 5 Apr 2023 01:09:49 +0200 Message-Id: <20230404230950.158556-3-arsen@aarsen.me> In-Reply-To: <20230404230950.158556-1-arsen@aarsen.me> References: <20230404230950.158556-1-arsen@aarsen.me> MIME-Version: 1.0 X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_INFOUSMEBIZ, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: =?utf-8?q?Arsen_Arsenovi=C4=87_via_Gcc-patches?= From: =?utf-8?q?Arsen_Arsenovi=C4=87?= Reply-To: =?utf-8?q?Arsen_Arsenovi=C4=87?= Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762289249428732597?= X-GMAIL-MSGID: =?utf-8?q?1762289249428732597?= Supporting the debug mode in freestanding is a non-trivial job, so instead, as a best-effort, enable assertions, which are light and easy. libstdc++-v3/ChangeLog: * include/bits/c++config: When __STDC_HOSTED__ is zero, disable _GLIBCXX_DEBUG and, if it was set, enable _GLIBCXX_ASSERTIONS. * testsuite/lib/libstdc++.exp (check_v3_target_debug_mode): Include when determining whether debug is set, in order to inherit the logic from above --- libstdc++-v3/include/bits/c++config | 7 +++++++ libstdc++-v3/testsuite/lib/libstdc++.exp | 1 + 2 files changed, 8 insertions(+) diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config index 71f2401402f..13892787e09 100644 --- a/libstdc++-v3/include/bits/c++config +++ b/libstdc++-v3/include/bits/c++config @@ -397,6 +397,13 @@ _GLIBCXX_END_NAMESPACE_VERSION # define _GLIBCXX_END_INLINE_ABI_NAMESPACE(X) } // inline namespace X #endif +// In the case that we don't have a hosted environment, we can't provide the +// debugging mode. Instead, we do our best and downgrade to assertions. +#if defined(_GLIBCXX_DEBUG) && !__STDC_HOSTED__ +#undef _GLIBCXX_DEBUG +#define _GLIBCXX_ASSERTIONS 1 +#endif + // Inline namespaces for special modes: debug, parallel. #if defined(_GLIBCXX_DEBUG) || defined(_GLIBCXX_PARALLEL) namespace std diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp b/libstdc++-v3/testsuite/lib/libstdc++.exp index 98512c973fb..490abd108fa 100644 --- a/libstdc++-v3/testsuite/lib/libstdc++.exp +++ b/libstdc++-v3/testsuite/lib/libstdc++.exp @@ -1007,6 +1007,7 @@ proc check_v3_target_debug_mode { } { global cxxflags return [check_v3_target_prop_cached et_debug_mode { set code " + #include #if ! defined _GLIBCXX_DEBUG # error no debug mode #endif