Skip to content
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

Factor out SETUP_ZLIB_LIB() #16798

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Factor out SETUP_ZLIB_LIB() #16798

wants to merge 5 commits into from

Conversation

cmb69
Copy link
Member

@cmb69 cmb69 commented Nov 14, 2024

The code is repetitive, and had some minor bugs regarding edge-cases. Thus we rework a bit. The messages of the individual commits contain some more information.

This is a mere refactoring for core readability and maintainability
reasons.

Note that this function is similar to `SETUP_OPENSSL`, but since the
zlib headers are not necessarily required, we append `_LIB`.
Extensions requiring zlib are looking only for zlib.lib if ext/zlib has
been built as shared extension.  This is overly restrictive at best,
and actually makes no sense, since (a) we're not shipping shared zlib
builds for years, and (b) users could have a zlib.lib which is a static
build (they could even just rename zlib_a.lib to zlib.lib).
We now can simplify `SETUP_ZLIB_LIB()`, and clean up formatting.
The bundled libgd relies on zlib; we're setting up the library, but
don't check for the header (which is included by gd_gd2.c), which may
pass configure, although the build fails.  We better fail early if the
required header is not available.
function SETUP_ZLIB_LIB(target, path_to_check)
{
return ((PHP_ZLIB == "no" || PHP_ZLIB_SHARED) && CHECK_LIB("zlib_a.lib;zlib.lib", target, path_to_check)) ||
(PHP_ZLIB == "yes" && !PHP_ZLIB_SHARED);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might need some explanation. zlib (like a couple of other extensions) is a bit special, because if PHP with zlib as static extension, php8.dll provides the functions as if they had been built as shared extension. Thus, there is no need to involve zlib.lib.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not correct; see #16801 (comment).

@devnexen
Copy link
Member

looks good but @petk might be more appropriate I think.

@cmb69
Copy link
Member Author

cmb69 commented Nov 14, 2024

I've just noticed that there is (and was) a glitch. If a user enables zlib and curl, but zlib can't be enabled because zlib.h is not found, configure would still pass (since curl is checked before zlib; there is no extension dependency), although the build would fail. I think we can stick with this, though.

@cmb69 cmb69 marked this pull request as draft November 15, 2024 11:51
@cmb69 cmb69 marked this pull request as ready for review November 18, 2024 23:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants