python312Packages.cffi: remove unnecessary Darwin patch (attempt 2) (#382404)
This commit is contained in:
@@ -1,29 +0,0 @@
|
||||
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
|
||||
@@ -44,20 +44,6 @@ 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 ];
|
||||
|
||||
@@ -25,6 +25,8 @@ mkAppleDerivation (finalAttrs: {
|
||||
patches = [
|
||||
# Clang 18 requires that no non-private symbols by defined after cfi_startproc. Apply the upstream libffi fix.
|
||||
./patches/llvm-18-compatibility.patch
|
||||
# Fix a memory leak when using the trampoline dylib. See https://github.com/libffi/libffi/pull/621#discussion_r955298301.
|
||||
./patches/fix-tramponline-memory-leak.patch
|
||||
];
|
||||
|
||||
# Make sure libffi is using the trampolines dylib in this package not the system one.
|
||||
@@ -46,7 +48,6 @@ mkAppleDerivation (finalAttrs: {
|
||||
|
||||
configureFlags = [
|
||||
"--with-gcc-arch=generic" # no detection of -march= or -mtune=
|
||||
"--enable-pax_emutramp"
|
||||
];
|
||||
|
||||
# Make sure aarch64-darwin is using the trampoline dylib.
|
||||
@@ -55,7 +56,8 @@ mkAppleDerivation (finalAttrs: {
|
||||
'';
|
||||
|
||||
postBuild = lib.optionalString stdenv.hostPlatform.isAarch64 ''
|
||||
$CC src/aarch64/trampoline.S -dynamiclib -o libffi-trampolines.dylib \
|
||||
$CC -Os -Wl,-allowable_client,! -Wl,-not_for_dyld_shared_cache -Wl,-no_compact_unwind \
|
||||
src/aarch64/trampoline.S -dynamiclib -o libffi-trampolines.dylib \
|
||||
-Iinclude -Iaarch64-apple-darwin -Iaarch64-apple-darwin/include \
|
||||
-install_name "$out/lib/libffi-trampoline.dylib" -Wl,-compatibility_version,1 -Wl,-current_version,1
|
||||
'';
|
||||
@@ -64,6 +66,9 @@ mkAppleDerivation (finalAttrs: {
|
||||
# The Darwin SDK puts the headers in `include/ffi`. Add a symlink for compatibility.
|
||||
''
|
||||
ln -s "$dev/include" "$dev/include/ffi"
|
||||
# Make sure Apple’s header with availability annotations is installed in place of the generated one.
|
||||
# Use `macCatalyst` instead of `iosmac` to avoid errors due to invalid availability annotations.
|
||||
substitute darwin/include/ffi.h "$dev/include/ffi.h" --replace-fail iosmac macCatalyst
|
||||
''
|
||||
# Install the trampoline dylib since it is build manually.
|
||||
+ lib.optionalString stdenv.hostPlatform.isAarch64 ''
|
||||
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
diff --git a/src/closures.c b/src/closures.c
|
||||
index 01f9950cd0..1dfd375cff 100644
|
||||
--- a/src/closures.c
|
||||
+++ b/src/closures.c
|
||||
@@ -329,7 +329,7 @@
|
||||
table->next->prev = table->prev;
|
||||
|
||||
/* Deallocate pages */
|
||||
- vm_deallocate (mach_task_self (), table->config_page, PAGE_MAX_SIZE * 2);
|
||||
+ vm_deallocate (mach_task_self (), table->config_page, FFI_TRAMPOLINE_ALLOCATION_PAGE_COUNT * PAGE_MAX_SIZE);
|
||||
|
||||
/* Deallocate free list */
|
||||
free (table->free_list_pool);
|
||||
Reference in New Issue
Block a user