Disable GCC warnings/errors about wrong self casts in final function calls

Numerous packages fail to build due to -Werror=incompatible-pointer-types
being the default in Fedora 40+.

The code is generated by Cython. No known fix at this time,
so better to disable the warning here than in each individual package.
This commit is contained in:
Miro Hrončok 2024-02-27 18:09:35 +01:00
parent e728dde39c
commit ba710e631b
2 changed files with 68 additions and 0 deletions

64
6039.patch Normal file
View File

@ -0,0 +1,64 @@
From 2b1022efeeeefe1b813bb0810675a6fcb98cbb6e Mon Sep 17 00:00:00 2001
From: Stefan Behnel <stefan_ml@behnel.de>
Date: Wed, 28 Feb 2024 10:03:58 +0100
Subject: [PATCH 1/2] Disable GCC warnings/errors about wrong self casts in
final function calls.
See https://github.com/cython/cython/issues/2747
---
Cython/Compiler/ExprNodes.py | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py
index d46e8b0cbdd..62364edd1b1 100644
--- a/Cython/Compiler/ExprNodes.py
+++ b/Cython/Compiler/ExprNodes.py
@@ -6498,7 +6498,13 @@ def generate_result_code(self, code):
goto_error = code.error_goto_if(" && ".join(exc_checks), self.pos)
else:
goto_error = ""
+ if self.function.is_attribute and self.function.entry and self.function.entry.final_func_cname:
+ # Hack around https://github.com/cython/cython/issues/2747
+ # Disable GCC warnings/errors for wrong self casts.
+ code.putln('#pragma GCC diagnostic ignored "-Wincompatible-pointer-types"')
code.putln("%s%s; %s" % (lhs, rhs, goto_error))
+ if self.function.is_attribute and self.function.entry and self.function.entry.final_func_cname:
+ code.putln("#pragma GCC diagnostic pop")
if self.type.is_pyobject and self.result():
self.generate_gotref(code)
if self.has_optional_args:
From facecc5fe67feac147afa47008a06f766bfb8cd3 Mon Sep 17 00:00:00 2001
From: Stefan Behnel <stefan_ml@behnel.de>
Date: Sat, 2 Mar 2024 08:54:26 +0100
Subject: [PATCH 2/2] Do not generate pragma in C++ mode since it is only valid
for gcc, not gpp.
---
Cython/Compiler/ExprNodes.py | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py
index 62364edd1b1..7ee239ae579 100644
--- a/Cython/Compiler/ExprNodes.py
+++ b/Cython/Compiler/ExprNodes.py
@@ -6498,12 +6498,17 @@ def generate_result_code(self, code):
goto_error = code.error_goto_if(" && ".join(exc_checks), self.pos)
else:
goto_error = ""
- if self.function.is_attribute and self.function.entry and self.function.entry.final_func_cname:
+ undo_gh2747_hack = False
+ if (self.function.is_attribute and
+ self.function.entry and self.function.entry.final_func_cname and
+ not code.funcstate.scope.is_cpp()
+ ):
# Hack around https://github.com/cython/cython/issues/2747
# Disable GCC warnings/errors for wrong self casts.
code.putln('#pragma GCC diagnostic ignored "-Wincompatible-pointer-types"')
+ undo_gh2747_hack = True
code.putln("%s%s; %s" % (lhs, rhs, goto_error))
- if self.function.is_attribute and self.function.entry and self.function.entry.final_func_cname:
+ if undo_gh2747_hack:
code.putln("#pragma GCC diagnostic pop")
if self.type.is_pyobject and self.result():
self.generate_gotref(code)

View File

@ -16,6 +16,10 @@ Source: https://github.com/cython/cython/archive/%{version}/Cython-%{ver
# Use Python 3.13.0a4 PyCFunctionFastWithKeywords
Patch: https://github.com/cython/cython/pull/6003.patch
# Disable GCC warnings/errors about wrong self casts in final function calls
# Upstream issue: https://github.com/cython/cython/issues/2747
Patch: https://github.com/cython/cython/pull/6039.patch
BuildRequires: python3-devel
%if %{with tests}