From 340c3f68329b191bef56ad0eafa6b0a8c9fac85c Mon Sep 17 00:00:00 2001 From: Emily Date: Mon, 6 Jan 2025 20:20:32 +0000 Subject: [PATCH] Revert "python312Packages.cffi: remove unnecessary Darwin patch" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix the build on `aarch64-darwin`. Need to figure out why either `!defined(FFI_AVAILABLE_APPLE)` or the `__builtin_available` checks are failing, but that’s a next cycle problem. This reverts commit eff89e3bd808ba8949356d0f4a4a61ac93cba81c. --- .../cffi/darwin-use-libffi-closures.diff | 29 +++++++++++++++++++ .../python-modules/cffi/default.nix | 14 +++++++++ 2 files changed, 43 insertions(+) create mode 100644 pkgs/development/python-modules/cffi/darwin-use-libffi-closures.diff diff --git a/pkgs/development/python-modules/cffi/darwin-use-libffi-closures.diff b/pkgs/development/python-modules/cffi/darwin-use-libffi-closures.diff new file mode 100644 index 000000000000..4ef51274aa28 --- /dev/null +++ b/pkgs/development/python-modules/cffi/darwin-use-libffi-closures.diff @@ -0,0 +1,29 @@ +diff --git a/src/c/_cffi_backend.c b/src/c/_cffi_backend.c +index 537271f..9c3bf94 100644 +--- a/src/c/_cffi_backend.c ++++ b/src/c/_cffi_backend.c +@@ -103,11 +103,11 @@ + # define CFFI_CHECK_FFI_PREP_CIF_VAR 0 + # define CFFI_CHECK_FFI_PREP_CIF_VAR_MAYBE 0 + +-#elif defined(__APPLE__) && defined(FFI_AVAILABLE_APPLE) ++#elif defined(__APPLE__) + +-# define CFFI_CHECK_FFI_CLOSURE_ALLOC __builtin_available(macos 10.15, ios 13, watchos 6, tvos 13, *) ++# define CFFI_CHECK_FFI_CLOSURE_ALLOC 1 + # define CFFI_CHECK_FFI_CLOSURE_ALLOC_MAYBE 1 +-# define CFFI_CHECK_FFI_PREP_CLOSURE_LOC __builtin_available(macos 10.15, ios 13, watchos 6, tvos 13, *) ++# define CFFI_CHECK_FFI_PREP_CLOSURE_LOC 1 + # define CFFI_CHECK_FFI_PREP_CLOSURE_LOC_MAYBE 1 +-# define CFFI_CHECK_FFI_PREP_CIF_VAR __builtin_available(macos 10.15, ios 13, watchos 6, tvos 13, *) ++# define CFFI_CHECK_FFI_PREP_CIF_VAR 1 + # define CFFI_CHECK_FFI_PREP_CIF_VAR_MAYBE 1 +@@ -6422,7 +6422,7 @@ static PyObject *b_callback(PyObject *self, PyObject *args) + else + #endif + { +-#if defined(__APPLE__) && defined(FFI_AVAILABLE_APPLE) && !FFI_LEGACY_CLOSURE_API ++#if defined(__APPLE__) && !FFI_LEGACY_CLOSURE_API + PyErr_Format(PyExc_SystemError, "ffi_prep_closure_loc() is missing"); + goto error; + #else diff --git a/pkgs/development/python-modules/cffi/default.nix b/pkgs/development/python-modules/cffi/default.nix index 7ce279008bdb..6597dd4749d0 100644 --- a/pkgs/development/python-modules/cffi/default.nix +++ b/pkgs/development/python-modules/cffi/default.nix @@ -24,6 +24,20 @@ else hash = "sha256-HDnGAWwyvEjdVFYZUOvWg24WcPKuRhKPZ89J54nFKCQ="; }; + patches = [ + # + # Trusts the libffi library inside of nixpkgs on Apple devices. + # + # Based on some analysis I did: + # + # https://groups.google.com/g/python-cffi/c/xU0Usa8dvhk + # + # I believe that libffi already contains the code from Apple's fork that is + # deemed safe to trust in cffi. + # + ./darwin-use-libffi-closures.diff + ]; + nativeBuildInputs = [ pkg-config ]; build-system = [ setuptools ];