This patch proposes a new option --explain. This patch is not intended to be
committed as-is but is for discussion.
So, I sent https://reviews.llvm.org/D67388 to dump the internal dependency graph
from the linker so that users can run arbitrary graph algorithms to analyze
linker outputs. But I believe in most cases what users want to know is simple:
why some file, that wasn't previously linked, is now included to the final
binary? I think this situation occurs so frequently that we probably should add
a new feature that answers to that particular question, so that users don't have
to write a graph analysis program.
This is an example output of lld when --explain=lib/libLLVMSupport.a(APInt.cpp.o)
is given (shortened to fit to the screen).
This is why 'lib/libLLVMSupport.a(APInt.cpp.o)' is linked: '(--entry option)' uses '_start' defined in '/usr/lib/x86_64-linux-gnu/crt1.o' which uses 'main' defined in 'tools/lld/tools/lld/CMakeFiles/lld.dir/lld.cpp.o' which uses 'StringRef::endswith_lower()' defined in 'lib/libLLVMSupport.a(StringRef.cpp.o)' which uses 'APInt::zext()' defined in 'lib/libLLVMSupport.a(APInt.cpp.o)'
What we are doing in this patch is the basic breadth-first search in the
dependency graph.
The feature implemented in this patch is somewhat redundant once we land
https://reviews.llvm.org/D67388, but this option seems pretty practical and easy
to use. So, I guess that adding something like this would make users life a bit
easier.
Missing full stop.