Skip to content

Commit 9034992

Browse files
committed
Remove remaining pthread function from WASM_WORKERS build. NFC
This includes `pthread_self`, which is not valid to call in Wasm Workers.
1 parent 7627e4e commit 9034992

File tree

3 files changed

+56
-50
lines changed

3 files changed

+56
-50
lines changed

ChangeLog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ See docs/process.md for more on how version tagging works.
2323
- The deprecated `EMSCRIPTEN` macro is now defined in `emscripten.h` rather than
2424
on the command line (`__EMSCRIPTEN__`, which is built into LLVM, should be
2525
used instead). (#26417)
26+
- All pthread functions are now undefined when building with `-sWASM_WORKERS`.
27+
This is an extension of #26336 which removed many of them. These APIs were
28+
not previously functional under Wasm Workers, but if there is strong use case
29+
it may be possible to enable them in future. (#26487)
2630

2731
5.0.3 - 03/14/26
2832
----------------

system/lib/pthread/emscripten_thread_state.S

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66

77
.section .globals,"",@
88

9+
#ifndef __EMSCRIPTEN_WASM_WORKERS__
910
.globaltype thread_ptr, PTR
1011
thread_ptr:
12+
#endif
1113

1214
.globaltype is_main_thread, i32
1315
is_main_thread:
@@ -28,8 +30,10 @@ done_init:
2830
.globl __set_thread_state
2931
__set_thread_state:
3032
.functype __set_thread_state (PTR, i32, i32, i32) -> ()
33+
#ifndef __EMSCRIPTEN_WASM_WORKERS__
3134
local.get 0
3235
global.set thread_ptr
36+
#endif
3337
local.get 1
3438
global.set is_main_thread
3539
local.get 2
@@ -56,14 +60,13 @@ lazy_init_thread_state:
5660
end_function
5761
#endif
5862

63+
#ifndef __EMSCRIPTEN_WASM_WORKERS__
5964
.globl __get_tp
6065
__get_tp:
6166
.functype __get_tp () -> (PTR)
62-
#if __EMSCRIPTEN_WASM_WORKERS__
63-
call lazy_init_thread_state
64-
#endif
6567
global.get thread_ptr
6668
end_function
69+
#endif
6770

6871
# Semantically the same as testing "!ENVIRONMENT_IS_PTHREAD" in JS
6972
.globl emscripten_is_main_runtime_thread

tools/system_libs.py

Lines changed: 46 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,53 +1217,6 @@ def get_files(self):
12171217
])
12181218
else:
12191219
ignore += ['thread']
1220-
libc_files += files_in_path(
1221-
path='system/lib/libc/musl/src/thread',
1222-
filenames=[
1223-
'pthread_self.c',
1224-
'pthread_cleanup_push.c',
1225-
'pthread_attr_init.c',
1226-
'pthread_attr_destroy.c',
1227-
'pthread_attr_get.c',
1228-
'pthread_attr_setdetachstate.c',
1229-
'pthread_attr_setguardsize.c',
1230-
'pthread_attr_setinheritsched.c',
1231-
'pthread_attr_setschedparam.c',
1232-
'pthread_attr_setschedpolicy.c',
1233-
'pthread_attr_setscope.c',
1234-
'pthread_attr_setstack.c',
1235-
'pthread_attr_setstacksize.c',
1236-
'pthread_getattr_np.c',
1237-
'pthread_getconcurrency.c',
1238-
'pthread_getcpuclockid.c',
1239-
'pthread_getschedparam.c',
1240-
'pthread_setschedprio.c',
1241-
'pthread_setconcurrency.c',
1242-
'default_attr.c',
1243-
# C11 thread library functions
1244-
'call_once.c',
1245-
'tss_create.c',
1246-
'tss_delete.c',
1247-
'tss_set.c',
1248-
'cnd_broadcast.c',
1249-
'cnd_destroy.c',
1250-
'cnd_init.c',
1251-
'cnd_signal.c',
1252-
'cnd_timedwait.c',
1253-
'cnd_wait.c',
1254-
'mtx_destroy.c',
1255-
'mtx_init.c',
1256-
'mtx_lock.c',
1257-
'mtx_timedlock.c',
1258-
'mtx_trylock.c',
1259-
'mtx_unlock.c',
1260-
'thrd_create.c',
1261-
'thrd_exit.c',
1262-
'thrd_join.c',
1263-
'thrd_sleep.c',
1264-
'thrd_yield.c',
1265-
])
1266-
12671220
libc_files += files_in_path(
12681221
path='system/lib/libc',
12691222
filenames=['emscripten_yield_stub.c'])
@@ -1288,6 +1241,52 @@ def get_files(self):
12881241
'pthread_self_stub.c',
12891242
'proxying_stub.c',
12901243
])
1244+
libc_files += files_in_path(
1245+
path='system/lib/libc/musl/src/thread',
1246+
filenames=[
1247+
'pthread_self.c',
1248+
'pthread_cleanup_push.c',
1249+
'pthread_attr_init.c',
1250+
'pthread_attr_destroy.c',
1251+
'pthread_attr_get.c',
1252+
'pthread_attr_setdetachstate.c',
1253+
'pthread_attr_setguardsize.c',
1254+
'pthread_attr_setinheritsched.c',
1255+
'pthread_attr_setschedparam.c',
1256+
'pthread_attr_setschedpolicy.c',
1257+
'pthread_attr_setscope.c',
1258+
'pthread_attr_setstack.c',
1259+
'pthread_attr_setstacksize.c',
1260+
'pthread_getattr_np.c',
1261+
'pthread_getconcurrency.c',
1262+
'pthread_getcpuclockid.c',
1263+
'pthread_getschedparam.c',
1264+
'pthread_setschedprio.c',
1265+
'pthread_setconcurrency.c',
1266+
'default_attr.c',
1267+
# C11 thread library functions
1268+
'call_once.c',
1269+
'tss_create.c',
1270+
'tss_delete.c',
1271+
'tss_set.c',
1272+
'cnd_broadcast.c',
1273+
'cnd_destroy.c',
1274+
'cnd_init.c',
1275+
'cnd_signal.c',
1276+
'cnd_timedwait.c',
1277+
'cnd_wait.c',
1278+
'mtx_destroy.c',
1279+
'mtx_init.c',
1280+
'mtx_lock.c',
1281+
'mtx_timedlock.c',
1282+
'mtx_trylock.c',
1283+
'mtx_unlock.c',
1284+
'thrd_create.c',
1285+
'thrd_exit.c',
1286+
'thrd_join.c',
1287+
'thrd_sleep.c',
1288+
'thrd_yield.c',
1289+
])
12911290

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

0 commit comments

Comments
 (0)