<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Mar 23, 2017, at 6:11 PM, Rui Ueyama <<a href="mailto:ruiu@google.com" class="">ruiu@google.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><div class="gmail_extra"><div class="gmail_quote">On Thu, Mar 23, 2017 at 5:16 PM, Mehdi Amini<span class="Apple-converted-space"> </span><span dir="ltr" class=""><<a href="mailto:mehdi.amini@apple.com" target="_blank" class="">mehdi.amini@apple.com</a>></span><span class="Apple-converted-space"> </span>wrote:<br class=""><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div style="word-wrap: break-word;" class=""><br class=""><div class=""><span class="gmail-"><blockquote type="cite" class=""><div class="">On Mar 23, 2017, at 3:17 PM, Rui Ueyama via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank" class="">llvm-dev@lists.llvm.org</a>> wrote:</div><br class="gmail-m_4218760657903398968Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="">Folks,</div><div class=""><br class=""></div><div class="">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 class=""><br class=""></div><div class="">Below are examples of the current error messages (note that characters in red are actually red on terminal):</div><div class=""><div class=""><br class=""></div></div><blockquote style="margin: 0px 0px 0px 40px; border: none; padding: 0px;" class=""><div class=""><div class=""><b class="">Undefined symbols</b></div></div><div class=""><div class="">/ssd/clang/bin/ld.lld: <font color="#ff0000" class="">error</font>: /ssd/llvm-project/lld/ELF/Writ<wbr class="">er.cpp:207: undefined symbol 'lld::elf::EhFrameSection<llvm<wbr class="">::object::ELFType<(llvm::suppo<wbr class="">rt::endianness)0, true> >::addSection(lld::elf::InputS<wbr class="">ectionBase*)'</div></div><div class=""><div class=""><br class=""></div></div><div class=""><div class=""><b class="">Conflicting symbols</b></div></div><div class=""><div class="">/ssd/clang/bin/ld.lld: <span style="color: rgb(255, 0, 0);" class="">error</span>: /ssd/llvm-project/lld/ELF/Writ<wbr class="">er.cpp:38: duplicate symbol 'lld::elf::MipsGotSection::add<wbr class="">Entry(lld::elf::SymbolBody&, long, lld::elf::RelExpr)'</div></div><div class=""><div class="">/ssd/clang/bin/ld.lld: error: /ssd/llvm-project/lld/ELF/Synt<wbr class="">heticSections.cpp:673: previous definition was here</div></div></blockquote><div class=""><br class=""></div><div class=""><div class="">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 class=""><br class=""></div></div><div class="">I'm thinking of changing the format to something like the following:</div><div class=""><br class=""></div><blockquote style="margin: 0px 0px 0px 40px; border: none; padding: 0px;" class=""><div class=""><div class=""><b class="">Undefined symbols</b></div></div><div class=""><div class="">/ssd/clang/bin/ld.lld: <span style="color: rgb(255, 0, 0);" class="">error</span>: undefined symbol: lld::elf::EhFrameSection<llvm:<wbr class="">:object::ELFType<(llvm::suppor<wbr class="">t::endianness)0, true> >::addSection(lld::elf::InputS<wbr class="">ectionBase*)</div></div><div class=""><div class=""> <span class="Apple-converted-space"> </span>Source: /ssd/llvm-project/lld/ELF/Writ<wbr class="">er.cpp:207</div></div><div class=""><div class=""> <span class="Apple-converted-space"> </span>Object: lib/liblldELF.a(Writer.cpp.o)</div></div></blockquote></div></div></blockquote><div class=""><br class=""></div></span><div class="">As a point of comparison, here is what ld64 displays:</div><div class=""><br class=""></div><div class="">Undefined symbols for architecture x86_64:<br class="">  "lld::elf::EhFrameSection<<wbr class="">llvm::object::ELFType<(llvm::<wbr class="">support::endianness)0, true> >::addSection(lld::elf::InputS<wbr class="">ectionBase*)", referenced from:<br class="">      foo() in lib/liblldELF.a(Writer.cpp.o)<br class=""><br class=""></div><div class="">Being able to display source location when available is a really nice idea!!</div><span class="gmail-"><div class=""><br class=""></div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><blockquote style="margin: 0px 0px 0px 40px; border: none; padding: 0px;" class=""><div class=""><div class=""><br class=""></div></div><div class=""><div class=""><b class="">Conflicting symbols</b></div></div><div class=""><div class="">/ssd/clang/bin/ld.lld: <span style="color: rgb(255, 0, 0);" class="">error</span>: duplicate symbol: lld::elf::MipsGotSection::addE<wbr class="">ntry(lld::elf::SymbolBody&, long, lld::elf::RelExpr)</div></div><div class=""><div class=""> <span class="Apple-converted-space"> </span>Source 1: /ssd/llvm-project/lld/ELF/Writ<wbr class="">er.cpp:38</div></div><div class=""><div class=""> <span class="Apple-converted-space"> </span>Source 2: /ssd/llvm-project/lld/ELF/Synt<wbr class="">heticSections.cpp:673</div></div><div class=""><div class=""> <span class="Apple-converted-space"> </span>Object 1: lib/liblldELF.a(Writer.cpp.o)</div></div><div class=""><div class=""> <span class="Apple-converted-space"> </span>Object 2 : lib/liblldELF.a(SyntheticSecti<wbr class="">ons.cpp.o)</div></div></blockquote><div class=""><br class=""></div><div class="">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 class=""><br class=""></div></span><div class="">I feel it is using too much vertical space, and the matching between source and object is lost. What about something like:</div><div class=""><br class=""></div><div class=""><span class="gmail-">/ssd/clang/bin/ld.lld: error: duplicate symbol: lld::elf::MipsGotSection::<wbr class="">addEntry(lld::elf::SymbolBody&<wbr class="">, long, lld::elf::RelExpr)<br class=""></span> <span class="Apple-converted-space"> </span>- Defined in lib/liblldELF.a(Writer.cpp.o) (from /ssd/llvm-project/lld/ELF/<wbr class="">Writer.cpp:38)</div><div class=""> <span class="Apple-converted-space"> </span>- Defined in lib/liblldELF.a(<wbr class="">SyntheticSections.cpp.o) (from /ssd/llvm-project/lld/ELF/<wbr class="">SyntheticSections.cpp:673)</div></div></div></blockquote><div class=""><br class=""></div><div class="">What would you print out for undefined symbols? `- Undefined in foo.o (from ...)` looks odd.</div></div></div></div></div></blockquote><br class=""></div><div>Haven’t thought about it, what about something like:</div><div><br class=""></div><div>/ssd/clang/bin/ld.lld: error: undefined symbol: lld::elf::EhFrameSection<llvm::object::ELFType<(llvm::support::endianness)0, true> >::addSection(lld::elf::InputSectionBase*)<br class="">  referenced from foo() at /ssd/llvm-project/lld/ELF/Writer.cpp:207 in lib/liblldELF.a(Writer.cpp.o)<br class=""><br class=""></div>— <div class="">Mehdi</div><div class=""><br class=""></div></body></html>