frankenphp icon indicating copy to clipboard operation
frankenphp copied to clipboard

Static builder issue with FrankenPHP 1.3.3 and PHP curl extension

Open d8vjork opened this issue 1 year ago • 1 comments

What happened?

Using the FrankenPHP static-builder Docker image provided on the docs is failing with a Laravel app at the spc check process and the libssh2 which seems a requirement of the CURL PHP extension

We didn't have this before on previous versions of this static builder

Build Type

Official static build

Worker Mode

Yes

Operating System

GNU/Linux

CPU Architecture

x86_64

PHP configuration

I don't have PHP on the machine but this is not relevant, we are using the latest version as this static builder script always fetches this

Relevant log output

348.8 libssh2.c:(.text+0x5835): undefined reference to `libssh2_session_block_directions'
348.8 /usr/lib/gcc/x86_64-alpine-linux-musl/14.2.0/../../../../x86_64-alpine-linux-musl/bin/ld: /go/src/app/dist/static-php-cli/buildroot/lib/libcurl.a(libssh2.c.o): in function `ssh_connect':
348.8 libssh2.c:(.text+0x58b5): undefined reference to `libssh2_session_init_ex'
348.8 /usr/lib/gcc/x86_64-alpine-linux-musl/14.2.0/../../../../x86_64-alpine-linux-musl/bin/ld: libssh2.c:(.text+0x5936): undefined reference to `libssh2_knownhost_init'
348.8 /usr/lib/gcc/x86_64-alpine-linux-musl/14.2.0/../../../../x86_64-alpine-linux-musl/bin/ld: libssh2.c:(.text+0x595a): undefined reference to `libssh2_knownhost_readfile'
348.8 /usr/lib/gcc/x86_64-alpine-linux-musl/14.2.0/../../../../x86_64-alpine-linux-musl/bin/ld: libssh2.c:(.text+0x5ac1): undefined reference to `libssh2_session_callback_set2'
348.8 /usr/lib/gcc/x86_64-alpine-linux-musl/14.2.0/../../../../x86_64-alpine-linux-musl/bin/ld: libssh2.c:(.text+0x5ad9): undefined reference to `libssh2_session_callback_set2'
348.8 /usr/lib/gcc/x86_64-alpine-linux-musl/14.2.0/../../../../x86_64-alpine-linux-musl/bin/ld: libssh2.c:(.text+0x5b0e): undefined reference to `libssh2_session_set_read_timeout'
348.8 /usr/lib/gcc/x86_64-alpine-linux-musl/14.2.0/../../../../x86_64-alpine-linux-musl/bin/ld: libssh2.c:(.text+0x5b32): undefined reference to `libssh2_session_flag'
348.8 /usr/lib/gcc/x86_64-alpine-linux-musl/14.2.0/../../../../x86_64-alpine-linux-musl/bin/ld: libssh2.c:(.text+0x5b8c): undefined reference to `libssh2_session_block_directions'
348.8 /usr/lib/gcc/x86_64-alpine-linux-musl/14.2.0/../../../../x86_64-alpine-linux-musl/bin/ld: libssh2.c:(.text+0x5ba8): undefined reference to `libssh2_session_free'
348.8 /usr/lib/gcc/x86_64-alpine-linux-musl/14.2.0/../../../../x86_64-alpine-linux-musl/bin/ld: /go/src/app/dist/static-php-cli/buildroot/lib/libcurl.a(libssh2.c.o): in function `Curl_ssh_init':
348.8 libssh2.c:(.text+0x5be7): undefined reference to `libssh2_init'
348.8 /usr/lib/gcc/x86_64-alpine-linux-musl/14.2.0/../../../../x86_64-alpine-linux-musl/bin/ld: /go/src/app/dist/static-php-cli/buildroot/lib/libcurl.a(libssh2.c.o): in function `Curl_ssh_version':
348.8 libssh2.c:(.text+0x5c1f): undefined reference to `libssh2_version'
348.8 /usr/lib/gcc/x86_64-alpine-linux-musl/14.2.0/../../../../x86_64-alpine-linux-musl/bin/ld: /go/src/app/dist/static-php-cli/buildroot/lib/libcurl.a(libssh2.c.o): in function `Curl_ssh_cleanup':
348.8 libssh2.c:(.text+0x5c01): undefined reference to `libssh2_exit'
349.0 collect2: error: ld returned 1 exit status
349.0 [11:48:52] [ERRO] Uncaught SPC\exception\RuntimeException: embed failed sanity check: build failed. Error message:  at /go/src/app/dist/static-php-cli/src/SPC/builder/unix/UnixBuilderBase.php(194)
349.0 [11:48:52] [ERRO] #0 /go/src/app/dist/static-php-cli/src/SPC/builder/linux/LinuxBuilder.php(208): SPC\builder\unix\UnixBuilderBase->sanityCheck()
349.0 #1 /go/src/app/dist/static-php-cli/src/SPC/command/BuildCliCommand.php(180): SPC\builder\linux\LinuxBuilder->buildPHP()
349.0 #2 /go/src/app/dist/static-php-cli/src/SPC/command/BaseCommand.php(107): SPC\command\BuildCliCommand->handle()
349.0 #3 /go/src/app/dist/static-php-cli/vendor/symfony/console/Command/Command.php(326): SPC\command\BaseCommand->execute()
349.0 #4 /go/src/app/dist/static-php-cli/vendor/symfony/console/Application.php(1078): Symfony\Component\Console\Command\Command->run()
349.0 #5 /go/src/app/dist/static-php-cli/vendor/symfony/console/Application.php(324): Symfony\Component\Console\Application->doRunCommand()
349.0 #6 /go/src/app/dist/static-php-cli/vendor/symfony/console/Application.php(175): Symfony\Component\Console\Application->doRun()
349.0 #7 /go/src/app/dist/static-php-cli/bin/spc(21): Symfony\Component\Console\Application->run()
349.0 #8 {main}
------

d8vjork avatar Jan 07 '25 11:01 d8vjork

Did some tests inside this Docker image and got a solution but I was only able to get there by editing the build-static.sh file

This is my command:

EMBED=dist/app PHP_VERSION=8.3.15 PHP_EXTENSIONS=apcu,bcmath,calendar,ctype,curl,dom,exif,fileinfo,filter,gd,iconv,intl,mbregex,mbstring,mysqlnd,opcache,openssl,pcntl,pdo,pdo_mysql,phar,posix,readline,redis,session,sockets,sodium,sqlite3,ssh2,tokenizer,uuid,xml,xsl,yaml,zip,zlib,zstd PHP_EXTENSION_LIBS=bzip2,freetype,libavif,libjpeg,liblz4,libwebp,libzip,curl,icu,libiconv,libpng,libsodium,libxml2,openssl,postgresql,readline,zlib,zstd,onig,libxslt,libssh2,nghttp2 ./build-static.sh

What happened I think was related to the PHP libs that SPC uses, leaving them blank causes the error (seems like is missing some match around curl or something depending on libssh2 and others)

I edited the build-static.sh file because I wasn't getting any error (it might be only relevant to PHP 8.4+ until SPC fixes its compatibility as its described in the comment above):

https://github.com/dunglas/frankenphp/blob/2f93baf984410056286d0de9a34b97b3d6ccd5f9/build-static.sh#L14

d8vjork avatar Jan 07 '25 16:01 d8vjork