Source: php7.3 Version: 7.3.12-1 Tags: patch upstream User: debian-cr...@lists.debian.org Usertags: ftcbfs
php7.3 fails to cross build from source. The immediate failure stems from using the build architecture pkg-config. Once doing so, it fails finding required dependencies that are only installed for the host architecture. This is a very common problem and the fix is very simple: Use AC_PATH_TOOL instead of AC_PATH_PROG for finding pkg-config. Then there is a non-failure, but one that struck my eyes anyway: In addition to using AC_CHECK_SIZEOF, php also has its own PHP_CHECK_SIZEOF. Unfortunately, it got cross compilation completely wrong. I'm attaching a patch that fixes the pkg-config issue and changes PHP_CHECK_SIZEOF to use AC_CHECK_SIZEOF underneath while retaining the additional headers. The patch should be suitable for upstream inclusion in my view. It does not make php7.3 cross buildable though. At some point, it fails running the cross built php for generating "phar.php". This problem doesn't seem to be new[1], but I don't particularly like the suggested workarounds. So I'm only reporting the well-understood aspects here. Please close this bug anyhow when fixing the pkg-config and sizeof aspects. Helmut [1] https://stackoverflow.com/questions/6559480/cross-compiling-php
--- php7.3-7.3.12.orig/acinclude.m4 +++ php7.3-7.3.12/acinclude.m4 @@ -1059,7 +1059,7 @@ LIBS= old_LDFLAGS=$LDFLAGS LDFLAGS= - AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h> + AC_CHECK_SIZEOF([$1],[$2],[ #if STDC_HEADERS #include <stdlib.h> #include <stddef.h> @@ -1071,21 +1071,8 @@ #include <unistd.h> #endif $3 - -int main() -{ - FILE *fp = fopen("conftestval", "w"); - if (!fp) return(1); - fprintf(fp, "%d\n", sizeof($1)); - return(0); -} - ]])], [ - eval $php_cache_value=`cat conftestval` - ], [ - eval $php_cache_value=0 - ], [ - ifelse([$2],,[eval $php_cache_value=0], [eval $php_cache_value=$2]) ]) + eval $php_cache_value=\$AS_TR_SH([ac_cv_sizeof_$1]) LDFLAGS=$old_LDFLAGS LIBS=$old_LIBS ]) @@ -2178,7 +2165,7 @@ dnl First try to find pkg-config if test -z "$PKG_CONFIG"; then - AC_PATH_PROG(PKG_CONFIG, pkg-config, no) + AC_PATH_TOOL(PKG_CONFIG, pkg-config, no) fi dnl If pkg-config is found try using it @@ -2337,7 +2324,7 @@ dnl First try to find pkg-config if test -z "$PKG_CONFIG"; then - AC_PATH_PROG(PKG_CONFIG, pkg-config, no) + AC_PATH_TOOL(PKG_CONFIG, pkg-config, no) fi dnl If pkg-config is found try using it @@ -2570,7 +2557,7 @@ dnl If xml2-config fails, try pkg-config if test "$found_libxml" = "no"; then if test -z "$PKG_CONFIG"; then - AC_PATH_PROG(PKG_CONFIG, pkg-config, no) + AC_PATH_TOOL(PKG_CONFIG, pkg-config, no) fi dnl If pkg-config is found try using it --- php7.3-7.3.12.orig/aclocal.m4 +++ php7.3-7.3.12/aclocal.m4 @@ -2176,7 +2176,7 @@ dnl First try to find pkg-config if test -z "$PKG_CONFIG"; then - AC_PATH_PROG(PKG_CONFIG, pkg-config, no) + AC_PATH_TOOL(PKG_CONFIG, pkg-config, no) fi dnl If pkg-config is found try using it @@ -2335,7 +2335,7 @@ dnl First try to find pkg-config if test -z "$PKG_CONFIG"; then - AC_PATH_PROG(PKG_CONFIG, pkg-config, no) + AC_PATH_TOOL(PKG_CONFIG, pkg-config, no) fi dnl If pkg-config is found try using it @@ -2570,7 +2570,7 @@ dnl If xml2-config fails, try pkg-config if test "$found_libxml" = "no"; then if test -z "$PKG_CONFIG"; then - AC_PATH_PROG(PKG_CONFIG, pkg-config, no) + AC_PATH_TOOL(PKG_CONFIG, pkg-config, no) fi dnl If pkg-config is found try using it --- php7.3-7.3.12.orig/ext/odbc/config.m4 +++ php7.3-7.3.12/ext/odbc/config.m4 @@ -319,7 +319,7 @@ AC_MSG_CHECKING(for iODBC support) if test "$PHP_IODBC" != "no"; then if test -z "$PKG_CONFIG"; then - AC_PATH_PROG(PKG_CONFIG, pkg-config, no) + AC_PATH_TOOL(PKG_CONFIG, pkg-config, no) fi if test -x "$PKG_CONFIG" && $PKG_CONFIG --exists libiodbc ; then PHP_ADD_LIBRARY_WITH_PATH(iodbc, $PHP_IODBC/$PHP_LIBDIR) --- php7.3-7.3.12.orig/sapi/fpm/config.m4 +++ php7.3-7.3.12/sapi/fpm/config.m4 @@ -582,7 +582,7 @@ if test "$PHP_FPM_SYSTEMD" != "no" ; then if test -z "$PKG_CONFIG"; then - AC_PATH_PROG(PKG_CONFIG, pkg-config, no) + AC_PATH_TOOL(PKG_CONFIG, pkg-config, no) fi unset SYSTEMD_LIBS unset SYSTEMD_INCS