[llvm-dev] [RFC] better link error messages

Mehdi Amini via llvm-dev
Fri, 24 Mar 2017 00:16:07 -0000

> On Mar 23, 2017, at 3:17 PM, Rui Ueyama via llvm-dev <llvm-dev at
lists.llvm.org> wrote:
>
> Folks,
>
> 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.
>
> Below are examples of the current error messages (note that characters in
red are actually red on terminal):
>
> Undefined symbols
> /ssd/clang/bin/ld.lld: error: /ssd/llvm-project/lld/ELF/Writer.cpp:207:
undefined symbol
'lld::elf::EhFrameSection<llvm::object::ELFType<(llvm::support::endianness)0,
true> >::addSection(lld::elf::InputSectionBase*)'
>
> Conflicting symbols
> /ssd/clang/bin/ld.lld: error: /ssd/llvm-project/lld/ELF/Writer.cpp:38:
duplicate symbol
'lld::elf::MipsGotSection::addEntry(lld::elf::SymbolBody&, long,
lld::elf::RelExpr)'
> /ssd/clang/bin/ld.lld: error:
/ssd/llvm-project/lld/ELF/SyntheticSections.cpp:673: previous definition was
here
>
> 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.
>
> I'm thinking of changing the format to something like the following:
>
> Undefined symbols
> /ssd/clang/bin/ld.lld: error: undefined symbol:
lld::elf::EhFrameSection<llvm::object::ELFType<(llvm::support::endianness)0,
true> >::addSection(lld::elf::InputSectionBase*)
>   Source: /ssd/llvm-project/lld/ELF/Writer.cpp:207
>   Object: lib/liblldELF.a(Writer.cpp.o)

As a point of comparison, here is what ld64 displays:

Undefined symbols for architecture x86_64:

"lld::elf::EhFrameSection<llvm::object::ELFType<(llvm::support::endianness)0,
true> >::addSection(lld::elf::InputSectionBase*)", referenced from:
      foo() in lib/liblldELF.a(Writer.cpp.o)

Being able to display source location when available is a really nice idea!!


>
> Conflicting symbols
> /ssd/clang/bin/ld.lld: error: duplicate symbol:
lld::elf::MipsGotSection::addEntry(lld::elf::SymbolBody&, long,
lld::elf::RelExpr)
>   Source 1: /ssd/llvm-project/lld/ELF/Writer.cpp:38
>   Source 2: /ssd/llvm-project/lld/ELF/SyntheticSections.cpp:673
>   Object 1: lib/liblldELF.a(Writer.cpp.o)
>   Object 2 : lib/liblldELF.a(SyntheticSections.cpp.o)
>
> The new error messages contain complete information that the linker is able
to gather, and it uses more vertical space to improve readability.

I feel it is using too much vertical space, and the matching between source and
object is lost. What about something like:

/ssd/clang/bin/ld.lld: error: duplicate symbol:
lld::elf::MipsGotSection::addEntry(lld::elf::SymbolBody&, long,
lld::elf::RelExpr)
  - Defined in lib/liblldELF.a(Writer.cpp.o) (from
/ssd/llvm-project/lld/ELF/Writer.cpp:38)
  - Defined in lib/liblldELF.a(SyntheticSections.cpp.o) (from
/ssd/llvm-project/lld/ELF/SyntheticSections.cpp:673)


—
Mehdi

-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20170323/36a86c38/attachment.html>