Hello, I follow the manual installation instruction on Fedora 35 since I understand that the nix setup won't allow me to use the editor on my intel machine.
However, I get the following error when running cargo build
error: failed to run custom build command for `roc_builtins v0.1.0 (/home/maxime/Documents/roc/compiler/builtins)`
Caused by:
process didn't exit successfully: `/home/maxime/Documents/roc/target/debug/build/roc_builtins-88c944ea58fa3aaa/build-script-build` (exit status: 101)
--- stdout
cargo:rerun-if-changed=build.rs
Compiling host ir to: /home/maxime/Documents/roc/compiler/builtins/bitcode/builtins-host.ll
--- stderr
thread 'main' panicked at 'zig failed: ./build.zig:60:24: error: expected type 'std.build.EmitOption', found 'bool'
obj.emit_llvm_ir = true;
^
/usr/lib/zig/std/build.zig:1597:28: note: std.build.EmitOption declared here
pub const EmitOption = union(enum) {
^
', compiler/builtins/build.rs:182:17
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting
Any idea how to fix that?
can you run zig version
?
0.9.1
ah, we didn't upgrate to zig 0.9.1 yet
it's in the pipeline
I tried zig 0.8.1, didn't work either
Caused by:
process didn't exit successfully: `/home/maxime/Documents/roc/target/debug/build/roc_builtins-88c944ea58fa3aaa/build-script-build` (exit status: 101)
--- stdout
cargo:rerun-if-changed=build.rs
Compiling host ir to: /home/maxime/Documents/roc/compiler/builtins/bitcode/builtins-host.ll
--- stderr
thread 'main' panicked at 'zig failed: /home/maxime/Documents/roc/compiler/builtins/bitcode/src/num.zig:27:21: error: unused capture
/home/maxime/Documents/roc/compiler/builtins/bitcode/src/num.zig:40:21: error: unused capture
/home/maxime/Documents/roc/compiler/builtins/bitcode/src/str.zig:2044:35: error: unused capture
/home/maxime/Documents/roc/compiler/builtins/bitcode/src/list.zig:1329:5: error: unused function parameter
builtins-host...The following command exited with error code 1:
/usr/bin/zig build-obj /home/maxime/Documents/roc/compiler/builtins/bitcode/src/main.zig -femit-llvm-ir -fno-emit-bin --strip -OReleaseFast --cache-dir /home/maxime/Documents/roc/compiler/builtins/bitcode/zig-cache --global-cache-dir /home/maxime/.cache/zig --name builtins-host -target native-native --enable-cache
error: the following build command failed with exit code 1:
/home/maxime/Documents/roc/compiler/builtins/bitcode/zig-cache/o/e85ea97b8a95d34f949e26b3f0ea5c21/build /usr/bin/zig /home/maxime/Documents/roc/compiler/builtins/bitcode /home/maxime/Documents/roc/compiler/builtins/bitcode/zig-cache /home/maxime/.cache/zig ir -Drelease=true
', compiler/builtins/build.rs:182:17
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
CI and I personally use 0.8.0
I'm on 0.8.1. on macOS :thinking:
those errors are strange:
compiler/builtins/bitcode/src/num.zig:27:21: error: unused capture
compiler/builtins/bitcode/src/num.zig:40:21: error: unused capture
compiler/builtins/bitcode/src/str.zig:2044:35: error: unused capture
compiler/builtins/bitcode/src/list.zig:1329:5: error: unused function parameter
I'd expect everyone using Zig 0.8.1 to get those same errors, or nobody
I assume this was on trunk
?
well those errors are really just warnings, so you should be close to get it working anyhow
Yes. I pulled again just in case without success. I also try to fix these errors by doing a dummy usage of the variables.
Here is what I have now
--- stderr
thread 'main' panicked at 'zig failed: builtins-host...The following command terminated unexpectedly:
/usr/bin/zig build-obj /home/maxime/Documents/roc/compiler/builtins/bitcode/src/main.zig -femit-llvm-ir -fno-emit-bin --strip -OReleaseFast --cache-dir /home/maxime/Documents/roc/compiler/builtins/bitcode/zig-cache --global-cache-dir /home/maxime/.cache/zig --name builtins-host -target native-native --enable-cache
error: the following build command failed with exit code 11:
/home/maxime/Documents/roc/compiler/builtins/bitcode/zig-cache/o/e85ea97b8a95d34f949e26b3f0ea5c21/build /usr/bin/zig /home/maxime/Documents/roc/compiler/builtins/bitcode /home/maxime/Documents/roc/compiler/builtins/bitcode/zig-cache /home/maxime/.cache/zig ir -Drelease=true
oh, maybe remove zig-cache
it does not work so well when you switch zig versions but keep the same cache
but usually it doesn't fail loudly
or, well, it doesn't tell you that that is what the problem is
I did rm -r ~/.cache/zig/*
and I still get the same error.
(By the way, thanks for helping me out)
maybe also try this one /home/maxime/Documents/roc/compiler/builtins/bitcode/zig-cache
I did. With cargo clean
. It didn't work either.
hmm, what does zig build test
do?
~/Documents/roc/compiler/builtins/bitcode trunk !5 ?2
❯ zig build test
./src/dec.zig:142:82: error: expected type 'std.fmt.Case', found 'bool'
var num_digits = std.fmt.formatIntBuf(digit_bytes_storage[0..], num, 10, false, .{});
^
/usr/lib/zig/std/fmt.zig:735:18: note: std.fmt.Case declared here
pub const Case = enum { lower, upper };
^
./src/dec.zig:142:46: note: referenced here
var num_digits = std.fmt.formatIntBuf(digit_bytes_storage[0..], num, 10, false, .{});
^
The following command exited with error code 1:
/usr/bin/zig test /home/maxime/Documents/roc/compiler/builtins/bitcode/src/main.zig -lc --cache-dir /home/maxime/Documents/roc/compiler/builtins/bitcode/zig-cache --global-cache-dir /home/maxime/.cache/zig --name test
error: the following build command failed with exit code 1:
/home/maxime/Documents/roc/compiler/builtins/bitcode/zig-cache/o/e85ea97b8a95d34f949e26b3f0ea5c21/build /usr/bin/zig /home/maxime/Documents/roc/compiler/builtins/bitcode /home/maxime/Documents/roc/compiler/builtins/bitcode/zig-cache /home/maxime/.cache/zig test
``
I am having this same error on NixOS with nix flakes. Have you found any workaround?
Edit: Strange that it compiles in another NixOS machine.
Hi @mostlyvoid,
I'm on NixOS as well. So we're on the same page; do you have the error error: failed to run custom build command for roc_builtins v0.1.0
when running cargo build
after nix develop
?
Yes, I think so. Here is the full log
roc on trunk via 🦀 v1.61.0 via ❄ impure (nix-shell)
❯ cargo run repl
Compiling roc_builtins v0.1.0 (/home/halum/code/roc/crates/compiler/builtins)
error: failed to run custom build command for `roc_builtins v0.1.0 (/home/halum/code/roc/crates/compiler/builtins)`
Caused by:
process didn't exit successfully: `/home/halum/code/roc/target/debug/build/roc_builtins-ac2eb2303333d02c/build-script-build` (exit status: 101)
--- stdout
cargo:rerun-if-changed=build.rs
Compiling host ir to: /home/halum/code/roc/crates/compiler/builtins/bitcode/builtins-host.ll
Compiling 64-bit bitcode to: /home/halum/code/roc/crates/compiler/builtins/bitcode/builtins-host.bc
--- stderr
thread 'main' panicked at 'zig failed: thread 50400 panic: index out of bounds
/nix/store/lhfjjvdp51y6lfyg2ssbxbp1plg4p8za-zig-0.9.1/lib/std/zig/system/NativeTargetInfo.zig:662:78: 0x2b16f4 in std.zig.system.NativeTargetInfo.abiAndDynamicLinkerFromFi
const rpath_list = mem.sliceTo(std.meta.assumeSentinel(strtab[rpoff_usize..].ptr, 0), 0);
^
/nix/store/lhfjjvdp51y6lfyg2ssbxbp1plg4p8za-zig-0.9.1/lib/std/zig/system/NativeTargetInfo.zig:387:39: 0x2a02e6 in std.zig.system.NativeTargetInfo.detectAbiAndDynamicLinker (build)
return abiAndDynamicLinkerFromFile(env_file, cpu, os, ld_info_list, cross_target) catch |err| switch (err) {
^
/nix/store/lhfjjvdp51y6lfyg2ssbxbp1plg4p8za-zig-0.9.1/lib/std/zig/system/NativeTargetInfo.zig:201:47: 0x29ba72 in std.zig.system.NativeTargetInfo.detect (build)
var result = try detectAbiAndDynamicLinker(allocator, cpu, os, cross_target);
^
/nix/store/lhfjjvdp51y6lfyg2ssbxbp1plg4p8za-zig-0.9.1/lib/std/build.zig:166:49: 0x29632e in std.build.Builder.create (build)
const host = try NativeTargetInfo.detect(allocator, .{});
^
/nix/store/lhfjjvdp51y6lfyg2ssbxbp1plg4p8za-zig-0.9.1/lib/std/special/build_runner.zig:43:39: 0x28c28f in main (build)
const builder = try Builder.create(
^
/nix/store/lhfjjvdp51y6lfyg2ssbxbp1plg4p8za-zig-0.9.1/lib/std/start.zig:561:37: 0x28562a in std.start.callMain (build)
const result = root.main() catch |err| {
^
/nix/store/lhfjjvdp51y6lfyg2ssbxbp1plg4p8za-zig-0.9.1/lib/std/start.zig:495:12: 0x26623e in std.start.callMainWithArgs (build)
return @call(.{ .modifier = .always_inline }, callMain, .{});
^
/nix/store/lhfjjvdp51y6lfyg2ssbxbp1plg4p8za-zig-0.9.1/lib/std/start.zig:409:17: 0x2652d6 in std.start.posixCallMainAndExit (build)
std.os.exit(@call(.{ .modifier = .always_inline }, callMainWithArgs, .{ argc, argv, envp }));
^
/nix/store/lhfjjvdp51y6lfyg2ssbxbp1plg4p8za-zig-0.9.1/lib/std/start.zig:322:5: 0x2650e2 in std.start._start (build)
@call(.{ .modifier = .never_inline }, posixCallMainAndExit, .{});
^
error: the following build command crashed:
/home/halum/code/roc/crates/compiler/builtins/bitcode/zig-cache/o/73d065ecbb0ad71677b5e532050e3bde/build /nix/store/lhfjjvdp51y6lfyg2ssbxbp1plg4p8za-zig-0.9.1/bin/zig /home/halum/code/roc/crates/compiler/builtins/bitcode /home/halum/code/roc/crates/compiler/builtins/bitcode/zig-cache /home/halum/.cache/zig ir -Drelease=true
', crates/compiler/builtins/build.rs:207:21
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
This is an issue with zig, documented here. It's been recently fixed on zig master but that also uses LLVM 14, and it is not easy to upgrade our code to LLVM 14. The issue appears to be hardware specific, I can run the repl without errors on NixOS on the latest version of the trunk branch. If you really want to fix this, you can fork zig 0.9.1, apply the fix and update our flake to use your fork.
@Anton @Maxime Tremblay I think I figured out the bug - https://github.com/ziglang/zig/issues/12112
As a temporary fix I changed this in the flake.nix
- zig-toolchain = zig.packages.${system}."0.9.1";
+ zig-toolchain = zig.packages.${system}.master.latest;
and also updated the flake.lock file via nix flake update
.
Now the repl builds but there is a new error whenever I try to do anything in the repl.
The rockin’ roc repl
────────────────────────
Enter an expression, or :help, or :exit/:q.
» 2
thread 'main' panicked at 'Unable to import builtins bitcode. LLVM error: "Invalid record"', crates/compiler/gen_llvm/src/llvm/build.rs:493:31
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
@mostlyvoid you may have missed my previous message. These appear to be LLVM 14 errors that would require a significant upgrade to our code to fix.
@Anton Sorry! I actually missed your message. Thanks!
I am wondering, is there any easier way to use the fix this without forking and all? Can I somehow emulate the hardware/ build a VM where it works? Excuse me if it is a stupid question.
For @Maxime Tremblay; although both errors start with failed to run custom build command for roc_builtins v0.1.0
the actual zig error is entirely different from this new error. So the fix mentioned in https://github.com/ziglang/zig/issues/12112 is not likely to fix Maxime's problem.
@mostlyvoid the zig issue does not go into detail about the hardware but I estimate that trying an Ubuntu VM has a 65% chance of fixing your problem.
Hey Folks! Sorry for reviving this topic, but I'm new to Roc, trying to build it locally on my mac from source, in order to contribute with the project. I'm using a MacOs 13.5 on a M1 chip, I tried to install everything that was needed, like LLVM and zig, tried different versions of zig, 0.8.1, 0.9.1, and 0.10.1, each of them I get a different error trying to build roc_bitcode v0.0.1 crate. Is roc compatible with M1 chip? Would I be able to contribute?
Certainly, I use MacOS 13 with an M2 chip. I normally use nix develop
which seems to just make everything work dependency wise. I'm not sure about compiling an individual crate, but normally I just run cargo build --release --locked
from the root directory to build from source.
Do you have any errors you could share?
you need matching llvm and zig versions (at least). We currently have zig 0.9.1 and llvm 13. But yeah I guess nix is the fastest way to fix these issues if you don't want to deal with them
I'm already using those versions, I'll try with nix
It's because I already use homebrew, so I didn't want to install nix too, only for roc, but no problem
OK, I've got it running with nix
I'm not sure if it's related to the error in this thread, but I'm seeing zig build ir -Drelease=true
on builtin bitcode failing with error: FileNotFound
(specifically in crates/compiler/builtins/bitcode/bc/build.rs:117:25)
this is on current main
on macOS, with zig and llvm being installed with homebrew, zig version
printing 0.11.0
, and llc --version
printing Homebrew LLVM version 16.0.6
I'll do a clean rebuild in nix on my mac
It looks similar to this CI failure https://github.com/roc-lang/roc/actions/runs/12076406799/job/33677747603?pr=6921
It builds fine for me in Nix
hm, that one looks like error: CacheUnavailable
https://github.com/roc-lang/roc/actions/runs/12076406799/job/33677747603?pr=6921#step:8:4607
And I can also run $ cargo build -p roc_bitcode
fine outside of nix
ok, while trying to git bisect, I found an older commit where it works, and now it works again even when I switch back to the branch...even after deleting zig-out
and zig-cache
:shrug:
so, all fixed...somehow!
is it still zig-cache
? I guess it is a newer version of zig that switches to .zig-cache
?
I bet your zig-cache
is old (and unrelated to any issues) and switching to an older commit forced .zig-cache
to rebuild. That then fixed your issue.
hmm, scratch that. 0.11.0 still use zig-cache
and not the hidden folder yet. So idk...
Last updated: Jul 06 2025 at 12:14 UTC