This is an archive of the discontinued LLVM Phabricator instance.

Use "foo-12345.o" instead of "foo.o-12345" as temporary file name.
AbandonedPublic

Authored by thakis on Aug 2 2017, 1:30 PM.

Details

Reviewers
rnk
rsmith
Summary

This helps some tools that do things based on the output's extension.

For example, we got reports from users on Windows that have a tool that scan a build output dir (but skip .obj files). The tool would keep the "foo.obj-12345" file open, and then when clang tried to rename the temp file to the final output filename, that would fail. By making the tempfile end in ".obj", tools like this will now skip the temp files as well.

Diff Detail

Event Timeline

thakis created this revision.Aug 2 2017, 1:30 PM
rnk accepted this revision.Aug 2 2017, 1:39 PM
rnk added a reviewer: rsmith.

Looks good, but let's confirm with Richard before we change behavior.

This revision is now accepted and ready to land.Aug 2 2017, 1:39 PM
hans added a subscriber: hans.Aug 2 2017, 1:45 PM

Seems reasonable to me as well..

rnk added a comment.Aug 3 2017, 11:37 AM

I discovered this code in llvm/lib/Support/Windows/Signals.inc which explains why we leak so many temp files on Windows:

// FIXME: open files cannot be deleted.
if (FilesToRemove != NULL)
  while (!FilesToRemove->empty()) {
    llvm::sys::fs::remove(FilesToRemove->back());
    FilesToRemove->pop_back();
  }

Output files are pretty much always open, so that FIXME is kind of a joke. The code basically doesn't work at all on Windows. =(

thakis added a comment.Aug 3 2017, 2:06 PM

I'm going to land this. It's early in the 6.0 cycle, so if this causes issues, we should have time to find them and then follow up in case we run into any.

thakis closed this revision.Aug 3 2017, 2:07 PM

309984.

chapuni reopened this revision.Aug 3 2017, 11:37 PM
chapuni added a subscriber: chapuni.

Excuse me, I have reverted this in rL310030 to unbreak -fmodules.

See GlobalModuleIndex.cpp. It seeks the suffix ".pcm".

This revision is now accepted and ready to land.Aug 3 2017, 11:37 PM
thakis added a comment.Aug 4 2017, 7:14 AM

Hm, that's unfortunate. I don't see a good way to rescue this patch.

We could keep the lhs of this and always append ".tmp", then tools at least had a way of filtering out the temp files. Hm.

thakis abandoned this revision.Mar 13 2019, 6:49 AM

We went with https://reviews.llvm.org/D36413 instead. (Upstream issue was https://crbug.com/751225)