This is an archive of the discontinued LLVM Phabricator instance.

[Support] [DebugInfo] Lazily create cache dir.
ClosedPublic

Authored by mysterymath on Jan 18 2022, 10:53 AM.

Details

Summary

This change defers creating Support/Caching.cpp's cache directory until
it actually writes to the cache.

This allows using Caching library in a read-only fashion. If read-only,
the cache is guaranteed not to write to disk. This keeps tools using
DebugInfod (currently llvm-symbolizer) hermetic when not configured to
perform remote lookups.

Diff Detail

Event Timeline

mysterymath created this revision.Jan 18 2022, 10:53 AM
mysterymath requested review of this revision.Jan 18 2022, 10:53 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 18 2022, 10:53 AM
phosek added inline comments.Jan 19 2022, 10:46 AM
llvm/lib/Support/Caching.cpp
153

Do you think we could avoid static and call sys::fs::create_directories(Path, /*IgnoreExisting=*/true) unconditionally?

Removed magic static wrapper; premature optimization.

llvm/lib/Support/Caching.cpp
153

Yeah, looking at this with fresh eyes, the attempt to avoid a syscall here is a premature optimization. Removed.

phosek accepted this revision.Jan 20 2022, 12:51 AM

LGTM

llvm/lib/Support/Caching.cpp
20

Is this needed?

This revision is now accepted and ready to land.Jan 20 2022, 12:51 AM

Remove unnecessary include.

llvm/lib/Support/Caching.cpp
20

Nope, removed.

This revision was landed with ongoing or failed builds.Jan 20 2022, 11:27 AM
This revision was automatically updated to reflect the committed changes.

This is causing a failure in LLVM :: tools/gold/X86/cache.ll on our side. Do you see the same failure?

...
ls: cannot access '/home/zhuhan/server-llvm-build/auto-rebase/test/tools/gold/X86/Output/cache.ll.tmp.cache': No such file or directory
Expected 1 lines, got 0.

This is causing a failure in LLVM :: tools/gold/X86/cache.ll on our side. Do you see the same failure?

...
ls: cannot access '/home/zhuhan/server-llvm-build/auto-rebase/test/tools/gold/X86/Output/cache.ll.tmp.cache': No such file or directory
Expected 1 lines, got 0.

I've verified the issue, and I've got a quick patch to the test case.
I'm going to go through all of the other uses of localCache and see if any of their tests similarly need updating; I didn't notice that my local build didn't include these.
Shouldn't take too long; I'll add you to the patch once it's ready.

Sounds good. Thank you.