<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Sep 6, 2017 at 10:28 PM, Davide Italiano <span dir="ltr"><<a href="mailto:davide@freebsd.org" target="_blank">davide@freebsd.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="gmail-HOEnZb"><div class="gmail-h5">On Wed, Sep 6, 2017 at 1:10 PM, Johan Engelen via llvm-dev<br>
<<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br>
> On Tue, Sep 5, 2017 at 11:34 PM, Davide Italiano <<a href="mailto:dccitaliano@gmail.com">dccitaliano@gmail.com</a>><br>
> wrote:<br>
>><br>
>> On Tue, Sep 5, 2017 at 2:09 PM, Teresa Johnson <<a href="mailto:tejohnson@google.com">tejohnson@google.com</a>><br>
>> wrote:<br>
>> ><br>
>> > Hi Johan,<br>
>> ><br>
>> > Right, per the bug this is fixed in lld (and was already handled in<br>
>> > gold-plugin), but I guess not in ld64. Note that lld and gold-plugin use the<br>
>> > new LTO API, while ld64 (and probably other linkers) are still using the<br>
>> > legacy libLTO (which is what ThinLTOCodeGenerator.cpp is part of). Fixing it<br>
>> > in the location you propose could work for all legacy libLTO users. But I<br>
>> > don't think that adding just the size will (always) be enough to<br>
>> > disambiguate (couldn't the 2 same named members have the same size?) -<br>
>> > although lld is doing the same thing so this may be as good as what is done<br>
>> > there. For gold-plugin we add the byte offset into the archive where the<br>
>> > member starts, which will be unique.<br>
>> > +davide for thoughts since he fixed it on the lld side.<br>
>> ><br>
>><br>
>> Yes, Teresa is right, this is the correct fix.<br>
>> I'm not sure what subset of GNU archives Mach-O supports, but the only<br>
>> way of being safe is using offset in the archive + archive name.<br>
><br>
><br>
> ThinLTOCodeGenerator::<wbr>addModule is called by the linker, right? (I can't<br>
> find any callers)<br>
> When it is called, we cannot retrieve the offset of the module inside the<br>
> archive, because the linker didn't tell us about it.<br>
<br>
</div></div>See here for the fix.<br>
<a href="https://reviews.llvm.org/D25495" rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>D25495</a><br>
You pass the the archive name + offset to `lto::InputFile::create`,<br>
assuming your linker uses the new LTO API (and I'm not sure whether<br>
ld64 already switched).<br>
The linker knows the archive name from which it's fetching the member,<br>
as well as its offset (it asks libArchive about it, for lld).<br>
I'm not sure how it works ld64, but of course, to get this mechanism<br>
working, you need some linker modifications.<br></blockquote><div><br></div><div><div>My first priority is fixing the old API so that we can release LDC with ThinLTO working for the stdlib on current OSX setups. I'll probably stick with adding the size to the identifier for simplicity (we have our own fork of LLVM for releasing).</div></div><div>From what I can tell from online sources, latest ld64 (274.2) is using the old api.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
CC:ed some Mach-O people, they probably know more about this than I do.<br></blockquote><div><br></div><div>Thanks.</div><div><br></div><div>- Johan</div><div> <br></div></div></div></div>