From: Stefano Rivera <stefanor@debian.org>
Date: Sat, 31 Aug 2024 12:58:23 +0200
Subject: GCC-14: Ignore -Wincompatible-pointer-types on 32-bit

Work around missing GCC-14 support for 32-builds of PyPy by suppressing
the GCC error. We hope to replace this with a real patch soon.

Bug-Upstream: https://github.com/pypy/pypy/issues/5016
---
 rpython/translator/c/genc.py           | 5 +++++
 rpython/translator/c/src/threadlocal.c | 3 +++
 2 files changed, 8 insertions(+)

diff --git a/rpython/translator/c/genc.py b/rpython/translator/c/genc.py
index ebbf52f..3ec6db5 100644
--- a/rpython/translator/c/genc.py
+++ b/rpython/translator/c/genc.py
@@ -700,6 +700,7 @@ class SourceGenerator:
                 print('/***********************************************************/', file=fc)
 
         nextralines = 12
+        IS_32_BIT = sys.maxint == 2**31-1
         for name, nodeiter in self.splitnodesimpl('implement.c',
                                                    self.funcnodes,
                                                    nextralines, 1,
@@ -715,6 +716,10 @@ class SourceGenerator:
                     if self.database.reverse_debugger:
                         print('#include "revdb_def.h"', file=fc)
                     print(file=fc)
+                if IS_32_BIT:
+                    print('#if defined __GNUC__ && __GNUC__ >= 14', file=fc)
+                    print('#pragma GCC diagnostic warning "-Wincompatible-pointer-types"', file=fc)
+                    print('#endif', file=fc)
                 print(MARKER, file=fc)
                 for node, impl in nodeiter:
                     print('\n'.join(impl), file=fc)
diff --git a/rpython/translator/c/src/threadlocal.c b/rpython/translator/c/src/threadlocal.c
index aae978f..9e708cf 100644
--- a/rpython/translator/c/src/threadlocal.c
+++ b/rpython/translator/c/src/threadlocal.c
@@ -7,6 +7,9 @@
 #include "src/threadlocal.h"
 #include "src/thread.h"
 
+#if defined __GNUC__ && __GNUC__ >= 14
+#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
+#endif
 
 /* this is a spin-lock that must be acquired around each doubly-linked-list
    manipulation (because such manipulations can occur without the GIL) */
