diff --git a/lld/COFF/PDB.cpp b/lld/COFF/PDB.cpp index dac8bb5d2d7f1..6791d523da37f 100644 --- a/lld/COFF/PDB.cpp +++ b/lld/COFF/PDB.cpp @@ -1648,9 +1648,13 @@ void PDBLinker::addSections(ArrayRef outputSections, } void PDBLinker::commit(codeview::GUID *guid) { - ExitOnError exitOnErr((config->pdbPath + ": ").str()); - // Write to a file. - exitOnErr(builder.commit(config->pdbPath, guid)); + // Print an error and continue if PDB writing fails. This is done mainly so + // the user can see the output of /time and /summary, which is very helpful + // when trying to figure out why a PDB file is too large. + if (Error e = builder.commit(config->pdbPath, guid)) { + checkError(std::move(e)); + error("failed to write PDB file " + Twine(config->pdbPath)); + } } static uint32_t getSecrelReloc() { diff --git a/llvm/include/llvm/DebugInfo/MSF/MSFError.h b/llvm/include/llvm/DebugInfo/MSF/MSFError.h index fbc4e6928536f..67962fbd50285 100644 --- a/llvm/include/llvm/DebugInfo/MSF/MSFError.h +++ b/llvm/include/llvm/DebugInfo/MSF/MSFError.h @@ -18,6 +18,7 @@ namespace msf { enum class msf_error_code { unspecified = 1, insufficient_buffer, + size_overflow, not_writable, no_stream, invalid_format, diff --git a/llvm/lib/DebugInfo/MSF/MSFBuilder.cpp b/llvm/lib/DebugInfo/MSF/MSFBuilder.cpp index a02b9ea9e35bd..1a92e2cb77546 100644 --- a/llvm/lib/DebugInfo/MSF/MSFBuilder.cpp +++ b/llvm/lib/DebugInfo/MSF/MSFBuilder.cpp @@ -15,6 +15,7 @@ #include "llvm/Support/Endian.h" #include "llvm/Support/Error.h" #include "llvm/Support/FileOutputBuffer.h" +#include "llvm/Support/FormatVariadic.h" #include #include #include @@ -348,8 +349,9 @@ Expected MSFBuilder::commit(StringRef Path, // block-based and as long as each stream is small enough, PDBs larger than // 4 GiB might work. Check if tools can handle these large PDBs, and if so // add support for writing them. - return make_error(msf_error_code::invalid_format, - "Output larger than 4 GiB"); + return make_error( + msf_error_code::size_overflow, + formatv("File size would have been {0,1:N}", FileSize)); } auto OutFileOrError = FileOutputBuffer::create(Path, FileSize); diff --git a/llvm/lib/DebugInfo/MSF/MSFError.cpp b/llvm/lib/DebugInfo/MSF/MSFError.cpp index b368b802c5643..f068d3334955b 100644 --- a/llvm/lib/DebugInfo/MSF/MSFError.cpp +++ b/llvm/lib/DebugInfo/MSF/MSFError.cpp @@ -27,6 +27,8 @@ class MSFErrorCategory : public std::error_category { case msf_error_code::insufficient_buffer: return "The buffer is not large enough to read the requested number of " "bytes."; + case msf_error_code::size_overflow: + return "Output data is larger than 4 GiB."; case msf_error_code::not_writable: return "The specified stream is not writable."; case msf_error_code::no_stream: