Lgtm<br><div class="gmail_quote"><div dir="ltr">On Fri, Sep 28, 2018 at 11:34 AM Alexandre Ganea via Phabricator <<a href="mailto:reviews@reviews.llvm.org">reviews@reviews.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">aganea created this revision.<br>
aganea added reviewers: thakis, zturner.<br>
Herald added a subscriber: llvm-commits.<br>
<br>
As described here <<a href="https://bugs.chromium.org/p/chromium/issues/detail?id=889990" rel="noreferrer" target="_blank">https://bugs.chromium.org/p/chromium/issues/detail?id=889990</a>>, this patch fixes the case where an OBJ has a reference to a PDB path which happens to map locally to a removable device, drive which has no media inserted at the time of the link. In that case, the first attempt to load the PDB returns "resource unavailable try again". This prevents retrying the PDB load with the OBJ's path.<br>
<br>
<br>
Repository:<br>
  rLLD LLVM Linker<br>
<br>
<a href="https://reviews.llvm.org/D52666" rel="noreferrer" target="_blank">https://reviews.llvm.org/D52666</a><br>
<br>
Files:<br>
  COFF/PDB.cpp<br>
<br>
<br>
Index: COFF/PDB.cpp<br>
===================================================================<br>
--- COFF/PDB.cpp<br>
+++ COFF/PDB.cpp<br>
@@ -351,6 +351,12 @@<br>
<br>
 static Expected<std::unique_ptr<pdb::NativeSession>><br>
 tryToLoadPDB(const GUID &GuidFromObj, StringRef TSPath) {<br>
+  // Ensure the file exists before anything else. We want to return ENOENT,<br>
+  // "file not found", even if the path points to a removable device (in which<br>
+  // case the return message would be EAGAIN, "resource unavailable try again")<br>
+  if (!llvm::sys::fs::exists(TSPath))<br>
+    return errorCodeToError(std::error_code(ENOENT, std::generic_category()));<br>
+<br>
   ErrorOr<std::unique_ptr<MemoryBuffer>> MBOrErr = MemoryBuffer::getFile(<br>
       TSPath, /*FileSize=*/-1, /*RequiresNullTerminator=*/false);<br>
   if (!MBOrErr)<br>
<br>
<br>
</blockquote></div>