Description
There was a pull request #113 that was exploring this direction, which was closed recently with a note to come back at a later time.
Let's look into collaborating with https://github.com/vmware-labs/webassembly-language-runtimes (see php-8.1.11) once WASI supports longjmp.
From what I understand, an advantage of compiling PHP to WASI is that it can be a standalone binary that runs without dependency on Node.js. I wanted to contribute a bit by gathering related links that I came across while studying about this topic.
In the WASI repo, there was an issue WebAssembly/WASI#490 asking about setjmp
support. It was closed with the following note:
The current plan is to wait for the exception-handling proposal to be standardized and implemented in wasm engines, and then to implement setjmp and longjmp using that feature. Exception-handling is currently in phase 3.
So the feature will be implemented eventually. That implies that any workaround solution is temporary, to be replaced/removed in the future.
In the meantime, a WebAssembly / WASI port of Ruby was developed, which gets around the limitation by emulating setjmp
and longjmp
with Asyncify. I learned about it from these articles:
Then someone re-purposed that setjmp
polyfill to integrate with PHP. Here's the as-yet-unmerged pull request:
In parallel, another person from VMware started on an ambitious effort in the PHP repo itself.
Hopefully this issue can serve as reference when there's progress in any of the above.