A hermetic build produces the same output from the same inputs, regardless of the machine performing the build. Zig aims to produce the same binary for a given platform wherever it is compiled. section 1.3.4
Hermeticity supports several practical benefits:
- Cross-compile from any supported platform to any other supported platform. section 1.3.4
- Produce self-contained binaries that are easier to distribute. section 1.3.4
- Cache build steps because Zig can rely on repeatable results. section 1.3.4
Comptime code cannot interact with the operating system or add randomness, since those actions would introduce nondeterminism. For tasks needing such functionality, use the build system, which does not share those limitations and can work alongside comptime. section 4.1.2
