# Wasm32-emscripten builds fail linking because of pthread dependency

**URL:** <https://ziggit.dev/t/wasm32-emscripten-builds-fail-linking-because-of-pthread-dependency/12879>\
**Category:** Help\
**Tags:** standard-library\
**Created:** [November 6, 2025, 4:09pm UTC](https://ziggit.dev/t/wasm32-emscripten-builds-fail-linking-because-of-pthread-dependency/12879 "2025-11-06T16:09:49Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![floooh](https://ziggit.dev/user_avatar/ziggit.dev/floooh/32/2989_2.png) [@floooh](https://ziggit.dev/u/floooh)\
**Post date:** [November 6, 2025, 4:09pm UTC](https://ziggit.dev/t/wasm32-emscripten-builds-fail-linking-because-of-pthread-dependency/12879/1 "2025-11-06T16:09:49Z")

</div>

My sokol-zig CI has started failing for the Emscripten builds (where the Zig code is compiled with `wasm32-emscripten` because the pthread\_kill() symbol is missing in the link step.

Does that ring a bell? Did the Zig stdlib accidentially get a general pthread dependency on `wasm32-emscripten` targets very recently? (which would suck because shared-memory multithreading in browsers is better to be avoided because SharedArrayBuffer is behind a COOP/COEP gate).

…I’ll also investigate on my side, more details to follow 🙂

PS: my CI is a few days behind because of the broken package download on Windows - and now I removed Windows from the build matrix and I’m running into the wasm32-emscripten problem.

---

<div class="post-metadata">

**Author:** ![castholm](https://ziggit.dev/user_avatar/ziggit.dev/castholm/32/1330_2.png) [@castholm](https://ziggit.dev/u/castholm)\
**Post date:** [November 6, 2025, 6:55pm UTC](https://ziggit.dev/t/wasm32-emscripten-builds-fail-linking-because-of-pthread-dependency/12879/2 "2025-11-06T18:55:24Z")

</div>

A quick search for `pthread_kill` in the repo suggests that these are the culprits:

> <https://github.com/ziglang/zig/blob/b2895f356fa6203d0f3f1476c4e8fb9cf5b6d860/lib/std/Io/Threaded.zig#L83>

> <https://github.com/ziglang/zig/blob/b2895f356fa6203d0f3f1476c4e8fb9cf5b6d860/lib/std/Thread.zig#L23>

I think the `use_pthreads` definition is too broad, but have you tried building with `-fsingle_threaded` (`module.single_threaded = true` in the build system)?

---

<div class="post-metadata">

**Author:** ![floooh](https://ziggit.dev/user_avatar/ziggit.dev/floooh/32/2989_2.png) [@floooh](https://ziggit.dev/u/floooh)\
**Post date:** [November 7, 2025, 8:03am UTC](https://ziggit.dev/t/wasm32-emscripten-builds-fail-linking-because-of-pthread-dependency/12879/3 "2025-11-07T08:03:39Z")

</div>

Hmm, slapping a `.single_threaded = true` on all my createModule() calls didn’t fix the issue, I’ll also need to investigate why that call even makes it into the build because most of the sokol-zig examples don’t even use the Zig stdlib.

PS: FWIW it works in release-fast and release-safe mode, only debug mode seems to include the pthread\_kill() call.

---

<div class="post-metadata">

**Author:** ![castholm](https://ziggit.dev/user_avatar/ziggit.dev/castholm/32/1330_2.png) [@castholm](https://ziggit.dev/u/castholm)\
**Post date:** [November 7, 2025, 9:00am UTC](https://ziggit.dev/t/wasm32-emscripten-builds-fail-linking-because-of-pthread-dependency/12879/4 "2025-11-07T09:00:08Z")

</div>

I think it’s getting pulled in via `std.debug.writeStackTrace()`:

> <https://github.com/ziglang/zig/blob/4b593a6c24797484e68a668818736b0f6a8d81a2/lib/std/debug.zig#L786>

Which is called by the `std.start` startup code that calls your main function, if your main function returns an error union:

> <https://github.com/ziglang/zig/blob/4b593a6c24797484e68a668818736b0f6a8d81a2/lib/std/start.zig#L710>

You might be able to work around in a few different ways, for example by declaring a non-error `void`/`u8` main function, building with error return traces disabled, building with debug info stripped, or declaring `pub const std_options: std.Options = .{ .allow_stack_tracing = false };`. (But clearly it would be even better if you open an issue explaining that `std.Io` has regressed Emscripten.)

---

<div class="post-metadata">

**Author:** ![floooh](https://ziggit.dev/user_avatar/ziggit.dev/floooh/32/2989_2.png) [@floooh](https://ziggit.dev/u/floooh)\
**Post date:** [November 7, 2025, 9:07am UTC](https://ziggit.dev/t/wasm32-emscripten-builds-fail-linking-because-of-pthread-dependency/12879/5 "2025-11-07T09:07:19Z")

</div>

> [@castholm](#):
>
> (But clearly it would be even better if you open an issue explaining that `std.Io` has regressed Emscripten.)

I’ll do that!

---

<div class="post-metadata">

**Author:** ![floooh](https://ziggit.dev/user_avatar/ziggit.dev/floooh/32/2989_2.png) [@floooh](https://ziggit.dev/u/floooh)\
**Post date:** [November 7, 2025, 4:25pm UTC](https://ziggit.dev/t/wasm32-emscripten-builds-fail-linking-because-of-pthread-dependency/12879/6 "2025-11-07T16:25:06Z")

</div>

Ok wrote a ticket here: [wasm32-emscripten started to depend on clib thread func · Issue #25856 · ziglang/zig · GitHub](https://github.com/ziglang/zig/issues/25856)

---

<div class="post-metadata">

**Author:** ![Sze](https://ziggit.dev/user_avatar/ziggit.dev/sze/32/496_2.png) [@Sze](https://ziggit.dev/u/Sze)\
**Post date:** [November 7, 2025, 4:41pm UTC](https://ziggit.dev/t/wasm32-emscripten-builds-fail-linking-because-of-pthread-dependency/12879/7 "2025-11-07T16:41:56Z")

</div>

I agree with the issue, however regarding:

> for instance any WASM blob that’s hosted on Github pages cannot use threading

I think you could use what @tobyjaffey is using here [Framebuffer and Audio WASM demos](https://ziggit.dev/t/framebuffer-and-audio-wasm-demos/7146), [coi-serviceworker](https://github.com/ringtailsoftware/zig-wasm-audio-framebuffer#cors-cross-origin-resource-sharing):

> However, this is worked around by using [coi-serviceworker](https://github.com/gzuidhof/coi-serviceworker) which reloads the page on startup.

But it seems you can’t avoid the reload on github pages.

---

<div class="post-metadata">

**Author:** ![floooh](https://ziggit.dev/user_avatar/ziggit.dev/floooh/32/2989_2.png) [@floooh](https://ziggit.dev/u/floooh)\
**Post date:** [November 7, 2025, 4:44pm UTC](https://ziggit.dev/t/wasm32-emscripten-builds-fail-linking-because-of-pthread-dependency/12879/8 "2025-11-07T16:44:00Z")

</div>

Yeah I know this service-worker “hack”, but I’ve also been hearing that this doesn’t work reliably.
