<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 Oct 19, 2016, at 9:14 AM, Reid Kleckner <<a href="mailto:rnk@google.com" class="">rnk@google.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote">On Thu, Oct 13, 2016 at 10:46 PM, Mehdi Amini via cfe-dev <span dir="ltr" class=""><<a href="mailto:cfe-dev@lists.llvm.org" target="_blank" class="">cfe-dev@lists.llvm.org</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">The problem is that the linkage “available_externally" is a “lie”: there is an external template instantiation in the header, but it is marked “visibility hidden”. So the function cannot be linked to in the libc++ dylib. (I think it’d work with a static libc++).<br class=""></blockquote><div class=""><br class=""></div><div class="">IMO this is the real problem. If basic_string isn't actually available externally, why have explicit template instaniation declarations in <string>? IIRC John put these back for some reason, but if all of basic_string is always_inline, what is the point? </div></div></div></div></div></blockquote><div><br class=""></div><div>It seems a general issue though: how do you mix visibility hidden and external template? This is fine if you link statically, but can’t be exported outside of a DSO.</div><div>Should we design a warning for when we mix external template with visibility hidden?</div><div><br class=""></div><div>Also the intent for libc++ seems that we’d like most of the class to be external template but for some method. Maybe it could be achieved with a base class that would be external template, and the derived wouldn’t? (The derived would contain the current “hidden” method).</div><div><br class=""></div><div><br class=""></div><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class="">I also think libc++ should stop abusing always_inline for linkage purposes. We should use __attribute__((internal_linkage)) instead, and allow the optimizer to make informed inlining decisions.</div></div></div></div>
</div></blockquote></div><br class=""><div class="">We have another thread for this: <a href="http://lists.llvm.org/pipermail/cfe-dev/2016-October/051151.html" class="">http://lists.llvm.org/pipermail/cfe-dev/2016-October/051151.html</a> ; feel free to chime in there!</div><div class=""><br class=""></div><div class="">— </div><div class="">Mehdi</div><div class=""><br class=""></div></body></html>