openswoole / ext-openswoole

Programmatic server for PHP with async IO, coroutines and fibers

Home Page:https://openswoole.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PHP 8.3 in Alpine Linux: cannot convert 'std::nullptr_t' to 'size_t' {aka 'long unsigned int'}

mlocati opened this issue · comments

  1. What did you do? If possible, provide a simple script for reproducing the error.

In a docker container launched with: docker run --rm -it php:8.3-rc-cli-alpine3.18 sh

apk add $PHPIZE_DEPS postgresql-libs libstdc++ curl-dev postgresql-dev linux-headers
echo '' | pecl install openswoole-22.1.0
  1. What did you expect to see?

Accordingly to the release notes, compilation should succeed on PHP 8.3.

  1. What did you see instead?
downloading openswoole-22.1.0.tgz ...
Starting to download openswoole-22.1.0.tgz (1,252,350 bytes)
........................................................................................................................................................................................................................................................done: 1,252,350 bytes
485 source files, building
running: phpize
Configuring for:
PHP Api Version:         20230831
Zend Module Api No:      20230831
Zend Extension Api No:   420230831
config.m4:327: warning: The macro `AC_PROG_CC_C99' is obsolete.
config.m4:327: You should run autoupdate.
./lib/autoconf/c.m4:1659: AC_PROG_CC_C99 is expanded from...
config.m4:327: the top level
enable coroutine sockets? [no] : enable openssl support? [no] : enable http2 protocol? [no] : enable coroutine mysqlnd? [no] : enable coroutine curl? [no] : enable coroutine postgres? [no] : building in /tmp/pear/temp/pear-build-defaultuserelceoe/openswoole-22.1.0
running: /tmp/pear/temp/openswoole/configure --with-php-config=/usr/local/bin/php-config --enable-sockets=no --enable-openssl=no --enable-http2=no --enable-mysqlnd=no --enable-hook-curl=no --with-postgres=no
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for a sed that does not truncate output... /bin/sed
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether the compiler supports GNU C... yes
checking whether cc accepts -g... yes
checking for cc option to enable C11 features... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking for system library directory... lib
checking if compiler supports -Wl,-rpath,... yes
checking build system type... x86_64-pc-linux-musl
checking host system type... x86_64-pc-linux-musl
checking target system type... x86_64-pc-linux-musl
checking for PHP prefix... /usr/local
checking for PHP includes... -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib
checking for PHP extension directory... /usr/local/lib/php/extensions/no-debug-non-zts-20230831
checking for PHP installed headers prefix... /usr/local/include/php
checking if debug is enabled... no
checking if zts is enabled... no
checking for gawk... no
checking for nawk... no
checking for awk... awk
checking if awk is broken... no
checking enable debug log... no
checking enable trace log... no
checking enable sockets support... no
checking enable openssl support... no
checking enable HTTP2 support... no
checking openswoole support... yes, shared
checking enable mysqlnd support... no
checking enable PostgreSQL support... no
checking enable c-ares support... no
checking dir of openssl... no
checking dir of jemalloc... no
checking enable asan... no
checking whether to enable coverage testing... no
checking whether to enable developer build flags... no
checking whether to enable Coroutine Hooks for CURL build flags... no
checking whether to enable thread context... no
checking if compiling with clang... no
checking for accept4 in -lc... yes
checking for signalfd in -lc... yes
checking for eventfd in -lc... yes
checking for epoll_create in -lc... yes
checking for poll in -lc... yes
checking for sendfile in -lc... yes
checking for kqueue in -lc... no
checking for backtrace in -lc... no
checking for daemon in -lc... yes
checking for mkostemp in -lc... yes
checking for inotify_init in -lc... yes
checking for malloc_trim in -lc... no
checking for inotify_init1 in -lc... yes
checking for ptrace in -lc... yes
checking for getrandom in -lc... yes
checking for arc4random in -lc... no
checking for pthread_rwlock_init in -lpthread... yes
checking for pthread_spin_lock in -lpthread... yes
checking for pthread_mutex_timedlock in -lpthread... yes
checking for pthread_barrier_init in -lpthread... yes
checking for pthread_mutexattr_setpshared in -lpthread... yes
checking for pthread_mutexattr_setrobust in -lpthread... yes
checking for pthread_mutex_consistent in -lpthread... yes
checking for pcre_compile in -lpcre... no
checking for ares_gethostbyname in -lcares... no
checking for gzgets in -lz... yes
checking for BrotliEncoderCreateInstance in -lbrotlienc... yes
checking for BrotliDecoderCreateInstance in -lbrotlidec... yes
checking for cpu affinity... no
checking for socket REUSEPORT... yes
checking for futex... yes
checking for ucontext... yes
checking for g++... g++
checking whether the compiler supports GNU C++... yes
checking whether g++ accepts -g... yes
checking for g++ option to enable C++11 features... none needed
checking for valgrind... no
checking for stdio.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for strings.h... yes
checking for sys/stat.h... yes
checking for sys/types.h... yes
checking for unistd.h... yes
checking for struct cmsghdr... yes
checking for hstrerror... yes
checking for socketpair... yes
checking for if_nametoindex... yes
checking for if_indextoname... yes
checking for netdb.h... yes
checking for netinet/tcp.h... yes
checking for sys/un.h... yes
checking for sys/sockio.h... no
checking for field ss_family in struct sockaddr_storage... yes
checking if getaddrinfo supports AI_V4MAPPED... yes
checking if getaddrinfo supports AI_ALL... yes
checking if getaddrinfo supports AI_IDN... no
checking if gethostbyname2_r is supported... yes
checking for valgrind... no
checking for clock_gettime in -lrt... yes
checking openssl fallback dir... checking openswoole coverage... enabled
checking whether the compiler supports GNU C++... (cached) yes
checking whether g++ accepts -g... (cached) yes
checking for g++ option to enable C++11 features... (cached) none needed
checking how to run the C++ preprocessor... g++ -E
checking for a sed that does not truncate output... /bin/sed
checking for ld used by cc... /usr/x86_64-alpine-linux-musl/bin/ld
checking if the linker (/usr/x86_64-alpine-linux-musl/bin/ld) is GNU ld... yes
checking for /usr/x86_64-alpine-linux-musl/bin/ld option to reload object files... -r
checking for BSD-compatible nm... /usr/bin/nm -B
checking whether ln -s works... yes
checking how to recognize dependent libraries... pass_all
checking for dlfcn.h... yes
checking how to run the C++ preprocessor... g++ -E
checking the maximum length of command line arguments... 98304
checking command to parse /usr/bin/nm -B output from cc object... ok
checking for objdir... .libs
checking for ar... ar
checking for ranlib... ranlib
checking for strip... strip
checking if cc supports -fno-rtti -fno-exceptions... no
checking for cc option to produce PIC... -fPIC
checking if cc PIC flag -fPIC works... yes
checking if cc static flag -static works... yes
checking if cc supports -c -o file.o... yes
checking whether the cc linker (/usr/x86_64-alpine-linux-musl/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no

creating libtool
appending configuration tag "CXX" to libtool
checking for ld used by g++... /usr/x86_64-alpine-linux-musl/bin/ld -m elf_x86_64
checking if the linker (/usr/x86_64-alpine-linux-musl/bin/ld -m elf_x86_64) is GNU ld... yes
checking whether the g++ linker (/usr/x86_64-alpine-linux-musl/bin/ld -m elf_x86_64) supports shared libraries... yes
checking for g++ option to produce PIC... -fPIC
checking if g++ PIC flag -fPIC works... yes
checking if g++ static flag -static works... yes
checking if g++ supports -c -o file.o... yes
checking whether the g++ linker (/usr/x86_64-alpine-linux-musl/bin/ld -m elf_x86_64) supports shared libraries... yes
checking dynamic linker characteristics... GNU/Linux ld.so
(cached) (cached) checking how to hardcode library paths into programs... immediate
configure: patching config.h.in
configure: creating ./config.status
config.status: creating config.h
running: make
/bin/sh /tmp/pear/temp/pear-build-defaultuserelceoe/openswoole-22.1.0/libtool --mode=compile g++ -I. -I/tmp/pear/temp/openswoole -I/tmp/pear/temp/pear-build-defaultuserelceoe/openswoole-22.1.0/include -I/tmp/pear/temp/pear-build-defaultuserelceoe/openswoole-22.1.0/main -I/tmp/pear/temp/openswoole -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -I/tmp/pear/temp/openswoole -I/tmp/pear/temp/openswoole/include -I/tmp/pear/temp/openswoole/ext-src -I/tmp/pear/temp/openswoole/thirdparty/hiredis  -DHAVE_CONFIG_H  -g -O2 -Wall -Wno-unused-function -Wno-deprecated -Wno-deprecated-declarations -std=c++11    -DENABLE_PHP_SWOOLE -DZEND_COMPILE_DL_EXT=1 -c /tmp/pear/temp/openswoole/ext-src/php_swoole.cc -o ext-src/php_swoole.lo  -MMD -MF ext-src/php_swoole.dep -MT ext-src/php_swoole.lo
mkdir ext-src/.libs
 g++ -I. -I/tmp/pear/temp/openswoole -I/tmp/pear/temp/pear-build-defaultuserelceoe/openswoole-22.1.0/include -I/tmp/pear/temp/pear-build-defaultuserelceoe/openswoole-22.1.0/main -I/tmp/pear/temp/openswoole -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -I/tmp/pear/temp/openswoole -I/tmp/pear/temp/openswoole/include -I/tmp/pear/temp/openswoole/ext-src -I/tmp/pear/temp/openswoole/thirdparty/hiredis -DHAVE_CONFIG_H -g -O2 -Wall -Wno-unused-function -Wno-deprecated -Wno-deprecated-declarations -std=c++11 -DENABLE_PHP_SWOOLE -DZEND_COMPILE_DL_EXT=1 -c /tmp/pear/temp/openswoole/ext-src/php_swoole.cc -MMD -MF ext-src/php_swoole.dep -MT ext-src/php_swoole.lo  -fPIC -DPIC -o ext-src/.libs/php_swoole.o
In file included from /usr/include/c++/12.2.1/clocale:42,
                 from /usr/include/c++/12.2.1/x86_64-alpine-linux-musl/bits/c++locale.h:41,
                 from /usr/include/c++/12.2.1/bits/localefwd.h:40,
                 from /usr/include/c++/12.2.1/string:43,
                 from /tmp/pear/temp/openswoole/include/swoole_log.h:21,
                 from /tmp/pear/temp/openswoole/include/swoole.h:129,
                 from /tmp/pear/temp/openswoole/include/swoole_api.h:21,
                 from /tmp/pear/temp/openswoole/ext-src/php_swoole_private.h:29,
                 from /tmp/pear/temp/openswoole/ext-src/php_swoole_cxx.h:19,
                 from /tmp/pear/temp/openswoole/ext-src/php_swoole.cc:16:
/tmp/pear/temp/openswoole/ext-src/php_swoole_private.h: In function 'char* php_swoole_http_build_query(zval*, size_t*, smart_str*)':
/tmp/pear/temp/openswoole/ext-src/php_swoole_private.h:1050:63: error: cannot convert 'std::nullptr_t' to 'size_t' {aka 'long unsigned int'}
 1050 |         php_url_encode_hash_ex(HASH_OF(zdata), formstr, NULL, NULL, NULL, NULL, NULL, (int) PHP_QUERY_RFC1738);
      |                                                               ^~~~
      |                                                               |
      |                                                               std::nullptr_t
In file included from /tmp/pear/temp/openswoole/ext-src/php_swoole_private.h:43:
/usr/local/include/php/ext/standard/php_http.h:25:64: note:   initializing argument 4 of 'void php_url_encode_hash_ex(HashTable*, smart_str*, const char*, size_t, const zend_string*, zval*, const zend_string*, int)'
   25 |                                 const char *num_prefix, size_t num_prefix_len,
      |                                                         ~~~~~~~^~~~~~~~~~~~~~
make: *** [Makefile:221: ext-src/php_swoole.lo] Error 1
ERROR: `make' failed
  1. What version of OpenSwoole are you using (show your php --ri openswoole)?

22.1.0 (from PECL)

  1. What is your machine environment used (show your uname -a & php -v & gcc -v) ?
$ uname -a
Linux 5514995017c8 5.15.90.1-microsoft-standard-WSL2 #1 SMP Fri Jan 27 02:56:13 UTC 2023 x86_64 Linux

$ php -v
PHP 8.3.0RC5 (cli) (built: Oct 28 2023 01:15:25) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.0RC5, Copyright (c) Zend Technologies

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-alpine-linux-musl/12.2.1/lto-wrapper
Target: x86_64-alpine-linux-musl
Configured with: /home/buildozer/aports/main/gcc/src/gcc-12-20220924/configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --build=x86_64-alpine-linux-musl --host=x86_64-alpine-linux-musl --target=x86_64-alpine-linux-musl --enable-checking=release --disable-fixed-point --disable-libstdcxx-pch --disable-multilib --disable-nls --disable-werror --disable-symvers --enable-__cxa_atexit --enable-default-pie --enable-default-ssp --enable-languages=c,c++,d,objc,go,fortran,ada --disable-libssp --disable-libsanitizer --enable-shared --enable-threads --enable-tls --with-bugurl=https://gitlab.alpinelinux.org/alpine/aports/-/issues --with-system-zlib --with-linker-hash-style=gnu --with-pkgversion='Alpine 12.2.1_git20220924-r10'
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 12.2.1 20220924 (Alpine 12.2.1_git20220924-r10)

I have the same issue with php:8.3.0RC5-fpm-alpine image.

Same issue here, the fix in #342 helped, thanks!