You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
zlib – Playground uses a 10 years old Emscripten-compatible port of zlib because my initial attempt to compile the upstream version as WASM failed. I'm sure this old port can be removed, especially since Emscripten comes with -s USE_ZLIB=1 switch these days, but I didn't get there yet. PRs welcome!
Currently a copy of this ported zlib lives in the Playground repo, in the folder packages/php-wasm/compile/build-assets/zlib. The README file says this is zlib version 1.2.5, while the port itself is at 1.2.8.
When you request that a port be used, emcc will fetch it from the remote server, set it up and build it locally, then link it with your project, add necessary include to your build commands, etc.
The Dockerfile for PHP WASM is daunting ("impressive, overwhelming, inspiring fear"), but here's my guess at what's necessary to remove the bundled copy and use Emscripten's zlib.
/root/.emcc-php-wasm-flags - Add -s USE_ZLIB=1 and remove -I /root/zlib
/root/.php-configure-flags - Update --with-zlib-dir=/root/lib to the destination path where Emscripten builds zlib?
Copy the same built zlib to the image emscripten-libz and/or /root/libz for steps that need it?
It puts the downloaded source and an additional file zconf.h into the directory:
{$EM_CACHE}/ports/zlib/zlib-{$ZLIB_VERSION}
The zlib version is hardcoded in the script here. There doesn't seem to be a way to get it from outside of emscripten/embuilder.
The built file libz.a is placed in the following directory (defined here).
{$EM_CACHE}/ports-builds/zlib
The cache directory defaults to emscripten/cache but can be overridden using the EM_CACHE environment variable (according to emcc docs here).
All that considered, perhaps it's easier to manually update the copy of zlib bundled with the Playground, instead of trying to use what Emscripten generates.
Just making a note here to serve as a reminder for the future.
Something I noticed in a comment that gives an overview of the patches applied by WordPress Playground:
Currently a copy of this ported zlib lives in the Playground repo, in the folder
packages/php-wasm/compile/build-assets/zlib
. The README file says this is zlib version 1.2.5, while the port itself is at 1.2.8.The
USE_ZLIB
option in Emscripten (added in version 1.26.1) uses a Python script to download and patch zlib from its original source repo, which is at version 1.2.13.According to the documentation, Building Projects: Emscripten Ports:
The Dockerfile for PHP WASM is daunting ("impressive, overwhelming, inspiring fear"), but here's my guess at what's necessary to remove the bundled copy and use Emscripten's zlib.
/root/.emcc-php-wasm-flags
- Add-s USE_ZLIB=1
and remove-I /root/zlib
/root/.php-configure-flags
- Update--with-zlib-dir=/root/lib
to the destination path where Emscripten builds zlib?emscripten-libz
and/or/root/libz
for steps that need it?From this pull request in Emscripten, Use common include directory for all ports #9983:
It seems the built zlib is at
{$EM_CACHE}/ports-builds/zlib
.The text was updated successfully, but these errors were encountered: