summary refs log tree commit diff
diff options
context:
space:
mode:
authorRandy Eckenrode <randy@largeandhighquality.com>2023-05-20 21:53:33 -0400
committerRandy Eckenrode <randy@largeandhighquality.com>2023-05-29 20:27:53 -0400
commit0b499eb86239cae23e52ba7c8ad2c3d30e6ed5b8 (patch)
treead4115b09b213c9ca415058504d20c8c239db745
parent5611fa71ab437f0be9fda35cdeb47df6fdc40659 (diff)
downloadnixpkgs-0b499eb86239cae23e52ba7c8ad2c3d30e6ed5b8.tar
nixpkgs-0b499eb86239cae23e52ba7c8ad2c3d30e6ed5b8.tar.gz
nixpkgs-0b499eb86239cae23e52ba7c8ad2c3d30e6ed5b8.tar.bz2
nixpkgs-0b499eb86239cae23e52ba7c8ad2c3d30e6ed5b8.tar.lz
nixpkgs-0b499eb86239cae23e52ba7c8ad2c3d30e6ed5b8.tar.xz
nixpkgs-0b499eb86239cae23e52ba7c8ad2c3d30e6ed5b8.tar.zst
nixpkgs-0b499eb86239cae23e52ba7c8ad2c3d30e6ed5b8.zip
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.
-rw-r--r--pkgs/development/python-modules/cffi/clang-pointer-substraction-warning.diff11
-rw-r--r--pkgs/development/python-modules/cffi/default.nix6
2 files changed, 17 insertions, 0 deletions
diff --git a/pkgs/development/python-modules/cffi/clang-pointer-substraction-warning.diff b/pkgs/development/python-modules/cffi/clang-pointer-substraction-warning.diff
new file mode 100644
index 00000000000..75b2677e380
--- /dev/null
+++ b/pkgs/development/python-modules/cffi/clang-pointer-substraction-warning.diff
@@ -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',
diff --git a/pkgs/development/python-modules/cffi/default.nix b/pkgs/development/python-modules/cffi/default.nix
index 5d3e220e98d..0d93941b974 100644
--- a/pkgs/development/python-modules/cffi/default.nix
+++ b/pkgs/development/python-modules/cffi/default.nix
@@ -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