[PATCH] D69607: Add a feature to explain why some file gets included to the linker's output
Rui Ueyama via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 30 00:40:05 PDT 2019
ruiu created this revision.
ruiu added reviewers: MaskRay, pcc, grimar, peter.smith.
Herald added subscribers: arichardson, mgorny, emaste.
Herald added a reviewer: espindola.
Herald added a project: LLVM.
This patch proposes a new option --explain. The feature implemented in this
patch is new, and GNU linkers don't have one. 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/libLLVMipo.a(Inliner.cpp.o)`
is given (shortened to fit to the screen).
This is why 'lib/libLLVMipo.a(Inliner.cpp.o)' gets linked:
'(--entry option)' uses '_start'
'/usr/lib/x86_64-linux-gnu/crt1.o' uses 'main'
'lld.cpp.o' uses 'lld::elf::link(llvm::ArrayRef<char const*>)'
'lib/liblldELF.a(Driver.cpp.o)' uses 'llvm::object::Archive::create()'
'lib/libLLVMObject.a(Archive.cpp.o)' uses 'llvm::Expected<bool>::operator bool()'
'lib/libLLVMPasses.a(PassBuilder.cpp.o)' uses 'llvm::InlinerPass::~InlinerPass()'
'lib/libLLVMipo.a(Inliner.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.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D69607
Files:
lld/ELF/CMakeLists.txt
lld/ELF/Driver.cpp
lld/ELF/Explain.cpp
lld/ELF/Explain.h
lld/ELF/Options.td
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D69607.227036.patch
Type: text/x-patch
Size: 9564 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191030/8a03295c/attachment.bin>
More information about the llvm-commits
mailing list