aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/LTO/ThinLTOCodeGenerator.cpp
diff options
context:
space:
mode:
authorMehdi Amini <mehdi.amini@apple.com>2016-05-14 05:16:35 +0000
committerMehdi Amini <mehdi.amini@apple.com>2016-05-14 05:16:35 +0000
commitb02139d66f38e5c4433d5fcdbd1dd558dc0a7083 (patch)
treeb3c489bdabde898935a19dc5e0ea9d40120af600 /llvm/lib/LTO/ThinLTOCodeGenerator.cpp
parent34b0241b81c7571a7c872ed195ac58278accb916 (diff)
downloadllvm-b02139d66f38e5c4433d5fcdbd1dd558dc0a7083.zip
llvm-b02139d66f38e5c4433d5fcdbd1dd558dc0a7083.tar.gz
llvm-b02139d66f38e5c4433d5fcdbd1dd558dc0a7083.tar.bz2
ThinLTOCodeGenerator: handle cases where temporary files can't be renamed
For instance when they're on different filesystem. From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 269544
Diffstat (limited to 'llvm/lib/LTO/ThinLTOCodeGenerator.cpp')
-rw-r--r--llvm/lib/LTO/ThinLTOCodeGenerator.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp
index b57166d..33d0a0c 100644
--- a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp
+++ b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp
@@ -504,8 +504,12 @@ public:
// Rename to final destination (hopefully race condition won't matter here)
EC = sys::fs::rename(TempFilename, EntryPath);
if (EC) {
- errs() << "Error: " << EC.message() << "\n";
- report_fatal_error("ThinLTO: Can't rename temporary file " + TempFilename + " to " + EntryPath);
+ sys::fs::remove(TempFilename);
+ raw_fd_ostream OS(EntryPath, EC, sys::fs::F_None);
+ if (EC)
+ report_fatal_error(Twine("Failed to open ") + EntryPath +
+ " to save cached entry\n");
+ OS << OutputBuffer.getBuffer();
}
}
};