Files
buildroot/package/gcc/13.4.0/0006-build-Move-sstream-and-memory-include-above-safe-cty.patch
Marcus Hoffmann 10ccbe079c package/gcc: fix gcc-13 build with host gcc 16
Backport 2 patches from upstream maintenance branch. Same fixes as
required for gcc-14.

Signed-off-by: Marcus Hoffmann <buildroot@bubu1.eu>
Signed-off-by: Julien Olivain <ju.o@free.fr>
2026-05-06 22:21:57 +02:00

80 lines
2.6 KiB
Diff

From 9239757a9c6e3a6e8d94d56803329d556ec914d7 Mon Sep 17 00:00:00 2001
From: Andrew Pinski <quic_apinski@quicinc.com>
Date: Mon, 25 Nov 2024 14:03:27 -0800
Subject: [PATCH] build: Move sstream and memory include above safe-ctype.h
[PR124830]
This picks r15-5661-gf6e00226a4ca6 to older branches, also moving
the <memory> include to fix build issues with a C++20 host compiler.
sstream in some versions of libstdc++ include locale which might not have been
included yet. safe-ctype.h defines the toupper, tolower, etc. as macros so the
c++ header files needed to be included before hand as comment in system.h says:
/* Include C++ standard headers before "safe-ctype.h" to avoid GCC
poisoning the ctype macros through safe-ctype.h */
I don't understand how it was working before when memory was included after
safe-ctype.h rather than before. But this makes sstream consistent with the
other C++ headers.
gcc/ChangeLog:
PR target/117771
PR c/124830
* system.h: Move the include of sstream and memory above safe-ctype.h.
Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
(cherry picked from commit 046776dac7cc74bdbab36f450af80644a045858a)
Signed-off-by: Marcus Hoffmann <buildroot@bubu1.eu>
Upstream: https://gcc.gnu.org/git?p=gcc.git;a=commit;h=9239757a9c6e3a6e8d94d56803329d556ec914d7
---
gcc/system.h | 21 +++++++++------------
1 file changed, 9 insertions(+), 12 deletions(-)
diff --git a/gcc/system.h b/gcc/system.h
index 0354883ed3f..1f013d3ac7a 100644
--- a/gcc/system.h
+++ b/gcc/system.h
@@ -222,6 +222,15 @@ extern int fprintf_unlocked (FILE *, const char *, ...);
#ifdef INCLUDE_FUNCTIONAL
# include <functional>
#endif
+#ifdef INCLUDE_SSTREAM
+# include <sstream>
+#endif
+/* Some of the headers included by <memory> can use "abort" within a
+ namespace, e.g. "_VSTD::abort();", which fails after we use the
+ preprocessor to redefine "abort" as "fancy_abort" below. */
+#ifdef INCLUDE_MEMORY
+# include <memory>
+#endif
# include <cstring>
# include <initializer_list>
# include <new>
@@ -736,22 +745,10 @@ extern int vsnprintf (char *, size_t, const char *, va_list);
#define LIKELY(x) (__builtin_expect ((x), 1))
#define UNLIKELY(x) (__builtin_expect ((x), 0))
-/* Some of the headers included by <memory> can use "abort" within a
- namespace, e.g. "_VSTD::abort();", which fails after we use the
- preprocessor to redefine "abort" as "fancy_abort" below. */
-
-#ifdef INCLUDE_MEMORY
-# include <memory>
-#endif
-
#ifdef INCLUDE_MUTEX
# include <mutex>
#endif
-#ifdef INCLUDE_SSTREAM
-# include <sstream>
-#endif
-
#ifdef INCLUDE_MALLOC_H
#if defined(HAVE_MALLINFO) || defined(HAVE_MALLINFO2)
#include <malloc.h>
--
2.54.0