[PATCH] D118212: [Support] [Windows] Don't cancel delete if we failed to set delete

Shezan Baig via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 25 20:18:38 PST 2022


sbaig1 created this revision.
Herald added subscribers: dexonsmith, hiraditya.
sbaig1 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Following up on commit 177176f75c6fa3f624d6d964b9d340ce39511565 <https://reviews.llvm.org/rG177176f75c6fa3f624d6d964b9d340ce39511565>, if we
failed to setDeleteDisposition(true) during TempFile creation, then
don't try to setDeleteDisposition(false) during TempFile::keep, since it
will likely fail as well.

Instead of letting TempFile::keep just fail, we should let it go ahead
and try renaming the file.

This fixes an issue we are seeing when running clang-cl.exe through the
Incredibuild distributed build system.  We're seeing that renaming
temporary object files would fail here:
https://github.com/llvm/llvm-project/blob/5c1f7b296ac0dddeca02891976e6ab5cfc006719/clang/lib/Frontend/CompilerInstance.cpp#L789


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D118212

Files:
  llvm/lib/Support/Path.cpp


Index: llvm/lib/Support/Path.cpp
===================================================================
--- llvm/lib/Support/Path.cpp
+++ llvm/lib/Support/Path.cpp
@@ -1254,7 +1254,8 @@
 #ifdef _WIN32
   // If we can't cancel the delete don't rename.
   auto H = reinterpret_cast<HANDLE>(_get_osfhandle(FD));
-  std::error_code RenameEC = setDeleteDisposition(H, false);
+  std::error_code RenameEC =
+      RemoveOnClose ? std::error_code() : setDeleteDisposition(H, false);
   bool ShouldDelete = false;
   if (!RenameEC) {
     RenameEC = rename_handle(H, Name);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D118212.403122.patch
Type: text/x-patch
Size: 563 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220126/7470333d/attachment.bin>


More information about the llvm-commits mailing list