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 closure compiler build fails after #94109 #94725

Closed
akien-mga opened this issue Jul 25, 2024 · 2 comments · Fixed by #94789
Closed

Web closure compiler build fails after #94109 #94725

akien-mga opened this issue Jul 25, 2024 · 2 comments · Fixed by #94789

Comments

@akien-mga
Copy link
Member

Tested versions

System information

Fedora Linux 40 (KDE Plasma) - Wayland - Vulkan (Forward+) - dedicated AMD Radeon RX 7600M XT (RADV NAVI33) - AMD Ryzen 7 7840HS w/ Radeon 780M Graphics (16 Threads)

Issue description

Using Emscripten 3.1.64, but I tested 3.1.63 and 3.1.62 which have the same issue.

I bisected the regression to #94109.

This error happens on a closure compiler Web editor compilation:

ERROR - [JSC_UNDEFINED_VARIABLE] variable __emscripten_thread_crashed is undeclared
  128| err(`worker: received unknown command ${cmd}`);err(msgData)}}catch(ex){__emscripten_thread_crashed();throw ex}}self.onmessage=handleMessage}// ENVIRONMENT_IS_PTHREAD
                                                                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^

@Faless started looking into it:

Most of the changes in how threads works seems to come from 21701, specifically, the function should be coming from wasm IIUC, while it was also part of the JS file before at least as a stub.

Anyway, I have a feeling removing that stub required a change somewhere else, I'll further investigate (likely tomorrow).
This will most likely require an emscripten patch, we can probably disable CC for editor in this RC, alternatively I've made the best hack I could think of: https://github.com/Faless/godot/tree/web/the_ugliest_cc_hack_you_can_imagine

Steps to reproduce

  • scons platform=web target=editor use_closure_compiler=yes verbose=yes scu_build=yes

Minimal reproduction project (MRP)

n/a

@Faless
Copy link
Collaborator

Faless commented Jul 26, 2024

Small update, it seems that wasm-metadce is marking _emscripten_thread_crashed as unused (and thus stripping it?):

shared:DEBUG: successfully executed /media/Storage/emsdk/upstream/bin/wasm-metadce --graph-file=/tmp/emscripten_temp/emcc_dce_graph_bzsx5gw4.json bin/godot.web.template_debug.wasm32.wasm -o bin/godot.web.template_debug.wasm32.wasm -g --mvp-features --enable-threads --enable-bulk-memory --enable-exception-handling --enable-multivalue --enable-mutable-globals --enable-reference-types --enable-sign-ext
building:DEBUG: saving debug copy /tmp/emscripten_temp/emcc-09-wasm-metadce.wasm
building:DEBUG: unused_imports: ['__assert_fail', '__syscall_fstat64']
building:DEBUG: unused_exports: ['_emscripten_run_callback_on_thread', '_emscripten_thread_crashed', 'emscripten_main_runtime_thread_id', 'emscripten_main_thread_process_queued_calls', 'emscripten_webgl_commit_frame']

I tried making a sample reproduction test (using the same Godot flags), but it doesn't seem to mark that function as unused (even if no thread code is present at all):

shared:DEBUG: successfully executed /media/Storage/emsdk//upstream/bin/wasm-metadce --graph-file=/tmp/emscripten_temp/emcc_dce_graph_ps3tsvs8.json test.wasm -o test.wasm -g --mvp-features --enable-threads --enable-bulk-memory --enable-exception-handling --enable-multivalue --enable-mutable-globals --enable-reference-types --enable-sign-ext
building:DEBUG: saving debug copy /tmp/emscripten_temp/emcc-09-wasm-metadce.wasm
building:DEBUG: unused_imports: ['_emscripten_get_now_is_monotonic', 'emscripten_date_now']
building:DEBUG: unused_exports: ['emscripten_main_runtime_thread_id', 'emscripten_main_thread_process_queued_calls']
shared:DEBUG: successfully executed /media/Storage/emsdk//node/18.20.3_64bit/bin/node /media/SSD/Code/git/emscripten/tools/acorn-optimizer.mjs /tmp/emscripten_temp/emcc_acorn_info_2zjqqv2t.js applyDCEGraphRemovals --closure-friendly -o /tmp/emscripten_temp/test.js.pgrow.jso3.js

Still investigating, but I'm a bit at lost tbh, I'll probably open an issue upstream with my findings if I can't figure it out by the end of today.

@Faless
Copy link
Collaborator

Faless commented Jul 26, 2024

Well, some more news, it seems I found the relevant upstream issues: emscripten-core/emscripten#21844 .
Though in our case, it also happens if we don't enable dlink (i.e. not using MAIN_MODULE).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Release Blocker
Development

Successfully merging a pull request may close this issue.

2 participants