[CDRIVER-2666] Call bundled zLib's CMake script to avoid warnings Created: 25/May/18 Updated: 31/Mar/22 |
|
| Status: | Backlog |
| Project: | C Driver |
| Component/s: | Build, libmongoc |
| Affects Version/s: | 1.10.0 |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Minor - P4 |
| Reporter: | Jeremy Mikola | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||
| Description |
|
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:
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. |
| Comments |
| Comment by A. Jesse Jiryu Davis [ 10/Oct/18 ] |
|
Thanks Henrik. Patches welcome if you feel up to it. |
| Comment by Henrik Edin [ 10/Oct/18 ] |
|
We also encountered this when building mongoc for iOS. Because we don't allow warnings in that build we had to disable ZLIB. If it could be fixed it would be great. |
| Comment by Jeremy Mikola [ 04/Jun/18 ] |
Are you referring to the same build warnings I saw above? If so, I think it may be worth fixing. It was trivial to add a check for unistd.h in I was under the impression that it's much easier to trigger a bundled library's configuration from CMake, so I might suggest doing that as a proper fix long term. |
| Comment by A. Jesse Jiryu Davis [ 31/May/18 ] |
|
Jeremy feel free to reopen if this is really a C Driver bug. |
| Comment by A. Jesse Jiryu Davis [ 30/May/18 ] |
|
Interesting. We are not invoking zlib's CMake configuration, we just copy zconf.h.in to zconf.h. That means Z_HAVE_UNISTD_H is not defined and unistd.h is not included. That works so far and only produces warnings, so I'm going to leave it as-is, but in a perfect world we might have done differently. |
| Comment by Jeremy Mikola [ 30/May/18 ] |
|
I don't believe this is a problem upstream, as zLib does check for unistd.h. If you are recursively invoking its CMake configuration, I expect this isn't a problem for libmongoc. Feel free to close this if so. |
| Comment by A. Jesse Jiryu Davis [ 27/May/18 ] |
|
The old Autotools scripts disabled warnings for the vendored zLib sources: https://github.com/mongodb/mongo-c-driver/blob/r1.9/src/mongoc/Makefile.am#L326 PHPC should do the same, unless zLib itself has fixed the issue upstream. Could you check if they have please?
|