From 9d6d9d60e740d182d4327cc052c741ba0a9fe196 Mon Sep 17 00:00:00 2001 From: Peter Kokot Date: Thu, 1 Aug 2024 14:58:27 +0200 Subject: [PATCH 1/2] Autotools: Fix ffi checks When libffi is installed on non-default places, also the calling convention check needs adjusted compilation flags to be able to find the ffi.h header file. --- ext/ffi/config.m4 | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ext/ffi/config.m4 b/ext/ffi/config.m4 index b2a889e5de7d..47136ba716b1 100644 --- a/ext/ffi/config.m4 +++ b/ext/ffi/config.m4 @@ -13,11 +13,15 @@ if test "$PHP_FFI" != "no"; then AC_CHECK_TYPES([long double]) - AC_DEFUN([PHP_FFI_CHECK_DECL], - [AC_CHECK_DECL([$1], + AC_DEFUN([PHP_FFI_CHECK_DECL], [ + CFLAGS_SAVE=$CFLAGS + CFLAGS="$CFLAGS $FFI_CFLAGS" + AC_CHECK_DECL([$1], [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_$1]), [1], - [Whether libffi supports the '$1' calling convention.])],, - [#include ])]) + [Define to 1 if libffi supports the '$1' calling convention.])],, + [#include ]) + CFLAGS=$CFLAGS_SAVE + ]) PHP_FFI_CHECK_DECL([FFI_FASTCALL]) PHP_FFI_CHECK_DECL([FFI_THISCALL]) From 2fb643628d0b5e2d1993ddc36e04b2d18f5a094a Mon Sep 17 00:00:00 2001 From: Peter Kokot Date: Fri, 2 Aug 2024 00:31:37 +0200 Subject: [PATCH 2/2] [skip ci] Move flags out of the macro to the outer scope if other checks will need to be done in the future --- ext/ffi/config.m4 | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/ext/ffi/config.m4 b/ext/ffi/config.m4 index 47136ba716b1..4b15070469bd 100644 --- a/ext/ffi/config.m4 +++ b/ext/ffi/config.m4 @@ -13,16 +13,14 @@ if test "$PHP_FFI" != "no"; then AC_CHECK_TYPES([long double]) - AC_DEFUN([PHP_FFI_CHECK_DECL], [ - CFLAGS_SAVE=$CFLAGS - CFLAGS="$CFLAGS $FFI_CFLAGS" - AC_CHECK_DECL([$1], + AC_DEFUN([PHP_FFI_CHECK_DECL], + [AC_CHECK_DECL([$1], [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_$1]), [1], [Define to 1 if libffi supports the '$1' calling convention.])],, - [#include ]) - CFLAGS=$CFLAGS_SAVE - ]) + [#include ])]) + CFLAGS_SAVE=$CFLAGS + CFLAGS="$CFLAGS $FFI_CFLAGS" PHP_FFI_CHECK_DECL([FFI_FASTCALL]) PHP_FFI_CHECK_DECL([FFI_THISCALL]) PHP_FFI_CHECK_DECL([FFI_STDCALL]) @@ -30,6 +28,7 @@ if test "$PHP_FFI" != "no"; then PHP_FFI_CHECK_DECL([FFI_REGISTER]) PHP_FFI_CHECK_DECL([FFI_MS_CDECL]) PHP_FFI_CHECK_DECL([FFI_SYSV]) + CFLAGS=$CFLAGS_SAVE PHP_NEW_EXTENSION([ffi], [ffi.c ffi_parser.c],