From 9db50f0ef4697aef7ac3e2681286293ae9e116e3 Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Tue, 29 Oct 2024 07:25:35 +0300 Subject: [PATCH 1/6] gh-125206: Correct detection of complex numbers support in libffi --- .../Library/2024-10-29-07-24-52.gh-issue-125322.sstOM-.rst | 1 + configure | 4 ++-- configure.ac | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) create mode 100644 Misc/NEWS.d/next/Library/2024-10-29-07-24-52.gh-issue-125322.sstOM-.rst diff --git a/Misc/NEWS.d/next/Library/2024-10-29-07-24-52.gh-issue-125322.sstOM-.rst b/Misc/NEWS.d/next/Library/2024-10-29-07-24-52.gh-issue-125322.sstOM-.rst new file mode 100644 index 00000000000000..e0cc91d287f89d --- /dev/null +++ b/Misc/NEWS.d/next/Library/2024-10-29-07-24-52.gh-issue-125322.sstOM-.rst @@ -0,0 +1 @@ +Correct detection of complex numbers support in libffi. diff --git a/configure b/configure index 97113f1fd967fe..6e865cc32ca119 100755 --- a/configure +++ b/configure @@ -15066,8 +15066,8 @@ if test ${ac_cv_ffi_complex_double_supported+y} then : printf %s "(cached) " >&6 else $as_nop - ac_save_cc="$CC" -CC="$CC -lffi" + ac_save_libs=“$LIBS” +LIBS="-lffi" if test "$cross_compiling" = yes then : ac_cv_ffi_complex_double_supported=no diff --git a/configure.ac b/configure.ac index 1534144bab3400..4d514322b67162 100644 --- a/configure.ac +++ b/configure.ac @@ -4098,8 +4098,8 @@ AS_VAR_IF([have_libffi], [yes], [ # See https://github.com/python/cpython/issues/125206 for more details. # AC_CACHE_CHECK([libffi has complex type support], [ac_cv_ffi_complex_double_supported], -[ac_save_cc="$CC" -CC="$CC -lffi" +[ac_save_libs=“$LIBS” +LIBS="-lffi" AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include #include From 5fdb838e72568756e1d8ad54e8db4821bfdf7ae0 Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Tue, 29 Oct 2024 08:17:40 +0300 Subject: [PATCH 2/6] +1 --- configure | 2 +- configure.ac | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/configure b/configure index 6e865cc32ca119..b78e687e42af53 100755 --- a/configure +++ b/configure @@ -15109,7 +15109,7 @@ rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi -CC="$ac_save_cc" +LIBS="$ac_save_libs" fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_ffi_complex_double_supported" >&5 printf "%s\n" "$ac_cv_ffi_complex_double_supported" >&6; } diff --git a/configure.ac b/configure.ac index 4d514322b67162..15cb863447395f 100644 --- a/configure.ac +++ b/configure.ac @@ -4126,7 +4126,7 @@ int main(void) ]])], [ac_cv_ffi_complex_double_supported=yes], [ac_cv_ffi_complex_double_supported=no], [ac_cv_ffi_complex_double_supported=no]) -CC="$ac_save_cc"]) +LIBS="$ac_save_libs"]) if test "$ac_cv_ffi_complex_double_supported" = "yes"; then AC_DEFINE([Py_FFI_SUPPORT_C_COMPLEX], [1], [Defined if _Complex C type can be used with libffi.]) From cbed501a713b34bb560ec1ac6eb707993f03de73 Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Tue, 29 Oct 2024 08:50:55 +0300 Subject: [PATCH 3/6] + WITH_SAVE_ENV --- configure | 20 +++++++++++++++++--- configure.ac | 9 ++++++--- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/configure b/configure index b78e687e42af53..c6ffbb7eaa71f2 100755 --- a/configure +++ b/configure @@ -15066,8 +15066,16 @@ if test ${ac_cv_ffi_complex_double_supported+y} then : printf %s "(cached) " >&6 else $as_nop - ac_save_libs=“$LIBS” -LIBS="-lffi" + save_CFLAGS=$CFLAGS +save_CPPFLAGS=$CPPFLAGS +save_LDFLAGS=$LDFLAGS +save_LIBS=$LIBS + + + CFLAGS="$LIBFFI_CFLAGS $CFLAGS" + LDFLAGS="$LIBFFI_LIBS $LDFLAGS" + LIBS="$LIBFFI_LIBS" + if test "$cross_compiling" = yes then : ac_cv_ffi_complex_double_supported=no @@ -15109,7 +15117,13 @@ rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi -LIBS="$ac_save_libs" + +CFLAGS=$save_CFLAGS +CPPFLAGS=$save_CPPFLAGS +LDFLAGS=$save_LDFLAGS +LIBS=$save_LIBS + + fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_ffi_complex_double_supported" >&5 printf "%s\n" "$ac_cv_ffi_complex_double_supported" >&6; } diff --git a/configure.ac b/configure.ac index 15cb863447395f..76d45e2e89685b 100644 --- a/configure.ac +++ b/configure.ac @@ -4098,8 +4098,11 @@ AS_VAR_IF([have_libffi], [yes], [ # See https://github.com/python/cpython/issues/125206 for more details. # AC_CACHE_CHECK([libffi has complex type support], [ac_cv_ffi_complex_double_supported], -[ac_save_libs=“$LIBS” -LIBS="-lffi" +[WITH_SAVE_ENV([ + CFLAGS="$LIBFFI_CFLAGS $CFLAGS" + LDFLAGS="$LIBFFI_LIBS $LDFLAGS" + LIBS="$LIBFFI_LIBS" + AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include #include @@ -4126,7 +4129,7 @@ int main(void) ]])], [ac_cv_ffi_complex_double_supported=yes], [ac_cv_ffi_complex_double_supported=no], [ac_cv_ffi_complex_double_supported=no]) -LIBS="$ac_save_libs"]) +])]) if test "$ac_cv_ffi_complex_double_supported" = "yes"; then AC_DEFINE([Py_FFI_SUPPORT_C_COMPLEX], [1], [Defined if _Complex C type can be used with libffi.]) From 66c1cf7c4fc4f2fef1b179fb453d150903a5685a Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Tue, 29 Oct 2024 09:03:38 +0300 Subject: [PATCH 4/6] +formatting --- configure | 7 +++---- configure.ac | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/configure b/configure index c6ffbb7eaa71f2..dae57530a20fde 100755 --- a/configure +++ b/configure @@ -15072,10 +15072,9 @@ save_LDFLAGS=$LDFLAGS save_LIBS=$LIBS - CFLAGS="$LIBFFI_CFLAGS $CFLAGS" - LDFLAGS="$LIBFFI_LIBS $LDFLAGS" - LIBS="$LIBFFI_LIBS" - + CFLAGS="$LIBFFI_CFLAGS $CFLAGS" + LDFLAGS="$LIBFFI_LIBS $LDFLAGS" + LIBS="$LIBFFI_LIBS" if test "$cross_compiling" = yes then : ac_cv_ffi_complex_double_supported=no diff --git a/configure.ac b/configure.ac index 76d45e2e89685b..ad1056038da8c4 100644 --- a/configure.ac +++ b/configure.ac @@ -4099,10 +4099,9 @@ AS_VAR_IF([have_libffi], [yes], [ # AC_CACHE_CHECK([libffi has complex type support], [ac_cv_ffi_complex_double_supported], [WITH_SAVE_ENV([ - CFLAGS="$LIBFFI_CFLAGS $CFLAGS" - LDFLAGS="$LIBFFI_LIBS $LDFLAGS" - LIBS="$LIBFFI_LIBS" - + CFLAGS="$LIBFFI_CFLAGS $CFLAGS" + LDFLAGS="$LIBFFI_LIBS $LDFLAGS" + LIBS="$LIBFFI_LIBS" AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include #include From 545f99fab2d202722b87ddd72ea2e848413b91fa Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Tue, 29 Oct 2024 12:33:45 +0300 Subject: [PATCH 5/6] address review: CFLAGS -> CPPFLAGS --- configure | 2 +- configure.ac | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/configure b/configure index dae57530a20fde..7f160f8a8d37ff 100755 --- a/configure +++ b/configure @@ -15072,7 +15072,7 @@ save_LDFLAGS=$LDFLAGS save_LIBS=$LIBS - CFLAGS="$LIBFFI_CFLAGS $CFLAGS" + CPPFLAGS="$LIBFFI_CFLAGS $CPPFLAGS" LDFLAGS="$LIBFFI_LIBS $LDFLAGS" LIBS="$LIBFFI_LIBS" if test "$cross_compiling" = yes diff --git a/configure.ac b/configure.ac index ad1056038da8c4..7f496063a45f86 100644 --- a/configure.ac +++ b/configure.ac @@ -4099,7 +4099,7 @@ AS_VAR_IF([have_libffi], [yes], [ # AC_CACHE_CHECK([libffi has complex type support], [ac_cv_ffi_complex_double_supported], [WITH_SAVE_ENV([ - CFLAGS="$LIBFFI_CFLAGS $CFLAGS" + CPPFLAGS="$LIBFFI_CFLAGS $CPPFLAGS" LDFLAGS="$LIBFFI_LIBS $LDFLAGS" LIBS="$LIBFFI_LIBS" AC_RUN_IFELSE([AC_LANG_SOURCE([[ From fc4ebff928815b3a0d55f15aa707342f14065d79 Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Tue, 29 Oct 2024 13:46:42 +0300 Subject: [PATCH 6/6] address review: +LIBS --- configure | 2 +- configure.ac | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/configure b/configure index 7f160f8a8d37ff..24c81c52389021 100755 --- a/configure +++ b/configure @@ -15074,7 +15074,7 @@ save_LIBS=$LIBS CPPFLAGS="$LIBFFI_CFLAGS $CPPFLAGS" LDFLAGS="$LIBFFI_LIBS $LDFLAGS" - LIBS="$LIBFFI_LIBS" + LIBS="$LIBFFI_LIBS $LIBS" if test "$cross_compiling" = yes then : ac_cv_ffi_complex_double_supported=no diff --git a/configure.ac b/configure.ac index 7f496063a45f86..92f614fb4af35a 100644 --- a/configure.ac +++ b/configure.ac @@ -4101,7 +4101,7 @@ AC_CACHE_CHECK([libffi has complex type support], [ac_cv_ffi_complex_double_supp [WITH_SAVE_ENV([ CPPFLAGS="$LIBFFI_CFLAGS $CPPFLAGS" LDFLAGS="$LIBFFI_LIBS $LDFLAGS" - LIBS="$LIBFFI_LIBS" + LIBS="$LIBFFI_LIBS $LIBS" AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include #include