Skip to content

Commit 8239f21

Browse files
authored
[PHP] Rebuild with sync fd_close on the web (#2620)
## Motivation for the change, related issues Solves WASM error that came up in #2586: ``` trying to suspend JS frames SuspendError: trying to suspend JS frames at php.wasm.close (php.wasm-0836494a) at php.wasm. rand_pool_cleanup (php.wasm-0836494a) ``` ## Implementation details Stop marking `fd_close` as JSPI import/export for the web builds. Only do it for Node.js builds. My theory is it works in Node because `fd_close` returns a promise there, but not in the browser where `fd_close` is synchronous. It seems like we should not mark non-asynchronous functions as JSPI_IMPORTS or JSPI_EXPORTS. ## Testing Instructions (or ideally a Blueprint) CI
1 parent 6b63e12 commit 8239f21

File tree

29 files changed

+23
-17
lines changed

29 files changed

+23
-17
lines changed

packages/php-wasm/compile/php/Dockerfile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2105,7 +2105,13 @@ RUN set -euxo pipefail; \
21052105
source /root/emsdk/emsdk_env.sh; \
21062106
if [ "$WITH_JSPI" = "yes" ]; then \
21072107
# Both imports and exports are required for inter-module communication with wrapped methods, e.g., wasm_recv.
2108-
export ASYNCIFY_FLAGS=" -s ASYNCIFY=2 -sSUPPORT_LONGJMP=wasm -fwasm-exceptions -sJSPI_IMPORTS=js_open_process,js_fd_read,js_waitpid,js_process_status,js_create_input_device,wasm_setsockopt,wasm_shutdown,wasm_close,wasm_recv,__syscall_fcntl64,js_flock,js_release_file_locks,js_waitpid,fd_close -sJSPI_EXPORTS=php_wasm_init,fd_close,wasm_sleep,wasm_read,emscripten_sleep,wasm_sapi_handle_request,wasm_sapi_request_shutdown,wasm_poll_socket,wrap_select,__wrap_select,select,php_pollfd_for,fflush,wasm_popen,wasm_read,wasm_php_exec,run_cli,wasm_recv -s EXTRA_EXPORTED_RUNTIME_METHODS=ccall,PROXYFS,wasmExports,_malloc,setErrNo "; \
2108+
export JSPI_ADD_IMPORTS=""; \
2109+
export JSPI_ADD_EXPORTS=""; \
2110+
if [ "$EMSCRIPTEN_ENVIRONMENT" = "node" ]; then \
2111+
export JSPI_ADD_IMPORTS=",fd_close"; \
2112+
export JSPI_ADD_EXPORTS=",fd_close"; \
2113+
fi; \
2114+
export ASYNCIFY_FLAGS=" -s ASYNCIFY=2 -sSUPPORT_LONGJMP=wasm -fwasm-exceptions -sJSPI_IMPORTS=js_open_process,js_fd_read,js_waitpid,js_process_status,js_create_input_device,wasm_setsockopt,wasm_shutdown,wasm_close,wasm_recv,__syscall_fcntl64,js_flock,js_release_file_locks,js_waitpid$JSPI_ADD_IMPORTS -sJSPI_EXPORTS=php_wasm_init,wasm_sleep,wasm_read,emscripten_sleep,wasm_sapi_handle_request,wasm_sapi_request_shutdown,wasm_poll_socket,wrap_select,__wrap_select,select,php_pollfd_for,fflush,wasm_popen,wasm_read,wasm_php_exec,run_cli,wasm_recv$JSPI_ADD_EXPORTS -s EXTRA_EXPORTED_RUNTIME_METHODS=ccall,PROXYFS,wasmExports,_malloc,setErrNo "; \
21092115
echo '#define PLAYGROUND_JSPI 1' > /root/php_wasm_asyncify.h; \
21102116
else \
21112117
export ASYNCIFY_FLAGS=" -s ASYNCIFY=1 -s ASYNCIFY_IGNORE_INDIRECT=1 -s EXPORTED_RUNTIME_METHODS=ccall,PROXYFS,wasmExports,setErrNo $(cat /root/.emcc-php-asyncify-flags) "; \

packages/php-wasm/supported-php-versions.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* @property {string} lastRelease
77
*/
88

9-
export const lastRefreshed = '2025-09-08T15:34:15.553Z';
9+
export const lastRefreshed = '2025-09-11T22:46:03.434Z';
1010

1111
/**
1212
* @type {PhpVersion[]}

0 commit comments

Comments
 (0)