[PATCH] D58484: [DO NOT SUBMIT] Add -vs-diagnostics.

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 20 17:42:39 PST 2019


ruiu created this revision.
ruiu added reviewers: chrisjackson, ikudrin.
Herald added subscribers: jdoerfert, arichardson, emaste.
Herald added a reviewer: espindola.
Herald added a project: LLVM.

This patch adds `-vs-diagnostics` flag to lld so that the linker prints
out error messages in the format that is friendly to Microsoft Visual Studio.

Since the existing error message format of lld and MSVC are significantly
different, and in most cases we print out more information than MSVC,
it is not practical nor beneficial to make lld to print out the same error
messages as MSVC does.

It looks like the most annoying issue if you are using lld on MSVC is that
the IDE automatically makes the first word of the first line of a linker
error message, expecting that the word is an error location. We print out
"ld.lld" there by default, so when you click that string on the IDE, it
opens the linker binary file -- which is not useful at all. In this patch,
I'm focusing on fixing that issue.

This patch adds a function to find an error location in an error message.
If `-vs-diagnostics` is given, lld calls that function and prints out its
return value instead of "ld.lld". That operation is purely textual; I
used regexps to recognize some error message patterns to extract an error
location.

An alternative approach would have been abstracting error message
construction so that we can construct both the existing and MSVC-style
error messages.

Doing everything over a text might seems too primitive compared to adding
an abstraction layer, but I think the former is overall a better approach
than the latter. It is much less intrusive and very easy to understand.
And if you think of it, this is similar to what IDEs do to recognize and
highlight compiler and linker error messages. They do recognize some
patterns because linkers print out somewhat structured error messages.
If IDEs can recognize it, so do we. If our error message is machine-
unfriendly, we should change the error message.

This is a counter-proposal to https://reviews.llvm.org/D58300. This is
a proof-of-concept to share the idea. I think I need to add a few more
regexes to make it usable.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D58484

Files:
  lld/Common/ErrorHandler.cpp
  lld/ELF/Driver.cpp
  lld/ELF/Options.td
  lld/include/lld/Common/ErrorHandler.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58484.187703.patch
Type: text/x-patch
Size: 3745 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190221/3f1e9be9/attachment.bin>


More information about the llvm-commits mailing list