This is an archive of the discontinued LLVM Phabricator instance.

LTO, Support: Add a safeguard against pruning a directory that is not a cache directory.
AbandonedPublic

Authored by pcc on Mar 17 2017, 1:00 PM.

Details

Reviewers
mehdi_amini
Summary

Use the presence of the llvmcache.timestamp file to mark a directory as a
cache directory. Only prune the cache if the file exists. The idea is to
protect against data loss if the user supplies an incorrect cache directory.

Event Timeline

pcc created this revision.Mar 17 2017, 1:00 PM

I believe this approach is too fragile, in particular because if llvmcache.timestamp is deleted, the cache no longer works, but the directory exists. That creates a broken state and user will have to learn about how the cache works. That breaks the principle of least surprise.

It would be a major problem, if it gets broken on a bot where no easy access to the filesystem exists.

Also, this approach makes tests cumbersome, as we can see in this CL.

lld/test/ELF/lto/cache.ll
18

Why is -R needed?

pcc abandoned this revision.Mar 17 2017, 1:26 PM

Ivan suggested that we can just use a hidden directory inside the user-supplied directory as the cache directory. I like that approach better, so I'm abandoning this.

mehdi_amini edited edge metadata.Mar 17 2017, 1:38 PM

The idea is to protect against data loss if the user supplies an incorrect cache directory.

I can see this "user" as "user of the API", but it is not clear to me as a "user of the linker" since the timestamp is automatically added.

In D31096#704183, @pcc wrote:

Ivan suggested that we can just use a hidden directory inside the user-supplied directory as the cache directory. I like that approach better, so I'm abandoning this.

Not sure how it'll look like...

What about pattern-matching the list of files to see if any don't have the expected name structure? The linker could warn (or error) when supplied such a directory as cache).

pcc added a comment.Mar 17 2017, 1:58 PM
In D31096#704183, @pcc wrote:

Ivan suggested that we can just use a hidden directory inside the user-supplied directory as the cache directory. I like that approach better, so I'm abandoning this.

Not sure how it'll look like...

What about pattern-matching the list of files to see if any don't have the expected name structure? The linker could warn (or error) when supplied such a directory as cache).

Thinking about it a little more, that does seem a little less surprising. We can require all files to have the prefix llvmcache- or something.