Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loading of dynamic extensions when using --libc=glibc #624

Closed
DubbleClick opened this issue Mar 11, 2025 · 24 comments · Fixed by #636
Closed

Loading of dynamic extensions when using --libc=glibc #624

DubbleClick opened this issue Mar 11, 2025 · 24 comments · Fixed by #636
Labels
kind/php-and-sapi Issues related to php source and SAPI new feature New feature or request

Comments

@DubbleClick
Copy link
Collaborator

.env.ini override:

SPC_DEFAULT_C_FLAGS=-fPIC
SPC_NO_MUSL_PATH=yes
CC=gcc
CXX=g++
AR=ar
LD=ld.gold
SPC_DEFAULT_C_FLAGS=-fPIE
EXTENSION_DIR=/usr/lib64/php/modules
SPC_CMD_PREFIX_PHP_CONFIGURE="${SPC_PHP_DEFAULT_LD_LIBRARY_PATH_CMD} ./configure --prefix= --with-valgrind=no --enable-shared=yes --enable-static=yes --disable-all --disable-cgi --disable-phpdbg --with-pic"
SPC_CMD_VAR_PHP_MAKE_EXTRA_LIBS="-ldl -lpthread -lm"
; EXTRA_LDFLAGS_PROGRAM for `make` php
SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS_PROGRAM="-Wl,-O1 -pie"

Building with:

bin/spc build --build-cli --build-fpm --build-embed "apcu,bcmath,calendar,ctype,curl,dba,dom,exif,fileinfo,filter,gd,iconv,intl,ldap,mbregex,mbstring,mysqli,mysqlnd,opcache,openssl,pcntl,pdo,pdo_mysql,pdo_sqlite,phar,posix,readline,redis,session,simplexml,sockets,sodium,sqlite3,tokenizer,xml,xmlreader,xmlwriter,xsl,zip,zlib" --enable-zts --with-config-file-path="/etc" --with-config-file-scan-dir="/etc/php.d"

Unfortunate, the result of attempting to load dynamic extensions:

[root@svmdev static-php-cli]# buildroot/bin/php -v
PHP Warning:  Failed loading Zend extension 'opcache' (tried: /usr/lib64/php/modules/opcache (/usr/lib64/php/modules/opcache: cannot open shared object file: No such file or directory), /usr/lib64/php/modules/opcache.so (/usr/lib64/php/modules/opcache.so: undefined symbol: compiler_globals)) in Unknown on line 0
PHP Warning:  Failed loading Zend extension 'xdebug-zts.so' (tried: /usr/lib64/php/modules/xdebug-zts.so (/usr/lib64/php/modules/xdebug-zts.so: undefined symbol: compiler_globals), /usr/lib64/php/modules/xdebug-zts.so.so (/usr/lib64/php/modules/xdebug-zts.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
PHP Warning:  PHP Startup: bz2: Unable to initialize module
Module compiled with build ID=API20240924,NTS
PHP    compiled with build ID=API20240924,TS
These options need to match
 in Unknown on line 0
PHP Warning:  Module "calendar" is already loaded in Unknown on line 0
PHP Warning:  Module "ctype" is already loaded in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'curl' (tried: /usr/lib64/php/modules/curl (/usr/lib64/php/modules/curl: cannot open shared object file: No such file or directory), /usr/lib64/php/modules/curl.so (/usr/lib64/php/modules/curl.so: undefined symbol: core_globals)) in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'dom' (tried: /usr/lib64/php/modules/dom (/usr/lib64/php/modules/dom: cannot open shared object file: No such file or directory), /usr/lib64/php/modules/dom.so (/usr/lib64/php/modules/dom.so: undefined symbol: executor_globals)) in Unknown on line 0
PHP Warning:  Module "exif" is already loaded in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'fileinfo' (tried: /usr/lib64/php/modules/fileinfo (/usr/lib64/php/modules/fileinfo: cannot open shared object file: No such file or directory), /usr/lib64/php/modules/fileinfo.so (/usr/lib64/php/modules/fileinfo.so: undefined symbol: file_globals)) in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'ftp' (tried: /usr/lib64/php/modules/ftp (/usr/lib64/php/modules/ftp: cannot open shared object file: No such file or directory), /usr/lib64/php/modules/ftp.so (/usr/lib64/php/modules/ftp.so: undefined symbol: compiler_globals)) in Unknown on line 0
PHP Warning:  Module "gd" is already loaded in Unknown on line 0
PHP Warning:  PHP Startup: gettext: Unable to initialize module
Module compiled with build ID=API20240924,NTS
PHP    compiled with build ID=API20240924,TS
These options need to match
 in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'iconv' (tried: /usr/lib64/php/modules/iconv (/usr/lib64/php/modules/iconv: cannot open shared object file: No such file or directory), /usr/lib64/php/modules/iconv.so (/usr/lib64/php/modules/iconv.so: undefined symbol: sapi_globals)) in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'intl' (tried: /usr/lib64/php/modules/intl (/usr/lib64/php/modules/intl: cannot open shared object file: No such file or directory), /usr/lib64/php/modules/intl.so (/usr/lib64/php/modules/intl.so: undefined symbol: executor_globals)) in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'ldap' (tried: /usr/lib64/php/modules/ldap (/usr/lib64/php/modules/ldap: cannot open shared object file: No such file or directory), /usr/lib64/php/modules/ldap.so (/usr/lib64/php/modules/ldap.so: undefined symbol: compiler_globals)) in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'mbstring' (tried: /usr/lib64/php/modules/mbstring (/usr/lib64/php/modules/mbstring: cannot open shared object file: No such file or directory), /usr/lib64/php/modules/mbstring.so (/usr/lib64/php/modules/mbstring.so: undefined symbol: sapi_globals)) in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'mysqlnd' (tried: /usr/lib64/php/modules/mysqlnd (/usr/lib64/php/modules/mysqlnd: cannot open shared object file: No such file or directory), /usr/lib64/php/modules/mysqlnd.so (/usr/lib64/php/modules/mysqlnd.so: undefined symbol: core_globals)) in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'pdo' (tried: /usr/lib64/php/modules/pdo (/usr/lib64/php/modules/pdo: cannot open shared object file: No such file or directory), /usr/lib64/php/modules/pdo.so (/usr/lib64/php/modules/pdo.so: undefined symbol: executor_globals)) in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'phar' (tried: /usr/lib64/php/modules/phar (/usr/lib64/php/modules/phar: cannot open shared object file: No such file or directory), /usr/lib64/php/modules/phar.so (/usr/lib64/php/modules/phar.so: undefined symbol: compiler_globals)) in Unknown on line 0
PHP Warning:  Module "posix" is already loaded in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'shmop' (tried: /usr/lib64/php/modules/shmop (/usr/lib64/php/modules/shmop: cannot open shared object file: No such file or directory), /usr/lib64/php/modules/shmop.so (/usr/lib64/php/modules/shmop.so: undefined symbol: compiler_globals)) in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'simplexml' (tried: /usr/lib64/php/modules/simplexml (/usr/lib64/php/modules/simplexml: cannot open shared object file: No such file or directory), /usr/lib64/php/modules/simplexml.so (/usr/lib64/php/modules/simplexml.so: undefined symbol: executor_globals)) in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'sodium' (tried: /usr/lib64/php/modules/sodium (/usr/lib64/php/modules/sodium: cannot open shared object file: No such file or directory), /usr/lib64/php/modules/sodium.so (/usr/lib64/php/modules/sodium.so: undefined symbol: compiler_globals)) in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'sqlite3' (tried: /usr/lib64/php/modules/sqlite3 (/usr/lib64/php/modules/sqlite3: cannot open shared object file: No such file or directory), /usr/lib64/php/modules/sqlite3.so (/usr/lib64/php/modules/sqlite3.so: undefined symbol: core_globals)) in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'sysvmsg' (tried: /usr/lib64/php/modules/sysvmsg (/usr/lib64/php/modules/sysvmsg: cannot open shared object file: No such file or directory), /usr/lib64/php/modules/sysvmsg.so (/usr/lib64/php/modules/sysvmsg.so: undefined symbol: executor_globals)) in Unknown on line 0
PHP Warning:  PHP Startup: sysvsem: Unable to initialize module
Module compiled with build ID=API20240924,NTS
PHP    compiled with build ID=API20240924,TS
These options need to match
 in Unknown on line 0
PHP Warning:  PHP Startup: sysvshm: Unable to initialize module
Module compiled with build ID=API20240924,NTS
PHP    compiled with build ID=API20240924,TS
These options need to match
 in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'tokenizer' (tried: /usr/lib64/php/modules/tokenizer (/usr/lib64/php/modules/tokenizer: cannot open shared object file: No such file or directory), /usr/lib64/php/modules/tokenizer.so (/usr/lib64/php/modules/tokenizer.so: undefined symbol: compiler_globals)) in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'xml' (tried: /usr/lib64/php/modules/xml (/usr/lib64/php/modules/xml: cannot open shared object file: No such file or directory), /usr/lib64/php/modules/xml.so (/usr/lib64/php/modules/xml.so: undefined symbol: executor_globals)) in Unknown on line 0
PHP Warning:  Module "xmlwriter" is already loaded in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'xsl' (tried: /usr/lib64/php/modules/xsl (/usr/lib64/php/modules/xsl: cannot open shared object file: No such file or directory), /usr/lib64/php/modules/xsl.so (/usr/lib64/php/modules/xsl.so: undefined symbol: executor_globals)) in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'mysqli' (tried: /usr/lib64/php/modules/mysqli (/usr/lib64/php/modules/mysqli: cannot open shared object file: No such file or directory), /usr/lib64/php/modules/mysqli.so (/usr/lib64/php/modules/mysqli.so: undefined symbol: compiler_globals)) in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'pdo_mysql' (tried: /usr/lib64/php/modules/pdo_mysql (/usr/lib64/php/modules/pdo_mysql: cannot open shared object file: No such file or directory), /usr/lib64/php/modules/pdo_mysql.so (/usr/lib64/php/modules/pdo_mysql.so: undefined symbol: executor_globals)) in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'pdo_sqlite' (tried: /usr/lib64/php/modules/pdo_sqlite (/usr/lib64/php/modules/pdo_sqlite: cannot open shared object file: No such file or directory), /usr/lib64/php/modules/pdo_sqlite.so (/usr/lib64/php/modules/pdo_sqlite.so: undefined symbol: core_globals)) in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'xmlreader' (tried: /usr/lib64/php/modules/xmlreader (/usr/lib64/php/modules/xmlreader: cannot open shared object file: No such file or directory), /usr/lib64/php/modules/xmlreader.so (/usr/lib64/php/modules/xmlreader.so: undefined symbol: executor_globals)) in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'zip.so' (tried: /usr/lib64/php/modules/zip.so (/usr/lib64/php/modules/zip.so: undefined symbol: compiler_globals), /usr/lib64/php/modules/zip.so.so (/usr/lib64/php/modules/zip.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'apcu.so' (tried: /usr/lib64/php/modules/apcu.so (/usr/lib64/php/modules/apcu.so: undefined symbol: zend_signal_globals), /usr/lib64/php/modules/apcu.so.so (/usr/lib64/php/modules/apcu.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
PHP 8.4.4 (cli) (built: Mar 11 2025 13:01:51) (ZTS)
Copyright (c) The PHP Group
Zend Engine v4.4.4, Copyright (c) Zend Technologies
    with Zend OPcache v8.4.4, Copyright (c), by Zend Technologies

Most of these failures are expected, as they're already built into the php executable,

But this one is not:

PHP Warning:  Failed loading Zend extension 'xdebug-zts.so' (tried: /usr/lib64/php/modules/xdebug-zts.so (/usr/lib64/php/modules/xdebug-zts.so: undefined symbol: compiler_globals), /usr/lib64/php/modules/xdebug-zts.so.so (/usr/lib64/php/modules/xdebug-zts.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
PHP Warning:  PHP Startup: bz2: Unable to initialize module
Module compiled with build ID=API20240924,NTS
PHP    compiled with build ID=API20240924,TS
These options need to match
 in Unknown on line 0

xdebug-zts.so was just built by me using pkg config pointing to /opt/static-php-cli/buildroot.

Edit:

Okay, I think the issue itself is almost resolved, but we should fix out php-config output prefix and properly document it.

buildroot/bin/php-config had the prefix empty, which resulted in xdebug ./configure looking at the NTS headers from the system wide php installation, effectively building xdebug for NTS php again.

Patching php-config to point to BUILD_ROOT_PATH:

[root@svmdev static-php-cli]# buildroot/bin/php -v
... blablabla most libs can't be loaded ...
PHP 8.4.4 (cli) (built: Mar 11 2025 13:01:51) (ZTS)
Copyright (c) The PHP Group
Zend Engine v4.4.4, Copyright (c) Zend Technologies
    with Xdebug v3.5.0-dev, Copyright (c) 2002-2024, by Derick Rethans
    with Zend OPcache v8.4.4, Copyright (c), by Zend Technologies
@DubbleClick DubbleClick added the new feature New feature or request label Mar 11, 2025
@crazywhalecc crazywhalecc added the kind/php-and-sapi Issues related to php source and SAPI label Mar 11, 2025
@DubbleClick
Copy link
Collaborator Author

@dunglas this will be very interesting for frankenphp. You could ship a static glibc build that can load xdebug, ffi, blackfire and new relic.

Speaking of which, how is the docker working at the moment? Does it compile php dynamically with and then compile every extension with zts after? If that's the case, I wonder why that's possible in docker containers, but not a single distro ships ZTS packages of php.

@dunglas
Copy link
Contributor

dunglas commented Mar 11, 2025

@DubbleClick Docker images indeed use a dynamic build, and extend the official ZTS images.

For the Linux distributions... that's more difficult indeed. See oerdnj/deb.sury.org#2208 (comment)

@DubbleClick
Copy link
Collaborator Author

Interesting read and yes, I wouldn't have expected the distros to maintain both ZTS and NTS packages of php. It was (from what I've gathered) a huge mess in the transition phase of mod_php (ZTS) to php-fpm (NTS).

Optimally, php would become thread safe by default and get rid of the distinction, but I'm not in a position to judge how realistic that would be.

Maybe just FrankenPHP (static but with glibc, all extensions and libraries included) and FrankenPHP-XDebug and FrankenPHP-FFI packages would be more realistic. Only problem would be the file size.

@DubbleClick
Copy link
Collaborator Author

Oh, just to make sure I don't forget, if you plan to ship a glibc static build of FrankenPHP, make sure to take out the --disable-opcache-jit. It works fine when using SPC on RHEL/Ubuntu.

@DubbleClick
Copy link
Collaborator Author

image

Cool, it worked

@crazywhalecc
Copy link
Owner

I haven't tried it yet. Do we need to change src or only env vars?

@DubbleClick
Copy link
Collaborator Author

Only env vars, see above. I think --enable-shared has to be activated and -all-static must be removed as well.

@crazywhalecc
Copy link
Owner

crazywhalecc commented Mar 13, 2025

What if build directly from bin/spc-gnu-docker? It has removed -all-static and can include the ffi extension and run normally.

@DubbleClick
Copy link
Collaborator Author

Haven't tried that. I went at it manually.

@crazywhalecc
Copy link
Owner

The result is that for this issue, we need only update the documentation part, right?

@DubbleClick
Copy link
Collaborator Author

Negative, the docker script does not work for me.

 => CACHED [10/20] RUN curl -o cmake.tgz -fsSL https://github.com/Kitware/CMake/releases/download/v3.31.4/cmake-3  0.0s
 => CACHED [11/20] WORKDIR /app                                                                                    0.0s
 => CACHED [12/20] ADD ./src /app/src                                                                              0.0s
 => CACHED [13/20] COPY ./composer.* /app/                                                                         0.0s
 => CACHED [14/20] ADD ./bin/setup-runtime /app/bin/setup-runtime                                                  0.0s
 => CACHED [15/20] ADD ./bin/spc /app/bin/spc                                                                      0.0s
 => ERROR [16/20] RUN /app/bin/setup-runtime                                                                       0.2s
------
 > [16/20] RUN /app/bin/setup-runtime:
0.135 /bin/sh: /app/bin/setup-runtime: Permission denied
------
Dockerfile:21
--------------------
  19 |     ADD ./bin/setup-runtime /app/bin/setup-runtime
  20 |     ADD ./bin/spc /app/bin/spc
  21 | >>> RUN /app/bin/setup-runtime
  22 |     RUN /app/bin/php /app/bin/composer install --no-dev --classmap-authoritative
  23 |     ENV PATH="/app/bin:/cmake/bin:/root/.local/bin:/root/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin"
--------------------
ERROR: failed to solve: process "/bin/sh -c /app/bin/setup-runtime" did not complete successfully: exit code: 126

@crazywhalecc
Copy link
Owner

Negative, the docker script does not work for me.

Looks like it's a permission problem. Does it have x permission? If you use git clone, you should get a bin file with x permissions by default. But if the host where the docker command is executed is Windows, I'm not sure.

@DubbleClick
Copy link
Collaborator Author

That's inside the dockerfile. I can't give it permissions from the host system since the file doesn't even exist on the hostsytem.

@DubbleClick
Copy link
Collaborator Author

Edit: Wait, it mounts the bin/setup-runtime file in the container, sorry!

@DubbleClick
Copy link
Collaborator Author

DubbleClick commented Mar 13, 2025

bin/spc-gnu-docker build "intl,ffi" --enable-zts --build-embed --build-cli --debug

 ___| |_ __ _| |_(_) ___      _ __ | |__  _ __
/ __| __/ _` | __| |/ __|____| '_ \| '_ \| '_ \
\__ \ || (_| | |_| | (_|_____| |_) | | | | |_) |
|___/\__\__,_|\__|_|\___|    | .__/|_| |_| .__/   v2.5.0
                             |_|         |_|
[04:26:27] [I] argv: bin/spc build intl,ffi --enable-zts --build-embed --build-cli --debug
[04:26:27] [I] Setting env: SPC_LIBC=musl-wrapper
[04:26:27] [I] Setting env: PATH=/app/buildroot/bin:/app/bin:/cmake/bin:/root/.local/bin:/root/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
[04:26:27] [I] Setting env: PKG_CONFIG=/app/buildroot/bin/pkg-config
[04:26:27] [I] Setting env: PKG_CONFIG_PATH=/app/buildroot/lib/pkgconfig
[04:26:27] [I] Setting env: SPC_PHP_DEFAULT_OPTIMIZE_CFLAGS=-g -fstack-protector-strong -fpic -fpie -Os -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
[04:26:27] [I] Setting env: SPC_LINUX_DEFAULT_CC=x86_64-linux-musl-gcc
[04:26:27] [I] Setting env: SPC_LINUX_DEFAULT_CXX=x86_64-linux-musl-g++
[04:26:27] [I] Setting env: SPC_LINUX_DEFAULT_AR=x86_64-linux-musl-ar
[04:26:27] [I] Setting env: SPC_CONCURRENCY=6
[04:26:27] [I] Setting env: SPC_SKIP_PHP_VERSION_CHECK=no
[04:26:27] [I] Setting env: EXTENSION_DIR=
[04:26:27] [I] Setting env: SPC_DEFAULT_CXX_FLAGS=
[04:26:27] [I] Setting env: SPC_EXTRA_LIBS=
[04:26:27] [I] Setting env: UPX_EXEC=/app/pkgroot/bin/upx
[04:26:27] [I] Setting env: SPC_MICRO_PATCHES=static_extensions_win32,cli_checks,disable_huge_page,vcruntime140,win32,zend_stream
[04:26:27] [I] Setting env: SPC_CMD_PREFIX_PHP_BUILDCONF=./buildconf --force
[04:26:27] [I] Setting env: SPC_CMD_PREFIX_PHP_CONFIGURE=./configure --prefix= --with-valgrind=no --enable-shared=no --enable-static=yes --disable-all --disable-cgi --disable-phpdbg --with-pic
[04:26:27] [I] Setting env: SPC_CMD_PREFIX_PHP_MAKE=make -j6
[04:26:27] [I] Setting env: SPC_CMD_VAR_PHP_EMBED_TYPE=static
[04:26:27] [I] Setting env: SPC_CMD_VAR_PHP_CONFIGURE_CFLAGS=-fPIE -fPIC -fPIE
[04:26:27] [I] Setting env: SPC_CMD_VAR_PHP_CONFIGURE_CPPFLAGS=-I/app/buildroot/include
[04:26:27] [I] Setting env: SPC_CMD_VAR_PHP_CONFIGURE_LDFLAGS=-L/app/buildroot/lib
[04:26:27] [I] Setting env: SPC_CMD_VAR_PHP_CONFIGURE_LIBS=-ldl -lpthread -lm
[04:26:27] [I] Setting env: SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS=-g -fstack-protector-strong -fpic -fpie -Os -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fno-ident -fPIE -fPIC
[04:26:27] [I] making cmake tool chain file for Linux x86_64 with CFLAGS='-fPIE -fPIC'
[04:26:27] [I] Dir /app/buildroot/lib/pkgconfig already exists, ignored
[04:26:27] [I] Dir /app/buildroot/include already exists, ignored
[04:26:27] [I] Init var [BUILD_ROOT_PATH]:                    /app/buildroot
[04:26:27] [I] Init var [BUILD_INCLUDE_PATH]:                 /app/buildroot/include
[04:26:27] [I] Init var [BUILD_LIB_PATH]:                     /app/buildroot/lib
[04:26:27] [I] Init var [BUILD_BIN_PATH]:                     /app/buildroot/bin
[04:26:27] [I] Init var [PKG_ROOT_PATH]:                      /app/pkgroot
[04:26:27] [I] Init var [SOURCE_PATH]:                        /app/source
[04:26:27] [I] Init var [DOWNLOAD_PATH]:                      /app/downloads
[04:26:27] [I] Init var [CPU_COUNT]:                          6
[04:26:27] [I] Init var [GNU_ARCH]:                           x86_64
[04:26:27] [I] Init var [MAC_ARCH]:                           x86_64
[04:26:27] [I] Init var [PATH]:                               /app/buildroot/bin:/app/bin:/cmake/bin:/root/.local/bin:/root/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
[04:26:27] [I] Init var [PKG_CONFIG]:                         /app/buildroot/bin/pkg-config
[04:26:27] [I] Init var [PKG_CONFIG_PATH]:                    /app/buildroot/lib/pkgconfig
[04:26:27] [I] Init var [SPC_PHP_DEFAULT_OPTIMIZE_CFLAGS]:    -g -fstack-protector-strong -fpic -fpie -Os -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
[04:26:27] [I] Init var [SPC_LINUX_DEFAULT_CC]:               x86_64-linux-musl-gcc
[04:26:27] [I] Init var [SPC_LINUX_DEFAULT_CXX]:              x86_64-linux-musl-g++
[04:26:27] [I] Init var [SPC_LINUX_DEFAULT_AR]:               x86_64-linux-musl-ar
[04:26:27] [I] Init var [SPC_CONCURRENCY]:                    6
[04:26:27] [I] Init var [SPC_SKIP_PHP_VERSION_CHECK]:         no
[04:26:27] [I] Init var [EXTENSION_DIR]:
[04:26:27] [I] Init var [SPC_DEFAULT_CXX_FLAGS]:
[04:26:27] [I] Init var [SPC_EXTRA_LIBS]:
[04:26:27] [I] Init var [UPX_EXEC]:                           /app/pkgroot/bin/upx
[04:26:27] [I] Init var [SPC_MICRO_PATCHES]:                  static_extensions_win32,cli_checks,disable_huge_page,vcruntime140,win32,zend_stream
[04:26:27] [I] Init var [SPC_CMD_PREFIX_PHP_BUILDCONF]:       ./buildconf --force
[04:26:27] [I] Init var [SPC_CMD_PREFIX_PHP_CONFIGURE]:       ./configure --prefix= --with-valgrind=no --enable-shared=no --enable-static=yes --disable-all --disable-cgi --disable-phpdbg --with-pic
[04:26:27] [I] Init var [SPC_CMD_PREFIX_PHP_MAKE]:            make -j6
[04:26:27] [I] Init var [SPC_CMD_VAR_PHP_EMBED_TYPE]:         static
[04:26:27] [I] Init var [SPC_CMD_VAR_PHP_CONFIGURE_CFLAGS]:   -fPIE -fPIC -fPIE
[04:26:27] [I] Init var [SPC_CMD_VAR_PHP_CONFIGURE_CPPFLAGS]: -I/app/buildroot/include
[04:26:27] [I] Init var [SPC_CMD_VAR_PHP_CONFIGURE_LDFLAGS]:  -L/app/buildroot/lib
[04:26:27] [I] Init var [SPC_CMD_VAR_PHP_CONFIGURE_LIBS]:     -ldl -lpthread -lm
[04:26:27] [I] Init var [SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS]:  -g -fstack-protector-strong -fpic -fpie -Os -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fno-ident -fPIE -fPIC
[04:26:27] [I] Build OS:         Linux (x86_64)
[04:26:27] [I] Build SAPI:       cli, embed
[04:26:27] [I] Extensions (2):   intl,ffi
[04:26:27] [I] Libraries (6):    pkg-config,icu,libffi
[04:26:27] [I] Strip Binaries:   yes
[04:26:27] [I] Enable ZTS:       yes
[04:26:27] [I] Config File Path: /usr/local/etc/php
[04:26:27] [I] PHP Version:      8.4.4
[04:26:27] [I] Build will start after 2s ...
[04:26:29] [I] scanning directory /app/src/SPC/builder/linux/library
[04:26:29] [I] scanning directory /app/src/SPC/builder/extension
[04:26:29] [I] Source [php-src] already extracted in /app/source/php-src, skip !
[04:26:29] [I] Source [micro] already extracted in /app/source/php-src/sapi/micro, skip !
[04:26:29] [I] Building required package [pkg-config]
[04:26:29] [I] Entering dir: /app/source/pkg-config
[04:26:29] [I] [EXEC] CFLAGS="-fPIE -fPIC " LDFLAGS=" --static" ./configure --disable-shared --enable-static --with-internal-glib --disable-host-tool --with-pic --prefix=/app/buildroot --without-sysroot --without-system-include-path --without-system-library-path --without-pc-path
[04:26:29] [I] Executed at: /app/src/SPC/util/UnixShell.php:88
[04:26:29] [I] [PASSTHRU] cd '/app/source/pkg-config' && CFLAGS="-fPIE -fPIC " LDFLAGS=" --static" ./configure --disable-shared --enable-static --with-internal-glib --disable-host-tool --with-pic --prefix=/app/buildroot --without-sysroot --without-system-include-path --without-system-library-path --without-pc-path
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking how to print strings... printf
checking for style of include used by make... GNU
checking for gcc... /opt/rh/devtoolset-10/root/usr/bin/gcc
checking whether the C compiler works... no
configure: error: in `/app/source/pkg-config':
configure: error: C compiler cannot create executables
See `config.log' for more details
[04:26:30] [I] Uncaught SPC\exception\RuntimeException: Command run failed with code[77]: cd '/app/source/pkg-config' && CFLAGS="-fPIE -fPIC " LDFLAGS=" --static" ./configure --disable-shared --enable-static --with-internal-glib --disable-host-tool --with-pic --prefix=/app/buildroot --without-sysroot --without-system-include-path --without-system-library-path --without-pc-path at /app/src/globals/functions.php(166)
[04:26:30] [I] #0 /app/src/SPC/util/UnixShell.php(51): f_passthru('cd '/app/source...')
#1 /app/src/SPC/util/UnixShell.php(88): SPC\util\UnixShell->exec('cd '/app/source...')
#2 /app/src/SPC/builder/unix/library/pkgconfig.php(18): SPC\util\UnixShell->execWithEnv('./configure --d...')
#3 /app/src/SPC/builder/LibraryBase.php(231): SPC\builder\linux\library\pkgconfig->build()
#4 /app/src/SPC/builder/LibraryBase.php(255): SPC\builder\LibraryBase->tryBuild(true)
#5 /app/src/SPC/builder/LibraryBase.php(51): SPC\builder\LibraryBase->tryBuild(false)
#6 /app/src/SPC/builder/BuilderBase.php(66): SPC\builder\LibraryBase->setup(false)
#7 /app/src/SPC/command/BuildCliCommand.php(162): SPC\builder\BuilderBase->setupLibs()
#8 /app/src/SPC/command/BaseCommand.php(106): SPC\command\BuildCliCommand->handle()
#9 /app/vendor/symfony/console/Command/Command.php(326): SPC\command\BaseCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#10 /app/vendor/symfony/console/Application.php(1078): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#11 /app/vendor/symfony/console/Application.php(324): Symfony\Component\Console\Application->doRunCommand(Object(SPC\command\BuildCliCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#12 /app/vendor/symfony/console/Application.php(175): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#13 /app/bin/spc(31): Symfony\Component\Console\Application->run()

I think it's trying to use the wrong compiler? Do I need to change the config in the host system?

@DubbleClick
Copy link
Collaborator Author

Ah, it doesn't automatically pass libc=glibc

@crazywhalecc
Copy link
Owner

crazywhalecc commented Mar 13, 2025

I just tried the main branch again locally and found that libacl and attr could not be used correctly under the bin/spc spc-config command because the compiled SAPI was not passed in and there was no corresponding patch code.

[04:46:20] [I] running embed sanity check
[04:46:20] [I] Entering dir: /app/source/embed-test
[04:46:20] [I] [EXEC] /opt/rh/devtoolset-10/root/usr/bin/gcc -o embed embed.c -I/app/buildroot/include -I/app/buildroot/include/php -I/app/buildroot/include/php/main -I/app/buildroot/include/php/TSRM -I/app/buildroot/include/php/Zend -I/app/buildroot/include/php/ext -L/app/buildroot/lib -lphp -lc -lffi -lacl -lattr -licui18n -licuio -licuuc -licudata -ldl -lpthread -lm -lresolv -lutil -lrt -lstdc++
[04:46:20] [I] Executed at: /app/src/SPC/builder/unix/UnixBuilderBase.php:191
/opt/rh/devtoolset-10/root/usr/libexec/gcc/aarch64-redhat-linux/10/ld: cannot find -lacl
/opt/rh/devtoolset-10/root/usr/libexec/gcc/aarch64-redhat-linux/10/ld: cannot find -lattr
collect2: error: ld returned 1 exit status
[04:46:21] [I] Uncaught SPC\exception\RuntimeException: embed failed sanity check: build failed. Error message:  at /app/src/SPC/builder/unix/UnixBuilderBase.php(193)
[04:46:21] [I] #0 /app/src/SPC/builder/linux/LinuxBuilder.php(221): SPC\builder\unix\UnixBuilderBase->sanityCheck(9)
#1 /app/src/SPC/command/BuildCliCommand.php(184): SPC\builder\linux\LinuxBuilder->buildPHP(9)
#2 /app/src/SPC/command/BaseCommand.php(106): SPC\command\BuildCliCommand->handle()
#3 /app/vendor/symfony/console/Command/Command.php(326): SPC\command\BaseCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#4 /app/vendor/symfony/console/Application.php(1078): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#5 /app/vendor/symfony/console/Application.php(324): Symfony\Component\Console\Application->doRunCommand(Object(SPC\command\BuildCliCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#6 /app/vendor/symfony/console/Application.php(175): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#7 /app/bin/spc(31): Symfony\Component\Console\Application->run()
#8 {main}

BTW, the current default error output is really overly verbose and barely helpful.

@DubbleClick
Copy link
Collaborator Author

I'm confused by that error. If you have --build-fpm, it will builkd -lacl and -lattr. If you don't use --build-fpm, the libraries won't build and therefore also shouldn't be added.

@crazywhalecc
Copy link
Owner

crazywhalecc commented Mar 13, 2025

I'm confused by that error. If you have --build-fpm, it will builkd -lacl and -lattr. If you don't use --build-fpm, the libraries won't build and therefore also shouldn't be added.

we removed libraries in BuildCliCommand:

if (PHP_OS_FAMILY !== 'Linux' || !($rule & BUILD_TARGET_FPM)) {
    $libraries = array_filter($libraries, fn ($lib) => !in_array($lib, ['attr', 'libacl']));
}

but SPCConfigCommand does not. And when we use spc-config, it's not passing --build-fpm to it. So the DependencyUtil thinks it depends on libacl. But the result is we didn't build it when building embed SAPI.

@DubbleClick
Copy link
Collaborator Author

I wasn't even aware of that command 😜

@DubbleClick
Copy link
Collaborator Author

Hmm, yeah, I had a look. I think there's no good way to handle dependencies for only one build target at the moment. We either need to always build it, even if it's potentially unused, or run into problems in many places.

But building it in the bin/spc-gnu.-docker doesn't work because the autopoint version is too low (1.13 instead of 1.15 required)

configure.ac:24: error: require Automake 1.15, but have 1.13.4

@DubbleClick
Copy link
Collaborator Author

Yeah, sadly I think our best course of action is to just make it optional. When building fpm, people can use --with-libs="libacl" to build fpm with support :/

@crazywhalecc
Copy link
Owner

Yeah, sadly I think our best course of action is to just make it optional. When building fpm, people can use --with-libs="libacl" to build fpm with support :/

Makes sense. And we also need to download and update autopoint in gnu docker, same as make and cmake.

@DubbleClick
Copy link
Collaborator Author

DubbleClick commented Mar 13, 2025

Built with bin/spc-gnu-docker, loaded xdebug zts 3.5.0 dev from /usr/lib64/php/modules/xdebug-zts.so

<title>PHP 8.4.4 - phpinfo()</title>
PHP logo

PHP Version 8.4.4

System Linux svmdev.college.local 5.14.0-427.24.1.el9_4.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Jul 9 15:32:20 EDT 2024 x86_64
Build Date Mar 13 2025 08:22:09
Build System Linux 6991ab8b07a4 5.14.0-427.24.1.el9_4.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Jul 9 15:32:20 EDT 2024 x86_64 x86_64 x86_64 GNU/Linux
Configure Command './configure' '--prefix=' '--with-valgrind=no' '--enable-shared=no' '--enable-static=yes' '--disable-all' '--disable-cgi' '--disable-phpdbg' '--with-pic' '--enable-cli' '--disable-fpm' '--enable-embed=static' '--disable-micro' '--with-config-file-path=/usr/local/etc/php' '--with-config-file-scan-dir=/usr/local/etc/php/conf.d' '--enable-zts' '--disable-zend-signals' '--enable-zend-max-execution-timers' '--with-amqp' '--with-librabbitmq-dir=/app/buildroot' '--enable-apcu' '--enable-ast' '--enable-bcmath' '--with-bz2=/app/buildroot' '--enable-calendar' '--enable-ctype' '--with-curl' '--enable-dba' '--enable-dio' '--enable-dom' '--enable-ds' '--with-zlib' '--enable-sockets' '--with-event-core' '--with-event-extra' '--with-event-libevent-dir=/app/buildroot' '--with-event-openssl=/app/buildroot' '--enable-event-sockets' '--enable-exif' '--enable-fileinfo' '--enable-filter' '--enable-ftp' '--enable-gd' '--with-freetype' '--with-jpeg' '--with-webp' '--with-avif' '--with-gettext=/app/buildroot' '--with-gmp=/app/buildroot' '--with-iconv=/app/buildroot' '--enable-session' '--with-imagick=/app/buildroot' '--enable-inotify' '--enable-intl' '--with-ldap=/app/buildroot' '--enable-xml' '--enable-mbstring' '--enable-mbregex' '--enable-memcache' '--with-zlib-dir=/app/buildroot' '--enable-mongodb' '--with-mongodb-system-libs=no' '--with-mongodb-client-side-encryption=no' '--with-mongodb-sasl=no' '--with-mongodb-ssl=openssl' '--with-mongodb-icu=yes' '--with-mongodb-zstd=yes' '--with-mongodb-zlib=yes' '--with-msgpack' '--enable-mysqlnd' '--with-mysqli' '--enable-opcache' '--enable-opentelemetry' '--enable-parallel' '--with-password-argon2=/app/buildroot' '--enable-pcntl' '--enable-pdo' '--with-pdo-mysql' '--with-pgsql' 'PGSQL_CFLAGS=-I/app/buildroot/include' 'PGSQL_LIBS=-L/app/buildroot/lib -lpq -lpgport -lpgcommon' '--with-pdo-pgsql=/app/buildroot' '--with-sqlite3=/app/buildroot' '--with-pdo-sqlite' '--enable-phar' '--enable-posix' '--enable-protobuf' '--enable-rar' '--with-readline=/app/buildroot' '--enable-redis' '--enable-redis-session' '--enable-redis-igbinary' '--enable-redis-zstd' '--enable-redis-lz4' '--with-liblz4=/app/buildroot' '--enable-simplexml' '--with-sodium' '--enable-sqlsrv' '--with-ssh2=/app/buildroot' '--enable-swow' '--enable-swow-ssl' '--enable-swow-curl' '--enable-sysvmsg' '--enable-sysvsem' '--enable-sysvshm' '--with-tidy=/app/buildroot' '--enable-tokenizer' '--with-uuid=/app/buildroot' '--with-uv=/app/buildroot' '--with-zip=/app/buildroot' '--with-xlswriter' '--enable-reader' '--with-openssl=/app/buildroot' '--enable-xmlreader' '--enable-xmlwriter' '--with-libxml=/app/buildroot' '--with-xsl=/app/buildroot' '--enable-yac' '--enable-igbinary' '--enable-json' '--with-yaml=/app/buildroot' '--enable-zstd' '--with-libzstd=/app/buildroot' 'PKG_CONFIG=/app/buildroot/bin/pkg-config' 'PKG_CONFIG_PATH=/app/buildroot/lib/pkgconfig' 'EXTENSION_DIR='
Server API Built-in HTTP server
Virtual Directory Support enabled
Configuration File (php.ini) Path /usr/local/etc/php
Loaded Configuration File /usr/local/etc/php/php.ini
Scan this dir for additional .ini files /usr/local/etc/php/conf.d
Additional .ini files parsed /usr/local/etc/php/conf.d/10-opcache.ini, /usr/local/etc/php/conf.d/15-xdebug.ini, /usr/local/etc/php/conf.d/20-bz2.ini, /usr/local/etc/php/conf.d/20-calendar.ini, /usr/local/etc/php/conf.d/20-ctype.ini, /usr/local/etc/php/conf.d/20-curl.ini, /usr/local/etc/php/conf.d/20-dom.ini, /usr/local/etc/php/conf.d/20-exif.ini, /usr/local/etc/php/conf.d/20-fileinfo.ini, /usr/local/etc/php/conf.d/20-ftp.ini, /usr/local/etc/php/conf.d/20-gd.ini, /usr/local/etc/php/conf.d/20-gettext.ini, /usr/local/etc/php/conf.d/20-iconv.ini, /usr/local/etc/php/conf.d/20-intl.ini, /usr/local/etc/php/conf.d/20-ldap.ini, /usr/local/etc/php/conf.d/20-mbstring.ini, /usr/local/etc/php/conf.d/20-mysqlnd.ini, /usr/local/etc/php/conf.d/20-pdo.ini, /usr/local/etc/php/conf.d/20-phar.ini, /usr/local/etc/php/conf.d/20-posix.ini, /usr/local/etc/php/conf.d/20-shmop.ini, /usr/local/etc/php/conf.d/20-simplexml.ini, /usr/local/etc/php/conf.d/20-sodium.ini, /usr/local/etc/php/conf.d/20-sqlite3.ini, /usr/local/etc/php/conf.d/20-sysvmsg.ini, /usr/local/etc/php/conf.d/20-sysvsem.ini, /usr/local/etc/php/conf.d/20-sysvshm.ini, /usr/local/etc/php/conf.d/20-tokenizer.ini, /usr/local/etc/php/conf.d/20-xml.ini, /usr/local/etc/php/conf.d/20-xmlwriter.ini, /usr/local/etc/php/conf.d/20-xsl.ini, /usr/local/etc/php/conf.d/30-mysqli.ini, /usr/local/etc/php/conf.d/30-pdo_mysql.ini, /usr/local/etc/php/conf.d/30-pdo_sqlite.ini, /usr/local/etc/php/conf.d/30-xmlreader.ini, /usr/local/etc/php/conf.d/30-zip.ini, /usr/local/etc/php/conf.d/40-apcu.ini, /usr/local/etc/php/conf.d/99-blackfire.ini
PHP API 20240924
PHP Extension 20240924
Zend Extension 420240924
Zend Extension Build API420240924,TS
PHP Extension Build API20240924,TS
PHP Integer Size 64 bits
Debug Build no
Thread Safety enabled
Thread API POSIX Threads
Zend Signal Handling disabled
Zend Memory Manager enabled
Zend Multibyte Support provided by mbstring
Zend Max Execution Timers enabled
IPv6 Support enabled
DTrace Support disabled
Registered PHP Streamshttps, ftps, compress.zlib, compress.bzip2, dio.raw, dio.serial, php, file, glob, data, http, ftp, rar, sqlsrv, ssh2.shell, ssh2.exec, ssh2.tunnel, ssh2.scp, ssh2.sftp, phar, zip, compress.zstd
Registered Stream Socket Transportstcp, udp, unix, udg, ssl, tls, tlsv1.0, tlsv1.1, tlsv1.2, tlsv1.3, pipe
Registered Stream Filterszlib.*, bzip2.*, string.rot13, string.toupper, string.tolower, convert.*, consumed, dechunk, convert.iconv.*
Zend logo This program makes use of the Zend Scripting Language Engine:
Zend Engine v4.4.4, Copyright (c) Zend Technologies with Xdebug v3.5.0-dev, Copyright (c) 2002-2024, by Derick Rethans with Zend OPcache v8.4.4, Copyright (c), by Zend Technologies

Configuration

xdebug

<title>Xdebug</title>
Version 3.5.0-dev
Support Xdebug on Patreon, GitHub, or as a business
Enabled Features
(through 'xdebug.mode' setting)
FeatureEnabled/DisabledDocs
Development Helpers✘ disabled
Coverage✘ disabled
GC Stats✘ disabled
Profiler✘ disabled
Step Debugger✔ enabled
Tracing✘ disabled
PHP Documentation
Authors Mehdi Achour, Friedhelm Betz, Antony Dovgal, Nuno Lopes, Hannes Magnusson, Philip Olson, Georg Richter, Damien Seguy, Jakub Vrana, Adam Harvey
Editor Peter Cowburn
User Note Maintainers Daniel P. Brown, Thiago Henrique Pojda
Other Contributors Previously active authors, editors and other contributors are listed in the manual.
PHP Quality Assurance Team
Ilia Alshanetsky, Joerg Behrens, Antony Dovgal, Stefan Esser, Moriyoshi Koizumi, Magnus Maatta, Sebastian Nohn, Derick Rethans, Melvyn Sopacua, Pierre-Alain Joye, Dmitry Stogov, Felipe Pena, David Soria Parra, Stanislav Malyshev, Julien Pauli, Stephen Zarkos, Anatol Belski, Remi Collet, Ferenc Kovacs
Websites and Infrastructure team
PHP Websites Team Rasmus Lerdorf, Hannes Magnusson, Philip Olson, Lukas Kahwe Smith, Pierre-Alain Joye, Kalle Sommer Nielsen, Peter Cowburn, Adam Harvey, Ferenc Kovacs, Levi Morrison
Event Maintainers Damien Seguy, Daniel P. Brown
Network Infrastructure Daniel P. Brown
Windows Infrastructure Alex Schoenmaker

PHP License

This program is free software; you can redistribute it and/or modify it under the terms of the PHP License as published by the PHP Group and included in the distribution in the file: LICENSE

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

If you did not receive a copy of the PHP license, or have any questions about PHP licensing, please contact [email protected].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/php-and-sapi Issues related to php source and SAPI new feature New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants