-
-
Notifications
You must be signed in to change notification settings - Fork 251
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
Handle HAVE_UNISTD_H defined to 0. #960
Conversation
|
What if I care only about the cmake build system? Is there a way to upstream this fix? |
Most of the stuff on |
Thanks for the pointers. I updated both configure and CMakeLists.txt. |
541f061
to
80c957b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Codecov Report
@@ Coverage Diff @@
## develop #960 +/- ##
===========================================
- Coverage 77.36% 75.81% -1.56%
===========================================
Files 74 74
Lines 8309 8082 -227
Branches 1374 1343 -31
===========================================
- Hits 6428 6127 -301
- Misses 1348 1425 +77
+ Partials 533 530 -3
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
@Dead2 can you re-run the CI? |
It seems like this change should also apply to |
Triggered re-runs now. |
CMakeLists.txt
Outdated
@@ -1054,7 +1054,7 @@ endif() | |||
if(HAVE_UNISTD_H) | |||
SET(ZCONF_UNISTD_LINE "#if 1 /* was set to #if 1 by configure/cmake/etc */") | |||
else() | |||
SET(ZCONF_UNISTD_LINE "#ifdef HAVE_UNISTD_H /* may be set to #if 1 by configure/cmake/etc */") | |||
SET(ZCONF_UNISTD_LINE "#if ~ HAVE_UNISTD_H + 1 /* may be set to #if 1 by configure/cmake/etc */") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain this logic a bit more?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If something is not defined, it equals either 0 or empty string...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has the exact same semantics as here 1; it is only written slightly shorter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think shorter is better in this case... It is just confusing...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO -_LARGEFILE64_SOURCE - -1 == 1
is just as unreadable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possibly... But fixing both would change scope of this pull request...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If these changes are going to be accepted they should be done for the other headers such as HAVE_STDARG_H
.
I don't see |
Some are obviously relics inherited from stock zlib... We already cleaned up CMakeLists.txt. |
So is the cleanup in scope of this PR? |
@lemourin Not in my opinion... |
I'm still not 100% sure if we should fix this in zlib-ng or if this is the best way to fix. Moving the fix to zconf.h.in and zconf-ng.h.in would also require editing two files and wouldn't be any cleaner solution as we would need to add extra lines before the current test that basically undefines the macro if it is set to 0. The cons for fixing this in configure/CMakeLists.txt are pretty much style issues and having the workaround only for case when the macro is set to 0 outside zlib-ng build system. If the macro is set to 1 outside zlib-ng build system, it is essentially no-op and ignored. |
The root cause of the issue is that macros are not scoped in C so in this case A different solution could be to replace I don't think undefining a macro is a good idea; it will likely break the users of zlib (i.e FFmpeg). If this is not zlib-ng issue then where does the fix belong? I don't want to create yet another zlib fork :( |
@lemourin There is no easy answer... Obviously FFmpeg should support zlib-ng without any changes just like it's supposed to support original zlib. To summarize, any project that includes another project as dependency should be able to handle configuration of that subproject without any patches to official sources. I'm in no position to blatantly reject pull requests, only @Dead2 can do that. But controversial changes like this require approval of two long-time collaborators and I'm not very keen in approving until I'm 100% confident there is no better alternative. |
After doing some investigation with folks in the ffmpeg IRC channel, we've determined that classic zlib does not include any references to the For compatibility, it would be best if zlib-ng followed suit here - there should be no references to the unprefixed Snippit of the installed #if 1 /* was set to #if 1 by ./configure */
# define Z_HAVE_UNISTD_H
#endif Edit: Ah, I'm probably misunderstanding something about exactly which conditions cause that replacement to be performed. It looks like there are some cases where the zlib configure script does leave the |
@kepstin I don't see anywhere in zlib build system where it replaces anything with |
Yeah, that does seem to be the case. That said, the configure script is pretty hard to read (or maybe i'm just not good at reading sed), and I'm not even sure how the I suppose the reason for the way the check was done in the original zlib was to make it easier to statically include the zlib source files in another project (in which case the header wouldn't get installed). |
@kepstin I've used Linux since December 1996 and I still get hairballs trying to decipher sed scripts... Sometimes I just guess repeatedly what the script should be until the result is expected... |
FFmpeg during the configure stage generates a config.h file with ``` #define HAVE_UNISTD_H 0 ``` on windows. Then somewhere in FFmpeg's code there is: ``` #include "config.h" // FFmpeg's config.h #include <zlib.h> ``` which causes zlib.h to include unistd.h on windows. It is way easier to handle the issue here than in FFmpeg. Co-authored-by: Mika Lindqvist <postmaster@raasu.org>
Can this be merged? :) |
@Dead2 will merge when he is online... |
I think we should wait for a proper fix which is:
|
- Minor code cleanup #983 #984 - Fix mpicc compilation #959 - Fix build on NetBSD #964 - Fix build on OpenBSD #970 - Fix build on Cygwin #972 #974 - Fix linter warnings in configure #975 - Spelling fixes #961 - Improve unistd.h handling #960 - Remove stdarg.h detection #976 - CI/Test improvements #977 #981 #985 - Cmake improvements #980
- Minor code cleanup #983 #984 - Fix mpicc compilation #959 - Fix build on NetBSD #964 - Fix build on OpenBSD #970 - Fix build on Cygwin #972 #974 - Fix linter warnings in configure #975 - Spelling fixes #961 - Improve unistd.h handling #960 - Remove stdarg.h detection #976 - CI/Test improvements #977 #981 #985 - Cmake improvements #980 #989
- Fix inflate corruption #982 - Minor code cleanup #983 #984 - Fix mpicc compilation #959 - Fix build on NetBSD #964 - Fix build on OpenBSD #970 - Fix build on Cygwin #972 #974 - Fix linter warnings in configure #975 - Spelling fixes #961 - Improve unistd.h handling #960 - Remove stdarg.h detection #976 - CI/Test improvements #977 #981 #985 - Cmake improvements #980 #989
- Fix inflate corruption #982 - Minor code cleanup #983 #984 - Fix mpicc compilation #959 - Fix build on NetBSD #964 - Fix build on OpenBSD #970 - Fix build on Cygwin #972 #974 - Fix linter warnings in configure #975 - Spelling fixes #961 - Improve unistd.h handling #960 - Remove stdarg.h detection #976 - CI/Test improvements #977 #981 #985 - Cmake improvements #980 #989
FFmpeg during the configure stage generates a config.h file with
on windows. Then somewhere in FFmpeg's code there is:
which causes zlib.h to include unistd.h on windows. It is way easier to handle the issue here than in FFmpeg.