Comments (9)
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 ext/standard/dir.c
, I assume that relates to -Wimplicit-function-declaration
being specified in make EXTRA_CFLAGS="..."
. That seems entirely unrelated to the MongoDB driver, so you should raise that issue upstream.
from mongo-php-driver.
Ideally, any modifications to build flags should be self-contained to the mongodb extension and not influence php-src or other extensions during a static build
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.
from mongo-php-driver.
@jmikola I haven't tested every detail in depth, but it compiles fine now without any patches. Thank you !
$ buildroot/bin/php --ri mongodb
mongodb
MongoDB support => enabled
MongoDB extension version => 1.20.0dev
MongoDB extension stability => devel
libbson bundled version => 1.27.0
libmongoc bundled version => 1.27.0
libmongoc SSL => enabled
libmongoc SSL library => Secure Transport
libmongoc crypto => enabled
libmongoc crypto library => Common Crypto
libmongoc crypto system profile => disabled
libmongoc SASL => disabled
libmongoc SRV => enabled
libmongoc compression => enabled
libmongoc compression snappy => disabled
libmongoc compression zlib => enabled
libmongoc compression zstd => disabled
libmongocrypt => disabled
Directive => Local Value => Master Value
mongodb.debug => no value => no value
from mongo-php-driver.
1.19.1 was released with the necessary fix.
from mongo-php-driver.
@jmikola Thanks for quick response. I'll test it after it have been fixed.
And for -Wimplicit-function-declaration
, it's actually the same with or without it. The error message is the same if EXTRA_CFLAGS is not specified, this error is not reported only when mongodb is not included. (I guess it may be because libmongoc or a library must use C99 features and will not affect each other when compiled independently?)
from mongo-php-driver.
I guess it may be because libmongoc or a library must use C99 features and will not affect each other when compiled independently?
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 EXTRA_CFLAGS
has no effect.
OpenSCAP/openscap#1626 (comment) is another discussion about chroot()
being undefined on macOS and mentions that "chroot()
is only defined if _POSIX_SOURCE
is undefined.
In scripts/autotools/PlatformFlags.m4, we explicitly enable POSIX features during compilation. That was necessary to address cross-platform compatibility issues with strerror_r()
when we upgraded to libmongoc 1.24.3 in PHP driver 1.16.2 (see: PHPC-2270. The relevant PR is #1458 if you'd like some additional context.
While we never explicitly define _POSIX_SOURCE
, we do define some other constants that may be influencing the header declaration of chroot()
. I'm not in a good position to investigate that further, given that I don't have access to macOS. The unistd.h
linked from OpenSCAP/openscap#1626 (comment) doesn't refer to any of the constants we're defining in PlatformFlags.m4
, but that may not be enough to rule out any connection.
In php-src, the chroot()
definition is conditional on HAVE_CHROOT
(see: ext/standard/dir.c). That detection likely happens before any of the PHP driver's M4 scripts are executed. In addition to HAVE_CHROOT
, the conditional also depends on ENABLE_CHROOT_FUNC
. Looking at ext/standard/config.m4, it appears to be inferred based on the SAPI (e.g. enabled for CLI, disabled for web servers). I'm not sure if PHP has a means to toggle that during configure time.
You could also look into patching PlatformFlags.m4
to call AC_DEFINE(ENABLE_CHROOT_FUNC, 0)
from the macOS conditional and see if that impacts the generation of php_config.h
during the PHP build process. I have reservations about making such a change directly in this library, though.
from mongo-php-driver.
Per feature_test_macros(7), our definition of _XOPEN_SOURCE=700
results in _POSIX_SOURCE=1
and _POSIX_C_SOURCE=200809L
to be defined. Consulting a newer version of unistd.h
, we can see how chroot()
is left undeclared:
/* 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 strerror_r()
in Zend/zend.c. While that function is always defined, I expect php-src ends up thinking it has a different signature at configuration time than build time.
Looking more closely at PlatformFlags.m4, I think there is room for improvement in how we assign CPPFLAGS
. Ideally, any modifications to build flags should be self-contained to the mongodb
extension and not influence php-src or other extensions during a static build. I'll look into that further for PHPC-2382.
If you're willing to test my idea, I'd be interested to see the impact of the following modification. In config.m4
, backup the $CPPFLAGS
variable in the if "$PHP_MONGODB_SYSTEM_LIBS" = "no"
conditional here, either before or after we initializing PHP_MONGODB_BUNDLED_CFLAGS
and restore the variable at the end of that conditional here. Note the two fi
tokens, so make sure you do this after the if test "$PHP_MONGODB_CLIENT_SIDE_ENCRYPTION" = "yes"
conditional (which isn't going to be executed given your configure
options). For example:
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
from mongo-php-driver.
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.
from mongo-php-driver.
@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.
from mongo-php-driver.
Related Issues (20)
- Adding configure options for zstd, snappy, zlib? HOT 3
- l
- apache stop when I added extension=mongodb.so to php.ini HOT 3
- `selectServer` takes too long on official php base image (connections opened sequentially) HOT 13
- libbson Bug Report : variable ret value type error HOT 8
- No suitable servers found (`serverSelectionTryOnce` set) when rs.initiate with localhost HOT 5
- Extract mongodb-1.6.2.tgz error HOT 5
- Sporadic "Authentication failed" errors HOT 8
- MongoDB PHP Driver 1.15+ increases PHP memory consumption HOT 7
- Error while compiling on macOS HOT 7
- Major slowdown since version 1.17.0 HOT 8
- PHP Warning: PHP Startup: Unable to load dynamic library 'mongodb.so' HOT 2
- MongoDB reporting "AuthenticationAbandoned: Overridden by new authentication session" for a PHP client HOT 14
- Windows build after 1.13.0 HOT 4
- linux general protection fault , sorry for my poor english HOT 1
- PHP refusing to load MongoDB PHP driver on Windows (on one machine but not another) HOT 1
- Can't download desired extension HOT 2
- Unable to install pecl mongodb-1.15.1 in php 8.2 HOT 1
- PHPStorm Stub for Manager class has outdated signature HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mongo-php-driver.