PHP: Do not pull WebGL in Playground web #2318
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 mainemcc
call linking the final PHP.wasm file. It worked fine in Node.js, but on the web, after rebuilding withrecompile:php:web:jspi:8.4
, Playground threw aReferenceError: 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 that assumesglobalThis.document
exists – hence the error. See this Emscripten thread 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 saysmissing 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:cc @mho22 @zaerl