Skip to content

Commit 26f17c3

Browse files
committed
[Web] Add workaround for missing export in threaded builds
The offending symbol gets stripped away by wasm-dce but it's used on the JavaScript side and causes and undefined symbol which also causes the closure compiler to throw an error.
1 parent 91eb688 commit 26f17c3

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

platform/web/detect.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,11 @@ def configure(env: "SConsEnvironment"):
227227
env.Append(LINKFLAGS=["-sDEFAULT_PTHREAD_STACK_SIZE=%sKB" % env["default_pthread_stack_size"]])
228228
env.Append(LINKFLAGS=["-sPTHREAD_POOL_SIZE=8"])
229229
env.Append(LINKFLAGS=["-sWASM_MEM_MAX=2048MB"])
230+
if not env["dlink_enabled"]:
231+
# Workaround https://github.com/emscripten-core/emscripten/issues/21844#issuecomment-2116936414.
232+
# Not needed (and potentially dangerous) when dlink_enabled=yes, since we set EXPORT_ALL=1 in that case.
233+
env.Append(LINKFLAGS=["-sEXPORTED_FUNCTIONS=['__emscripten_thread_crashed','_main']"])
234+
230235
elif env["proxy_to_pthread"]:
231236
print_warning('"threads=no" support requires "proxy_to_pthread=no", disabling proxy to pthread.')
232237
env["proxy_to_pthread"] = False

0 commit comments

Comments
 (0)