I'm trying to compile nodejs-wasm example in a docker image with roc nightly and zig 0.11. Getting an error for this file
https://github.com/roc-lang/roc/blob/main/examples/nodejs-interop/wasm/platform/host.zig
$ roc build --target=wasm32
🔨 Rebuilding platform...
An internal compiler expectation was broken.
This is definitely a compiler bug.
Please file an issue here: https://github.com/roc-lang/roc/issues/new/choose
thread '<unnamed>' panicked at 'Error:
Failed to rebuild host.zig:
The executed command was:
zig build-obj platform/host.zig -femit-llvm-ir=platform/main.bc --mod glue::/roc/crates/compiler/builtins/bitcode/src/glue.zig --deps glue --library c -target wasm32-wasi -fPIC -fstrip
stderr of that command:
platform/host.zig:27:33: error: expected type 'u32', found 'type'
platform/host.zig:33:23: error: expected type 'u32', found 'type'
', crates/compiler/build/src/link.rs:1414:21
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Is there an easy fix (in the Zig file I suppose)?
we probably missed updating it to 0.11
Oh, I see
In some place we use @alignOf(Align)
and others just Align
yeah, small fix
@Brendan Hansknecht Here you go
https://github.com/roc-lang/roc/pull/6237
Now it is complaining that it cannot find wasi-libc.a
. I guess I could install or build it but I'm not sure that there are more things to install as well. Does anyone know?
If you build the compiler from source it should build that file. I think we might not be packaging it correctly.
It took me a few hours to figure out how to build compiler in my Docker file. The thing I'm trying to understand now is how to get past this error during building:
No suitable version of LLVM was found system-wide or pointed...
Hi @Vladimir Zotov,
You need to set LLVM_SYS_160_PREFIX
to the path of where you installed llvm 16.
I think there's an open GitHub issue for the wasi-libc issues. I remember running into that a while back
I know, there are two of them actually, I already explored them. Building from scratch was the answer. Annoyingly, apt install for llvm is broken on Ubuntu with a ticket open on github, so I have to do a sad plain download of clang, llvm and other stuff.
I'm making a VSCode devcontainer, which makes getting started with roc super easy (I got it running the roc's CLI example). I'll probably get there with node WASM as well :melting_face:
This file may also be useful to you
Thanks! I've got mine working as well in the end :upside_down:
Hey @Brendan Hansknecht
https://github.com/roc-lang/roc/blob/012d93574ae59ce67647d7e2dcd9b47c93855651/examples/nodejs-interop/wasm/hello.js#L4
That line assumes the compiled file is called roc-app.wasm
but instead mine is compiled tomain.wasm
. Should I submit a PR with the change??
If it is, I've got a runtime error:
const instance = new WebAssembly.Instance(wasmModule, importObj);
^
LinkError: WebAssembly.Instance(): Import #2 module="wasi_snapshot_preview1" function="random_get" error: function import requires a callable
at hello (/home/node/proj/hello.js:44:22)
I have no idea where it gets random_get
from :melting_face:
That's a WASI function it's trying to import into the Wasm module so something in the platform must be using it.
Last updated: Jul 05 2025 at 12:14 UTC