There are currently some issues, that make it practically impossible to bundle a wasm platform.
roc currently uses zig 0.9.1 which has a bug, that the zig-cache
has to be removed manually: https://github.com/ziglang/zig/issues/12864
It is not possible to build a platform with a different version of zig.
roc can currently not use a "binary"-platform, but has to rebuild it every time. By doing it, it creates a folder `$HOME/.cache/roc/packages/example.com/SOME_HASH/zig-cache that has to be removed manually.
Can you think of any workaround how a wasm platform could currently be bundled? I tried to set --cache-dir /dev/null
in link.rs
. But zig expects a directory and not a file.
Do you plan to upgrade the zig version in the near future?
It is not possible to build a platform with a different version of zig.
Really? Why not?
Oh, actually, I think I have a guess. It is probably cause we currently bundle some of the code to zig automatically for convenience and it is in zig 0.9.1.
That is a hack that we probably need to remove to enable using a newer version of zig without roc updating its internal version of zig.
Do you plan to upgrade the zig version in the near future?
We have wanted to do this for a while, but it is not an easy project cause we have to update zig and llvm at the same time. On top of that, it can often cause issue with our custom linker that is not quite feature full.
I thought @Folkert de Vries had the Zig upgrade working on a branch, except that it broke some Zig hosts
I wonder if this is related? like maybe the problem there is the hosts being accidentally coupled to the Zig version the compiler is using :thinking:
zig is not the problem here, althought a new zig release is close (2 weeks, I think?) so it might make sense to wait for that at least
I was able to build my platform with zig 0.10.1. All I had to do was looking at the error message :grinning:
The error message was: "error: unrecognized parameter: '--strip'"
So I removed this line and rebuild roc from source: https://github.com/roc-lang/roc/blob/addd513528b64326d26658549a045647ae7a0f44/crates/compiler/build/src/link.rs#L1287
Afterwards, it works.
But my zig-code does not include any glue-code. So I don't know if this is something that helps in every case.
The zig 0.10 release notes say:
--strip is renamed to -fstrip and -fno-strip is introduced. Stripping is enabled by default for ReleaseSmall and the flag is properly forwarded to LLD
Since ReleaseSmall
is used anyway, there is no need to replace --strip
with another flag.
Would it be possible for roc to check the zig version and only use --stip
in version 0.9.1? Or would you accept a PR that removes --strip
for all versions of zig?
When I tested it yesterday, I still was in the nix-environment. So I actually tested it with zig 0.9 :face_with_peeking_eye:
It still works with zig 0.10. But you also have to remove this line: https://github.com/roc-lang/roc/blob/addd513528b64326d26658549a045647ae7a0f44/crates/compiler/build/src/link.rs#L390
Shen you run roc build
, you get a log of messages like
wasm-ld: warning: Linking two modules of different data layouts: '/home/ossi/src/roc/target/debug/build/wasi_libc_sys-661fd49d43379bb3/out/wasi-libc.a(lrint.o at 2551060)' is 'e-m:e-p:32:32-i64:64-n32:64-S128-ni:1:10:20' whereas 'ld-temp.o' is 'e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-n32:64-S128-ni:1:10:20'
But it works anyway.
Last updated: Jul 06 2025 at 12:14 UTC