Description
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:
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.
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:
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?
From this pull request in Emscripten, Use common include directory for all ports #9983:
All ports now install their headers into a shared directory under
EM_CACHE
.
It seems the built zlib is at {$EM_CACHE}/ports-builds/zlib
.