Updated description: We currently ignore the bundled zLib code's CMakeLists.txt, and instead just include the zLib code into our project without any of zLib's config checks. This results in some compiler warnings: we skip the step in zLib's CMake script that would set Z_HAVE_UNISTD_H, and therefore zLib's source doesn't include unistd.h, therefore we get warnings about implicit declarations. We have worked around the issue by suppressed warnings when compiling bundled zLib. Instead, our CMake script should call zLib's, this may have other (good?) consequences besides defining Z_HAVE_UNISTD_H . It should allow zLib's source to compile without warnings, and then we can remove our workaround that suppresses warnings when compiling bundled zLib.
Original report from Jeremy: "Implicit declaration warnings when building bundled zlib"
I noticed the following build warnings when compiling libmongoc with zlib support:
/home/jmikola/workspace/mongodb/phpc/src/libmongoc/src/zlib-1.2.11/gzlib.c: In function ‘gz_open’: /home/jmikola/workspace/mongodb/phpc/src/libmongoc/src/zlib-1.2.11/gzlib.c:14:17: warning: implicit declaration of function ‘lseek’; did you mean ‘fseek’? [-Wimplicit-function-declaration] # define LSEEK lseek ^ /home/jmikola/workspace/mongodb/phpc/src/libmongoc/src/zlib-1.2.11/gzlib.c:252:9: note: in expansion of macro ‘LSEEK’ LSEEK(state->fd, 0, SEEK_END); /* so gzoffset() is correct */ ^~~~~ /home/jmikola/workspace/mongodb/phpc/src/libmongoc/src/zlib-1.2.11/gzread.c: In function ‘gz_load’: /home/jmikola/workspace/mongodb/phpc/src/libmongoc/src/zlib-1.2.11/gzread.c:36:15: warning: implicit declaration of function ‘read’; did you mean ‘fread’? [-Wimplicit-function-declaration] ret = read(state->fd, buf + *have, get); ^~~~ fread /home/jmikola/workspace/mongodb/phpc/src/libmongoc/src/zlib-1.2.11/gzread.c: In function ‘gzclose_r’: /home/jmikola/workspace/mongodb/phpc/src/libmongoc/src/zlib-1.2.11/gzread.c:652:11: warning: implicit declaration of function ‘close’; did you mean ‘pclose’? [-Wimplicit-function-declaration] ret = close(state->fd); ^~~~~ pclose /home/jmikola/workspace/mongodb/phpc/src/libmongoc/src/zlib-1.2.11/gzwrite.c: In function ‘gz_comp’: /home/jmikola/workspace/mongodb/phpc/src/libmongoc/src/zlib-1.2.11/gzwrite.c:90:20: warning: implicit declaration of function ‘write’; did you mean ‘fwrite’? [-Wimplicit-function-declaration] writ = write(state->fd, strm->next_in, put); ^~~~~ fwrite /home/jmikola/workspace/mongodb/phpc/src/libmongoc/src/zlib-1.2.11/gzwrite.c: In function ‘gzclose_w’: /home/jmikola/workspace/mongodb/phpc/src/libmongoc/src/zlib-1.2.11/gzwrite.c:662:9: warning: implicit declaration of function ‘close’; did you mean ‘pclose’? [-Wimplicit-function-declaration] if (close(state->fd) == -1) ^~~~~ pclose
I expect patching the vendored sources with #include <unistd.h> would resolve this. Alternatively, this might have been fixed upstream. This is certainly not unique to libmongoc (see: opencv/opencv_contrib#721).
Lastly, I'm not sure why we only recently noticed this in PHPC builds, but I expect it's due to our recent Autotools migration. We may be passing developer CFLAGS for libmongoc sources now.
- is related to
-
CDRIVER-2511 Disable warnings for zlib in CMake
- Closed
- related to
-
PHPC-1197 Check for unistd.h when compiling bundled zLib
- Closed
- links to