# stage2: introduce renameTmpIntoCache into the linker API · gitcafe/zig

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

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

Visibility: public

Requested revision: d94303be2bcee33e7efba22a186fd06eaa809707

Requested commit: d94303be2bcee33e7efba22a186fd06eaa809707

Commit: d94303be2bcee33e7efba22a186fd06eaa809707

Tree: 883b8f12094809995e885658652e9c43334def23

Author: Andrew Kelley

Committer: Andrew Kelley

## Message

```
stage2: introduce renameTmpIntoCache into the linker API

Doc comments reproduced here:

This function is called by the frontend before flush(). It communicates that
`options.bin_file.emit` directory needs to be renamed from
`[zig-cache]/tmp/[random]` to `[zig-cache]/o/[digest]`.
The frontend would like to simply perform a file system rename, however,
some linker backends care about the file paths of the objects they are linking.
So this function call tells linker backends to rename the paths of object files
to observe the new directory path.
Linker backends which do not have this requirement can fall back to the simple
implementation at the bottom of this function.
This function is only called when CacheMode is `whole`.

This solves stack trace regressions on Windows and macOS because the
linker backends do not observe object file paths until flush().

```

## Parents

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

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