[PATCH] D22677: [ThinLTO/gold] Support for getting list of included objects from gold

Teresa Johnson via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 22 12:04:11 PDT 2016


On Fri, Jul 22, 2016 at 11:46 AM, Xinliang David Li <davidxl at google.com>
wrote:

> Can we have a subdir in the test that requires latest version of gold --
> so that more tests can be added?
>

AFAICT there is no way to require a specific version of gold via Lit
currently, but I think I see how such a requirement could be added (there
is something similar for the python version, in utils/lit/tests/lit.cfg,
although I don't see it being used anywhere). Let me try to do that.

Teresa


>
> David
>
> On Fri, Jul 22, 2016 at 11:41 AM, Teresa Johnson <tejohnson at google.com>
> wrote:
>
>> tejohnson added inline comments.
>>
>> ================
>> Comment at: test/tools/gold/X86/thinlto_emit_linked_objects.ll:18
>> @@ +17,3 @@
>> +; RUN:    %t.o \
>> +; RUN:    --start-lib %t2.o --end-lib
>> +
>> ----------------
>> tejohnson wrote:
>> > mehdi_amini wrote:
>> > > tejohnson wrote:
>> > > > tejohnson wrote:
>> > > > > tejohnson wrote:
>> > > > > > mehdi_amini wrote:
>> > > > > > > tejohnson wrote:
>> > > > > > > > tejohnson wrote:
>> > > > > > > > > davidxl wrote:
>> > > > > > > > > > tejohnson wrote:
>> > > > > > > > > > > davidxl wrote:
>> > > > > > > > > > > > tejohnson wrote:
>> > > > > > > > > > > > > davidxl wrote:
>> > > > > > > > > > > > > > Perhaps add test case about real archive case
>> as well.
>> > > > > > > > > > > > > For a distributed build the build system needs to
>> extract the constituent objects (otherwise the combined index paths will
>> not point to an object file)
>> > > > > > > > > > > > I think this feature is more about two step link
>> (not about a particular distributed build system). It is possible that some
>> other distributed build system uses archive, right?
>> > > > > > > > > > > Using archives directly with a distributed build
>> won't work - the combined index module paths need to point to an object
>> file for the distributed backends to import from. The build system needs to
>> extract the objects (e.g. into a temp dir) and pass those.
>> > > > > > > > > > >
>> > > > > > > > > > > Note that archives passed to a non-distributed build
>> work fine because we load the modules from the offset within the archive
>> passed to the plugin from gold and serve those to the importer.
>> > > > > > > > > > how about thin archive?
>> > > > > > > > > Gold does not seem to like thin archives (regardless of
>> LTO vs ThinLTO). I get an error (from gold, not the plugin) like:
>> > > > > > > > >
>> > > > > > > > > error: foo.a: no archive symbol table (run ranlib)
>> > > > > > > > >
>> > > > > > > > > (even when I run ranlib)
>> > > > > > > > Note this issue is specific to bitcode files in the archive
>> - gold with regular native objects in a thin archive works just fine. Looks
>> like ranlib doesn't work on an archive of bitcode files, and that seems to
>> be needed with a thin archive.
>> > > > > > > Do you mean "ranlib doesn't work on a *thin* archive of
>> bitcode files"?
>> > > > > > > Otherwise how do you build LLVM itself with LTO?
>> > > > > > According to http://llvm.org/docs/GoldPlugin.html it isn't
>> supported for archives of bitcode files at all, but apparently isn't needed
>> for a whole (non-thin) archive:
>> > > > > >
>> > > > > > "export RANLIB=/bin/true #ranlib is not needed, and doesn't
>> support .bc files in .a"
>> > > > > So I can't get gold to work with a (non-thin) archive created by
>> ar, it gives the same error. Maybe it needs to take the -plugin option? In
>> any case, a non-thin archive created via llvm-ar is accepted and works
>> fine. I don't see an llvm-ar option to create a thin archive though?
>> > > > Aha - llvm-ar does support thin archives, it's just that the T
>> option is not documented in the help. =)
>> > > >
>> > > > With that, it does work for llvm-ar thin archives! Will add another
>> case to the new test that does the same for thin archives before submitting.
>> > > > According to http://llvm.org/docs/GoldPlugin.html it isn't
>> supported for archives of bitcode files at all.
>> > >
>> > > Documentation patch?
>> > Reading through that page some more, it gives instructions earlier on
>> getting the plugin to work with ar:
>> > "ar and nm also accept the -plugin option and it’s possible to to
>> install LLVMgold.so to /usr/lib/bfd-plugins for a seamless setup. If you
>> built your own gold, be sure to install the ar and nm-new you built to
>> /usr/bin."
>> >
>> > So I think it is ok. I just took the latter comment out of context.
>> >
>> > However, I will send a patch to document the llvm-ar T modifier
>> > With that, it does work for llvm-ar thin archives! Will add another
>> case to the new test that does the same for thin archives before submitting.
>>
>> And, removed in r276453 due to bot failure - looks like gold v1.11 does
>> not like the thin archive (gold v1.12 is fine though!).
>>
>>
>> Repository:
>>   rL LLVM
>>
>> https://reviews.llvm.org/D22677
>>
>>
>>
>>
>


-- 
Teresa Johnson |  Software Engineer |  tejohnson at google.com |  408-460-2413
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160722/c655dd8e/attachment.html>


More information about the llvm-commits mailing list