This is an archive of the discontinued LLVM Phabricator instance.

[lld-macho] Ensure cached objects are affected by `-object_path_lto`
ClosedPublic

Authored by lgrey on Aug 10 2022, 2:56 PM.

Details

Summary

This refactors LTO compile to look more like COFF, where cache hits and misses are all funneled through the same code path.

Previously, cache hits were *not* being saved to -object_path_lto, which led to them sometimes falling out of the cache before dsymutil could process them. As a side effect of the refactor, cached objects are now saved with -save-temps as well, which seems desirable.

(Deleted lld/test/MachO/lto-cache-dsymutil.ll and rolled it into lld/test/MachO/lto-object-path.ll, since the cache-only, non object path approach is unreliable anyway).

Diff Detail

Event Timeline

lgrey created this revision.Aug 10 2022, 2:56 PM
Herald added a reviewer: Restricted Project. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
lgrey requested review of this revision.Aug 10 2022, 2:56 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 10 2022, 2:56 PM
thakis added a subscriber: thakis.Aug 11 2022, 9:08 AM

Making this more like COFF is generally good, but isn't -cache_path_lto supposed to control where these files go in ld64 (and hence ld64.lld)?

steven_wu accepted this revision.Aug 11 2022, 9:56 AM

LGTM.

For ld64, -cache_path_lto controls where the ThinLTO cache is and -object_path_lto controls where to write MachO object file from thinLTO codegen for dsymutil to use. The behavior in this patch is correct.

This revision is now accepted and ready to land.Aug 11 2022, 9:56 AM

One thing missing is that in libLTO, the cached object is written to -object_path_lto using a hard-link. That is intentional to reduce the disk usage and it is faster than write a file buffer to output file. Might want to consider doing that in lld for future.

thakis accepted this revision.Aug 11 2022, 10:30 AM

Thanks for the clarification, Steven!

lgrey added a comment.Aug 12 2022, 7:56 AM

One thing missing is that in libLTO, the cached object is written to -object_path_lto using a hard-link. That is intentional to reduce the disk usage and it is faster than write a file buffer to output file. Might want to consider doing that in lld for future.

This makes a lot of sense, thanks! I'll do it in a follow-up for revertability.

lld/MachO/LTO.cpp