diff --git a/lld/COFF/Writer.cpp b/lld/COFF/Writer.cpp --- a/lld/COFF/Writer.cpp +++ b/lld/COFF/Writer.cpp @@ -648,7 +648,8 @@ 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 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -589,7 +589,8 @@ 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 --- a/lld/MachO/Writer.cpp +++ b/lld/MachO/Writer.cpp @@ -1118,7 +1118,8 @@ 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 --- 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 --- a/lld/wasm/Writer.cpp +++ b/lld/wasm/Writer.cpp @@ -1661,7 +1661,8 @@ 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.