Browse Source

Merge branch 'PHP-8.5'

* PHP-8.5:
  Fix cross-compilation for musl C library
pull/17433/merge
Peter Kokot 7 days ago
parent
commit
3b67680609
No known key found for this signature in database GPG Key ID: A94800907AA79B36
  1. 40
      build/php.m4
  2. 13
      configure.ac
  3. 3
      ext/posix/config.m4

40
build/php.m4

@ -2502,3 +2502,43 @@ AC_DEFUN([PHP_REMOVE_OPTIMIZATION_FLAGS], [
CFLAGS=$(echo "$CFLAGS" | $SED -e "$sed_script")
CXXFLAGS=$(echo "$CXXFLAGS" | $SED -e "$sed_script")
])
dnl
dnl PHP_C_STANDARD_LIBRARY
dnl
dnl Determine the C standard library used for the build. The uclibc is checked
dnl first because it also defines the __GLIBC__ and could otherwise be detected
dnl as glibc. Musl C library is determined heuristically.
dnl
AC_DEFUN([PHP_C_STANDARD_LIBRARY],
[AC_CACHE_CHECK([C standard library implementation],
[php_cv_c_standard_library],
[php_cv_c_standard_library=unknown
dnl Check if C standard library is uclibc.
AS_VAR_IF([php_cv_c_standard_library], [unknown],
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <features.h>],
[#ifndef __UCLIBC__
(void) __UCLIBC__;
#endif])],
[php_cv_c_standard_library=uclibc],
[php_cv_c_standard_library=unknown])])
dnl Check if C standard library is GNU C.
AS_VAR_IF([php_cv_c_standard_library], [unknown],
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <features.h>],
[#ifndef __GLIBC__
(void) __GLIBC__;
#endif])],
[php_cv_c_standard_library=glibc],
[php_cv_c_standard_library=unknown])])
dnl Check if C standard library is musl libc.
AS_VAR_IF([php_cv_c_standard_library], [unknown],
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <stdarg.h>],
[#ifndef __DEFINED_va_list
(void) __DEFINED_va_list;
#endif])],
[php_cv_c_standard_library=musl],
[AS_IF([command -v ldd >/dev/null && ldd --version 2>&1 | grep ^musl >/dev/null 2>&1],
[php_cv_c_standard_library=musl],
[php_cv_c_standard_library=unknown])])])
])
])

13
configure.ac

@ -250,15 +250,10 @@ case $host_alias in
;;
esac
dnl Detect musl libc
AC_MSG_CHECKING([whether we are using musl libc])
if command -v ldd >/dev/null && ldd --version 2>&1 | grep ^musl >/dev/null 2>&1
then
AC_MSG_RESULT([yes])
AC_DEFINE([__MUSL__], [1], [Define to 1 when using musl libc.])
else
AC_MSG_RESULT([no])
fi
dnl Detect C library.
PHP_C_STANDARD_LIBRARY
AS_VAR_IF([php_cv_c_standard_library], [musl],
[AC_DEFINE([__MUSL__], [1], [Define to 1 when using musl libc.])])
dnl Add _GNU_SOURCE compile definition because the php_config.h with definitions
dnl by AC_USE_SYSTEM_EXTENSIONS might be included after the system headers which

3
ext/posix/config.m4

@ -44,7 +44,8 @@ if test "$PHP_POSIX" = "yes"; then
dnl Skip pathconf and fpathconf check on musl libc due to limited implementation
dnl (first argument is not validated and has different error).
AS_IF([command -v ldd >/dev/null && ldd --version 2>&1 | grep ^musl >/dev/null 2>&1],
PHP_C_STANDARD_LIBRARY
AS_VAR_IF([php_cv_c_standard_library], [musl],
[],
[AC_CHECK_FUNCS([pathconf fpathconf])])

Loading…
Cancel
Save