Hacker News new | ask | show | jobs
by lewurm 1405 days ago
Thanks for the context!

What's the difference between the stage2 and stage3 binary? Does stage1 produce different binaries for the same input compared to stage2/stage3?

1 comments

Ideally there should be no difference and building stage 3 is basically a sanity check to ensure the compiler is working correctly.
Not quite - what you said is true for a hypothetical "stage4" however there is a distinct difference between stage2 and stage3. While they are built from the same source code, and therefore have the same logic, they are lowered by different backends, meaning they will have potentially drastically different performance characteristics depending on the differences between the stage1 and stage2 backend, respectively.

Related: https://github.com/ziglang/zig/issues/12183