[PATCH] D28010: FileOutputBuffer: support non-mmap'able file.

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 9 15:18:03 PST 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL291496: Support non-regular output files. (authored by ruiu).

Changed prior to commit:
  https://reviews.llvm.org/D28010?vs=82187&id=83719#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28010

Files:
  lld/trunk/ELF/Writer.cpp
  lld/trunk/test/ELF/basic.s


Index: lld/trunk/test/ELF/basic.s
===================================================================
--- lld/trunk/test/ELF/basic.s
+++ lld/trunk/test/ELF/basic.s
@@ -4,6 +4,7 @@
 # RUN: ld.lld %t -o %t2
 # RUN: llvm-readobj -file-headers -sections -program-headers -symbols %t2 \
 # RUN:   | FileCheck %s
+# RUN: ld.lld %t -o /dev/null
 
 # exits with return code 42 on linux
 .globl _start
Index: lld/trunk/ELF/Writer.cpp
===================================================================
--- lld/trunk/ELF/Writer.cpp
+++ lld/trunk/ELF/Writer.cpp
@@ -1635,10 +1635,12 @@
   // Path as a new file. If we do that in a different thread, the new
   // thread can remove the new file.
   SmallString<128> TempPath;
-  if (auto EC = sys::fs::createUniqueFile(Path + "tmp%%%%%%%%", TempPath))
-    fatal(EC, "createUniqueFile failed");
-  if (auto EC = sys::fs::rename(Path, TempPath))
-    fatal(EC, "rename failed");
+  if (sys::fs::createUniqueFile(Path + "tmp%%%%%%%%", TempPath))
+    return;
+  if (sys::fs::rename(Path, TempPath)) {
+    sys::fs::remove(TempPath);
+    return;
+  }
 
   // Remove TempPath in background.
   std::thread([=] { ::remove(TempPath.str().str().c_str()); }).detach();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28010.83719.patch
Type: text/x-patch
Size: 1200 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170109/54c72f30/attachment.bin>


More information about the llvm-commits mailing list