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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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

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

Lines changed: 3455 additions & 28778 deletions
Original file line numberDiff line numberDiff line change

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

Lines changed: 3451 additions & 28769 deletions
Original file line numberDiff line numberDiff line change

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

Lines changed: 3486 additions & 28782 deletions
Original file line numberDiff line numberDiff line change

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

Lines changed: 3514 additions & 28774 deletions
Original file line numberDiff line numberDiff line change

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

Lines changed: 3514 additions & 28771 deletions
Original file line numberDiff line numberDiff line change

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

Lines changed: 3514 additions & 28771 deletions
Original file line numberDiff line numberDiff line change

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

Lines changed: 3490 additions & 28765 deletions
Original file line numberDiff line numberDiff line change
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

packages/php-wasm/web/public/php/asyncify/php_7_2.js

Lines changed: 34 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/php-wasm/web/public/php/asyncify/php_7_3.js

Lines changed: 34 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/php-wasm/web/public/php/asyncify/php_7_4.js

Lines changed: 34 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/php-wasm/web/public/php/asyncify/php_8_0.js

Lines changed: 34 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/php-wasm/web/public/php/asyncify/php_8_1.js

Lines changed: 35 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/php-wasm/web/public/php/asyncify/php_8_2.js

Lines changed: 34 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/php-wasm/web/public/php/asyncify/php_8_3.js

Lines changed: 34 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/php-wasm/web/public/php/asyncify/php_8_4.js

Lines changed: 34 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

packages/php-wasm/web/public/php/jspi/php_7_2.js

Lines changed: 35 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/php-wasm/web/public/php/jspi/php_7_3.js

Lines changed: 35 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/php-wasm/web/public/php/jspi/php_7_4.js

Lines changed: 35 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/php-wasm/web/public/php/jspi/php_8_0.js

Lines changed: 33 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/php-wasm/web/public/php/jspi/php_8_1.js

Lines changed: 33 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/php-wasm/web/public/php/jspi/php_8_2.js

Lines changed: 33 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/php-wasm/web/public/php/jspi/php_8_3.js

Lines changed: 33 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/php-wasm/web/public/php/jspi/php_8_4.js

Lines changed: 33 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)