[llvm-bugs] [Bug 28553] New: "Failed to parse object file" diagnostic doesn't list object file; diagnostics pretty inconsistent in general

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Jul 14 12:01:47 PDT 2016


https://llvm.org/bugs/show_bug.cgi?id=28553

            Bug ID: 28553
           Summary: "Failed to parse object file" diagnostic doesn't list
                    object file; diagnostics pretty inconsistent in
                    general
           Product: lld
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: COFF
          Assignee: unassignedbugs at nondot.org
          Reporter: nicolasweber at gmx.de
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

I was playing with cross-linking chrome/win on Linux again. At some point, lld
failed with

Failed to parse object file: The file was not recognized as a valid object file

which is not a very useful error message. It tells me that things didn't work
twice, but doesn't tell me which file the problem was with. So I did:

Index: COFF/InputFiles.cpp
===================================================================
--- COFF/InputFiles.cpp    (revision 275409)
+++ COFF/InputFiles.cpp    (working copy)
@@ -105,8 +104,7 @@
   // Parse a memory buffer as a COFF file.
   auto BinOrErr = createBinary(MB);
   if (!BinOrErr)
-    error(errorToErrorCode(BinOrErr.takeError()),
-                           "Failed to parse object file");
+    error(errorToErrorCode(BinOrErr.takeError()), getShortName());
   std::unique_ptr<Binary> Bin = std::move(*BinOrErr);

   if (auto *Obj = dyn_cast<COFFObjectFile>(Bin.get())) {


Then I realized that InputFiles has the same problem in a few other places, so
I made the same change in a few other places.  Then I noticed that the warnings
I changed now have the format "dynamic string: fixed error string" while a few
other diagnostics follow the pattern "fixed error string: dynamic string"
(where "dynamic string" is the name of an object file, a symbol, etc), so I
started changing these to the other format as well.

Punctuation, capitalization, etc are also inconsistent.

And then I realized that it's probably best if Rui makes some decision on how
diagnostic messages should look like :-)


I think for greppability (and scanability by users) it'd also be helpful if
each error message started with "error: ", e.g.

error: obj/third_party/angle/libglesv2/libglesv2.res: The file was not
recognized as a valid object file


Here's where I was at before I realized I should instead file a bug before I
get in too deep.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160714/50d10274/attachment.html>


More information about the llvm-bugs mailing list