Skip to content

fix(config.m4): support out-of-tree builds by resolving injected extension sources via absolute paths - #6294

Merged
matyhtf merged 1 commit into
swoole:masterfrom
alwaysLinger:fix(config.m4)/vpath-source-discovery
Oct 10, 2026
Merged

matyhtf merged 1 commit into
swoole:masterfrom
alwaysLinger:fix(config.m4)/vpath-source-discovery

Conversation

@alwaysLinger

Copy link
Copy Markdown
Contributor

Observed failure

Building a TypePHP application that calls swoole_version() fails while TypePHP is building its private PHP runtime: the CLI SAPI link dies with undefined Swoole symbols. The app build never started.

TypePHP automatically downloads PHP 8.4.26 and PECL Swoole 6.2.3, injects Swoole at ext/swoole in the php-src tree, and configures from a separate build directory. Configure logs two directory errors and continues; the generated Makefile contains only Swoole thirdparty objects.

configure: line 86269: cd: ext/swoole: No such file or directory
configure: line 86270: cd: ext/swoole: No such file or directory
/usr/bin/ld: main/internal_functions_cli.o: undefined reference to `swoole_module_entry'
/usr/bin/ld: proc_open.cc: undefined reference to `swoole::Coroutine::current' ...
make: *** [Makefile:263: sapi/cli/php] Error 1

Reproduction

project.yml:

name: swoole-version
mode: bin
php-builder:
  extensions: [swoole]
  zts: off

main():

function main(): void
{
    echo "Swoole: ", swoole_version(), "\n";
}

Run php vendor/bin/tpc.php project.yml --php-builder in a Linux environment with PHP build dependencies. The private runtime build fails at the CLI link with the symbols above. The same failure reproduces without TypePHP by injecting PECL swoole 6.2.3 into a php-src tree at ext/swoole and running an out-of-tree configure --enable-swoole.

Root cause

swoole_source_dir falls through to the relative fallback ext/swoole, which is resolved against the build directory where cd ext/swoole fails silently. The two find calls for ext-src/*.cc and src/*.cc therefore return empty lists, configure continues, and only the hardcoded thirdparty file list enters the build. In-tree builds (pecl install) never hit this because the working directory already is the source tree.

Fix

config.m4 (this diff): resolve the injected tree via an absolute path, verify the extension entry source exists, check the exit status of every cd/find, and fail configure when either source list is empty.

Verification

With this diff, the same out-of-tree build compiles all 130 extension/core objects, links the CLI SAPI, and the installed runtime loads swoole (swoole_version() = 6.3.0RC1). In-tree (pecl install) and standalone builds are unaffected. Control extensions with explicit config.m4 source lists (redis, mongodb) build and run unchanged.

@matyhtf
matyhtf merged commit 5daa5c4 into swoole:master Oct 10, 2026
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.

2 participants