mold icon indicating copy to clipboard operation
mold copied to clipboard

Better reporting for undefined symbols

Open mrichtarsky opened this issue 2 years ago • 3 comments

lld did some nice "innovation" in the error reporting some time ago that I find quite helpful. Perhaps mold can adapt that?

ld: error: undefined symbol: std::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >::basic_ostringstream()
>>> referenced by moz-decimal-utils.h:66 (/xmake/j/prod-build7010/w/598o5ujxkb/src/mfbt/decimal/moz-decimal-utils.h:66)
>>>               Decimal.o:(mozToString(long)) in archive /data/.HappyMake/cache/dependencies/newdb/spidermonkey-45.9.0-sap11-linuxx86_64-gcc9.release.linuxx86_64/dbg/lib/libmozglue.a
>>> referenced by moz-decimal-utils.h:72 (/xmake/j/prod-build7010/w/598o5ujxkb/src/mfbt/decimal/moz-decimal-utils.h:72)
>>>               Decimal.o:(mozToString(unsigned long)) in archive /data/.HappyMake/cache/dependencies/newdb/spidermonkey-45.9.0-sap11-linuxx86_64-gcc9.release.linuxx86_64/dbg/lib/libmozglue.a
>>> did you mean: std::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >::~basic_ostringstream()
>>> defined in: /data/d048964/build/ws8/build/ClangDebug/gen/libstdc++.so

Especially helpful is the reporting which archive/library pulls in the symbol. The link here has lots of libraries and lld provided the easiest way to track down the library by far.

mrichtarsky avatar May 11 '22 15:05 mrichtarsky

I personally can live without it, but it may be because I have a very deep knowledge on the linker.

Especially helpful is the reporting which archive/library pulls in the symbol.

It looks like showing a complete dependency chain reaching to an unresolved undefined symbol is a good idea.

Currently, I'm using the --print-dependencies linker option to know the dependency info, though.

rui314 avatar May 12 '22 01:05 rui314

FWIW, the thing I find really nice about the lld output is that it reports each symbol just once and then at most few places where the symbol is referenced. That often makes the error list way shorter and more readable.

llunak avatar May 12 '22 18:05 llunak

I personally can live without it, but it may be because I have a very deep knowledge on the linker.

FWIW, the thing I find really nice about the lld output is that it reports each symbol just once and then at most few places where the symbol is referenced. That often makes the error list way shorter and more readable.

100% agreed. Having concise and actionable error messages lowers the bar to systems programming for everyone regardless of their level of expertise.

One of the main design decisions listed in the readme is:

"mold is designed to increase developer productivity" and I think it can do that by reducing build times and reducing it time it takes to diagnose and fix linker errors.

As a user, I would really appreciate having messages like this, though i am not sure how much of a performance cost this adds.

petr-tik avatar May 12 '22 23:05 petr-tik