This is an archive of the discontinued LLVM Phabricator instance.

[lld-macho] Hardlink -object_path_lto files to cache when possible
ClosedPublic

Authored by lgrey on Sep 2 2022, 10:59 AM.

Diff Detail

Event Timeline

lgrey created this revision.Sep 2 2022, 10:59 AM
lgrey requested review of this revision.Sep 2 2022, 10:59 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 2 2022, 10:59 AM
thakis accepted this revision.Sep 3 2022, 7:57 AM
thakis added a subscriber: thakis.

Cool, thanks!

Should we try to test this? Say, with a REQUIRES: shell line (to rule out Windows which can't hardlink files without admin) and ls -l somefile | cut -f 3 -d ' ' and check that this link count is 2?

lld/MachO/LTO.cpp
60

nit: To make it more clear that this isn't a function that returns a success bool, I'd write this as:

autor err = fs::create_hard_link(*originalPath, path);
if (!err)
  return;

(I assumed create_hard_link returns true on success and false on failure and the wondered why we'd return on failure here.)

This revision is now accepted and ready to land.Sep 3 2022, 7:57 AM
smeenai added a subscriber: smeenai.Sep 3 2022, 9:23 AM

(to rule out Windows which can't hardlink files without admin)

IIRC Windows can create hard links without admin. It's symbolic links which require admin (until developer mode on Windows 10).

lgrey updated this revision to Diff 458248.Sep 6 2022, 12:51 PM
lgrey marked an inline comment as done.

Add test, clarify control flow

lgrey added a comment.Sep 6 2022, 12:51 PM

Added test. For some reason, I thought it was less practical than it ended up being, thanks for the suggestion.

I guess the Windows thing is a moot point either way since this test already has`UNSUPPORTED: system-windows`

steven_wu accepted this revision.Sep 6 2022, 2:45 PM

LGTM. Small comment inline.

lld/test/MachO/lto-object-path.ll
26

Would be good to add a short comment about what this is testing. It is not obvious that you are reading the number of links field from ls long format.

lgrey updated this revision to Diff 458515.Sep 7 2022, 10:51 AM

Comment on test, make test work on Linux

This revision was automatically updated to reflect the committed changes.
lgrey marked an inline comment as done.