-
Notifications
You must be signed in to change notification settings - Fork 207
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
Bug & Question: How to compile mongodb statically into PHP? #1549
Comments
Static compilation was broken in 1.17.0 by PHPC-2275. I've opened PHPC-2382 to restore that functionality and will cross-reference a PR once I can successfully reproduce a static build. As for the build error in |
@jmikola Thanks for quick response. I'll test it after it have been fixed. And for |
libmongoc 1.24+ does require C99 (see: config.m4); however, so does php-src since 8.0.0 (see: php/php-src@b51a99a). I don't think the issue is C99 specifically, but rather that implicit function declarations are in error since C99 (see: Implicit function declarations in C Programming. That would explain why changing OpenSCAP/openscap#1626 (comment) is another discussion about In scripts/autotools/PlatformFlags.m4, we explicitly enable POSIX features during compilation. That was necessary to address cross-platform compatibility issues with While we never explicitly define In php-src, the You could also look into patching |
Per feature_test_macros(7), our definition of /* Begin XSI */
/* Removed in Issue 6 */
#if !defined(_POSIX_C_SOURCE) || _POSIX_C_SOURCE < 200112L
#if !defined(_POSIX_C_SOURCE)
__deprecated __WATCHOS_PROHIBITED __TVOS_PROHIBITED
#endif
void *brk(const void *);
int chroot(const char *) __POSIX_C_DEPRECATED(199506L);
#endif I expect there may also be another side effect going unnoticed here, since php-src also uses Looking more closely at PlatformFlags.m4, I think there is room for improvement in how we assign If you're willing to test my idea, I'd be interested to see the impact of the following modification. In if test "$PHP_MONGODB_SYSTEM_LIBS" = "no"; then
+ PHP_MONGODB_ORIGINAL_CPPFLAGS="$CPPFLAGS"
PHP_MONGODB_BUNDLED_CFLAGS="$STD_CFLAGS -DBSON_COMPILATION -DMONGOC_COMPILATION"
...
fi
+ CPPFLAGS="$PHP_MONGODB_ORIGINAL_CPPFLAGS"
fi
|
Applied this patch for backup CPPFLAGS, and it works well. Here's my before and after patch php-src config.log: I can also provide more details if needed. |
Yeah. I found snappy, swoole and some other pecl extensions had this similar issue before, example kjdev/php-ext-snappy#24 People usually use dynamic compilation, and this kind of problem is difficult to detect. |
@crazywhalecc: #1555 has been merged to v1.19 if you'd like to give that one more try. I reckon we can release 1.19.1 once we sort out some upstream breaks to Windows builds (PHPC-2388). Hopefully early next week. |
@jmikola I haven't tested every detail in depth, but it compiles fine now without any patches. Thank you !
|
1.19.1 was released with the necessary fix. |
Bug Report
I'm trying to statically compile mongodb with PHP, with following steps:
php-src
andmongo-php-driver
mongo-php-driver
tophp-src/ext/mongodb
./buildconf --force
./configure --disable-shared --enable-static --disable-phpdbg --enable-cli --enable-mongodb --with-mongodb-system-libs=no --with-mongodb-client-side-encryption=no --with-mongodb-sasl=no --without-iconv
And it shows error:
From mongo source, I found it uses
php-config
directly to get PHP version, and inline build (static compilation) apparently have no any dev command. So I tried to patchconfig.m4
like this:And in order to add and test other flags more easily, I directly use static-php-cli to compile it. The main compilation methods and commands have not changed. In short, it uses commands below:
And finally got this strange error from standard ext:
I actually have no idea, this build procedure works well on Linux. It would be better if someone could provide more clues 🕵️
Environment
Debug Log
php-src/config.log
Related Issue
crazywhalecc/static-php-cli#281
The text was updated successfully, but these errors were encountered: