Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Web editor build with closure compiler fails to compile with Emscripten 3.1.53 #88008

Closed
akien-mga opened this issue Feb 6, 2024 · 2 comments · Fixed by #88010
Closed

Web editor build with closure compiler fails to compile with Emscripten 3.1.53 #88008

akien-mga opened this issue Feb 6, 2024 · 2 comments · Fixed by #88010

Comments

@akien-mga
Copy link
Member

Tested versions

Reproducible in 4.3.dev (d335281) with Emscripten 3.1.53.
Didn't try earlier versions yet on current Godot, but 4.3.dev2 built fine with Emscripten 3.1.39 a few weeks ago.

System information

Fedora 39, Emscripten 3.1.53

Issue description

Compiling official builds for the first time with Emscripten 3.1.53 (upgrading from 3.1.39), I ran into the following issue for scons target=editor use_closure_compiler=yes production=yes:

godot.html bin/.web_zip/godot.service.worker.js bin/.web_zip/godot.offline.html as bin/godot.web.template_debug.wasm32.zip
scons: done building targets.
[Time elapsed: 00:17:54.741]
building:ERROR: Closure compiler run failed:

building:ERROR: /tmp/emscripten_temp_0hktqios/godot.web.editor.wasm32.js.pgrow.js:1214:1: ERROR - [JSC_LANGUAGE_FEATURE] This language feature is only supported for ECMASCRIPT_2021 mode or better: Logical assignments.
  1214|  warnOnce.shown ||= {};
         ^
 
/tmp/emscripten_temp_0hktqios/godot.web.editor.wasm32.js.pgrow.js:1683:2: ERROR - [JSC_LANGUAGE_FEATURE] This language feature is only supported for ECMASCRIPT_2021 mode or better: Logical assignments.
  1683|   MEMFS.ops_table ||= {
          ^
 
/tmp/emscripten_temp_0hktqios/godot.web.editor.wasm32.js.pgrow.js:5070:2: ERROR - [JSC_LANGUAGE_FEATURE] This language feature is only supported for ECMASCRIPT_2021 mode or better: Logical assignments.
  5070|   stream.getdents ||= FS.readdir(stream.path);
          ^
 
/tmp/emscripten_temp_0hktqios/godot.web.editor.wasm32.js.pgrow.js:5865:2: ERROR - [JSC_LANGUAGE_FEATURE] This language feature is only supported for ECMASCRIPT_2021 mode or better: Logical assignments.
  5865|   context ||= GL.currentContext;
          ^
 
/tmp/emscripten_temp_0hktqios/godot.web.editor.wasm32.js.pgrow.js:6493:2: ERROR - [JSC_LANGUAGE_FEATURE] This language feature is only supported for ECMASCRIPT_2021 mode or better: Logical assignments.
  6493|   window.getUserMedia ||= navigator["getUserMedia"] || navigator["mozGetUserMedia"];
          ^
 
/tmp/emscripten_temp_0hktqios/godot.web.editor.wasm32.js.pgrow.js:6594:5: ERROR - [JSC_LANGUAGE_FEATURE] This language feature is only supported for ECMASCRIPT_2021 mode or better: Logical assignments.
  6594|      last ||= coords;
             ^
 
6 error(s), 0 warning(s)

em++: error: [0mclosure compiler failed (rc: 6): /root/emsdk/node/16.20.0_64bit/bin/node --max_old_space_size=8192 /root/emsdk/upstream/emscripten/node_modules/.bin/google-closure-compiler --compilation_level ADVANCED_OPTIMIZATIONS --language_in ECMASCRIPT_2021 --language_out NO_TRANSPILE --emit_use_strict=false --externs /root/emsdk/upstream/emscripten/src/closure-externs/closure-externs.js --language_in ECMASCRIPT_2020 --externs /root/godot0/modules/webxr/native/webxr.externs.js --externs /root/godot0/platform/web/js/libs/library_godot_webgl2.externs.js --js /tmp/emscripten_temp_0hktqios/godot.web.editor.wasm32.js.pgrow.js --js_output_file tmppx2_prxq.cc.js --formatting PRETTY_PRINT

Steps to reproduce

  • Install Emscripten 3.1.53
  • scons target=editor use_closure_compiler=yes production=yes

Minimal reproduction project (MRP)

n/a

@akien-mga
Copy link
Member Author

This seems to solve it:

diff --git a/platform/web/detect.py b/platform/web/detect.py
index 89cdab9fa4..bbe1634dfa 100644
--- a/platform/web/detect.py
+++ b/platform/web/detect.py
@@ -169,7 +169,7 @@ def configure(env: "Environment"):
     env.AddMethod(create_template_zip, "CreateTemplateZip")
 
     # Closure compiler extern and support for ecmascript specs (const, let, etc).
-    env["ENV"]["EMCC_CLOSURE_ARGS"] = "--language_in ECMASCRIPT_2020"
+    env["ENV"]["EMCC_CLOSURE_ARGS"] = "--language_in ECMASCRIPT_2021"
 
     env["CC"] = "emcc"
     env["CXX"] = "em++"

I suspect it's related to this change: https://github.com/emscripten-core/emscripten/blob/main/ChangeLog.md#3142---062223

The default minimum Node version of Emscripten output was bumped from 10.19 to 16.0. To run the output JS in an older version of node, you can use e.g. -sMIN_NODE_VERSION=101900 which will apply the previous minimum version of 10.19.0. (#19192).

I don't know if we have a reason to stay on ECMASCRIPT_2020, or if it's fine to bump. CC @Faless

@adamscott
Copy link
Member

adamscott commented Feb 6, 2024

@akien-mga Sorry, it totally flew above my head yesterday when I did my pass through the Change Log.

The default minimum Node version of Emscripten output was bumped from 10.19 to 16.0. To run the output JS in an older version of node, you can use e.g. -sMIN_NODE_VERSION=101900 which will apply the previous minimum version of 10.19.0. (#19192).

I didn't realize that it would impact us about the language used.

akien-mga added a commit to akien-mga/godot that referenced this issue Mar 9, 2024
akien-mga added a commit to akien-mga/godot that referenced this issue Mar 10, 2024
akien-mga added a commit to akien-mga/godot that referenced this issue Apr 25, 2024
akien-mga added a commit to akien-mga/godot that referenced this issue Apr 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants