PHPC-2715: Fix out-of-source-tree builds#2010
Conversation
Runs phpize in the extension source directory, then invokes configure and make from a separate build directory. This catches regressions where generated headers are placed relative to $PWD rather than the extension source (PHP_EXT_SRCDIR), which breaks any build where configure is not run from within the extension directory.
|
The system-library test failure is due to the release of libmongocrypt 1.18 breaking the expected install of libmongocrypt 1.17. I'll see if there's an easy workaround to bring CI back to green. We can still merge this PR as the out-of-source builds are now fixed. |
There was a problem hiding this comment.
Pull request overview
Adds CI coverage for building the extension from a separate build directory (configure/make out-of-source) to catch regressions related to incorrect header generation paths during configuration.
Changes:
- Update
config.m4to usePHP_EXT_SRCDIR(mongodb)when registering configured header outputs viaAC_CONFIG_FILES. - Bump the PHP version used by the “Static PHP Build” workflow job and add a new “Out-of-source Build” job.
- Add a GitHub Actions job that runs
phpizein the source dir, then runsconfigure/makefrom a separate build directory.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| config.m4 | Adjusts how configured header output paths are specified (builddir vs srcdir semantics). |
| .github/workflows/tests.yml | Updates PHP version for static build job and adds a new CI job for out-of-source extension builds. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| AC_CONFIG_FILES([ | ||
| ${php_mongodb_ext_builddir}/src/libmongocrypt/src/mongocrypt-config.h | ||
| ${php_mongodb_ext_srcdir}/src/libmongocrypt/src/mongocrypt-config.h |
| run: | | ||
| mkdir -p /tmp/mongodb-build | ||
| cd /tmp/mongodb-build | ||
| ${GITHUB_WORKSPACE}/configure --enable-mongodb-developer-flags |
| dnl Write generated config headers into the extension's build directory | ||
| dnl (${php_mongodb_ext_builddir}/... relative to the configure invocation directory). | ||
| dnl For standalone out-of-source builds this stays in the build tree; for | ||
| dnl PHP in-tree builds it lands under ext/mongodb/ rather than the PHP root. | ||
| AC_CONFIG_FILES([ | ||
| ${php_mongodb_ext_builddir}/src/libmongoc/src/common/src/common-config.h | ||
| ${php_mongodb_ext_builddir}/src/libmongoc/src/libbson/src/bson/config.h | ||
| ${php_mongodb_ext_builddir}/src/libmongoc/src/libbson/src/bson/version.h | ||
| ${php_mongodb_ext_builddir}/src/libmongoc/src/libmongoc/src/mongoc/mongoc-config.h | ||
| ${php_mongodb_ext_builddir}/src/libmongoc/src/libmongoc/src/mongoc/mongoc-config-private.h | ||
| ${php_mongodb_ext_builddir}/src/libmongoc/src/libmongoc/src/mongoc/mongoc-version.h | ||
| ${php_mongodb_ext_srcdir}/src/libmongoc/src/common/src/common-config.h | ||
| ${php_mongodb_ext_srcdir}/src/libmongoc/src/libbson/src/bson/config.h | ||
| ${php_mongodb_ext_srcdir}/src/libmongoc/src/libbson/src/bson/version.h | ||
| ${php_mongodb_ext_srcdir}/src/libmongoc/src/libmongoc/src/mongoc/mongoc-config.h | ||
| ${php_mongodb_ext_srcdir}/src/libmongoc/src/libmongoc/src/mongoc/mongoc-config-private.h | ||
| ${php_mongodb_ext_srcdir}/src/libmongoc/src/libmongoc/src/mongoc/mongoc-version.h |
| PHP_MONGODB_ADD_INCLUDE([src/libmongoc/src/zlib-1.3.1/]) | ||
| PHP_MONGODB_ADD_BUILD_DIR([src/libmongoc/src/zlib-1.3.1/]) | ||
| AC_CONFIG_FILES([${php_mongodb_ext_builddir}/src/libmongoc/src/zlib-1.3.1/zconf.h]) | ||
| AC_CONFIG_FILES([${php_mongodb_ext_srcdir}/src/libmongoc/src/zlib-1.3.1/zconf.h]) |
|
The build failure looks related to #2008, should we backport this PR also? |
| env: | ||
| # Update this when cutting a new PHP 8.3 patch release | ||
| PHP_VERSION: "8.3.21" | ||
| PHP_VERSION: "8.5.5" |
There was a problem hiding this comment.
Any specific reason to select this PHP version?
There was a problem hiding this comment.
It's the latest patch release. For the download, we have to specify an exact version number, and I forgot to switch to an 8.5 release in the previous PR.
Up to you -- I'm fine ignoring it as well since 8.6 support isn't gonna be required for v2.3. |
Either we drop PHP 8.6 build from this branch or we backport the fix. But I don't want to see a failing job. |
PHPC-2715
Runs phpize in the extension source directory, then invokes configure and make from a separate build directory. This catches regressions where generated headers are placed relative to $PWD rather than the extension source (PHP_EXT_SRCDIR), which breaks any build where configure is not run from within the extension directory.
This PR also cherry-picks the fix from #2007 to ensure the out-of-source build is actually fixed.