<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Nov 21, 2016, at 2:27 PM, Nico Weber <<a href="mailto:thakis@chromium.org" class="">thakis@chromium.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><div class="gmail_extra"><div class="gmail_quote">On Mon, Nov 21, 2016 at 5:19 PM, Mehdi AMINI via cfe-commits<span class="Apple-converted-space"> </span><span dir="ltr" class=""><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank" class="">cfe-commits@lists.llvm.org</a>></span><span class="Apple-converted-space"> </span>wrote:<br class=""><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;">mehdi_amini added a comment.<br class=""><span class=""><br class="">In<span class="Apple-converted-space"> </span><a href="https://reviews.llvm.org/D25932#601842" rel="noreferrer" target="_blank" class="">https://reviews.llvm.org/<wbr class="">D25932#601842</a>, @rnk wrote:<br class=""><br class="">> In<span class="Apple-converted-space"> </span><a href="https://reviews.llvm.org/D25932#601820" rel="noreferrer" target="_blank" class="">https://reviews.llvm.org/<wbr class="">D25932#601820</a>, @mehdi_amini wrote:<br class="">><br class="">> > We ship `clang + libLTO + ld64` bundled in the toolchain, so even if you don't package libLTO yourself, it is already accessible from the linker: it will use the one in the toolchain when needed.<br class="">> ><br class="">> > I don't have an immediate idea to prevent this and have the linker issue an error (other than removing manually libLTO from the Xcode installation).<br class="">><br class="">><br class="">> So, even if clang doesn't pass -lto_library to ld64, ld64 will auto-discover the bundled libLTO that happens to be next to it? That could go badly.<br class=""><br class=""><br class=""></span>Right: until LLVM 3.8, clang was *never* passing the `-lto_library` option. The only way to have your own libLTO used by ld64 instead of the one in the Xcode toolchain was setting the environment variable "DYLD_LIBRARY_PATH".<br class="">Of course was has many issues, and that's what lead us to have clang passing this option to ld64. Initially only when the driver was invoked with -flto, but recently I had issues with clients that didn't use LTO themselves but were having static archives they depend on that were containing bitcode.<br class=""></blockquote><div class=""><br class=""></div><div class="">Where those archives system libraries, or other things?</div></div></div></div></div></blockquote><div><br class=""></div><div>We have two cases:</div><div><br class=""></div><div>1) Internal teams producing libraries in an internal SDK with LTO enabled, and other teams consuming these libraries and linking to the framework. It seems also something that people out-in-the-wild are doing according to some bug reports.</div><div>2) Any Xcode user that have a somehow complex project which is split in multiple targets. Xcode can’t tell clang from one target that it is linking with LTO even if LTO is disabled just because another dependency has LTO enabled. And sometimes Xcode is only seeing static archive as an input anyway.</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><div class="gmail_extra"><div class="gmail_quote"><div class="">Maybe clang could sniff archives for bitcode and pass only -flto in that case?</div></div></div></div></div></blockquote><div><br class=""></div><div>That seems like a possibility. It’d have to resolve paths to the static archives, which it doesn’t do right now I believe (they can be resolved with `-Lpath -lfoo`).</div><div><br class=""></div><div>— </div><div>Mehdi</div><div><br class=""></div></div></body></html>