Skip to content

Commit 5991425

Browse files
authored
Fix compiler crash on misuse of WASM_WORKERS (#22176)
Fixes: #22175
1 parent a94a40e commit 5991425

File tree

4 files changed

+23
-9
lines changed

4 files changed

+23
-9
lines changed

embuilder.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@
3333
'libbulkmemory',
3434
'libcompiler_rt',
3535
'libcompiler_rt-wasm-sjlj',
36+
'libcompiler_rt-ww',
3637
'libc',
3738
'libc-debug',
39+
'libc-ww-debug',
3840
'libc_optz',
3941
'libc_optz-debug',
4042
'libc++abi',
@@ -43,13 +45,16 @@
4345
'libc++abi-debug',
4446
'libc++abi-debug-except',
4547
'libc++abi-debug-noexcept',
48+
'libc++abi-debug-ww-noexcept',
4649
'libc++',
4750
'libc++-except',
4851
'libc++-noexcept',
52+
'libc++-ww-noexcept',
4953
'libal',
5054
'libdlmalloc',
5155
'libdlmalloc-tracing',
5256
'libdlmalloc-debug',
57+
'libdlmalloc-ww',
5358
'libembind',
5459
'libembind-rtti',
5560
'libemmalloc',
@@ -63,8 +68,10 @@
6368
'libGL-getprocaddr',
6469
'libGL-emu-webgl2-ofb-getprocaddr',
6570
'libGL-webgl2-ofb-getprocaddr',
71+
'libGL-ww-getprocaddr',
6672
'libhtml5',
6773
'libsockets',
74+
'libsockets-ww',
6875
'libstubs',
6976
'libstubs-debug',
7077
'libstandalonewasm-nocatch',

src/library_wasm_worker.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,16 @@
2020
#error "Internal error! SHARED_MEMORY should be enabled when building with WASM_WORKERS"
2121
#endif
2222
#if SINGLE_FILE
23-
#error "-sSINGLE_FILE is not supported with -sWASM_WORKERS!"
23+
#error "-sSINGLE_FILE is not supported with -sWASM_WORKERS"
2424
#endif
2525
#if LINKABLE
26-
#error "-sLINKABLE is not supported with -sWASM_WORKERS!"
26+
#error "-sLINKABLE is not supported with -sWASM_WORKERS"
2727
#endif
28-
#if SIDE_MODULE
29-
#error "-sSIDE_MODULE is not supported with -sWASM_WORKERS!"
30-
#endif
31-
#if MAIN_MODULE
32-
#error "-sMAIN_MODULE is not supported with -sWASM_WORKERS!"
28+
#if RELOCATABLE
29+
#error "dynamic linking is not supported with -sWASM_WORKERS"
3330
#endif
3431
#if PROXY_TO_WORKER
35-
#error "-sPROXY_TO_WORKER is not supported with -sWASM_WORKERS!"
32+
#error "-sPROXY_TO_WORKER is not supported with -sWASM_WORKERS"
3633
#endif
3734

3835
#endif // ~WASM_WORKERS

test/test_other.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13840,6 +13840,14 @@ def test_debug_opt_warning(self, should_fail, args):
1384013840
def test_wasm_worker_closure(self):
1384113841
self.run_process([EMCC, test_file('wasm_worker/lock_async_acquire.c'), '-O2', '-sWASM_WORKERS', '--closure=1'])
1384213842

13843+
def test_wasm_worker_errors(self):
13844+
err = self.expect_fail([EMCC, test_file('hello_world.c'), '-sWASM_WORKERS', '-sSINGLE_FILE'])
13845+
self.assertContained('-sSINGLE_FILE is not supported with -sWASM_WORKERS', err)
13846+
err = self.expect_fail([EMCC, test_file('hello_world.c'), '-sWASM_WORKERS', '-sPROXY_TO_WORKER'])
13847+
self.assertContained('-sPROXY_TO_WORKER is not supported with -sWASM_WORKERS', err)
13848+
err = self.expect_fail([EMCC, test_file('hello_world.c'), '-sWASM_WORKERS', '-sRELOCATABLE'])
13849+
self.assertContained('dynamic linking is not supported with -sWASM_WORKERS', err)
13850+
1384313851
def test_clock_nanosleep(self):
1384413852
self.do_runf('other/test_clock_nanosleep.c')
1384513853

tools/system_libs.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2384,7 +2384,9 @@ def add_sanitizer_libs():
23842384
if settings.LINK_AS_CXX:
23852385
add_library('libwebgpu_cpp')
23862386

2387-
if settings.WASM_WORKERS:
2387+
if settings.WASM_WORKERS and (not settings.SINGLE_FILE and
2388+
not settings.RELOCATABLE and
2389+
not settings.PROXY_TO_WORKER):
23882390
add_library('libwasm_workers')
23892391

23902392
if settings.WASMFS:

0 commit comments

Comments
 (0)