From b3f1b9e2aa079f8ec73e3cb48143a16645c49566 Mon Sep 17 00:00:00 2001
From: Andrew Pinski <quic_apinski@quicinc.com>
Date: Fri, 22 Nov 2024 09:31:44 -0800
Subject: [PATCH] build: Remove INCLUDE_MEMORY [PR117737]

Since diagnostic.h is included in over half of the sources, requiring to `#define INCLUDE_MEMORY`
does not make sense. Instead lets unconditionally include memory in system.h.

The majority of this patch is just removing `#define INCLUDE_MEMORY` from the sources which currently
have it.

This should also fix the mingw build issue but I have not tried it.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
Signed-off-by: Martin Jansa <martin.jansa@gmail.com>
Upstream-Status: Backport [gcc-15.1.0 b3f1b9e2aa07 partial, only the gcc/system.h change]
---
 gcc/system.h | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/gcc/system.h b/gcc/system.h
index c18c7c5ec58d..c209871df72d 100644
--- a/gcc/system.h
+++ b/gcc/system.h
@@ -222,6 +222,7 @@ extern int fprintf_unlocked (FILE *, const char *, ...);
 #ifdef INCLUDE_FUNCTIONAL
 # include <functional>
 #endif
+# include <memory>
 # include <cstring>
 # include <initializer_list>
 # include <new>
@@ -758,13 +759,6 @@ private:
 #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>
