[ThinLTO/gold] Support for getting list of included objects from gold
authorTeresa Johnson <tejohnson@google.com>
Fri, 22 Jul 2016 18:20:22 +0000 (18:20 +0000)
committerTeresa Johnson <tejohnson@google.com>
Fri, 22 Jul 2016 18:20:22 +0000 (18:20 +0000)
commit1e2708c9e03661c8a8c737b1d271996ac0c11755
tree6da4328ad977e23a8aa8ca6fd12d32a76f3fc080
parente04d0eff29642f27742102bc9c7badd55b2b7042
[ThinLTO/gold] Support for getting list of included objects from gold

Summary:
In the distributed backend case, the ThinLink step and the final native
object link are separate processes. This can be problematic when archive
libraries are involved in the link (e.g. via --start-lib/--end-lib
pairs). The linker only includes objects from libraries when
there is a strong reference to them, and depending on the intervening
ThinLTO backend processes' importing/inlining, the strong references
may appear different in the two link steps. See D22356 and D22467
for two scenarios where this causes issues.

To ensure that the final link includes the same objects, this patch
adds support for an "=filename" form of the thinlto-index-only plugin
option, in which case objects gold included in the link are emitted to
the given filename. This should be used as input to the final link (e.g.
via the @filename option to gold), instead of listing all the objects
within --start-lib/--end-lib pairs again.

Note that the support for the gold callback that identifies included
objects was added in gold version 1.12.

Reviewers: davidxl, mehdi_amini

Subscribers: llvm-commits, mehdi_amini

Differential Revision: https://reviews.llvm.org/D22677

llvm-svn: 276450
llvm/test/tools/gold/X86/Inputs/thinlto_emit_linked_objects.ll [new file with mode: 0644]
llvm/test/tools/gold/X86/thinlto_emit_linked_objects.ll [new file with mode: 0644]
llvm/tools/gold/gold-plugin.cpp