# build: avoid compiling self-hosted twice · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/caddbbc315e834241c6ae7e22434b574c589e5fc)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: caddbbc315e834241c6ae7e22434b574c589e5fc

Requested commit: caddbbc315e834241c6ae7e22434b574c589e5fc

Commit: caddbbc315e834241c6ae7e22434b574c589e5fc

Tree: fe412c607e0e4a21a8f43da130335ace3c4fe304

Author: Andrew Kelley

Committer: Andrew Kelley

## Message

```
build: avoid compiling self-hosted twice

build.zig: add a 'compile' step to compile the self-hosted compiler
without installing it.
Compilation: set cache mode to whole when using the LLVM backend and
--enable-cache is passed.

This makes `zig build` act the same as it does with stage1. Upside is
that a second invocation of `zig build` on an unmodified source tree
will avoid redoing the compilation again. Downside is that it will
proliferate more garbage in the project-local cache (same as stage1).

This can eventually be fixed when Zig's incremental compilation is more
robust; we can go back to having LLVM use CacheMode.incremental and rely
on it detecting no changes and avoiding doing the flush() step.

```

## Parents

- [10132126972604c4636b148df27ab7fe9e50136b](https://git.cafe/gitcafe/zig/commit/10132126972604c4636b148df27ab7fe9e50136b?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/caddbbc315e834241c6ae7e22434b574c589e5fc?format=markdown)
