Skip to content

Building static binary through build-static.sh fails on Linux #2395

@nook24

Description

@nook24

What happened?

Hi,

I noticed that the build-static.sh script fails to run on Linux (arm64 in my case). I try to build a custom
version of FrankenPHP as I need the gearman extension.

In my case, the build already fails, when I go with the defaults from the build-static.sh - no changes so far.

Steps to reproduce

docker run --rm -it php:8.4-zts-trixie bash
apt-get update
apt-get install -y libgearman-dev sudo build-essential curl git vim
apt-get install -y bison flex automake autopoint unzip cmake libtool pkg-config 


export PHP_EXTENSIONS="amqp,apcu,ast,bcmath,brotli,bz2,calendar,ctype,curl,dba,dom,exif,fileinfo,filter,ftp,gd,gmp,gettext,iconv,igbinary,imagick,intl,ldap,lz4,mbregex,mbstring,memcached,mysqli,mysqlnd,opcache,openssl,password-argon2,parallel,pcntl,pdo,pdo_mysql,pdo_pgsql,pdo_sqlite,pgsql,phar,posix,protobuf,readline,redis,session,shmop,simplexml,soap,sockets,sodium,sqlite3,ssh2,sysvmsg,sysvsem,sysvshm,tidy,tokenizer,xlswriter,xml,xmlreader,xmlwriter,xsl,xz,zip,zlib,yaml,zstd"


php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php composer-setup.php
mv composer.phar /usr/local/bin/composer

git clone https://github.com/php/frankenphp
cd frankenphp
./build-static.sh

Build fails with export SPC_LIBC=glibc

[18:02:10] [I] [EXEC] ./embed
⚠ Validation failed: embed failed to run. Error message:
Warning: Failed loading Zend extension 'opcache' (tried: /lib/php/extensions/no-debug-zts-20240924/opcache (/lib/php/extensions/no-debug-zts-20240924/opcache: cannot open shared object file: No such file or directory), /lib/php/extensions/no-debug-zts-20240924/opcache.so (/lib/php/extensions/no-debug-zts-20240924/opcache.so: cannot open shared object file: No such file or directory)) in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'sodium' (tried: /lib/php/extensions/no-debug-zts-20240924/sodium (/lib/php/extensions/no-debug-zts-20240924/sodium: cannot open shared object file: No such file or directory), /lib/php/extensions/no-debug-zts-20240924/sodium.so (/lib/php/extensions/no-debug-zts-20240924/sodium.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
hello

Build fails with export SPC_LIBC=musl

[18:21:11] [I] [EXEC] ./embed
⚠ Validation failed: embed failed to run. Error message:
Warning: Failed loading Zend extension 'opcache' (tried: /lib/php/extensions/no-debug-zts-20240924/opcache (Dynamic loading not supported), /lib/php/extensions/no-debug-zts-20240924/opcache.so (Dynamic loading not supported)) in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'sodium' (tried: /lib/php/extensions/no-debug-zts-20240924/sodium (Dynamic loading not supported), /lib/php/extensions/no-debug-zts-20240924/sodium.so (Dynamic loading not supported)) in Unknown on line 0
hello

I did not found any obvious error in the log file so not sure what I'm missing.
For testing I also tried the Docker based builds docker buildx bake --load static-builder-musl which fail as well:

4 /usr/bin/php && 	go install github.com/caddyserver/xcaddy/cmd/xcaddy@latest:
0.198 exec /bin/ash: exec format error

I think it tries to use amd64 binaries instead of arm64 in this case.

Build Type

Custom (tell us more in the description)

Worker Mode

Yes

Operating System

GNU/Linux

CPU Architecture

aarch64

PHP configuration

phpinfo() output
Not relevant

Relevant log output

Relevant log output

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions