Add shared-extensions, frankenphp and zts to build-unix workflow#1062
Add shared-extensions, frankenphp and zts to build-unix workflow#1062crazywhalecc merged 9 commits intocrazywhalecc:mainfrom
Conversation
.github/workflows/build-unix.yml
Outdated
| ALL_EXTS="$ALL_EXTS,$SHARED_EXTS" | ||
| case "${{ inputs.os }}" in | ||
| linux-x86_64|linux-aarch64) | ||
| echo "Shared extensions (e.g. xdebug) require glibc/macOS targets. Use linux-*-glibc or macos-*." |
There was a problem hiding this comment.
that's not true, shared extensions work with musl too if you set SPC_TARGET="x86_64-linux-musl -dynamic".
There was a problem hiding this comment.
or on alpine with SPC_MUSL_DYNAMIC=true
There was a problem hiding this comment.
Thanks! I have now removed this check as to simply let spc itself handle those cases. An example can be seen here https://github.com/N-Silbernagel/static-php-cli/actions/runs/23154572457/job/67265649704 where I tried to build xdebug with linux-x86_64.
There was a problem hiding this comment.
Yes, that's better. Could you update that error message to mention SPC_MUSL_DYNAMIC, though?
There was a problem hiding this comment.
I must say I'm not quite confident what that flag does exactly and couldn't find too many info in the PR it was added in. The error message now says:
You're building against musl libc statically (the default on Linux), but you're trying to build shared extensions.
Static musl libc does not implement dlopen, so your php binary is not able to load shared extensions.
Either use SPC_LIBC=glibc to link against glibc on a glibc OS, use SPC_TARGET="native-native-musl -dynamic" to link against musl libc dynamically using zig cc or use SPC_MUSL_DYNAMIC=true on alpine.
Hope that is what you were thinking.
let SPC handle check for compatible shared extension targets
src/SPC/builder/Extension.php
Outdated
| $soFile = BUILD_MODULES_PATH . '/' . $this->getName() . '.so'; | ||
| $soDest = $soFile; | ||
| preg_match('/-release\s+(\S*)/', getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS'), $matches); | ||
| preg_match('/-release\s+(\S*)/', getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS') ?: '', $matches); |
There was a problem hiding this comment.
why? that var must always be defined
There was a problem hiding this comment.
Honestly just added it because it was failing on build. Now after you comment and some digging, i figured it was because of using mac in the action and SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS wasnt defined for macos in env.ini. I now added it there instead
src/SPC/builder/Extension.php
Outdated
| 'CXXFLAGS' => $config['cflags'], | ||
| 'LDFLAGS' => $config['ldflags'], | ||
| 'EXTRA_LDFLAGS' => getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS'), | ||
| 'EXTRA_LDFLAGS' => getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS') ?: '', |
.github/workflows/build-unix.yml
Outdated
| name: php-shared-ext-${{ inputs.php-version }}-${{ inputs.os }} | ||
| path: | | ||
| buildroot/modules/*.so | ||
| buildroot/modules/*.dylib |
There was a problem hiding this comment.
extensions are built as .so on macOS too
There was a problem hiding this comment.
You are right, thanks for pointing this out!
already handled in BuilderBase
|
Addressed the feedback, also removed the custom error mesage on frankenphp without zts |
crazywhalecc
left a comment
There was a problem hiding this comment.
Need syncing Chinese docs, I'll translate later.
What does this PR do?
This PR adds options for shared-extensions, build-frankenphp and enable-zts to the build-unix workflow. The change enables me to build a (mostly) static frankenphp together with xdebug without installing any tools. I'm hoping this also benefits others.
Needed to add "getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS') ?: ''" because "getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS')" returns false in gh action where the env var is not set.
Checklist before merging
If you modified
*.phpor*.json, run them locally to ensure your changes are valid:composer cs-fixcomposer analysecomposer testbin/spc dev:sort-configThis fails, but already does so on commit 4625c6a
If it's an extension or dependency update, please ensure the following:
src/globals/test-extensions.php.extension testortest extensionsto trigger full test suite.