-
-
Notifications
You must be signed in to change notification settings - Fork 268
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
Comments
@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. |
@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) |
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. |
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. |
I haven't tried it yet. Do we need to change |
Only env vars, see above. I think --enable-shared has to be activated and -all-static must be removed as well. |
What if build directly from |
Haven't tried that. I went at it manually. |
The result is that for this issue, we need only update the documentation part, right? |
Negative, the docker script does not work for me.
|
Looks like it's a permission problem. Does it have |
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. |
Edit: Wait, it mounts the bin/setup-runtime file in the container, sorry! |
___| |_ __ _| |_(_) ___ _ __ | |__ _ __
/ __| __/ _` | __| |/ __|____| '_ \| '_ \| '_ \
\__ \ || (_| | |_| | (_|_____| |_) | | | | |_) |
|___/\__\__,_|\__|_|\___| | .__/|_| |_| .__/ 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? |
Ah, it doesn't automatically pass libc=glibc |
I just tried the main branch again locally and found that libacl and attr could not be used correctly under the
|
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 |
I wasn't even aware of that command 😜 |
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 |
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 |
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>
Configurationxdebug
PHP License
|
.env.ini override:
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:
Most of these failures are expected, as they're already built into the php executable,
But this one is not:
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:
The text was updated successfully, but these errors were encountered: