diff --git a/ports/php/php.patch b/ports/php/php.patch new file mode 100644 index 00000000..11fec5f2 --- /dev/null +++ b/ports/php/php.patch @@ -0,0 +1,840 @@ +diff -Paur --no-dereference -- php.upstream/Zend/zend_cpuinfo.h php/Zend/zend_cpuinfo.h +--- php.upstream/Zend/zend_cpuinfo.h ++++ php/Zend/zend_cpuinfo.h +@@ -21,6 +21,10 @@ + + #include "zend.h" + ++#if defined(__GNUC__) && 6 < __GNUC__ ++#define __builtin_cpu_supports(x) 0 ++#endif ++ + #define ZEND_CPU_EBX_MASK (1<<30) + #define ZEND_CPU_EDX_MASK (1U<<31) + +diff -Paur --no-dereference -- php.upstream/Zend/zend_signal.c php/Zend/zend_signal.c +--- php.upstream/Zend/zend_signal.c ++++ php/Zend/zend_signal.c +@@ -64,7 +64,7 @@ + static void zend_signal_handler(int signo, siginfo_t *siginfo, void *context); + static zend_result zend_signal_register(int signo, void (*handler)(int, siginfo_t*, void*)); + +-#if defined(__CYGWIN__) || defined(__PASE__) ++#if defined(__CYGWIN__) || defined(__PASE__) || !defined(SIGPROF) + /* Matches zend_execute_API.c; these platforms don't support ITIMER_PROF. */ + #define TIMEOUT_SIG SIGALRM + #else +diff -Paur --no-dereference -- php.upstream/build/Makefile.global php/build/Makefile.global +--- php.upstream/build/Makefile.global ++++ php/build/Makefile.global +@@ -1,3 +1,5 @@ ++INSTALL_ROOT = $(DESTDIR) ++ + mkinstalldirs = $(top_srcdir)/build/shtool mkdir -p + INSTALL = $(top_srcdir)/build/shtool install -c + INSTALL_DATA = $(INSTALL) -m 644 +@@ -134,6 +136,7 @@ + rm -f ext/phar/phar/phar.inc; \ + fi + $(EGREP) define'.*include/php' $(top_srcdir)/configure | $(SED) 's/.*>//'|xargs rm -f ++ rm -f config.nice sapi/phpdbg/phpdbg sapi/fpm/www.conf + + prof-gen: + CCACHE_DISABLE=1 $(MAKE) PROF_FLAGS=-fprofile-generate all +diff -Paur --no-dereference -- php.upstream/configure php/configure +--- php.upstream/configure ++++ php/configure +@@ -4456,13 +4456,6 @@ + case $target_os in *\ *) target_os=`echo "$target_os" | sed 's/ /-/g'`;; esac + + +-# The aliases save the names the user supplied, while $host etc. +-# will get canonicalized. +-test -n "$target_alias" && +- test "$program_prefix$program_suffix$program_transform_name" = \ +- NONENONEs,x,x, && +- program_prefix=${target_alias}- +- + if test -z "$host_alias" && test -n "$host"; then + host_alias=$host + fi +@@ -18144,7 +18137,9 @@ + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ +- ++ #if defined(__GNUC__) && __GNUC__ < 6 ++ #error "sortix gcc 5.2.0 has binutils 2.24 which is too old" ++ #endif + #include + int main(void) { + __m512i mask = _mm512_set1_epi32(0x1); +@@ -18183,7 +18178,9 @@ + CFLAGS="-mavx512f -mavx512cd -mavx512vl -mavx512dq -mavx512bw -mavx512vbmi $CFLAGS" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ +- ++ #if defined(__GNUC__) && __GNUC__ < 6 ++ #error "sortix gcc 5.2.0 has binutils 2.24 which is too old" ++ #endif + #include + int main(void) { + __m512i mask = _mm512_set1_epi32(0x1); +@@ -19517,7 +19514,7 @@ + ac_cv_func_getaddrinfo=yes + ;; + *) +- ac_cv_func_getaddrinfo=no ++ ac_cv_func_getaddrinfo=yes + ;; + esac + +@@ -43142,6 +43139,10 @@ + + + ++# PATCH: Bypass poorly implemented libiconv detection logic. ++if [ "$host_os" = sortix ]; then ++LIBS="$LIBS -liconv" ++fi + + if test "$PHP_ICONV" != "no"; then + +@@ -43151,7 +43152,9 @@ + + if test "$PHP_ICONV" = "yes"; then + LIBS_save="$LIBS" ++ if [ "$host_os" != sortix ]; then + LIBS= ++ fi + ac_fn_c_check_func "$LINENO" "iconv" "ac_cv_func_iconv" + if test "x$ac_cv_func_iconv" = xyes + then : +@@ -98080,7 +98083,8 @@ + fi; + + all_targets="$lcov_target \$(OVERALL_TARGET) \$(PHP_MODULES) \$(PHP_ZEND_EX) \$(PHP_BINARIES) $pharcmd" +-install_targets="$install_sapi $install_modules $install_binaries install-build install-headers install-programs $install_pear $pharcmd_install" ++# PATCH: Don't install includes and build files since php is static. ++install_targets="$install_sapi $install_modules $install_binaries install-programs $install_pear $pharcmd_install" + + + PHP_VAR_SUBST="$PHP_VAR_SUBST all_targets" +@@ -98546,6 +98550,7 @@ + builddir = $abs_builddir + top_srcdir = $abs_srcdir + top_builddir = $abs_builddir ++cross_compiling = $cross_compiling + EOF + for i in $PHP_VAR_SUBST; do + eval echo "$i = \$$i" >> Makefile +@@ -98684,11 +98689,7 @@ + + + +- { printf "%s\n" "$as_me:${as_lineno-$LINENO}: patching main/php_config.h.in" >&5 +-printf "%s\n" "$as_me: patching main/php_config.h.in" >&6;} +- +- $SED -e 's/^#undef PACKAGE_[^ ]*/\/\* & \*\//g' < $srcdir/main/php_config.h.in \ +- > $srcdir/main/php_config.h.in.tmp && mv $srcdir/main/php_config.h.in.tmp $srcdir/main/php_config.h.in ++# PATCH: Don't rewrite main/php_config.h.in as it is a source file. + + + : "${CONFIG_STATUS=./config.status}" +diff -Paur --no-dereference -- php.upstream/ext/fileinfo/libmagic/file.h php/ext/fileinfo/libmagic/file.h +--- php.upstream/ext/fileinfo/libmagic/file.h ++++ php/ext/fileinfo/libmagic/file.h +@@ -79,9 +79,6 @@ + #include /* For open and flags */ + + #include +-#ifndef WIN32 +-#include +-#endif + /* Do this here and now, because struct stat gets re-defined on solaris */ + #include + #include +diff -Paur --no-dereference -- php.upstream/ext/iconv/iconv.c php/ext/iconv/iconv.c +--- php.upstream/ext/iconv/iconv.c ++++ php/ext/iconv/iconv.c +@@ -40,10 +40,6 @@ + #include + #endif + +-#ifdef HAVE_LIBICONV +-#undef iconv +-#endif +- + #if defined(__NetBSD__) + // unfortunately, netbsd has still the old non posix conformant signature + // libiconv tends to match the eventual system's iconv too. +diff -Paur --no-dereference -- php.upstream/ext/pdo/Makefile.frag php/ext/pdo/Makefile.frag +--- php.upstream/ext/pdo/Makefile.frag ++++ php/ext/pdo/Makefile.frag +@@ -32,4 +32,4 @@ + done; + + # mini hack +-install: $(all_targets) $(install_targets) install-pdo-headers ++install: $(all_targets) $(install_targets) +diff -Paur --no-dereference -- php.upstream/ext/phar/Makefile.frag php/ext/phar/Makefile.frag +--- php.upstream/ext/phar/Makefile.frag ++++ php/ext/phar/Makefile.frag +@@ -9,6 +9,11 @@ + pharcmd: $(builddir)/phar.php $(builddir)/phar.phar + + PHP_PHARCMD_SETTINGS = -n -d 'open_basedir=' -d 'output_buffering=0' -d 'memory_limit=-1' -d phar.readonly=0 ++ ++# Cross-compile using a local php that is the same version. ++ifeq ($(cross_compiling),yes) ++PHP_PHARCMD_EXECUTABLE=php ++else + PHP_PHARCMD_EXECUTABLE = ` \ + if test -x "$(top_builddir)/$(SAPI_CLI_PATH)"; then \ + $(top_srcdir)/build/shtool echo -n -- "$(top_builddir)/$(SAPI_CLI_PATH) -n"; \ +@@ -23,15 +28,14 @@ + else \ + $(top_srcdir)/build/shtool echo -n -- "$(PHP_EXECUTABLE)"; \ + fi;` +-PHP_PHARCMD_BANG = `$(top_srcdir)/build/shtool echo -n -- "$(INSTALL_ROOT)$(bindir)/$(program_prefix)php$(program_suffix)$(EXEEXT)";` ++endif ++PHP_PHARCMD_BANG = `$(top_srcdir)/build/shtool echo -n -- "$(bindir)/$(program_prefix)php$(program_suffix)$(EXEEXT)";` + + $(builddir)/phar/phar.inc: $(srcdir)/phar/phar.inc + -@test -d $(builddir)/phar || mkdir $(builddir)/phar + -@test -f $(builddir)/phar/phar.inc || cp $(srcdir)/phar/phar.inc $(builddir)/phar/phar.inc + +- +-TEST_PHP_EXECUTABLE = $(shell $(PHP_EXECUTABLE) -v 2>&1) +-TEST_PHP_EXECUTABLE_RES = $(shell echo "$(TEST_PHP_EXECUTABLE)" | grep -c 'Exec format error') ++TEST_PHP_EXECUTABLE_RES=0 + + $(builddir)/phar.php: $(srcdir)/build_precommand.php $(srcdir)/phar/*.inc $(srcdir)/phar/*.php $(SAPI_CLI_PATH) + -@(echo "Generating phar.php"; \ +@@ -60,7 +64,6 @@ + $(LN_S) -f $(program_prefix)phar$(program_suffix).phar $(INSTALL_ROOT)$(bindir)/$(program_prefix)phar$(program_suffix); \ + $(mkinstalldirs) $(INSTALL_ROOT)$(mandir)/man1; \ + $(INSTALL_DATA) $(builddir)/phar.1 $(INSTALL_ROOT)$(mandir)/man1/$(program_prefix)phar$(program_suffix).1; \ +- $(INSTALL_DATA) $(builddir)/phar.phar.1 $(INSTALL_ROOT)$(mandir)/man1/$(program_prefix)phar$(program_suffix).phar.1; \ + else \ + echo "Skipping install-pharcmd during cross compilation"; \ + fi) +diff -Paur --no-dereference -- php.upstream/ext/phar/func_interceptors.c php/ext/phar/func_interceptors.c +--- php.upstream/ext/phar/func_interceptors.c ++++ php/ext/phar/func_interceptors.c +@@ -350,6 +350,7 @@ + wmask=S_IWGRP; + xmask=S_IXGRP; + } else { ++#if !defined(__sortix__) || defined(__SORTIX_HAS_GETGROUPS__) + int groups, n, i; + gid_t *gids; + +@@ -367,6 +368,7 @@ + } + efree(gids); + } ++#endif + } + } + +diff -Paur --no-dereference -- php.upstream/ext/posix/posix.c php/ext/posix/posix.c +--- php.upstream/ext/posix/posix.c ++++ php/ext/posix/posix.c +@@ -266,9 +266,13 @@ + /* }}} */ + + /* {{{ Get current process group id (POSIX.1, 4.3.1) */ ++static pid_t php_getpgrp(void) ++{ ++ return getpgid(0); ++} + PHP_FUNCTION(posix_getpgrp) + { +- PHP_POSIX_RETURN_LONG_FUNC(getpgrp); ++ PHP_POSIX_RETURN_LONG_FUNC(php_getpgrp); + } + /* }}} */ + +diff -Paur --no-dereference -- php.upstream/ext/standard/crypt_sha256.c php/ext/standard/crypt_sha256.c +--- php.upstream/ext/standard/crypt_sha256.c ++++ php/ext/standard/crypt_sha256.c +@@ -23,7 +23,6 @@ + #ifdef PHP_WIN32 + # include + #else +-# include + # include + # include + #endif +diff -Paur --no-dereference -- php.upstream/ext/standard/crypt_sha512.c php/ext/standard/crypt_sha512.c +--- php.upstream/ext/standard/crypt_sha512.c ++++ php/ext/standard/crypt_sha512.c +@@ -22,7 +22,6 @@ + #ifdef PHP_WIN32 + # include + #else +-# include + # include + # include + #endif +diff -Paur --no-dereference -- php.upstream/ext/standard/dl.c php/ext/standard/dl.c +--- php.upstream/ext/standard/dl.c ++++ php/ext/standard/dl.c +@@ -33,7 +33,6 @@ + #include "win32/winutil.h" + #define GET_DL_ERROR() php_win_err() + #else +-#include + #define GET_DL_ERROR() DL_ERROR() + #endif + #endif /* defined(HAVE_LIBDL) */ +diff -Paur --no-dereference -- php.upstream/ext/standard/dns.c php/ext/standard/dns.c +--- php.upstream/ext/standard/dns.c ++++ php/ext/standard/dns.c +@@ -241,9 +241,7 @@ + { + char *hostname; + size_t hostname_len; +- struct hostent *hp; + struct in_addr in; +- int i; + #ifdef HAVE_INET_NTOP + char addr4[INET_ADDRSTRLEN]; + #endif +@@ -258,54 +256,47 @@ + RETURN_FALSE; + } + +- hp = php_network_gethostbyname(hostname); +- if (!hp) { ++ struct addrinfo hints = { .ai_family = AF_INET }; ++ struct addrinfo *res0 = NULL; ++ int status = getaddrinfo(hostname, NULL, &hints, &res0); ++ if (status) { + RETURN_FALSE; + } + + array_init(return_value); + +- for (i = 0;; i++) { +- /* On macos h_addr_list entries may be misaligned. */ +- struct in_addr *h_addr_entry; /* Don't call this h_addr, it's a macro! */ +- memcpy(&h_addr_entry, &hp->h_addr_list[i], sizeof(struct in_addr *)); +- if (!h_addr_entry) { +- return; +- } +- +- in = *h_addr_entry; ++ for (struct addrinfo *res = res0; res; res = res->ai_next) ++ { ++ in = *(struct in_addr *)res->ai_addr; + #ifdef HAVE_INET_NTOP + add_next_index_string(return_value, inet_ntop(AF_INET, &in, addr4, INET_ADDRSTRLEN)); + #else + add_next_index_string(return_value, inet_ntoa(in)); + #endif + } ++ freeaddrinfo(res0); + } + /* }}} */ + + /* {{{ php_gethostbyname */ + static zend_string *php_gethostbyname(char *name) + { +- struct hostent *hp; +- struct in_addr *h_addr_0; /* Don't call this h_addr, it's a macro! */ + struct in_addr in; + #ifdef HAVE_INET_NTOP + char addr4[INET_ADDRSTRLEN]; + #endif + const char *address; + +- hp = php_network_gethostbyname(name); +- if (!hp) { ++ struct addrinfo hints = { .ai_family = AF_INET }; ++ struct addrinfo *res0 = NULL; ++ int status = getaddrinfo(name, NULL, &hints, &res0); ++ if (status) { + return zend_string_init(name, strlen(name), 0); + } + +- /* On macos h_addr_list entries may be misaligned. */ +- memcpy(&h_addr_0, &hp->h_addr_list[0], sizeof(struct in_addr *)); +- if (!h_addr_0) { +- return zend_string_init(name, strlen(name), 0); +- } ++ memcpy(&in.s_addr, res0->ai_addr, sizeof(in.s_addr)); + +- memcpy(&in.s_addr, h_addr_0, sizeof(in.s_addr)); ++ freeaddrinfo(res0); + + #ifdef HAVE_INET_NTOP + address = inet_ntop(AF_INET, &in, addr4, INET_ADDRSTRLEN); +diff -Paur --no-dereference -- php.upstream/ext/standard/filestat.c php/ext/standard/filestat.c +--- php.upstream/ext/standard/filestat.c ++++ php/ext/standard/filestat.c +@@ -836,6 +836,7 @@ + wmask=S_IWGRP; + xmask=S_IXGRP; + } else { ++#if !defined(__sortix__) || defined(__SORTIX_HAS_GETGROUPS__) + int groups, n, i; + gid_t *gids; + +@@ -853,6 +854,7 @@ + } + efree(gids); + } ++#endif + } + } + +diff -Paur --no-dereference -- php.upstream/ext/standard/ftp_fopen_wrapper.c php/ext/standard/ftp_fopen_wrapper.c +--- php.upstream/ext/standard/ftp_fopen_wrapper.c ++++ php/ext/standard/ftp_fopen_wrapper.c +@@ -33,8 +33,6 @@ + #include + #define O_RDONLY _O_RDONLY + #include "win32/param.h" +-#else +-#include + #endif + + #include "php_standard.h" +diff -Paur --no-dereference -- php.upstream/ext/standard/http_fopen_wrapper.c php/ext/standard/http_fopen_wrapper.c +--- php.upstream/ext/standard/http_fopen_wrapper.c ++++ php/ext/standard/http_fopen_wrapper.c +@@ -36,8 +36,6 @@ + #ifdef PHP_WIN32 + #define O_RDONLY _O_RDONLY + #include "win32/param.h" +-#else +-#include + #endif + + #include "php_standard.h" +diff -Paur --no-dereference -- php.upstream/ext/standard/microtime.c php/ext/standard/microtime.c +--- php.upstream/ext/standard/microtime.c ++++ php/ext/standard/microtime.c +@@ -125,7 +125,7 @@ + #ifdef PHP_WIN32 /* Windows only implements a limited amount of fields from the rusage struct */ + PHP_RUSAGE_PARA(ru_majflt); + PHP_RUSAGE_PARA(ru_maxrss); +-#elif !defined(_OSD_POSIX) && !defined(__HAIKU__) ++#elif !defined(_OSD_POSIX) && !defined(__HAIKU__) && !defined(__sortix__) + PHP_RUSAGE_PARA(ru_oublock); + PHP_RUSAGE_PARA(ru_inblock); + PHP_RUSAGE_PARA(ru_msgsnd); +diff -Paur --no-dereference -- php.upstream/ext/standard/net.c php/ext/standard/net.c +--- php.upstream/ext/standard/net.c ++++ php/ext/standard/net.c +@@ -295,8 +295,14 @@ + iface_append_unicast(unicast, + p->ifa_flags, + p->ifa_addr, p->ifa_netmask, +- (p->ifa_flags & IFF_BROADCAST) ? p->ifa_broadaddr : NULL, +- (p->ifa_flags & IFF_POINTOPOINT) ? p->ifa_dstaddr : NULL); ++#ifdef IFF_BROADCAST ++ (p->ifa_flags & IFF_BROADCAST) ? p->ifa_broadaddr : ++#endif ++ NULL, ++#ifdef IFF_POINTOPOINT ++ (p->ifa_flags & IFF_POINTOPOINT) ? p->ifa_dstaddr : ++#endif ++ NULL); + status = zend_hash_str_find(Z_ARR_P(iface), "up", sizeof("up") - 1); + if (!status) { + add_assoc_bool(iface, "up", ((p->ifa_flags & IFF_UP) != 0)); +diff -Paur --no-dereference -- php.upstream/ext/standard/pack.c php/ext/standard/pack.c +--- php.upstream/ext/standard/pack.c ++++ php/ext/standard/pack.c +@@ -25,8 +25,6 @@ + #ifdef PHP_WIN32 + #define O_RDONLY _O_RDONLY + #include "win32/param.h" +-#else +-#include + #endif + #include "ext/standard/head.h" + #include "php_string.h" +diff -Paur --no-dereference -- php.upstream/ext/standard/php_fopen_wrapper.c php/ext/standard/php_fopen_wrapper.c +--- php.upstream/ext/standard/php_fopen_wrapper.c ++++ php/ext/standard/php_fopen_wrapper.c +@@ -317,11 +317,7 @@ + return NULL; + } + +-#ifdef HAVE_UNISTD_H +- dtablesize = getdtablesize(); +-#else + dtablesize = INT_MAX; +-#endif + + if (fildes_ori < 0 || fildes_ori >= dtablesize) { + php_stream_wrapper_log_error(wrapper, options, +diff -Paur --no-dereference -- php.upstream/init/php-fpm php/init/php-fpm +--- php.upstream/init/php-fpm ++++ php/init/php-fpm +@@ -0,0 +1 @@ ++exec php-fpm -FO +diff -Paur --no-dereference -- php.upstream/main/fastcgi.c php/main/fastcgi.c +--- php.upstream/main/fastcgi.c ++++ php/main/fastcgi.c +@@ -689,21 +689,17 @@ + sa.sa_inet.sin_addr.s_addr = inet_addr(host); + if (sa.sa_inet.sin_addr.s_addr == INADDR_NONE) { + #endif +- struct hostent *hep; +- +- if(strlen(host) > MAXFQDNLEN) { +- hep = NULL; +- } else { +- hep = php_network_gethostbyname(host); +- } +- if (!hep || hep->h_addrtype != AF_INET || !hep->h_addr_list[0]) { ++ struct addrinfo hints = { .ai_family = AF_INET }; ++ struct addrinfo *res0 = NULL; ++ int status = getaddrinfo(host, NULL, &hints, &res0); ++ if (status) { + fcgi_log(FCGI_ERROR, "Cannot resolve host name '%s'!\n", host); +- return -1; +- } else if (hep->h_addr_list[1]) { ++ } else if (res0->ai_next) { + fcgi_log(FCGI_ERROR, "Host '%s' has multiple addresses. You must choose one explicitly!\n", host); + return -1; + } +- sa.sa_inet.sin_addr.s_addr = ((struct in_addr*)hep->h_addr_list[0])->s_addr; ++ sa.sa_inet.sin_addr.s_addr = ((struct in_addr*)res0->ai_addr)->s_addr; ++ freeaddrinfo(res0); + } + } + } else { +diff -Paur --no-dereference -- php.upstream/main/fopen_wrappers.c php/main/fopen_wrappers.c +--- php.upstream/main/fopen_wrappers.c ++++ php/main/fopen_wrappers.c +@@ -30,8 +30,6 @@ + #ifdef PHP_WIN32 + #define O_RDONLY _O_RDONLY + #include "win32/param.h" +-#else +-#include + #endif + + #include "ext/standard/head.h" +diff -Paur --no-dereference -- php.upstream/main/network.c php/main/network.c +--- php.upstream/main/network.c ++++ php/main/network.c +@@ -29,8 +29,6 @@ + # include "win32/winutil.h" + # define O_RDONLY _O_RDONLY + # include "win32/param.h" +-#else +-#include + #endif + + #include +@@ -74,6 +72,11 @@ + #include + #endif + ++#if defined(__sortix__) && !defined(timercmp) ++#define timercmp(s,t,op) ((s)->tv_sec == (t)->tv_sec ? \ ++ (s)->tv_usec op (t)->tv_usec : (s)->tv_sec op (t)->tv_sec) ++#endif ++ + #include "ext/standard/file.h" + + #ifdef PHP_WIN32 +@@ -247,6 +250,8 @@ + errno = E2BIG; + } else { + host_info = php_network_gethostbyname(host); ++ host_info = NULL; ++ errno = ENOTSUP; + } + if (host_info == NULL) { + if (error_string) { +@@ -871,9 +876,9 @@ + if (inet_aton(bindto, &local_address.in4.sin_addr)) { + #endif + local_address_len = sizeof(struct sockaddr_in); ++ memset(&(local_address.in4), 0, sizeof(local_address.in4)); + local_address.in4.sin_family = sa->sa_family; + local_address.in4.sin_port = htons(bindport); +- memset(&(local_address.in4.sin_zero), 0, sizeof(local_address.in4.sin_zero)); + } + } + #if HAVE_IPV6 && HAVE_INET_PTON +@@ -1330,7 +1335,7 @@ + + PHPAPI struct hostent* php_network_gethostbyname(const char *name) { + #if !defined(HAVE_GETHOSTBYNAME_R) +- return gethostbyname(name); ++ return NULL; // PATCH: Only use getaddrinfo. + #else + if (FG(tmp_host_buf)) { + free(FG(tmp_host_buf)); +diff -Paur --no-dereference -- php.upstream/main/php.h php/main/php.h +--- php.upstream/main/php.h ++++ php/main/php.h +@@ -225,7 +225,6 @@ + #include "win32/param.h" + # else + #include +-#include + # endif + #endif + +diff -Paur --no-dereference -- php.upstream/main/php_open_temporary_file.c php/main/php_open_temporary_file.c +--- php.upstream/main/php_open_temporary_file.c ++++ php/main/php_open_temporary_file.c +@@ -27,7 +27,6 @@ + #include "win32/param.h" + #include "win32/winutil.h" + #else +-#include + #include + #include + #include +@@ -43,10 +42,6 @@ + #include + #endif + +-#if !defined(P_tmpdir) +-#define P_tmpdir "" +-#endif +- + /* {{{ php_do_open_temporary_file */ + + /* Loosely based on a tempnam() implementation by UCLA */ +diff -Paur --no-dereference -- php.upstream/sapi/cgi/cgi_main.c php/sapi/cgi/cgi_main.c +--- php.upstream/sapi/cgi/cgi_main.c ++++ php/sapi/cgi/cgi_main.c +@@ -1989,7 +1989,7 @@ + + /* Create a process group for us & children */ + setsid(); +- pgroup = getpgrp(); ++ pgroup = getpgid(0); + #ifdef DEBUG_FASTCGI + fprintf(stderr, "Process group %d\n", pgroup); + #endif +diff -Paur --no-dereference -- php.upstream/sapi/fpm/Makefile.frag php/sapi/fpm/Makefile.frag +--- php.upstream/sapi/fpm/Makefile.frag ++++ php/sapi/fpm/Makefile.frag +@@ -14,10 +14,18 @@ + echo "Installing PHP FPM defconfig: skipping"; \ + else \ + echo "Installing PHP FPM defconfig: $(INSTALL_ROOT)$(sysconfdir)/" && \ +- $(mkinstalldirs) $(INSTALL_ROOT)$(sysconfdir)/php-fpm.d; \ +- $(INSTALL_DATA) sapi/fpm/php-fpm.conf $(INSTALL_ROOT)$(sysconfdir)/php-fpm.conf.default; \ +- $(INSTALL_DATA) sapi/fpm/www.conf $(INSTALL_ROOT)$(sysconfdir)/php-fpm.d/www.conf.default; \ ++ $(mkinstalldirs) $(INSTALL_ROOT)$(sysconfdir)/default/php-fpm.d; \ ++ $(INSTALL_DATA) sapi/fpm/php-fpm.conf $(INSTALL_ROOT)$(sysconfdir)/default/php-fpm.conf; \ ++ $(INSTALL_DATA) sapi/fpm/www.conf $(INSTALL_ROOT)$(sysconfdir)/default/php-fpm.d/www.conf; \ + fi ++ mkdir -p $(INSTALL_ROOT)$(datarootdir)/init ++ cp init/php-fpm $(INSTALL_ROOT)$(datarootdir)/init/php-fpm ++ mkdir -p '$(INSTALL_ROOT)$(sysconfdir)/default/passwd.d' ++ mkdir -p '$(INSTALL_ROOT)$(sysconfdir)/default/group.d' ++ echo "_php-fpm:x:102:102:_php-fpm:/var/empty:sh" \ ++ > '$(INSTALL_ROOT)$(sysconfdir)/default/passwd.d/php' ++ echo "_php-fpm::102:_php-fpm,_nginx" \ ++ > '$(INSTALL_ROOT)$(sysconfdir)/default/group.d/php' + + @echo "Installing PHP FPM man page: $(INSTALL_ROOT)$(mandir)/man8/" + @$(mkinstalldirs) $(INSTALL_ROOT)$(mandir)/man8 +diff -Paur --no-dereference -- php.upstream/sapi/fpm/fpm/fpm_children.c php/sapi/fpm/fpm/fpm_children.c +--- php.upstream/sapi/fpm/fpm/fpm_children.c ++++ php/sapi/fpm/fpm/fpm_children.c +@@ -272,7 +272,7 @@ + } + } else if (WIFSTOPPED(status)) { + +- zlog(ZLOG_NOTICE, "child %d stopped for tracing", (int) pid); ++ zlog(ZLOG_NOTICE, "child %jd stopped for tracing", (intmax_t) pid); + + if (child && child->tracer) { + child->tracer(child); +@@ -297,9 +297,9 @@ + if (!fpm_pctl_can_spawn_children()) { + severity = ZLOG_DEBUG; + } +- zlog(severity, "[pool %s] child %d exited %s after %ld.%06d seconds from start", wp->config->name, (int) pid, buf, (long)tv2.tv_sec, (int) tv2.tv_usec); ++ zlog(severity, "[pool %s] child %jd exited %s after %ld.%06d seconds from start", wp->config->name, (intmax_t) pid, buf, (long)tv2.tv_sec, (int) tv2.tv_usec); + } else { +- zlog(ZLOG_DEBUG, "[pool %s] child %d has been killed by the process management after %ld.%06d seconds from start", wp->config->name, (int) pid, (long)tv2.tv_sec, (int) tv2.tv_usec); ++ zlog(ZLOG_DEBUG, "[pool %s] child %jd has been killed by the process management after %ld.%06d seconds from start", wp->config->name, (intmax_t) pid, (long)tv2.tv_sec, (int) tv2.tv_usec); + } + + fpm_child_close(child, 1 /* in event_loop */); +@@ -340,9 +340,9 @@ + } + } + } else if (fpm_globals.parent_pid == 1) { +- zlog(ZLOG_DEBUG, "unknown child (%d) exited %s - most likely an orphan process (master process is the init process)", pid, buf); ++ zlog(ZLOG_DEBUG, "unknown child (%jd) exited %s - most likely an orphan process (master process is the init process)", (intmax_t) pid, buf); + } else { +- zlog(ZLOG_WARNING, "unknown child (%d) exited %s - potentially a bug or pre exec child (e.g. s6-notifyoncheck)", pid, buf); ++ zlog(ZLOG_WARNING, "unknown child (%jd) exited %s - potentially a bug or pre exec child (e.g. s6-notifyoncheck)", (intmax_t) pid, buf); + } + } + } +diff -Paur --no-dereference -- php.upstream/sapi/fpm/fpm/fpm_conf.c php/sapi/fpm/fpm/fpm_conf.c +--- php.upstream/sapi/fpm/fpm/fpm_conf.c ++++ php/sapi/fpm/fpm/fpm_conf.c +@@ -1846,6 +1846,20 @@ + return -1; + } + ++ /* PATCH: Search /etc/default for packaged default config. */ ++ if (access(tmp, F_OK) < 0 && errno == ENOENT) { ++ efree(tmp); ++ if (fpm_globals.prefix == NULL) { ++ spprintf(&tmp, 0, "%s/default/php-fpm.conf", PHP_SYSCONFDIR); ++ } else { ++ spprintf(&tmp, 0, "%s/etc/default/php-fpm.conf", fpm_globals.prefix); ++ } ++ if (!tmp) { ++ zlog(ZLOG_SYSERROR, "spprintf() failed (tmp for fpm_globals.config)"); ++ return -1; ++ } ++ } ++ + fpm_globals.config = strdup(tmp); + efree(tmp); + +diff -Paur --no-dereference -- php.upstream/sapi/fpm/fpm/fpm_main.c php/sapi/fpm/fpm/fpm_main.c +--- php.upstream/sapi/fpm/fpm/fpm_main.c ++++ php/sapi/fpm/fpm/fpm_main.c +@@ -1844,6 +1844,14 @@ + } + fpm_is_running = 1; + ++ if (getenv("READYFD")) { ++ int readyfd = atoi(getenv("READYFD")); ++ char c = '\n'; ++ write(readyfd, &c, 1); ++ close(readyfd); ++ unsetenv("READYFD"); ++ } ++ + fcgi_fd = fpm_run(&max_requests); + parent = 0; + +diff -Paur --no-dereference -- php.upstream/sapi/fpm/fpm/fpm_shm.c php/sapi/fpm/fpm/fpm_shm.c +--- php.upstream/sapi/fpm/fpm/fpm_shm.c ++++ php/sapi/fpm/fpm/fpm_shm.c +@@ -19,7 +19,11 @@ + { + void *mem; + ++#if defined(__sortix__) && !defined(__SORTIX_HAS_WORKING_MAP_SHARED__) ++ mem = mmap(0, size, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); ++#else + mem = mmap(0, size, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_SHARED, -1, 0); ++#endif + + #ifdef MAP_FAILED + if (mem == MAP_FAILED) { +diff -Paur --no-dereference -- php.upstream/sapi/fpm/fpm/fpm_trace_pread.c php/sapi/fpm/fpm/fpm_trace_pread.c +--- php.upstream/sapi/fpm/fpm/fpm_trace_pread.c ++++ php/sapi/fpm/fpm/fpm_trace_pread.c +@@ -22,7 +22,7 @@ + int fpm_trace_signal(pid_t pid) /* {{{ */ + { + if (0 > fpm_pctl_kill(pid, FPM_PCTL_STOP)) { +- zlog(ZLOG_SYSERROR, "failed to send SIGSTOP to %d", pid); ++ zlog(ZLOG_SYSERROR, "failed to send SIGSTOP to %jd", (intmax_t)pid); + return -1; + } + return 0; +diff -Paur --no-dereference -- php.upstream/sapi/fpm/fpm/fpm_unix.c php/sapi/fpm/fpm/fpm_unix.c +--- php.upstream/sapi/fpm/fpm/fpm_unix.c ++++ php/sapi/fpm/fpm/fpm_unix.c +@@ -481,10 +481,12 @@ + } + } + if (wp->set_uid) { ++#if !defined(__sortix__) || defined(__SORTIX_HAS_INITGROUPS__) + if (0 > initgroups(wp->set_user ? wp->set_user : wp->config->user, wp->set_gid)) { + zlog(ZLOG_SYSERROR, "[pool %s] failed to initgroups(%s, %d)", wp->config->name, wp->config->user, wp->set_gid); + return -1; + } ++#endif + if (0 > setuid(wp->set_uid)) { + zlog(ZLOG_SYSERROR, "[pool %s] failed to setuid(%d)", wp->config->name, wp->set_uid); + return -1; +diff -Paur --no-dereference -- php.upstream/sapi/fpm/fpm/zlog.c php/sapi/fpm/fpm/zlog.c +--- php.upstream/sapi/fpm/fpm/zlog.c ++++ php/sapi/fpm/fpm/zlog.c +@@ -177,8 +177,8 @@ + } + if (zlog_level == ZLOG_DEBUG) { + if (!fpm_globals.is_child) { +- len += snprintf(buf + len, buf_size - len, "%s: pid %d, %s(), line %d: ", +- level_names[flags & ZLOG_LEVEL_MASK], getpid(), function, line); ++ len += snprintf(buf + len, buf_size - len, "%s: pid %jd, %s(), line %d: ", ++ level_names[flags & ZLOG_LEVEL_MASK], (intmax_t)getpid(), function, line); + } else { + len += snprintf(buf + len, buf_size - len, "%s: %s(), line %d: ", + level_names[flags & ZLOG_LEVEL_MASK], function, line); +diff -Paur --no-dereference -- php.upstream/sapi/fpm/php-fpm.conf.in php/sapi/fpm/php-fpm.conf.in +--- php.upstream/sapi/fpm/php-fpm.conf.in ++++ php/sapi/fpm/php-fpm.conf.in +@@ -140,4 +140,4 @@ + ; Relative path can also be used. They will be prefixed by: + ; - the global prefix if it's been set (-p argument) + ; - @prefix@ otherwise +-include=@php_fpm_sysconfdir@/php-fpm.d/*.conf ++include=@php_fpm_sysconfdir@/default/php-fpm.d/*.conf +diff -Paur --no-dereference -- php.upstream/sapi/fpm/www.conf.in php/sapi/fpm/www.conf.in +--- php.upstream/sapi/fpm/www.conf.in ++++ php/sapi/fpm/www.conf.in +@@ -38,7 +38,8 @@ + ; (IPv6 and IPv4-mapped) on a specific port; + ; '/path/to/unix/socket' - to listen on a unix socket. + ; Note: This value is mandatory. +-listen = 127.0.0.1:9000 ++; listen = 127.0.0.1:9000 ; php upstream default ++listen = /var/run/php-fpm + + ; Set listen(2) backlog. + ; Default Value: 511 (-1 on Linux, FreeBSD and OpenBSD) +diff -Paur --no-dereference -- php.upstream/sapi/phpdbg/phpdbg_prompt.c php/sapi/phpdbg/phpdbg_prompt.c +--- php.upstream/sapi/phpdbg/phpdbg_prompt.c ++++ php/sapi/phpdbg/phpdbg_prompt.c +@@ -54,7 +54,6 @@ + #include "win32/winutil.h" + #define GET_DL_ERROR() php_win_err() + #else +-#include + #define GET_DL_ERROR() DL_ERROR() + #endif + #endif +diff -Paur --no-dereference -- php.upstream/scripts/Makefile.frag php/scripts/Makefile.frag +--- php.upstream/scripts/Makefile.frag ++++ php/scripts/Makefile.frag +@@ -23,8 +23,10 @@ + build/config.guess \ + build/config.sub + +-bin_SCRIPTS = phpize php-config +-man_PAGES = phpize php-config ++# PATCH: pkg-config must be used instead of foo-config. ++# PATCH: phpize is not useful when statically linked. ++bin_SCRIPTS = ++man_PAGES = + + install-build: + @echo "Installing build environment: $(INSTALL_ROOT)$(phpbuilddir)/" +@@ -33,7 +35,7 @@ + $(INSTALL) $(BUILD_FILES_EXEC) $(INSTALL_ROOT)$(phpbuilddir) && \ + $(INSTALL_DATA) $(BUILD_FILES) $(INSTALL_ROOT)$(phpbuilddir)) + +-install-programs: $(builddir)/phpize $(builddir)/php-config ++install-programs: + @echo "Installing helper programs: $(INSTALL_ROOT)$(bindir)/" + @$(mkinstalldirs) $(INSTALL_ROOT)$(bindir) + @for prog in $(bin_SCRIPTS); do \ diff --git a/ports/php/php.port b/ports/php/php.port new file mode 100644 index 00000000..ff3ceb20 --- /dev/null +++ b/ports/php/php.port @@ -0,0 +1,18 @@ +NAME=php +BUILD_LIBRARIES='libiconv libsqlite3 libxml2 libbz2? libcurl? libffi? libintl? libgmp? libreadline? liblzma? libssl? libpcre? libz?' +VERSION=8.3.6 +DISTNAME=$NAME-$VERSION +COMPRESSION=tar.gz +ARCHIVE=$DISTNAME.$COMPRESSION +SHA256SUM=39695f5bd107892e36fd2ed6b3d3a78140fd4b05d556d6c6531a921633cacb5f +UPSTREAM_SITE=https://www.php.net/distributions +UPSTREAM_ARCHIVE=$ARCHIVE +RELEASE_SEARCH_PAGE=https://www.php.net/downloads.php +LICENSE=PHP-3.0 +USE_BOOTSTRAP=true # php uses php to build phar +BOOTSTRAP_BUILD_SYSTEM=configure +BOOTSTRAP_CONFIGURE_ARGS='--with-layout=GNU --disable-cgi --disable-phpdbg --disable-all --enable-phar' +BOOTSTRAP_MAKE_VARS='V=1' +BUILD_SYSTEM=configure +CONFIGURE_ARGS='--with-layout=GNU --disable-opcache --disable-fileinfo --enable-mbstring --disable-mbregex --enable-fpm --with-fpm-user=_php-fpm --with-fpm-group=_php-fpm' +MAKE_VARS='V=1'