<div dir="ltr"><div>RFC: lld- Add visual studio compatible diagnostics output to lld</div><div><br></div><div>Hello all,</div><div><br></div><div>We have a proposal to extend the diagnostics output capabilities of lld.</div><div><br></div><div>## Problem</div><div><br></div><div>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 </div><div>attempts to open the linker executable for edit, as this is interpreted as a source code file. Normally this causes visual studio </div><div>to become unresponsive until the file open operation times out. This output in its current format is displayed in visual studio as:</div><div><br></div><div>------ Build started: Project: lldDiagnostics, Configuration: Debug ------</div><div>X:\bin\lld.exe : error : undefined symbol: foo</div><div>>>> referenced by diagMain.cpp:5 (X:\lldDiagnostics\lldDiagnostics\diagMain.cpp:5)</div><div>>>> Debug\diagMain.o:(main)</div><div>Done building project "lldDiagnostics.vcxproj" -- FAILED.</div><div>========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========</div><div><br></div><div><br></div><div>## Proposed Solution </div><div><br></div><div>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 </div><div>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.</div><div><br></div><div>A visual studio conformant diagnostics output would look something like:</div><div><br></div><div>X:\lldDiagnostics\lldDiagnostics\diagMain.cpp(5) : error : undefined symbol ‘foo’ referenced in function ‘main’ in file ‘Debug\diagMain.o’</div><div><br></div><div>VS would be display this as:</div><div><br></div><div>------ Build started: Project: Project1, Configuration: Debug Win32 ------</div><div>Link : error : L0039: reference to undefined symbol `foo' in file "X:\lldDiagnostics\lldDiagnostics\diagMain\diagMain.o"</div><div>X:\lldDiagnostics\lldDiagnostics\diagMain.cpp : error : L0039: reference to undefined symbol `foo' in file</div><div>"X:\lldDiagnostics\lldDiagnostics\diagMain\diagMainSource.o"</div><div>========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========</div><div><br></div><div>Thanks.</div><div><br></div><div><br></div><div>Best Regards,</div><div><br></div><div><br></div><div>Chris</div><div><br></div><div>
<div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration-style:initial;text-decoration-color:initial"><br class="gmail-Apple-interchange-newline">[1] <a href="https://docs.microsoft.com/en-us/cpp/ide/formatting-the-output-of-a-custom-build-step-or-build-event">https://docs.microsoft.com/en-us/cpp/ide/formatting-the-output-of-a-custom-build-step-or-build-event</a></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration-style:initial;text-decoration-color:initial">[2] <a href="https://blogs.msdn.microsoft.com/msbuild/2006/11/02/msbuild-visual-studio-aware-error-messages-and-message-formats/">https://blogs.msdn.microsoft.com/msbuild/2006/11/02/msbuild-visual-studio-aware-error-messages-and-message-formats/</a></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration-style:initial;text-decoration-color:initial">[3] <a href="https://clang.llvm.org/docs/UsersManual.html#cmdoption-fdiagnostics-format">https://clang.llvm.org/docs/UsersManual.html#cmdoption-fdiagnostics-format</a></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration-style:initial;text-decoration-color:initial">[4] <a href="http://lists.llvm.org/pipermail/cfe-dev/2011-May/015115.html">http://lists.llvm.org/pipermail/cfe-dev/2011-May/015115.html</a></div>
<br></div><div><br></div></div>