r/Compilers • u/matthieum • Jul 28 '26
Inside Zig's Incremental Compilation | mlugg
https://mlugg.co.uk/posts/incremental-compilation-internals/
47
Upvotes
r/Compilers • u/matthieum • Jul 28 '26
6
u/matthieum Jul 28 '26
Of particular interest to me, here, is the ZIR.
After parsing, the Zig compiler converts to the AST to a ZIR:
Due to being untyped -- and the symbols being unresolved -- the conversion is entirely self-contained.
I must admit I do wonder as to why the AST is converted to ZIR, and the blog post unfortunately doesn't address it. Introducing an intermediate model has a cost, so there must be some benefit to it... Perhaps its flatter nature (compared to the AST)?
4
u/igors84 Jul 28 '26
Extremely interesting text full of interesting ideas. I wish they just mentioned that this doesn't work with llvm backend which should be obvious but also that debugging doesn't really work with their backend yet which is not obvious and might be pretty important to some people...
4
u/MirrorLake Jul 28 '26
I had one question, but it was answered at the end of the blog:
Really nice ergonomic upgrade, happy to see it's likely to become default in the future.
1
u/muth02446 Jul 29 '26 edited Jul 29 '26
I am somewhat skeptical of this approach, e.g.:
* you get a lot of complexity in the incremental linking stage
* the compiler is becoming some long running daemon job
2
u/Inevitable-Spinach-7 Jul 28 '26
I am interested too,
First thing is that you may receive a better response in ziggit.
And I may be wrong but I think it is easier to resolve types there than the AST itself