<div dir="ltr"><div dir="ltr"><div dir="ltr"><div>I see the GNU ld behavior as a limitation, not as a feature, as Peter Smith also pointed out in <a href="https://reviews.llvm.org/D86762">https://reviews.llvm.org/D86762</a>. While it can be argued that there are certain cases where it can help detect layering violations as you mentioned in your change, I'm not sure how valuable that is in practice. Every case I've encountered so far either in Chrome or in Fuchsia was a valid use case, most commonly interceptors. The solution has always been the same, wrap all libraries in --start-group/--stop-group and it's what most projects do by default to avoid dealing with these issues, see for example [Chromium](<a href="https://source.chromium.org/chromium/chromium/src/+/master:build/toolchain/gcc_toolchain.gni;l=409" target="_blank">https://source.chromium.org/chromium/chromium/src/+/master:build/toolchain/gcc_toolchain.gni;l=409</a>). In our case, compatibility with linkers on other platforms is more important than compatibility with GNU ld, so I'd prefer to keep the current behavior. Projects that care about compatibility with GNU ld can use --warn-backrefs.</div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Aug 31, 2020 at 1:44 PM Fāng-ruì Sòng <<a href="mailto:maskray@google.com" target="_blank">maskray@google.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Mon, Aug 31, 2020 at 1:29 PM David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>> wrote:<br>
><br>
><br>
><br>
> On Mon, Aug 31, 2020 at 1:24 PM Fāng-ruì Sòng <<a href="mailto:maskray@google.com" target="_blank">maskray@google.com</a>> wrote:<br>
>><br>
>> On Fri, Aug 28, 2020 at 11:16 AM David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>> wrote:<br>
>> ><br>
>> > Would you like to conduct the conversation here, or on the review thread? (I lean towards having them here, but don't mind if folks feel like it keeps the noise down & want to more post a notice saying "hey, here's this thing, if you're interested, go discuss it over there" - more an optional opt-in rather than requiring people to opt-out via muting the thread, etc)<br>
>><br>
>> Yes, we can conduct the "should we enable --warn-backrefs by default"<br>
>> conversation here. Since the semantics --warn-backrefs of are a bit<br>
>> complex, we need a documentation. <a href="https://reviews.llvm.org/D86762" rel="noreferrer" target="_blank">https://reviews.llvm.org/D86762</a> is<br>
>> put up to get wording suggestions. Explicitly adding the people to the<br>
>> CC list...<br>
>><br>
>> FWIW for many code bases, --warn-backrefs should produce no warnings<br>
>> (error if --fatal-warnings). For some code bases, GNU ld may error<br>
>> "undefined reference". --warn-backrefs can catch such problems.<br>
><br>
><br>
> One of the questions raised on the thread there was about different linker semantics. I assume the "--warn-backrefs by default" we're discussing is only related to the ld.lld frontend? Not the Windows linker lld behavior (or ld64 (old or new) lld behavior)?<br>
<br>
Yes, the ELF port (lld/ELF). No other port has implemented<br>
--warn-backrefs. The intion of --warn-backrefs is to capture behavior<br>
differences with GNU ld's ELF ports. If traditional ELF linkers don't<br>
behave like that, I can replace "traditional ELF linkers" in<br>
<a href="https://reviews.llvm.org/D86762" rel="noreferrer" target="_blank">https://reviews.llvm.org/D86762</a> with "GNU linkers".<br>
<br>
>><br>
>><br>
>><br>
>> > On Thu, Aug 27, 2020 at 10:15 PM Fangrui Song via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br>
>> >><br>
>> >> Hi all, LLD's --warn-backrefs is a tool to identify potential<br>
>> >> incompatible archive selection semantics with traditional Unix linkers.<br>
>> >> I have improved it (via D77522,D77630 and D77512) to a state where a<br>
>> >> --warn-backrefs diagnostic almost assuredly means that the link will<br>
>> >> fail with GNU ld, or the symbol will get different resolution in GNU ld and LLD.<br>
>> >><br>
>> >> My conclusion is that --warn-backrefs is a very useful layering check tool.<br>
>> >> I just wrote a documentation about the advantage (of GNU ld's archive<br>
>> >> selection semantics..... But we can do better with --warn-backrefs!<br>
>> >> GNU ld just reports "undefined reference" with no actionable feedback<br>
>> >> about the offending archive)<br>
>> >><br>
>> >> <a href="https://reviews.llvm.org/D86762" rel="noreferrer" target="_blank">https://reviews.llvm.org/D86762</a><br>
>> >><br>
>> >> I am wondering whether in the next release we can make --warn-backrefs<br>
>> >> the default. I have added many known users to the review.<br>
>> >> (There is no need for --no-warn-backrefs because --warn-backrefs-exclude='*' does the same job)<br>
>> >> _______________________________________________<br>
>> >> LLVM Developers mailing list<br>
>> >> <a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
>> >> <a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div></div>