Skip to content

build: add Emscripten/WASM support#9

Merged
torque merged 1 commit intoallyourcodebase:masterfrom
Rawan10101:emscripten-wasm-support
Mar 5, 2026
Merged

build: add Emscripten/WASM support#9
torque merged 1 commit intoallyourcodebase:masterfrom
Rawan10101:emscripten-wasm-support

Conversation

@Rawan10101
Copy link
Contributor

Fixes: #8

@torque
Copy link
Collaborator

torque commented Mar 4, 2026

Looks like build.zig needs to be hit with zig fmt. I have no way to test this, but if you've tested this with neovim and it works for you I'm happy to merge it.

@Rawan10101
Copy link
Contributor Author

@torque yes, I tested this with Neovim's Zig build system targeting wasm32-emscripten. it builds successfully and it produces a libuv.a static library. I will fix the formatting with zig fmt and address the --search-prefix suggestion now.

@torque
Copy link
Collaborator

torque commented Mar 4, 2026

Can you confirm the correct usage is now something like

zig build -Dtarget=wasm32-emscripten --search-prefix $EMSDK/upstream/emscripten/cache/sysroot

In projects that use this as a dependency, do they need to make any changes to their build.zig to support this, or does --search-prefix get propagated automagically?

@Rawan10101
Copy link
Contributor Author

Yes, it is the correct usage. For most projects that use libuv as a dependency, no changes are needed in their build.zig as --search-prefix is propagated automatically to all dependencies.
The only exception is projects that cross-compile two targets simultaneously like Neovim, as it builds a native host tool and a WASM binary in the same build. In that case the project needs to handle the sysroot explicitly in its own build.zig to avoid applying it to the host build. But that is the dependent project's concern not libuv's.

The wasm build requires the Emscripten SDK to be available. Then the
library can be built with something like:

   zig build -Dtarget=wasm32-emscripten --search-prefix $EMSDK/upstream/emscripten/cache/sysroot
@torque torque force-pushed the emscripten-wasm-support branch from 62f2435 to e4dc0dd Compare March 5, 2026 06:04
@torque torque merged commit e4dc0dd into allyourcodebase:master Mar 5, 2026
18 checks passed
@torque
Copy link
Collaborator

torque commented Mar 5, 2026

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support building for wasm32-emscripten target

2 participants