GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat: static build support (--enable-php-debugger) by pronskiy · Pull Request #47 · php-debugger/php-debugger

Conversation

@pronskiy

@pronskiy pronskiy commented Apr 14, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

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)

# Symlink or copy into php-src/ext/
ln -s /path/to/php-debugger ext/php_debugger

# Build
./buildconf --force
./configure --enable-php-debugger [other flags...]
make -j$(nproc)

# Verify
./sapi/cli/php -m | grep php_debugger

static-php-cli

Also verified with static-php-cli — produces a fully static, zero-dependency binary:

$ file php
ELF 64-bit LSB executable, x86-64, statically linked, stripped

$ ls -lh php
4.6M

$ ./php -v
PHP 8.4.20 (cli) (NTS x86_64-linux-musl-gcc)
Built by static-php-cli 2.8.5
Zend Engine v4.4.20
    with PHP Debugger v0.1.0-dev

$ ./php -r "var_dump(extension_loaded('php_debugger'), extension_loaded('xdebug'));"
bool(true)
bool(true)

static-php-cli recipe will be submitted as a separate PR.

Changes

  • MINIT self-registration — In static builds, zend_startup_extensions() has already run by MINIT time, so we register the Zend extension manually from PHP_MINIT_FUNCTION and call the startup functions inline
  • xdebug_zend_startup() guard — Early return in static builds to prevent double module registration when zend_startup_extensions() calls it after MINIT
  • 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 for header discovery
  • ZTS fix — COMPILE_DL_XDEBUG → COMPILE_DL_PHP_DEBUGGER in RINIT
  • CI — Dedicated static-build.yml workflow: 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)

Config Time Overhead
Vanilla PHP (no ext) 0.573s baseline
Static php_debugger (loaded, no client) 0.605s ~5.6%

Same observer API floor as the shared build.

Compatibility

  • extension_loaded("php_debugger") ✅
  • extension_loaded("xdebug") ✅ (compat alias)
  • All php_debugger.* and xdebug.* INI settings work
  • Shared builds (zend_extension=php_debugger.so) unaffected
  • Verified with static-php-cli (musl, fully static, 4.6 MB)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@pronskiy

pronskiy commented Apr 14, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@pronskiy pronskiy added enhancement New feature or request static-build Static compilation, FrankenPHP, static-php-cli labels Apr 14, 2026
@pronskiy
pronskiy force-pushed the feature/static-build branch from 9ab4c01 to 6cb250d Compare April 14, 2026 19:15
@pronskiy
pronskiy requested a review from carlos-granados April 14, 2026 20:42
carlos-granados
carlos-granados approved these changes Apr 15, 2026
View reviewed changes

@carlos-granados carlos-granados left a comment

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

This is brilliant @pronskiy

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
pronskiy added 5 commits May 2, 2026 23:49
@pronskiy
feat: static build support (--enable-php-debugger)
cdd0a08
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)
@pronskiy
ci: add static build smoke test workflow
232eb28
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)
@pronskiy
fix(ci): copy m4 macros to php-src root for buildconf
46b9917
config.m4 includes m4/pkg.m4 and m4/clocks.m4 which resolve relative
to the php-src root, not the extension directory.
@pronskiy
fix(ci): ensure php-src clone before m4 copy
e1d9277
Remove cache step (not worth complexity for a rarely-triggered workflow).
Always clone fresh — simpler and more reliable.
@pronskiy
fix(ci): ensure m4 directory exists before copying macros
14bc967
@pronskiy
pronskiy force-pushed the feature/static-build branch from dd6d678 to 14bc967 Compare May 2, 2026 21:49
@pronskiy
feat: add php_debugger_info() alias for xdebug_info()
44324ae
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).
@pronskiy
pronskiy merged commit 1a27e5b into main May 3, 2026
16 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@carlos-granados
carlos-granados deleted the feature/static-build branch May 3, 2026 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@carlos-granados carlos-granados carlos-granados approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

enhancement New feature or request static-build Static compilation, FrankenPHP, static-php-cli

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Allow compiling this debugger statically into the php core

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@pronskiy @carlos-granados
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.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.