diff options
Diffstat (limited to 'lib/Support/Path.cpp')
| -rw-r--r-- | lib/Support/Path.cpp | 10 | 
1 files changed, 7 insertions, 3 deletions
| diff --git a/lib/Support/Path.cpp b/lib/Support/Path.cpp index a806da23ec50..098230290ed2 100644 --- a/lib/Support/Path.cpp +++ b/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 | 
