python3Packages.cffi: fix build with newer clang

cffi uses a technique to find the offset of a struct that causes newer
clangs to issue a warning regarding null pointer subtraction. This
patch silences the warning, so cffi can build.
This commit is contained in:
Randy Eckenrode 2023-05-20 21:53:33 -04:00
parent 5611fa71ab
commit 0b499eb862
No known key found for this signature in database
GPG key ID: 64C1CD4EC2A600D9
2 changed files with 17 additions and 0 deletions

View file

@ -0,0 +1,11 @@
diff -r c649a735cf82 testing/support.py
--- a/testing/support.py Thu Feb 23 05:42:01 2023 +0100
+++ b/testing/support.py Sat May 20 21:46:56 2023 -0400
@@ -112,6 +112,7 @@
'-Wno-unreachable-code']
# special things for clang
extra_compile_args.append('-Qunused-arguments')
+ extra_compile_args.append('-Wno-null-pointer-subtraction')
else:
# assume a standard gcc
extra_compile_args = ['-Werror', '-Wall', '-Wextra', '-Wconversion',

View file

@ -50,6 +50,12 @@ if isPyPy then null else buildPythonPackage rec {
];
hash = "sha256-+2daRTvxtyrCPimOEAmVbiVm1Bso9hxGbaAbd03E+ws=";
})
] ++ lib.optionals (stdenv.cc.isClang && lib.versionAtLeast (lib.getVersion stdenv.cc) "13") [
# -Wnull-pointer-subtraction is enabled with -Wextra. Suppress it to allow the following tests
# to run and pass when cffi is built with newer versions of clang:
# - testing/cffi1/test_verify1.py::test_enum_usage
# - testing/cffi1/test_verify1.py::test_named_pointer_as_argument
./clang-pointer-substraction-warning.diff
] ++ lib.optionals (pythonAtLeast "3.11") [
# Fix test that failed because python seems to have changed the exception format in the
# final release. This patch should be included in the next version and can be removed when