Skip to content

Add shared-extensions, frankenphp and zts to build-unix workflow#1062

Merged
crazywhalecc merged 9 commits intocrazywhalecc:mainfrom
N-Silbernagel:main
Mar 20, 2026
Merged

Add shared-extensions, frankenphp and zts to build-unix workflow#1062
crazywhalecc merged 9 commits intocrazywhalecc:mainfrom
N-Silbernagel:main

Conversation

@N-Silbernagel
Copy link
Copy Markdown
Contributor

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 your PR involves the changes mentioned below and completed the action, please tick the corresponding option.
If a modification is not involved, please skip it directly.

  • If you modified *.php or *.json, run them locally to ensure your changes are valid:

    • [ x ] composer cs-fix
    • [ x ] composer analyse
    • [ x ] composer test
    • [ ] bin/spc dev:sort-config
      This fails, but already does so on commit 4625c6a
  • If it's an extension or dependency update, please ensure the following:

    • Add your test combination to src/globals/test-extensions.php.
    • If adding new or fixing bugs, add commit message containing extension test or test extensions to trigger full test suite.

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-*."
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's not true, shared extensions work with musl too if you set SPC_TARGET="x86_64-linux-musl -dynamic".

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or on alpine with SPC_MUSL_DYNAMIC=true

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's better. Could you update that error message to mention SPC_MUSL_DYNAMIC, though?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
$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);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why? that var must always be defined

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

'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') ?: '',
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again why?

name: php-shared-ext-${{ inputs.php-version }}-${{ inputs.os }}
path: |
buildroot/modules/*.so
buildroot/modules/*.dylib
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extensions are built as .so on macOS too

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, thanks for pointing this out!

@N-Silbernagel
Copy link
Copy Markdown
Contributor Author

Addressed the feedback, also removed the custom error mesage on frankenphp without zts

Copy link
Copy Markdown
Collaborator

@henderkes henderkes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you

Copy link
Copy Markdown
Owner

@crazywhalecc crazywhalecc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need syncing Chinese docs, I'll translate later.

@crazywhalecc crazywhalecc merged commit 295df19 into crazywhalecc:main Mar 20, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants