From cd7ffa2e52ce1ee5cf387ac0188e9ff046e2b161 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Thu, 1 Sep 2022 10:01:54 -0400 Subject: [PATCH] lld: Include name of output file in "failed to write output" diag Differential Revision: https://reviews.llvm.org/D133110 --- lld/COFF/Writer.cpp | 3 ++- lld/ELF/Writer.cpp | 3 ++- lld/MachO/Writer.cpp | 3 ++- lld/test/ELF/link-open-file.test | 2 +- lld/wasm/Writer.cpp | 3 ++- 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lld/COFF/Writer.cpp b/lld/COFF/Writer.cpp index 93521bc..0883841 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 cc8742e..57e0369 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -589,7 +589,8 @@ template void Writer::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 0df3849..44c34db 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 void Writer::run() { diff --git a/lld/test/ELF/link-open-file.test b/lld/test/ELF/link-open-file.test index f123930..17c7ba9 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 9604f52..14dc82d 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. -- 2.7.4