[lld] cd7ffa2 - lld: Include name of output file in "failed to write output" diag

Nico Weber via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 14 11:58:03 PDT 2022


Author: Nico Weber
Date: 2022-09-14T14:57:47-04:00
New Revision: cd7ffa2e52ce1ee5cf387ac0188e9ff046e2b161

URL: https://github.com/llvm/llvm-project/commit/cd7ffa2e52ce1ee5cf387ac0188e9ff046e2b161
DIFF: https://github.com/llvm/llvm-project/commit/cd7ffa2e52ce1ee5cf387ac0188e9ff046e2b161.diff

LOG: lld: Include name of output file in "failed to write output" diag

Differential Revision: https://reviews.llvm.org/D133110

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/lld/COFF/Writer.cpp b/lld/COFF/Writer.cpp
index 93521bc1956c4..088384143e262 100644
--- a/lld/COFF/Writer.cpp
+++ b/lld/COFF/Writer.cpp
@@ -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) {

diff  --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index cc8742e652b64..57e0369e17d87 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -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)));
   }
 }
 

diff  --git a/lld/MachO/Writer.cpp b/lld/MachO/Writer.cpp
index 0df38498d0a2c..44c34db00b1fd 100644
--- a/lld/MachO/Writer.cpp
+++ b/lld/MachO/Writer.cpp
@@ -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() {

diff  --git a/lld/test/ELF/link-open-file.test b/lld/test/ELF/link-open-file.test
index f1239308324c7..17c7ba95e6ebe 100644
--- a/lld/test/ELF/link-open-file.test
+++ b/lld/test/ELF/link-open-file.test
@@ -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

diff  --git a/lld/wasm/Writer.cpp b/lld/wasm/Writer.cpp
index 9604f52b7b0c3..14dc82d0284a8 100644
--- a/lld/wasm/Writer.cpp
+++ b/lld/wasm/Writer.cpp
@@ -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.


        


More information about the llvm-commits mailing list