[PATCH] D43664: Fail early if an output file is not writable.

Zachary Turner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 22 17:53:51 PST 2018


zturner accepted this revision.
zturner added inline comments.
This revision is now accepted and ready to land.


================
Comment at: lld/COFF/Driver.cpp:1278
+  // Fail early if an output file is not writable.
+  if (auto E = tryCreateFile(Config->OutputFile)) {
+    error("cannot open output file " + Config->OutputFile + ": " + E.message());
----------------
There's still a race condition here, in that a program could open the file after this call succeeds but before we get around to writing it.  It would be nice if there were a way for this function to grab the file handle for exclusive write access up front, but this seems hard to do due to the several layers of indirection between here and when we actually write the output file.


https://reviews.llvm.org/D43664





More information about the llvm-commits mailing list