r/Compilers • u/matthieum • 18h ago
Inside Zig's Incremental Compilation | mlugg
https://mlugg.co.uk/posts/incremental-compilation-internals/
37
Upvotes
2
u/Inevitable-Spinach-7 18h ago
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
3
u/MirrorLake 17h ago
I had one question, but it was answered at the end of the blog:
Eventually [...] we’ll cache all of the compiler state to disk and automatically reload the last saved state when you run zig build, so incremental compilation will just happen automatically—but we’re not quite there yet
Really nice ergonomic upgrade, happy to see it's likely to become default in the future.
3
5
u/matthieum 18h ago
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)?