Skip to content

Commit 9d1c39f

Browse files
committed
Restructure detect_libffi().
Avoid restoring variables we just set.
1 parent 890ecca commit 9d1c39f

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

Tools/configure/conf_extlibs.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,17 @@ def detect_libffi(v):
6666
ffi_inc = (
6767
f"{sdkroot}/usr/include/ffi" if sdkroot else "/usr/include/ffi"
6868
)
69+
found_darwin_ffi = False
6970
with pyconf.save_env():
7071
v.CFLAGS = f"-I{ffi_inc} {v.CFLAGS}".strip()
7172
if pyconf.check_header("ffi.h"):
7273
if pyconf.check_lib("ffi", "ffi_call"):
73-
# use ffi from SDK root
74-
v.have_libffi = True
75-
v.LIBFFI_CFLAGS = f"-I{ffi_inc} -DUSING_APPLE_OS_LIBFFI=1"
76-
v.LIBFFI_LIBS = "-lffi"
74+
found_darwin_ffi = True
75+
if found_darwin_ffi:
76+
# use ffi from SDK root
77+
v.have_libffi = True
78+
v.LIBFFI_CFLAGS = f"-I{ffi_inc} -DUSING_APPLE_OS_LIBFFI=1"
79+
v.LIBFFI_LIBS = "-lffi"
7780

7881
if v.have_libffi == "missing":
7982
# Try pkg-config

Tools/configure/configure.awk

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3540,7 +3540,7 @@ function u_setup_expat( _opt_result, with_system_expat) {
35403540
v_export("LIBEXPAT_INTERNAL")
35413541
}
35423542

3543-
function u_detect_libffi( ac_cv_ffi_complex_double_supported, ctypes_malloc_closure, ffi_inc, found_ffi_h, output, parts, pkg, sdkroot, status, _ar_4, _ar_5) {
3543+
function u_detect_libffi( ac_cv_ffi_complex_double_supported, ctypes_malloc_closure, ffi_inc, found_darwin_ffi, found_ffi_h, output, parts, pkg, sdkroot, status, _ar_4, _ar_5) {
35443544
delete _ar_4
35453545
delete _ar_5
35463546
V["have_libffi"] = "missing"
@@ -3550,16 +3550,20 @@ function u_detect_libffi( ac_cv_ffi_complex_double_supported, ctypes_malloc_c
35503550
if ((V["ac_sys_system"] == "Darwin")) {
35513551
sdkroot = V["SDKROOT"]
35523552
ffi_inc = (((sdkroot != "") && (sdkroot != "no")) ? sdkroot "/usr/include/ffi" : "/usr/include/ffi")
3553+
found_darwin_ffi = "no"
35533554
pyconf_save_env()
35543555
V["CFLAGS"] = _str_strip("-I" ffi_inc " " V["CFLAGS"])
35553556
if (pyconf_check_header("ffi.h")) {
35563557
if (pyconf_check_lib("ffi", "ffi_call", "", "")) {
3557-
V["have_libffi"] = "yes"
3558-
V["LIBFFI_CFLAGS"] = "-I" ffi_inc " -DUSING_APPLE_OS_LIBFFI=1"
3559-
V["LIBFFI_LIBS"] = "-lffi"
3558+
found_darwin_ffi = "yes"
35603559
}
35613560
}
35623561
pyconf_restore_env()
3562+
if (((found_darwin_ffi != "") && (found_darwin_ffi != "no"))) {
3563+
V["have_libffi"] = "yes"
3564+
V["LIBFFI_CFLAGS"] = "-I" ffi_inc " -DUSING_APPLE_OS_LIBFFI=1"
3565+
V["LIBFFI_LIBS"] = "-lffi"
3566+
}
35633567
}
35643568
if ((V["have_libffi"] == "missing")) {
35653569
pkg = pyconf_find_prog("pkg-config")

0 commit comments

Comments
 (0)