diff options
Diffstat (limited to 'llvm/lib/Support')
| -rw-r--r-- | llvm/lib/Support/Path.cpp | 10 | ||||
| -rw-r--r-- | llvm/lib/Support/Windows/Path.inc | 2 |
2 files changed, 8 insertions, 4 deletions
diff --git a/llvm/lib/Support/Path.cpp b/llvm/lib/Support/Path.cpp index a806da23ec5..098230290ed 100644 --- a/llvm/lib/Support/Path.cpp +++ b/llvm/lib/Support/Path.cpp @@ -1157,9 +1157,13 @@ Error TempFile::keep(const Twine &Name) { setDeleteDisposition(H, true); #else std::error_code RenameEC = fs::rename(TmpName, Name); - // If we can't rename, discard the temporary file. - if (RenameEC) - remove(TmpName); + if (RenameEC) { + // If we can't rename, try to copy to work around cross-device link issues. + RenameEC = sys::fs::copy_file(TmpName, Name); + // If we can't rename or copy, discard the temporary file. + if (RenameEC) + remove(TmpName); + } sys::DontRemoveFileOnSignal(TmpName); #endif diff --git a/llvm/lib/Support/Windows/Path.inc b/llvm/lib/Support/Windows/Path.inc index f425d607af4..b64b013d740 100644 --- a/llvm/lib/Support/Windows/Path.inc +++ b/llvm/lib/Support/Windows/Path.inc @@ -450,7 +450,7 @@ static std::error_code rename_handle(HANDLE FromHandle, const Twine &To) { if (std::error_code EC2 = realPathFromHandle(FromHandle, WideFrom)) return EC2; if (::MoveFileExW(WideFrom.begin(), WideTo.begin(), - MOVEFILE_REPLACE_EXISTING)) + MOVEFILE_REPLACE_EXISTING | MOVEFILE_COPY_ALLOWED)) return std::error_code(); return mapWindowsError(GetLastError()); } |

