Skip to content

PHPC-2715: Fix out-of-source-tree builds#2010

Merged
GromNaN merged 4 commits intomongodb:v2.3from
alcaeus:fix-out-of-source-builds
May 4, 2026
Merged

PHPC-2715: Fix out-of-source-tree builds#2010
GromNaN merged 4 commits intomongodb:v2.3from
alcaeus:fix-out-of-source-builds

Conversation

@alcaeus
Copy link
Copy Markdown
Member

@alcaeus alcaeus commented May 4, 2026

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.

alcaeus and others added 3 commits May 4, 2026 09:34
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.
@alcaeus alcaeus marked this pull request as ready for review May 4, 2026 07:42
@alcaeus alcaeus requested a review from a team as a code owner May 4, 2026 07:42
@alcaeus alcaeus requested review from GromNaN and Copilot and removed request for a team May 4, 2026 07:42
@alcaeus alcaeus changed the title Add CI job to verify out-of-source builds PHPC-2715: Fix out-of-source-tree builds May 4, 2026
@alcaeus
Copy link
Copy Markdown
Member Author

alcaeus commented May 4, 2026

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.

@alcaeus alcaeus enabled auto-merge (squash) May 4, 2026 07:45
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.m4 to use PHP_EXT_SRCDIR(mongodb) when registering configured header outputs via AC_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 phpize in the source dir, then runs configure/make from 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.

Comment thread config.m4

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
Comment thread config.m4
Comment on lines 418 to +428
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
Comment thread config.m4
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])
@GromNaN
Copy link
Copy Markdown
Member

GromNaN commented May 4, 2026

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

Choose a reason for hiding this comment

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

Any specific reason to select this PHP version?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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.

@alcaeus
Copy link
Copy Markdown
Member Author

alcaeus commented May 4, 2026

The build failure looks related to #2008, should we backport this PR also?

Up to you -- I'm fine ignoring it as well since 8.6 support isn't gonna be required for v2.3.

@GromNaN
Copy link
Copy Markdown
Member

GromNaN commented May 4, 2026

The build failure looks related to #2008, should we backport this PR also?

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.

@alcaeus alcaeus disabled auto-merge May 4, 2026 08:15
@GromNaN GromNaN merged commit 8f28ee4 into mongodb:v2.3 May 4, 2026
44 of 45 checks passed
@alcaeus alcaeus deleted the fix-out-of-source-builds branch May 4, 2026 10:52
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.

4 participants