-
Notifications
You must be signed in to change notification settings - Fork 208
[WAIT] PHPC-759: Ensure that the driver can be compiled as a built-in PHP extension #749
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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.
I'm wondering whether we should display the configuration summary for the MongoDB extension. That makes sense for the shared object version, but less so for the in-php-src-tree build where it almost implies it's for all of PHP
AC_MSG_CHECKING([for PHP_CONFIG binary]) | ||
AC_CHECK_PROG(PHP_CONFIG_BINARY, [${PHP_CONFIG}], [yes], [no]) | ||
AC_MSG_CHECKING([supported PHP versions]) | ||
if test x"$PHP_CONFIG_BINARY" == x"yes"; then |
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.
The PHP binary doesn't always exist... so we need to check for it.
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.
When was PHP_CONFIG
introduced? Just curious where you found it missing.
Note that the leading "x" for equality checks is only necessary if an operand is potentially an empty string. In this case, AC_CHECK_PROG()
will either assign "yes" or "no", so you're safe comparing the variable to "yes" directly.
m4_include(scripts/build/autotools/CheckSSL.m4) | ||
sinclude(scripts/build/autotools/m4/pkg.m4) | ||
sinclude(scripts/build/autotools/CheckHost.m4) | ||
sinclude(scripts/build/autotools/CheckSSL.m4) |
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.
sinclude
works like m4_include
, but doesn't bail out if it can't find the file. As this happens during ./buildconf
, we can't make use of shell magic so this seems the only (ugly) way: we just try them both.
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.
How is this different than deciding to call PHP_ADD_SOURCES()
or PHP_ADD_SOURCES_X()
based on the value of $ext_shared
? Does that solution not apply here because m4_include()
is evaluated earlier to generate the configure
script, long before we'd be able to check the value of $ext_shared
?
I tried using m4_include(PHP_EXT_DIR(mongodb)[scripts/build/autotools/m4/pkg.m4])
but that results in:
/usr/bin/m4:config.m4:314: cannot open `""scripts/build/autotools/m4/pkg.m4': No such file or directory
Is PHP_EXT_DIR(mongodb)
only an empty string when building a shared extension? I found it declared in phpize.m4
as an empty string. There is a more substantial definition in configure.ac
, but I assume that's for built-in extensions.
else | ||
prefixdir=${srcdir}/ext/mongodb | ||
fi | ||
AC_CREATE_STDINT_H([$prefixdir/src/libbson/src/bson/bson-stdint.h]) |
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.
We need to create files in the right directory.
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.
Since this is after PHP_NEW_EXTENSION()
is called, can we use $ext_srcdir
here and avoid the conditional?
fi | ||
|
||
EXTRA_LIBS="$EXTRA_LIBS $MONGODB_SHARED_LIBADD" |
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.
Without this, extra libs like snappy or zlib aren't passed on to PHP.
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.
Is this ignored for shared builds?
I see bits of EXTRA_LIBS
in PHP core but it's oddly absent from any extension config.m4
files. Given that many of those link extra libraries and can also be built-in, is there a reason for that?
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.
We discussed why EXTRA_LIBS
is needed. Long-term, let's see if we can use PHP_ADD_LIBPATH()
.
AC_MSG_CHECKING([for PHP_CONFIG binary]) | ||
AC_CHECK_PROG(PHP_CONFIG_BINARY, [${PHP_CONFIG}], [yes], [no]) | ||
AC_MSG_CHECKING([supported PHP versions]) | ||
if test x"$PHP_CONFIG_BINARY" == x"yes"; then |
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.
When was PHP_CONFIG
introduced? Just curious where you found it missing.
Note that the leading "x" for equality checks is only necessary if an operand is potentially an empty string. In this case, AC_CHECK_PROG()
will either assign "yes" or "no", so you're safe comparing the variable to "yes" directly.
AC_MSG_ERROR([not supported. Need a PHP version >= 5.5.0 (found $PHP_MONGODB_FOUND_VERSION)]) | ||
fi | ||
else | ||
AC_MSG_RESULT([undeterminate, continuing, but need a PHP version >= 5.5.0]) |
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.
"indeterminate" would be more common to use here.
m4_include(scripts/build/autotools/CheckSSL.m4) | ||
sinclude(scripts/build/autotools/m4/pkg.m4) | ||
sinclude(scripts/build/autotools/CheckHost.m4) | ||
sinclude(scripts/build/autotools/CheckSSL.m4) |
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.
How is this different than deciding to call PHP_ADD_SOURCES()
or PHP_ADD_SOURCES_X()
based on the value of $ext_shared
? Does that solution not apply here because m4_include()
is evaluated earlier to generate the configure
script, long before we'd be able to check the value of $ext_shared
?
I tried using m4_include(PHP_EXT_DIR(mongodb)[scripts/build/autotools/m4/pkg.m4])
but that results in:
/usr/bin/m4:config.m4:314: cannot open `""scripts/build/autotools/m4/pkg.m4': No such file or directory
Is PHP_EXT_DIR(mongodb)
only an empty string when building a shared extension? I found it declared in phpize.m4
as an empty string. There is a more substantial definition in configure.ac
, but I assume that's for built-in extensions.
m4_include(src/libbson/build/autotools/m4/ac_compile_check_sizeof.m4) | ||
m4_include(src/libbson/build/autotools/m4/ac_create_stdint_h.m4) | ||
AC_CREATE_STDINT_H([$srcdir/src/libbson/src/bson/bson-stdint.h]) | ||
sinclude(src/libbson/build/autotools/CheckAtomics.m4) |
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.
Side question: once we sinclude()
a file, is an include within that file relative to the file's own path? I wonder if we could clean up a lot of this by having a single gateway include that then includes all of these general m4 files.
else | ||
prefixdir=${srcdir}/ext/mongodb | ||
fi | ||
AC_CREATE_STDINT_H([$prefixdir/src/libbson/src/bson/bson-stdint.h]) |
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.
Since this is after PHP_NEW_EXTENSION()
is called, can we use $ext_srcdir
here and avoid the conditional?
prefixdir=${srcdir} | ||
else | ||
prefixdir=${srcdir}/ext/mongodb | ||
fi |
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.
Same question here regarding $ext_srcdir
.
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.
Changes look good. Up to you if you'd like this added for 1.4.0 or would rather it sit until we import libmongoc Autotools in 1.5.0.
Either way, I think we should add a blurb in CONTRIBUTING.md
that instructs how to easily build PHP from source with the extension built-in (similar to our Windows build example).
Superseded by #830. |
https://jira.mongodb.org/browse/PHPC-759