Skip to content

WIP: Improve Emscripten support - #5259

Draft
kinke wants to merge 7 commits into
ldc-developers:masterfrom
kinke:emscripten
Draft

WIP: Improve Emscripten support#5259
kinke wants to merge 7 commits into
ldc-developers:masterfrom
kinke:emscripten

Conversation

@kinke

@kinke kinke commented Aug 10, 2026

Copy link
Copy Markdown
Member

Based on WASI.

@kinke

kinke commented Aug 10, 2026

Copy link
Copy Markdown
Member Author

@QuantumSegfault: This seems like a viable approach - basing Emscripten on your WASI work, after reading https://v8.dev/blog/emscripten-standalone-wasm and noting that they apparently try to use WASI APIs as much as possible, even in non-standalone-wasm mode.

To get the druntime test runners to link, I only had to avoid a single undefined _CLOCK_MONOTONIC symbol. And a single module fails its unittests (core.sync.event): https://github.com/ldc-developers/ldc/actions/runs/31392028311/job/93465932716?pr=5259

@QuantumSegfault

Copy link
Copy Markdown
Contributor

I'm not sure this makes sense to do like this.

Emscripten use a more vanilla Musl, without all of the differences to the headers WASI-libc made. They opted to stub out functions, rather than remove them, and otherwise use the unmodified types, constants, etc. (other than where architecture specific differences are concerned). A lot of the CRuntime_WASI blocks, particularly in Phobos, may be unnecessary.

WASI is also iffy, as that's an internal implementation detail. Emscripten also provides fuller emulation of things like threads, that we disable tests for on WASI. Also they provide their own filesystem, which isn't subject to all the quirks of WASI (e.g. the inability to have absolute symlinks; though that's largely a Wasmtime limitation).

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.

2 participants