I'm using zig 0.9 and it does not compile. I'm using the trunk
branch.
Should I update the code to fit zig 0.9?
good question!
I think we should hold off until there's an official 0.9 release
otherwise it's harder for people to get the right version, since currently 0.9 is built from Zig's master
branch
Can I do the update in another branch?
oh sure! I just wouldn't want to merge it into trunk
until the 0.9 release is out :big_smile:
although, depending on how long that takes, the branch might have problems with drift
as people add more to the zig code in trunk
so it might end up needing recurring updates over time to stay mergeable :sweat_smile:
I think all changes we need to backwards compatible, like removing packed
enum.
good to know! :rock_on:
Also building compiler/bitcode
crashes the zig compiler
on 0.9?
yes
maybe a known bug? it is a master
build after all haha
it crashes in LLVMStructGetTypeAtIndex
ok, sounds like it's too soon for us to try 0.9 :big_smile:
ok this is jank
const std = @import("std");
comptime {
@export(eq, .{ .name = "eq" });
}
pub const RocDec = extern struct {
num: i128,
};
pub fn eq(self: RocDec, other: RocDec) callconv(.C) bool {
return self.num == other.num;
}
using i128
just crashes the compiler while i64
doesn't
blocked by https://github.com/ziglang/zig/issues/10039
Before updating the zig version we usually need to update the version of LLVM we use and before updating our LLVM version we need to update our zig version. This tends to occur because zig quickly moves to the latest version of LLVM and their release cycles kinda alternate. So we usually do those at the same time
there’s a few things already addressed for the 0.9 update like unused vars etc. but definitely some other stuff as well
0.9 isn’t too far out. I’m pretty sure it’ll use LLVM 13 and we use v12 last I checked
I updated inkwell already so upgrading llvm versions is not blocked on anything
excellent
Can someone give a rationale why zig is even in the codebase? I don't yet see what the benefit is over just implementing everything in Rust...
All of the compiler is written in rust, because as you say that makes sense.
We use zig for writing code that we want to end up in the binary that a user makes. That binary is a combination of code the user wrote, and some "runtime system" that does things like implement our builtins (list and string data structures) and manage memory (the whole refcounting machinery).
zig makes it easy to do this for all the platforms that we target: zig can be converted to LLVM IR, to webassembly and to machine code (e.g. X86_64 assembly)
and it does that 1) way faster than rust and 2) with way less baggage: rust brings a runtime system of its own that is much larger than what C and zig bring along
okay, I can see that .
Still, I wonder whether no_std rust would be viable to reduce the "runtime" you speak of. I don't know zig, so I cannot judge it, but rust provides guarantees that are really neat and I was hyped when I saw that roc is implemented in Rust! :smile:
yes, and we really want those guarantees for the compiler itself, but for that runtime system, any overhead is a shame and we actually want to do a bunch of unsafe things there
in other words, using rust there has less of the advantages in that scenario than for writing this massive compiler application
we actually tried Rust with no_std first, and it was tons of unsafe
plus linking difficulties plus not getting much help debugging memory safety issues, so we tried zig and it's gone much better!
Hi! I am Ivo Balbaert, a PL enthousiast and author of some books on emerging languages.
I worked in software industry (mainly 4GL, ASP.NET, C#) and taught programming languages and databases.
Last updated: Jul 26 2025 at 12:14 UTC