Skip to content

[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

Closed
wants to merge 1 commit into from

Conversation

derickr
Copy link
Contributor

@derickr derickr commented Feb 2, 2018

@derickr derickr requested review from jmikola and kvwalker February 2, 2018 15:48
Copy link
Contributor Author

@derickr derickr left a 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
Copy link
Contributor Author

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.

Copy link
Member

@jmikola jmikola Feb 6, 2018

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)
Copy link
Contributor Author

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.

Copy link
Member

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])
Copy link
Contributor Author

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.

Copy link
Member

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"
Copy link
Contributor Author

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.

Copy link
Member

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?

Copy link
Member

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

@jmikola jmikola Feb 6, 2018

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])
Copy link
Member

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)
Copy link
Member

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)
Copy link
Member

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])
Copy link
Member

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

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.

Copy link
Member

@jmikola jmikola left a 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).

@jmikola jmikola changed the title PHPC-759: Ensure that the driver can be compiled as a built-in PHP extension [WAIT] PHPC-759: Ensure that the driver can be compiled as a built-in PHP extension Feb 6, 2018
@wysow wysow mentioned this pull request May 9, 2018
@jmikola
Copy link
Member

jmikola commented May 15, 2018

Superseded by #830.

@jmikola jmikola closed this May 15, 2018
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