PHPC-2714: Fix in-tree PHP builds#2005
Merged
alcaeus merged 3 commits intomongodb:v2.3from Apr 30, 2026
Merged
Conversation
Downloads a PHP source tarball, symlinks the extension into php-src/ext/mongodb (mirroring the StaticPHP in-tree build layout), and builds PHP with --enable-mongodb (not =shared) so the extension is compiled directly into the PHP binary. Verifies that the extension is present via --ri mongodb, then runs the full test suite using PHP's own run-tests.php with -n to avoid any system php.ini attempting to dlopen a mongodb.so that does not exist in a static build. --enable-mongodb-coverage is intentionally omitted: config.m4 rejects that flag for static builds with AC_MSG_ERROR.
4e177c9 to
bcb79c1
Compare
PR mongodb#1893 (PHPC-2647) broke in-tree PHP builds (used by StaticPHP and similar projects) in two ways: 1. Include paths used $PWD, which during in-tree PHP builds resolves to the PHP source root rather than the extension's subdirectory, so the compiler couldn't find generated headers under ext/mongodb/. 2. AC_CONFIG_FILES paths were bare relative paths (e.g. src/libmongoc/.../config.h), which config.status resolved relative to the configure invocation directory — the PHP source root for in-tree builds — writing headers to the wrong location. Fix both by introducing ac_ext_builddir=PHP_EXT_BUILDDIR(mongodb), which expands to "ext/mongodb" for in-tree PHP builds and "." for standalone phpize builds. Absolute include paths become $abs_builddir/$ac_ext_builddir/src/..., and all AC_CONFIG_FILES paths become ${ac_ext_builddir}/src/..., placing generated headers in the extension's own build directory in every build layout while keeping the original PHPC-2647 goal of not polluting the source tree during standalone out-of-source builds.
Member
Author
|
@eramongodb This should theoretically keep the directory clean when |
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes in-tree (static) PHP builds of the MongoDB extension by ensuring generated libmongoc/libbson config headers are written to—and included from—the extension’s build directory instead of the PHP build root, and adds CI coverage for that build mode.
Changes:
- Adjust bundled libmongoc/libbson
AC_CONFIG_FILESoutputs and include paths to use the extension build dir (supports PHP in-tree builds). - Add a GitHub Actions job that builds PHP from source with
--enable-mongodb(static/in-tree) and verifies the extension is compiled in.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
config.m4 |
Writes generated config headers under the extension build dir and updates include paths to match, fixing in-tree PHP builds. |
.github/workflows/tests.yml |
Adds a CI job to build PHP statically with the extension in-tree to prevent regressions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
GromNaN
reviewed
Apr 30, 2026
- Rename ac_ext_builddir to php_mongodb_ext_builddir to avoid the ac_ prefix reserved for autoconf internals - Expand the TODO comment to explain why the block cannot move after PHP_NEW_EXTENSION (PHP_ADD_INCLUDE and source additions must precede it) - Add bison and re2c to the static PHP build CI job's apt dependencies, as ./buildconf --force requires them - Add a comment to the test-static-php-build job explaining its purpose
GromNaN
approved these changes
Apr 30, 2026
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.
PHPC-2714, fixes #2003 and #2004