Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ See docs/process.md for more on how version tagging works.
- The deprecated `EMSCRIPTEN` macro is now defined in `emscripten.h` rather than
on the command line (`__EMSCRIPTEN__`, which is built into LLVM, should be
used instead). (#26417)
- All pthread functions are now undefined when building with `-sWASM_WORKERS`.
This is an extension of #26336 which removed many of them. These APIs were
not previously functional under Wasm Workers, but if there is strong use case
it may be possible to enable them in future. (#26487)

5.0.3 - 03/14/26
----------------
Expand Down
8 changes: 5 additions & 3 deletions system/include/emscripten/val.h
Original file line number Diff line number Diff line change
Expand Up @@ -566,9 +566,11 @@ class EMBIND_VISIBILITY_DEFAULT val {

private:
// takes ownership, assumes handle already incref'd and lives on the same thread
explicit val(EM_VAL handle)
: handle(handle), thread(pthread_self())
{}
explicit val(EM_VAL handle) :
#ifdef _REENTRANT
thread(pthread_self()),
#endif
handle(handle) {}

// Whether this value is a uses incref/decref (true) or is a special reserved
// value (false).
Expand Down
9 changes: 6 additions & 3 deletions system/lib/pthread/emscripten_thread_state.S
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@

.section .globals,"",@

#ifndef __EMSCRIPTEN_WASM_WORKERS__
.globaltype thread_ptr, PTR
thread_ptr:
#endif

.globaltype is_main_thread, i32
is_main_thread:
Expand All @@ -28,8 +30,10 @@ done_init:
.globl __set_thread_state
__set_thread_state:
.functype __set_thread_state (PTR, i32, i32, i32) -> ()
#ifndef __EMSCRIPTEN_WASM_WORKERS__
local.get 0
global.set thread_ptr
#endif
local.get 1
global.set is_main_thread
local.get 2
Expand All @@ -56,14 +60,13 @@ lazy_init_thread_state:
end_function
#endif

#ifndef __EMSCRIPTEN_WASM_WORKERS__
.globl __get_tp
__get_tp:
.functype __get_tp () -> (PTR)
#if __EMSCRIPTEN_WASM_WORKERS__
call lazy_init_thread_state
#endif
global.get thread_ptr
end_function
#endif

# Semantically the same as testing "!ENVIRONMENT_IS_PTHREAD" in JS
.globl emscripten_is_main_runtime_thread
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"a.html.gz": 371,
"a.js": 5353,
"a.js.gz": 2524,
"a.wasm": 5798,
"a.wasm.gz": 2731,
"total": 11699,
"total_gz": 5626
"a.wasm": 5741,
"a.wasm.gz": 2690,
"total": 11642,
"total_gz": 5585
}
93 changes: 46 additions & 47 deletions tools/system_libs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1217,53 +1217,6 @@ def get_files(self):
])
else:
ignore += ['thread']
libc_files += files_in_path(
path='system/lib/libc/musl/src/thread',
filenames=[
'pthread_self.c',
'pthread_cleanup_push.c',
'pthread_attr_init.c',
'pthread_attr_destroy.c',
'pthread_attr_get.c',
'pthread_attr_setdetachstate.c',
'pthread_attr_setguardsize.c',
'pthread_attr_setinheritsched.c',
'pthread_attr_setschedparam.c',
'pthread_attr_setschedpolicy.c',
'pthread_attr_setscope.c',
'pthread_attr_setstack.c',
'pthread_attr_setstacksize.c',
'pthread_getattr_np.c',
'pthread_getconcurrency.c',
'pthread_getcpuclockid.c',
'pthread_getschedparam.c',
'pthread_setschedprio.c',
'pthread_setconcurrency.c',
'default_attr.c',
# C11 thread library functions
'call_once.c',
'tss_create.c',
'tss_delete.c',
'tss_set.c',
'cnd_broadcast.c',
'cnd_destroy.c',
'cnd_init.c',
'cnd_signal.c',
'cnd_timedwait.c',
'cnd_wait.c',
'mtx_destroy.c',
'mtx_init.c',
'mtx_lock.c',
'mtx_timedlock.c',
'mtx_trylock.c',
'mtx_unlock.c',
'thrd_create.c',
'thrd_exit.c',
'thrd_join.c',
'thrd_sleep.c',
'thrd_yield.c',
])

libc_files += files_in_path(
path='system/lib/libc',
filenames=['emscripten_yield_stub.c'])
Expand All @@ -1288,6 +1241,52 @@ def get_files(self):
'pthread_self_stub.c',
'proxying_stub.c',
])
libc_files += files_in_path(
path='system/lib/libc/musl/src/thread',
filenames=[
'pthread_self.c',
'pthread_cleanup_push.c',
'pthread_attr_init.c',
'pthread_attr_destroy.c',
'pthread_attr_get.c',
'pthread_attr_setdetachstate.c',
'pthread_attr_setguardsize.c',
'pthread_attr_setinheritsched.c',
'pthread_attr_setschedparam.c',
'pthread_attr_setschedpolicy.c',
'pthread_attr_setscope.c',
'pthread_attr_setstack.c',
'pthread_attr_setstacksize.c',
'pthread_getattr_np.c',
'pthread_getconcurrency.c',
'pthread_getcpuclockid.c',
'pthread_getschedparam.c',
'pthread_setschedprio.c',
'pthread_setconcurrency.c',
'default_attr.c',
# C11 thread library functions
'call_once.c',
'tss_create.c',
'tss_delete.c',
'tss_set.c',
'cnd_broadcast.c',
'cnd_destroy.c',
'cnd_init.c',
'cnd_signal.c',
'cnd_timedwait.c',
'cnd_wait.c',
'mtx_destroy.c',
'mtx_init.c',
'mtx_lock.c',
'mtx_timedlock.c',
'mtx_trylock.c',
'mtx_unlock.c',
'thrd_create.c',
'thrd_exit.c',
'thrd_join.c',
'thrd_sleep.c',
'thrd_yield.c',
])

if self.is_mt or self.is_ww:
# Low level thread primitives available in both pthreads and wasm workers builds.
Expand Down
Loading