From 09d3f9be864fa5ac3687cbad464b7d201536d518 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Tue, 17 Mar 2026 15:44:51 -0700 Subject: [PATCH] Don't pass `-sWASM_WORKERS` when building libc-mt. NFC This library gets linking into `-pthreads` build where wasm worker APIs are not available. If we have code in libc that looks like this it would fail to link in that case: ``` use_wasm_worker_api(); ``` The fact that this is worked thus far only because we don't use that macro anywhere in libc today. --- system/lib/pthread/emscripten_thread_state.S | 12 ++++++------ tools/system_libs.py | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/system/lib/pthread/emscripten_thread_state.S b/system/lib/pthread/emscripten_thread_state.S index bbe707a324bc9..2060fb977acd5 100644 --- a/system/lib/pthread/emscripten_thread_state.S +++ b/system/lib/pthread/emscripten_thread_state.S @@ -18,7 +18,7 @@ is_runtime_thread: .globaltype supports_wait, i32 supports_wait: -#if WASM_WORKERS_ONLY +#if __EMSCRIPTEN_WASM_WORKERS__ .globaltype done_init, i32 done_init: #endif @@ -38,7 +38,7 @@ __set_thread_state: global.set supports_wait end_function -#if WASM_WORKERS_ONLY +#if __EMSCRIPTEN_WASM_WORKERS__ // With Wasm Workers we do lazy initializtion of the thread // state so that only workers that call these APIs actually // initializes their state. @@ -59,7 +59,7 @@ lazy_init_thread_state: .globl __get_tp __get_tp: .functype __get_tp () -> (PTR) -#if WASM_WORKERS_ONLY +#if __EMSCRIPTEN_WASM_WORKERS__ call lazy_init_thread_state #endif global.get thread_ptr @@ -69,7 +69,7 @@ __get_tp: .globl emscripten_is_main_runtime_thread emscripten_is_main_runtime_thread: .functype emscripten_is_main_runtime_thread () -> (i32) -#if WASM_WORKERS_ONLY +#if __EMSCRIPTEN_WASM_WORKERS__ call lazy_init_thread_state #endif global.get is_runtime_thread @@ -79,7 +79,7 @@ emscripten_is_main_runtime_thread: .globl emscripten_is_main_browser_thread emscripten_is_main_browser_thread: .functype emscripten_is_main_browser_thread () -> (i32) -#if WASM_WORKERS_ONLY +#if __EMSCRIPTEN_WASM_WORKERS__ call lazy_init_thread_state #endif global.get is_main_thread @@ -89,7 +89,7 @@ emscripten_is_main_browser_thread: .globl _emscripten_thread_supports_atomics_wait _emscripten_thread_supports_atomics_wait: .functype _emscripten_thread_supports_atomics_wait () -> (i32) -#if WASM_WORKERS_ONLY +#if __EMSCRIPTEN_WASM_WORKERS__ call lazy_init_thread_state #endif global.get supports_wait diff --git a/tools/system_libs.py b/tools/system_libs.py index 7de3102fd9db6..466e81c45fe0b 100644 --- a/tools/system_libs.py +++ b/tools/system_libs.py @@ -714,9 +714,9 @@ def __init__(self, **kwargs): def get_cflags(self): cflags = super().get_cflags() if self.is_mt: - cflags += ['-pthread', '-sWASM_WORKERS'] + cflags += ['-pthread'] if self.is_ww: - cflags += ['-sWASM_WORKERS', '-DWASM_WORKERS_ONLY'] + cflags += ['-sWASM_WORKERS'] return cflags def get_base_name(self):