diff options
author | Bob Haarman <llvm@inglorion.net> | 2017-11-16 01:16:52 +0000 |
---|---|---|
committer | Bob Haarman <llvm@inglorion.net> | 2017-11-16 01:16:52 +0000 |
commit | f349107e5546551f606b85fe6259d89553f91496 (patch) | |
tree | 09ee87503a68d3b159742e3168bbc0b8c7c05521 /lib/LTO | |
parent | d0222efb1938ef918da292ac8c2e45a5a94d960c (diff) |
LTO: clarify why we need to gracefully handle sys::fs::rename failures
Reviewers: pcc, rafael
Reviewed By: pcc
Subscribers: mehdi_amini, llvm-commits, hiraditya
Differential Revision: https://reviews.llvm.org/D40094
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@318362 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/LTO')
-rw-r--r-- | lib/LTO/Caching.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/LTO/Caching.cpp b/lib/LTO/Caching.cpp index e6338b2e18d..dd47eb584b7 100644 --- a/lib/LTO/Caching.cpp +++ b/lib/LTO/Caching.cpp @@ -73,13 +73,15 @@ Expected<NativeObjectCache> lto::localCache(StringRef CacheDirectoryPath, TempFile.TmpName + ": " + MBOrErr.getError().message() + "\n"); - // This is atomic on POSIX systems. - // On Windows, it can fail with permission denied if the destination - // file already exists. Since the existing file should be semantically - // equivalent to the one we are trying to write, we give AddBuffer - // a copy of the bytes we wrote in that case. We do this instead of - // just using the existing file, because the pruner might delete the - // file before we get a chance to use it. + // On POSIX systems, this will atomically replace the destination if + // it already exists. We try to emulate this on Windows, but this may + // fail with a permission denied error (for example, if the destination + // is currently opened by another process that does not give us the + // sharing permissions we need). Since the existing file should be + // semantically equivalent to the one we are trying to write, we give + // AddBuffer a copy of the bytes we wrote in that case. We do this + // instead of just using the existing file, because the pruner might + // delete the file before we get a chance to use it. Error E = TempFile.keep(EntryPath); E = handleErrors(std::move(E), [&](const ECError &E) -> Error { std::error_code EC = E.convertToErrorCode(); |