kjdev / php-ext-zstd

Zstd Extension for PHP
MIT License
201 stars 27 forks source link

Documenting APCu support #66

Open ryandesign opened 5 months ago

ryandesign commented 5 months ago

Hi, I maintain the PHP ports in MacPorts and I just discovered that the zstd extension will check for the presence of the APCu extension at build time:

https://github.com/kjdev/php-ext-zstd/blob/0bf5825ad683e637211a0eacec4fe545992f5b67/config.m4#L105-L112

Now I have to decide how I should handle this in MacPorts and I didn't find any documentation about what the zstd extension does with APCu so I wanted to ask here if you could answer some questions or maybe document it.

What does the zstd extension do if it finds APCu at build time? How does it use it?

If the zstd extension finds APCu at build time, does it require it to be present at runtime? This would dictate whether I give the php-zstd port a dependency on the php-APCu port that is only needed at build time or also at runtime.

When the APCu code was first added to the zstd extension in 45c876a41bfae9a0ff6de52346c909aeb18fb6a2, the check for APCu in config.m4 was unconditional but all the uses of APCu-related code were guarded by PHP_MAJOR_VERSION >= 7. At that time the zstd extension still supported PHP 5. I believe the last version of the zstd extension that supported PHP 5 was 0.11.1 and the last version of APCu to do so was 4.0.11. If I have that version of APCu installed while building that version of the zstd extension with PHP 5, am I correct in assuming that it will find APCu at configure time but will do nothing with it at build time and that therefore no APCu dependency of any kind should be added for the PHP 5 case?

Thanks.

remicollet commented 5 months ago

What does the zstd extension do if it finds APCu at build time? How does it use it?

zstd may be used as an APCu optional serializer (sic... not really a serializer)

At buildtime it will use the code from the header (inline function) At runtime, it APCu is present, it will register the serializer