This is an archive of the discontinued LLVM Phabricator instance.

Fail early if an output file is not writable.
ClosedPublic

Authored by ruiu on Feb 22 2018, 5:43 PM.

Event Timeline

ruiu created this revision.Feb 22 2018, 5:43 PM
zturner accepted this revision.Feb 22 2018, 5:51 PM
zturner added inline comments.
lld/COFF/Driver.cpp
1278

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.

This revision is now accepted and ready to land.Feb 22 2018, 5:51 PM
ruiu added a comment.Feb 22 2018, 6:01 PM

Yes, there's a chance that this test succeeds but the final output fails, but that should be acceptable. File writing could fail for other reasons, like disk full situation, and there's no way to know that before we actually write bytes to a file, so I think it's not worth to spend too much effort to be more accurate.

This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald Transcript