Skip to content

Conversation

@petk
Copy link
Member

@petk petk commented Jan 8, 2026

This optionally checks whether zlib is installed on the system, regardless of PHP extension zlib being built as static, shared or disabled. The zlib library is needed to be linked for having SWC files support in PHP.

Previously, only SWC support was possible only if PHP was built with static zlib PHP extension.

As SWC files are obsolete, no additional configuration option is provided and check is done as optional to have as little backward incopatibilities in builds.

Fixes: GH-4681

What do you think?

cc @andypost @glensc

Earlier bug report was also at: https://bugs.php.net/bug.php?id=34338

Edit: I've opened also an issue about this as it's unclear how to best resolve this issue #20868 It's problematic as it's hidden and undocumented that for SWC files zlib extension needs to be built as static. And there is also a new API that perhaps would resolve this better - commented in image.c as TODO: with the new php_image_register_handler() APIs, this restriction could be solved.

This optionally checks whether zlib is installed on the system,
regardless of PHP extension zlib being built as static, shared or
disabled. The zlib library is needed to be linked for having SWC files
support in PHP.

Previously, only SWC support was possible only if PHP was built with
static zlib PHP extension.

As SWC files are obsolete, no additional configuration option is
provided and check is done as optional to have as little backward
incopatibilities in builds.

Fixes: phpGH-4681
@andypost
Copy link
Contributor

andypost commented Jan 8, 2026

Is the SWC files the only place which require zlib?

@petk
Copy link
Member Author

petk commented Jan 8, 2026

Is the SWC files the only place which require zlib?

Yes.

@andypost
Copy link
Contributor

andypost commented Jan 8, 2026

thank you, gonna try build it this weekend

@ndossche
Copy link
Member

ndossche commented Jan 9, 2026

I don't particularly like linking the core binary with zlib. I think the comment - that I put - points to the right solution. It shouldn't be hard to do this I think. It would be a tiny BC break as the constant value of IMAGETYPE_SWC changes and you'd get an undefined constant error instead of a warning...

@petk
Copy link
Member Author

petk commented Jan 12, 2026

@ndossche yes, agreed totally. I can't say that I would know how to change the code to the php_image_register_handler(). I'll close this pull request in favor of the opened issue instead so it's logged and if someone can perhaps do this one day. In the meantime, this patch otherwise bypasses the main issue if anyone would need patching the sources for releasing distro packages. I've done it similarly for the CMake-based build system, so at least zlib extension can be built as shared without this issue.

Another option would be here to treat ext/zlib as "required" extension. Similar to ext/libxml. At least from the PHP packaging point of view.

@petk petk closed this Jan 12, 2026
@andypost
Copy link
Contributor

I like the idea "to treat ext/zlib as "required" extension" as it was really hard to understand why I can't build it as shared

@ndossche
Copy link
Member

ext/libxml is not a required extension, it is a default extension however

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.

3 participants