This is an archive of the discontinued LLVM Phabricator instance.

[Support] Use final filename for Caching buffer identifier
ClosedPublic

Authored by lgrey on Dec 3 2021, 11:13 AM.

Details

Summary

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.

Diff Detail

Event Timeline

lgrey created this revision.Dec 3 2021, 11:13 AM
lgrey requested review of this revision.Dec 3 2021, 11:13 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 3 2021, 11:13 AM

Is it possible to test this?

A manual test looks like this:

% out/gn/bin/clang -c -flto=thin main.cc -g
% out/gn/bin/clang -flto=thin main.o -fuse-ld=lld -Wl,-cache_path_lto,thinltocache
% dsymutil a.out

Without this change, this prints:

% dsymutil a.out
warning: (x86_64) /Users/thakis/src/llvm-project/thinltocache/Thin-6c0491.tmp.o unable to open object file: No such file or directory
warning: no debug symbols in executable (-arch x86_64)

With this change, it doesn't print that.

This revision was not accepted when it landed; it landed in state Needs Review.Dec 4 2021, 7:25 PM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptDec 4 2021, 7:25 PM
Herald added a reviewer: Restricted Project. · View Herald Transcript
thakis added a comment.EditedDec 4 2021, 7:38 PM

lg. I went ahead and committed it, with a test added. Please take a look at the test and check that it's along the lines you imagined.