For #4992 the issue is that find_zig_str_path
is looking for the str.zig
file.
It first tries the the lib path relative to the executable location, and then looks in crates/compiler/builtins/bitcode/src/str.zig
. However if I have a Zig platform and am using roc cli from somewhere else then I am not sure how to provide this zig file. Where should the lib
directory be located in this instance?
I.e. I want to run % roc build --target wasm32 examples/echo.roc
without having to manually copy and paste the *.zig
builtins into the platform or app repository I am working in.
This is the related comment in crates/utils/command/src/lib.rs
// get the path of the lib folder
// runtime dependencies like zig files, Windows dylib builds, are put in the lib folder
If I add the following to find_zig_str_path() -> PathBuf
then I can use zig platforms outside of the roc repository. However I need to copy most of the .zig
files from crates/compiler/builtins/bitcode
across to ./platform/*.zig
. This seems a bit hacky, how should this work?
// Check 'platform/' folder
let zig_ztr_platform_path = PathBuf::from("./platform/str.zig");
if std::path::Path::exists(&zig_ztr_platform_path) {
return zig_ztr_platform_path;
}
We've tried to resolve this issue before, I think @Brendan Hansknecht knows the most about this.
At some point we removed the lib folder that lives next to the roc binary. That is where it should go for portability. So ./roc
and ./lib/str.zig
.
That said, really this is just s hack and should go away completely. We are basically injecting a dependency into all zig apps.
This should be replaced by glue generating a similar file for zig apps that need it.
Also, i thought we set it up currently such that roc would search relative to its current directory for crates/compiler/builtins/bitcode/str.zig
. so where you put the roc
binary, just also copy that specific folder. I think nightly does the same.
So turns out, we only check for the lib
folder relative to the roc
executable and not the crates/compiler/builtins/bitcode/
folder.
Let me push another small hack to keep this functioning.
#5328 should fix this.
Ok, a second part to this to enable import things besides the string library, like list and dec: #5332
Last updated: Jul 06 2025 at 12:14 UTC