# Compilation: fix cache hash of incremental builds · gitcafe/zig

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

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

Visibility: public

Requested revision: a89d6878d2780f966b7327f8d366e6ac5f5cd8fc

Requested commit: a89d6878d2780f966b7327f8d366e6ac5f5cd8fc

Commit: a89d6878d2780f966b7327f8d366e6ac5f5cd8fc

Tree: 547470c99ded448aabc88fa2ef6b968ebddf92cb

Author: Andrew Kelley

Committer: Andrew Kelley

## Message

```
Compilation: fix cache hash of incremental builds

Without this commit, unrelated test builds using incremental cache mode
(self-hosted, no lld) would end up using the same cache namespace, which
is undesireable since concurrent builds will clobber each other's work.

This happened because of passing the root module to
addModuleToCacheHash. In the case of a test build, the root module
actually does not connect to the rest of the import table. Instead, the
main module needs to be passed, which has "root" in its import table.

The other call to addModuleTableToCacheHash which is in
addNonIncrementalStuffToCacheManifest already correctly passes the main
module.

In the future, I think this problem can be fully addressed by obtaining
an advisory lock on the output binary file. However, even in that case,
it is still valuable to make different compilations use different cache
namespaces lest unrelated compilations suffer from pointless thrashing
rather than being independently edited.

```

## Parents

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

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