<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Mar 23, 2017 at 5:16 PM, Mehdi Amini <span dir="ltr"><<a href="mailto:mehdi.amini@apple.com" target="_blank">mehdi.amini@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word"><br><div><span class="gmail-"><blockquote type="cite"><div>On Mar 23, 2017, at 3:17 PM, Rui Ueyama via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:</div><br class="gmail-m_4218760657903398968Apple-interchange-newline"><div><div dir="ltr"><div>Folks,</div><div><br></div><div>I'd like propose a new error message format for LLD so that error message for undefined or duplicated symbols are more informative and easy to read.</div><div><br></div><div>Below are examples of the current error messages (note that characters in red are actually red on terminal):</div><div><div><br></div></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div><b>Undefined symbols</b></div></div><div><div>/ssd/clang/bin/ld.lld: <font color="#ff0000">error</font>: /ssd/llvm-project/lld/ELF/Writ<wbr>er.cpp:207: undefined symbol 'lld::elf::EhFrameSection<llvm<wbr>::object::ELFType<(llvm::suppo<wbr>rt::endianness)0, true> >::addSection(lld::elf::InputS<wbr>ectionBase*)'</div></div><div><div><br></div></div><div><div><b>Conflicting symbols</b></div></div><div><div>/ssd/clang/bin/ld.lld: <span style="color:rgb(255,0,0)">error</span>: /ssd/llvm-project/lld/ELF/Writ<wbr>er.cpp:38: duplicate symbol 'lld::elf::MipsGotSection::add<wbr>Entry(lld::elf::SymbolBody&, long, lld::elf::RelExpr)'</div></div><div><div>/ssd/clang/bin/ld.lld: error: /ssd/llvm-project/lld/ELF/Synt<wbr>heticSections.cpp:673: previous definition was here</div></div></blockquote><div><br></div><div><div>For each error, we want to print out information about 1) symbol name, 2) source file name(s) and source location(s) if available and 3) source object file name(s) and archive file name(s) if available. Currently, these messages lack object file names, and I think the above error messages are a bit hard to grasp because too much information is packed into each line.</div><div><br></div></div><div>I'm thinking of changing the format to something like the following:</div><div><br></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div><b>Undefined symbols</b></div></div><div><div>/ssd/clang/bin/ld.lld: <span style="color:rgb(255,0,0)">error</span>: undefined symbol: lld::elf::EhFrameSection<llvm:<wbr>:object::ELFType<(llvm::suppor<wbr>t::endianness)0, true> >::addSection(lld::elf::InputS<wbr>ectionBase*)</div></div><div><div>  Source: /ssd/llvm-project/lld/ELF/Writ<wbr>er.cpp:207</div></div><div><div>  Object: lib/liblldELF.a(Writer.cpp.o)</div></div></blockquote></div></div></blockquote><div><br></div></span><div>As a point of comparison, here is what ld64 displays:</div><div><br></div><div>Undefined symbols for architecture x86_64:<br>  "lld::elf::EhFrameSection<<wbr>llvm::object::ELFType<(llvm::<wbr>support::endianness)0, true> >::addSection(lld::elf::InputS<wbr>ectionBase*)", referenced from:<br>      foo() in lib/liblldELF.a(Writer.cpp.o)<br><br></div><div>Being able to display source location when available is a really nice idea!!</div><span class="gmail-"><div><br></div><br><blockquote type="cite"><div><div dir="ltr"><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div><br></div></div><div><div><b>Conflicting symbols</b></div></div><div><div>/ssd/clang/bin/ld.lld: <span style="color:rgb(255,0,0)">error</span>: duplicate symbol: lld::elf::MipsGotSection::addE<wbr>ntry(lld::elf::SymbolBody&, long, lld::elf::RelExpr)</div></div><div><div>  Source 1: /ssd/llvm-project/lld/ELF/Writ<wbr>er.cpp:38</div></div><div><div>  Source 2: /ssd/llvm-project/lld/ELF/Synt<wbr>heticSections.cpp:673</div></div><div><div>  Object 1: lib/liblldELF.a(Writer.cpp.o)</div></div><div><div>  Object 2 : lib/liblldELF.a(SyntheticSecti<wbr>ons.cpp.o)</div></div></blockquote><div><br></div><div>The new error messages contain complete information that the linker is able to gather, and it uses more vertical space to improve readability.</div></div></div></blockquote><div><br></div></span><div>I feel it is using too much vertical space, and the matching between source and object is lost. What about something like:</div><div><br></div><div><span class="gmail-">/ssd/clang/bin/ld.lld: error: duplicate symbol: lld::elf::MipsGotSection::<wbr>addEntry(lld::elf::SymbolBody&<wbr>, long, lld::elf::RelExpr)<br></span>  - Defined in lib/liblldELF.a(Writer.cpp.o) (from /ssd/llvm-project/lld/ELF/<wbr>Writer.cpp:38)</div><div>  - Defined in lib/liblldELF.a(<wbr>SyntheticSections.cpp.o) (from /ssd/llvm-project/lld/ELF/<wbr>SyntheticSections.cpp:673)</div></div></div></blockquote><div><br></div><div>What would you print out for undefined symbols? `- Undefined in foo.o (from ...)` looks odd.</div></div></div></div>