[PATCH] D43728: [WebAssembly] Do not remove existing output file.

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 23 22:56:52 PST 2018


ruiu created this revision.
ruiu added a reviewer: sbc100.
Herald added subscribers: sunfish, aheejin, jgravelle-google, dschuff, jfb.

FileOutputBuffer automatically removes an existing file, so we don't
need to do that. Actually doing that is discouraged because when the
linker fails to create an output for some reason after instantiating
FileOutputBufffer, FileOutputBuffer removes a temporary file and don't
touch an existing file. That's an desired behavior from the user's
point of view.

(Internally, FileOutputBuffer writes its contents to a temporary file
and then rename it over to an existing file on commit()).


https://reviews.llvm.org/D43728

Files:
  lld/wasm/Writer.cpp


Index: lld/wasm/Writer.cpp
===================================================================
--- lld/wasm/Writer.cpp
+++ lld/wasm/Writer.cpp
@@ -986,7 +986,6 @@
 // Open a result file.
 void Writer::openFile() {
   log("writing: " + Config->OutputFile);
-  ::remove(Config->OutputFile.str().c_str());
 
   Expected<std::unique_ptr<FileOutputBuffer>> BufferOrErr =
       FileOutputBuffer::create(Config->OutputFile, FileSize,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43728.135785.patch
Type: text/x-patch
Size: 428 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180224/ef42e0ff/attachment.bin>


More information about the llvm-commits mailing list