From 15c37bc09f6642d3dad8ced0965610bcd414900b Mon Sep 17 00:00:00 2001 From: Advit Arora Date: Wed, 21 Oct 2026 23:13:36 +0100 Subject: [PATCH] gh-155813: Stop overwriting LIBFFI_CFLAGS and LIBFFI_LIBS on macOS (GH-156486) Ensures that a user-specified LIBFFI_CFLAGS and LIBFFI_LIBS is honored when building on macOS. (cherry picked from commit 6839f8ce22e54cffdaa9d8fe40009b7964450b69) Co-authored-by: Advit Arora --- .../next/Build/2026-08-27-23-24-29.gh-issue-155813.LxRQu9.rst | 3 +++ configure | 4 ++-- configure.ac | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-) create mode 100644 Misc/NEWS.d/next/Build/2026-08-27-23-24-29.gh-issue-155813.LxRQu9.rst diff --git a/Misc/NEWS.d/next/Build/2026-08-27-23-24-29.gh-issue-155813.LxRQu9.rst b/Misc/NEWS.d/next/Build/2026-08-27-23-24-29.gh-issue-155813.LxRQu9.rst new file mode 100644 index 000000000000000..c614826ba4c19ad --- /dev/null +++ b/Misc/NEWS.d/next/Build/2026-08-27-23-24-29.gh-issue-155813.LxRQu9.rst @@ -0,0 +1,3 @@ +On macOS, :option:`LIBFFI_CFLAGS` and :option:`LIBFFI_LIBS` are no longer +ignored when the SDK provides ``libffi``, so :mod:`ctypes` can again be built +against a different ``libffi``. Patch by Advit Arora. diff --git a/configure b/configure index 5a728e8ba68a3a1..c9678e24ddf1166 100755 --- a/configure +++ b/configure @@ -15931,8 +15931,8 @@ if test "x$ac_cv_lib_ffi_ffi_call" = xyes then : have_libffi=yes - LIBFFI_CFLAGS="-I${SDKROOT}/usr/include/ffi -DUSING_APPLE_OS_LIBFFI=1" - LIBFFI_LIBS="-lffi" + LIBFFI_CFLAGS=${LIBFFI_CFLAGS-"-I${SDKROOT}/usr/include/ffi -DUSING_APPLE_OS_LIBFFI=1"} + LIBFFI_LIBS=${LIBFFI_LIBS-"-lffi"} fi diff --git a/configure.ac b/configure.ac index 08cfd620afb1eeb..719b3cc5baac9bf 100644 --- a/configure.ac +++ b/configure.ac @@ -4286,8 +4286,8 @@ AS_VAR_IF([ac_sys_system], [Darwin], [ AC_CHECK_LIB([ffi], [ffi_call], [ dnl use ffi from SDK root have_libffi=yes - LIBFFI_CFLAGS="-I${SDKROOT}/usr/include/ffi -DUSING_APPLE_OS_LIBFFI=1" - LIBFFI_LIBS="-lffi" + LIBFFI_CFLAGS=${LIBFFI_CFLAGS-"-I${SDKROOT}/usr/include/ffi -DUSING_APPLE_OS_LIBFFI=1"} + LIBFFI_LIBS=${LIBFFI_LIBS-"-lffi"} ]) ]) ])