[llvm-dev] RFC: LLVM - lld - Add visual studio compatible diagnostics output to lld

Chris Jackson via llvm-dev llvm-dev at lists.llvm.org
Mon Feb 19 07:21:50 PST 2018


RFC: lld- Add visual studio compatible diagnostics output to lld

Hello all,

We have a proposal to extend the diagnostics output capabilities of lld.

## Problem

MS Visual Studio expects the diagnostic output of build tools to conform to
a specific format, described here: [1] and [2] . Currently lld cannot emit
warnings and errors in this format. lld prefixes diagnostic output with
args[0], which can be a full path to the lld executable. If a diagnostic
message of this format is clicked within visual studio, the program
attempts to open the linker executable for edit, as this is interpreted as
a source code file. Normally this causes visual studio
to become  unresponsive until the file open operation times out. This
output in its current format is displayed in visual studio as:

------ Build started: Project: lldDiagnostics, Configuration: Debug ------
X:\bin\lld.exe : error : undefined symbol: foo
>>> referenced by diagMain.cpp:5
(X:\lldDiagnostics\lldDiagnostics\diagMain.cpp:5)
>>>               Debug\diagMain.o:(main)
Done building project "lldDiagnostics.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


## Proposed Solution

We propose the addition of an option to output diagnostics that fully
conform to [1]. There is currently an option in clang that enables VS
compatible output, '-fdiagnostics-format=msvc' [3] [4]. This will enable
visual studio to parse the full diagnostic. This will
result in clickable links so that the IDE can display the source from which
the error or warning originates, as well as adding errors and warnings to
the error list.

A visual studio conformant diagnostics output would look something like:

X:\lldDiagnostics\lldDiagnostics\diagMain.cpp(5) : error : undefined symbol
‘foo’ referenced in function ‘main’ in file ‘Debug\diagMain.o’

VS would be display this as:

------ Build started: Project: Project1, Configuration: Debug Win32 ------
Link : error : L0039: reference to undefined symbol `foo' in file
"X:\lldDiagnostics\lldDiagnostics\diagMain\diagMain.o"
X:\lldDiagnostics\lldDiagnostics\diagMain.cpp : error : L0039: reference to
undefined symbol `foo' in file
"X:\lldDiagnostics\lldDiagnostics\diagMain\diagMainSource.o"
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Thanks.


Best Regards,


Chris


[1]
https://docs.microsoft.com/en-us/cpp/ide/formatting-the-output-of-a-custom-build-step-or-build-event
[2]
https://blogs.msdn.microsoft.com/msbuild/2006/11/02/msbuild-visual-studio-aware-error-messages-and-message-formats/
[3]
https://clang.llvm.org/docs/UsersManual.html#cmdoption-fdiagnostics-format
[4] http://lists.llvm.org/pipermail/cfe-dev/2011-May/015115.html
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180219/248d03d8/attachment-0001.html>


More information about the llvm-dev mailing list