]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Downgrade DEBUG to ASSERTIONS when !HOSTED
authorArsen Arsenović <arsen@aarsen.me>
Tue, 4 Apr 2023 17:25:09 +0000 (19:25 +0200)
committerArsen Arsenović <arsen@aarsen.me>
Wed, 5 Apr 2023 16:45:14 +0000 (18:45 +0200)
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
libstdc++-v3/testsuite/lib/libstdc++.exp

index 71f2401402fab7c95cfdcffb442de666abfd4a63..13892787e095c9810a616399658d0d98de6338e9 100644 (file)
@@ -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
index 98512c973fb93a70ab6b42cd0fc8da9b556f0de7..490abd108fada7ab91a553bfc0f85770c74004bb 100644 (file)
@@ -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