feat: static build support (--enable-php-debugger) - #47
Merged
Merged
Conversation
Member
Author
|
I want to add some automated test, but don't want to slow down the whole CI for that. Any suggestions? Upd: added test |
pronskiy
force-pushed
the
feature/static-build
branch
from
April 14, 2026 19:15
9ab4c01 to
6cb250d
Compare
Add support for compiling php_debugger as a static extension into php-src using ./configure --enable-php-debugger (without --enable-shared). Changes: - MINIT self-registration: in static builds, the Zend extension is registered from PHP_MINIT_FUNCTION since zend_startup_extensions() has already run by the time MINIT fires. Manually calls xdebug_library_zend_startup() and xdebug_debugger_zend_startup() to replicate xdebug_zend_startup() logic. - xdebug_zend_startup() early return: prevents double module registration when zend_startup_extensions() calls it after MINIT already initialized. - php_php_debugger.h: bridge header providing phpext_php_debugger_ptr for PHP's static extension table (main/internal_functions.c). - config.m4: add PHP_ADD_INCLUDE($ext_srcdir) for header discovery. - Fix COMPILE_DL_XDEBUG -> COMPILE_DL_PHP_DEBUGGER in RINIT ZTS guard. Benchmark (PHP 8.6.0-dev, bench.php): Vanilla PHP: 0.573s (baseline) Static php_debugger: 0.605s (~5.6% overhead, observer API floor)
Dedicated CI job that builds PHP from source with --enable-php-debugger and verifies the extension loads correctly as a static build. Only triggers on changes to config.m4, php_php_debugger.h, xdebug.c, or the workflow itself — does not slow down the main test suite. Smoke tests: - Module list (php_debugger + xdebug compat) - Zend extension registration - extension_loaded() for both names - INI settings (both prefixes) - Function existence (both aliases)
config.m4 includes m4/pkg.m4 and m4/clocks.m4 which resolve relative to the php-src root, not the extension directory.
Remove cache step (not worth complexity for a rarely-triggered workflow). Always clone fresh — simpler and more reliable.
pronskiy
force-pushed
the
feature/static-build
branch
from
May 2, 2026 21:49
dd6d678 to
14bc967
Compare
Registers php_debugger_info as a ZEND_FALIAS of xdebug_info so the php_debugger_* function namespace has at least one user-visible entry point alongside the php_debugger.* INI namespace. Updates the static-build smoke test to assert php_debugger_info() exists, replacing a stale assertion for php_debugger_break() (an alias that was removed when arginfo got regenerated in #48).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds support for compiling php_debugger as a static extension into php-src, producing a single binary with the debugger built in — no .so required.
Fixes #40
Usage
In-tree (php-src)
static-php-cli
Also verified with static-php-cli — produces a fully static, zero-dependency binary:
static-php-cli recipe will be submitted as a separate PR.
Changes
zend_startup_extensions()has already run by MINIT time, so we register the Zend extension manually fromPHP_MINIT_FUNCTIONand call the startup functions inlinexdebug_zend_startup()guard — Early return in static builds to prevent double module registration whenzend_startup_extensions()calls it after MINITphp_php_debugger.h— Bridge header providingphpext_php_debugger_ptrfor PHP's static extension table (main/internal_functions.c)config.m4— AddPHP_ADD_INCLUDEfor header discoveryCOMPILE_DL_XDEBUG→COMPILE_DL_PHP_DEBUGGERin RINITstatic-build.ymlworkflow: builds PHP from source with--enable-php-debugger, runs smoke tests. Only triggers on changes to static-build-related files.Benchmark (PHP 8.6.0-dev, bench.php, Linux x86_64)
Same observer API floor as the shared build.
Compatibility
extension_loaded("php_debugger")✅extension_loaded("xdebug")✅ (compat alias)php_debugger.*andxdebug.*INI settings workzend_extension=php_debugger.so) unaffected