[Support] Use final filename for Caching buffer identifier
authorLeonard Grey <lgrey@chromium.org>
Sun, 5 Dec 2021 03:24:58 +0000 (22:24 -0500)
committerNico Weber <thakis@chromium.org>
Sun, 5 Dec 2021 03:25:49 +0000 (22:25 -0500)
commit134275d994d5fb38edfeb587ba45c8f495c8bf66
tree252048a3738f3f8c936dc5d3c6077d1c83b666cb
parentee4b462693b1ffeccfe1b8fcf0a0c12896ac6e6a
[Support] Use final filename for Caching buffer identifier

Mach-O LLD uses the buffer identifier of the memory buffer backing an object
file to generate stabs which are used by `dsymutil` to find the object file for
dSYM generation.

When using thinLTO, these buffers are provided by the cache which initially
saves them to disk as temporary files beginning with "Thin-" but renames them
to persistent files beginning with "llvmcache-" before the buffer is provided
to the cache user.

However, the buffer is created before the file is renamed and is given the temp
file's name as an identifier. This causes the generated stabs to point to
nonexistent files.

This change names the buffer with the eventual persistent filename. I think
this is safe because failing to rename the temp file is a fatal error.

Differential Revision: https://reviews.llvm.org/D115055
lld/test/MachO/lto-cache-dsymutil.ll [new file with mode: 0644]
llvm/lib/Support/Caching.cpp