From 0b499eb86239cae23e52ba7c8ad2c3d30e6ed5b8 Mon Sep 17 00:00:00 2001 From: Randy Eckenrode Date: Sat, 20 May 2023 21:53:33 -0400 Subject: [PATCH] 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. --- .../cffi/clang-pointer-substraction-warning.diff | 11 +++++++++++ pkgs/development/python-modules/cffi/default.nix | 6 ++++++ 2 files changed, 17 insertions(+) create mode 100644 pkgs/development/python-modules/cffi/clang-pointer-substraction-warning.diff 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 000000000000..75b2677e380e --- /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 5d3e220e98de..0d93941b974d 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