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
2 changes: 2 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ See docs/process.md for more on how version tagging works.

4.0.24 (in development)
-----------------------
- Calling pthread_create in a single-threaded build will now return ENOTSUP
rather then EAGAIN. (#26105)
- compiler-rt and libunwind were updated to LLVM 21.1.8. (#26036 and #26045)
- A new `-sEXECUTABLE` setting was added which adds a #! line to the resulting
JavaScript and makes it executable. This setting defaults to true when the
Expand Down
6 changes: 5 additions & 1 deletion system/lib/pthread/library_pthread_stub.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,11 @@ int pthread_barrier_destroy(pthread_barrier_t* mutex) { return 0; }
int pthread_barrier_wait(pthread_barrier_t* mutex) { return 0; }

int __pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine) (void *), void *arg) {
return EAGAIN;
// ENOTSUP, while not mentioned in the pthread_create docs, does better
// describe the situation.
// See https://github.com/WebAssembly/wasi-libc/pull/716 for discussion
// on this error code vs, for example, EAGAIN.
return ENOTSUP;
}

weak_alias(__pthread_create, emscripten_builtin_pthread_create);
Expand Down
4 changes: 2 additions & 2 deletions test/codesize/test_codesize_hello_dylink_all.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"a.out.js": 244848,
"a.out.nodebug.wasm": 577875,
"total": 822723,
"a.out.nodebug.wasm": 577876,
"total": 822724,
"sent": [
"IMG_Init",
"IMG_Load",
Expand Down
4 changes: 2 additions & 2 deletions test/other/test_pthread_stub.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ void* start_pthread(void* arg) {
}

#define CHECK(X, EXPECTED) rtn = X; if (rtn != EXPECTED) printf(#X " returned %s\n", strerror(rtn)); assert(rtn == EXPECTED)
#define CHECK_FAIL(X) CHECK(X, EAGAIN)
#define CHECK_FAIL(X) CHECK(X, ENOTSUP)
#define CHECK_SUCCESS(X) CHECK(X, 0)

#define CHECK_C11(X, expected) rtn = X; if (rtn != expected) printf(#X " returned %d\n", rtn); assert(rtn == expected)
#define CHECK_C11_SUCCESS(X) CHECK_C11(X, thrd_success)
#define CHECK_C11_FAIL(X) CHECK_C11(X, thrd_nomem)
#define CHECK_C11_FAIL(X) CHECK_C11(X, thrd_error)

void test_c11_threads() {
printf("test_c11_threads\n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,20 @@
#include <assert.h>
#include <errno.h>

void *ThreadMain(void *arg)
{
pthread_exit(NULL);
void *ThreadMain(void *arg) {
pthread_exit(NULL);
}

int main()
{
pthread_t thread;
int rc = pthread_create(&thread, NULL, ThreadMain, NULL);
pthread_join(thread, NULL);
int main() {
pthread_t thread;
int rc = pthread_create(&thread, NULL, ThreadMain, NULL);
pthread_join(thread, NULL);

if (emscripten_has_threading_support()) assert(rc == 0);
else assert(rc == EAGAIN);
if (emscripten_has_threading_support()) {
assert(rc == 0);
} else {
assert(rc == ENOTSUP);
}

return 0;
return 0;
}
2 changes: 1 addition & 1 deletion test/test_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -3911,7 +3911,7 @@ def test_pthread_file_io(self):
'mt': (['-pthread', '-sPTHREAD_POOL_SIZE=8'],),
})
def test_pthread_supported(self, args):
self.btest_exit('pthread/test_pthread_supported.cpp', cflags=['-O3'] + args)
self.btest_exit('pthread/test_pthread_supported.c', cflags=['-O3'] + args)

def test_pthread_dispatch_after_exit(self):
self.btest_exit('pthread/test_pthread_dispatch_after_exit.c', cflags=['-pthread'])
Expand Down
2 changes: 1 addition & 1 deletion test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -15095,7 +15095,7 @@ def test_libcxx_errors(self):

# Since we are building without -pthread the thread constructor will fail,
# and in debug mode at least we expect to see the error message from libc++
expected = 'system_error was thrown in -fno-exceptions mode with error 6 and message "thread constructor failed"'
expected = 'system_error was thrown in -fno-exceptions mode with error 138 and message "thread constructor failed"'
self.do_runf('main.cpp', expected, assert_returncode=NON_ZERO)

def test_parsetools_make_removed_fs_assert(self):
Expand Down