From: "Arsen Arsenović" <arsen@aarsen.me>
To: gcc-patches@gcc.gnu.org
Cc: libstdc++@gcc.gnu.org, "Arsen Arsenović" <arsen@aarsen.me>
Subject: [PATCH 3/4] libstdc++: Downgrade DEBUG to ASSERTIONS when !HOSTED
Date: Wed, 5 Apr 2023 01:09:49 +0200 [thread overview]
Message-ID: <20230404230950.158556-3-arsen@aarsen.me> (raw)
In-Reply-To: <20230404230950.158556-1-arsen@aarsen.me>
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 <bits/c++config.h> 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 <bits/c++config.h>
#if ! defined _GLIBCXX_DEBUG
# error no debug mode
#endif
--
2.40.0
next prev parent reply other threads:[~2023-04-04 23:10 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-04 23:09 [PATCH 1/4] libstdc++: Harmonize <version> and other headers Arsen Arsenović
2023-04-04 23:09 ` [PATCH 2/4] libstdc++: Add a test for <version> FTM redefinitions Arsen Arsenović
2023-04-05 10:59 ` Jonathan Wakely
2023-04-05 11:31 ` Arsen Arsenović
2023-04-05 11:38 ` Arsen Arsenović
2023-04-05 12:07 ` Jonathan Wakely
2023-04-04 23:09 ` Arsen Arsenović [this message]
2023-04-05 11:00 ` [PATCH 3/4] libstdc++: Downgrade DEBUG to ASSERTIONS when !HOSTED Jonathan Wakely
2023-04-04 23:09 ` [PATCH 4/4] libstdc++: Fix some freestanding test failures Arsen Arsenović
2023-04-05 11:08 ` Jonathan Wakely
2023-04-05 11:28 ` Arsen Arsenović
2023-04-05 10:52 ` [PATCH 1/4] libstdc++: Harmonize <version> and other headers Jonathan Wakely
2023-04-05 11:33 ` Arsen Arsenović
2023-04-05 12:09 ` Jonathan Wakely
2023-04-05 12:10 ` Jonathan Wakely
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230404230950.158556-3-arsen@aarsen.me \
--to=arsen@aarsen.me \
--cc=gcc-patches@gcc.gnu.org \
--cc=libstdc++@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).