lld: Include name of output file in "failed to write output" diag
authorNico Weber <thakis@chromium.org>
Thu, 1 Sep 2022 14:01:54 +0000 (10:01 -0400)
committerNico Weber <thakis@chromium.org>
Wed, 14 Sep 2022 18:57:47 +0000 (14:57 -0400)
Differential Revision: https://reviews.llvm.org/D133110

lld/COFF/Writer.cpp
lld/ELF/Writer.cpp
lld/MachO/Writer.cpp
lld/test/ELF/link-open-file.test
lld/wasm/Writer.cpp

index 93521bc..0883841 100644 (file)
@@ -648,7 +648,8 @@ void Writer::run() {
 
   ScopedTimer t2(ctx.outputCommitTimer);
   if (auto e = buffer->commit())
-    fatal("failed to write the output file: " + toString(std::move(e)));
+    fatal("failed to write output '" + buffer->getPath() +
+          "': " + toString(std::move(e)));
 }
 
 static StringRef getOutputSectionName(StringRef name) {
index cc8742e..57e0369 100644 (file)
@@ -589,7 +589,8 @@ template <class ELFT> void Writer<ELFT>::run() {
       return;
 
     if (auto e = buffer->commit())
-      error("failed to write to the output file: " + toString(std::move(e)));
+      fatal("failed to write output '" + buffer->getPath() +
+            "': " + toString(std::move(e)));
   }
 }
 
index 0df3849..44c34db 100644 (file)
@@ -1118,7 +1118,8 @@ void Writer::writeOutputFile() {
   writeCodeSignature();
 
   if (auto e = buffer->commit())
-    error("failed to write to the output file: " + toString(std::move(e)));
+    fatal("failed to write output '" + buffer->getPath() +
+          "': " + toString(std::move(e)));
 }
 
 template <class LP> void Writer::run() {
index f123930..17c7ba9 100644 (file)
@@ -12,7 +12,7 @@
 
 # RUN:     %python %s %t.o 7
 # RUN: not %python %s %t.o 3 2>&1 | FileCheck %s
-# CHECK: error: failed to write to the output file
+# CHECK: error: failed to write output '{{.*}}': {{.*}}
 
 import contextlib
 import ctypes
index 9604f52..14dc82d 100644 (file)
@@ -1661,7 +1661,8 @@ void Writer::run() {
     return;
 
   if (Error e = buffer->commit())
-    fatal("failed to write the output file: " + toString(std::move(e)));
+    fatal("failed to write output '" + buffer->getPath() +
+          "': " + toString(std::move(e)));
 }
 
 // Open a result file.