Skip to content

Commit 5821cee

Browse files
adamzielzaerl
andauthored
PHP: Do not pull WebGL in Playground web (#2318)
## Motivation for the change, related issues Only uses `-s MAIN_MODULE` when building for Node.js+JSPI to fix a crash in the web version of Playground. #2248 added `-s MAIN_MODULE` to the main `emcc` call linking the final PHP.wasm file. It worked fine in Node.js, but on the web, after rebuilding with `recompile:php:web:jspi:8.4`, Playground threw a `ReferenceError: document is not defined`. It turn out, `-s MAIN_MODULE` pulls in a pile of extra libraries in case some dynamically loaded lib needs them. One of them was [webgl](https://github.com/emscripten-core/emscripten/blob/b0c461c10482e12f88e192e04b3640acb1577f64/src/lib/libhtml5_webgl.js#L423) that assumes `globalThis.document` exists – hence the error. See [this Emscripten thread](https://groups.google.com/g/emscripten-discuss/c/nz2rXAp_vuQ?pli=1) for more details. ## Implementation Moves `-s MAIN_MODULE` to platform-only flags for Node.js+JSPI. I've tried switching to `-s MAIN_MODULE=2` as suggested in the mailing lists. It fixes it for the web build, but it breaks loading XDebug.so in Node. The error says `missing export type for core_globals`. I assume we need to pull in some additional dependencies and declare them explicitly. ## Remaining work Rebuild all the PHP versions – Node.js and Web – and confirm the tests pass --- Unrelated – I've noticed to patch `with-xdebug.ts` as follows to be able to run it from source: ``` diff --git a/packages/php-wasm/node/src/lib/xdebug/with-xdebug.ts b/packages/php-wasm/node/src/lib/xdebug/with-xdebug.ts index 3b40aa2..41fec3d237 100644 --- a/packages/php-wasm/node/src/lib/xdebug/with-xdebug.ts +++ b/packages/php-wasm/node/src/lib/xdebug/with-xdebug.ts @@ -17,7 +17,11 @@ export async function withXdebug( } const fileName = 'xdebug.so'; - const filePath = await getXdebugExtensionModule(version); + let filePath = await getXdebugExtensionModule(version); + if (filePath.startsWith('file://')) { + filePath = filePath.substring(7); + } + const extension = fs.readFileSync(filePath); return { ``` cc @mho22 @zaerl --------- Co-authored-by: Francesco Bigiarini <[email protected]>
1 parent bf9c3fa commit 5821cee

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+28418
-230311
lines changed

packages/php-wasm/compile/php/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
-10.8 MB
Binary file not shown.
-11 MB
Binary file not shown.
-11 MB
Binary file not shown.
-11.9 MB
Binary file not shown.
-12.4 MB
Binary file not shown.
-12.4 MB
Binary file not shown.
-13.1 MB
Binary file not shown.
-13.5 MB
Binary file not shown.

packages/php-wasm/node/asyncify/php_7_2.js

Lines changed: 3450 additions & 28773 deletions
Original file line numberDiff line numberDiff line change

0 commit comments

Comments
 (0)