<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=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">This change makes it impossible to change the visibility of operator+ with -fvisibility=hidden, which is not desirable on Darwin.</div><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""></div><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">For example:</div><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""></div><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">$ cat test.cpp</div><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">#include <string></span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255); min-height: 13px;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""></span><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">using namespace std;</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255); min-height: 13px;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""></span><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">string foo1(string s) {</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">  return "abc" + s;</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">}</span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""><br class=""></span></div></div><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">$ clang++ test.cpp -fvisibility=hidden -c; nm -m -a test.o | grep <span style="font-family: Menlo; font-size: 11px; background-color: rgb(255, 255, 255);" class="">__ZNSt3__1plIcNS_11char_traitsIcEENS_9allocatorIcEEEENS_12basic_stringIT_T0_T1_EEPKS6_RKS9_</span></div><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">0000000000000030 (__TEXT,__text) weak external __ZNSt3__1plIcNS_11char_traitsIcEENS_9allocatorIcEEEENS_12basic_stringIT_T0_T1_EEPKS6_RKS9_</span></div><div class=""><br class=""></div></div></div><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">The symbol used to be “weak private external”, but it is “weak external” now.</div><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""></div><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div><blockquote type="cite" class=""><div class="">On Jul 13, 2017, at 2:35 PM, Shoaib Meenai via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org" class="">cfe-commits@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">Author: smeenai<br class="">Date: Thu Jul 13 14:35:52 2017<br class="">New Revision: 307966<br class=""><br class="">URL: <a href="http://llvm.org/viewvc/llvm-project?rev=307966&view=rev" class="">http://llvm.org/viewvc/llvm-project?rev=307966&view=rev</a><br class="">Log:<br class="">[libc++] Mark string operator+ _LIBCPP_FUNC_VIS<br class=""><br class="">It has an extern template instantiation declaration in the headers and a<br class="">corresponding instantiation definition in the library, so we must mark<br class="">it with _LIBCPP_FUNC_VIS to make it available outside the library.<br class=""><br class="">This doesn't cause any ABI changes as-is since we don't build libc++<br class="">with hidden visibility (so the function is exported anyway). It's needed<br class="">for building libc++ with hidden visibility, however.<br class=""><br class="">Clarify the Windows behavior for extern function templates while I'm<br class="">here, since this exercises that behavior.<br class=""><br class="">Modified:<br class="">    libcxx/trunk/docs/DesignDocs/VisibilityMacros.rst<br class="">    libcxx/trunk/include/string<br class=""><br class="">Modified: libcxx/trunk/docs/DesignDocs/VisibilityMacros.rst<br class="">URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/docs/DesignDocs/VisibilityMacros.rst?rev=307966&r1=307965&r2=307966&view=diff" class="">http://llvm.org/viewvc/llvm-project/libcxx/trunk/docs/DesignDocs/VisibilityMacros.rst?rev=307966&r1=307965&r2=307966&view=diff</a><br class="">==============================================================================<br class="">--- libcxx/trunk/docs/DesignDocs/VisibilityMacros.rst (original)<br class="">+++ libcxx/trunk/docs/DesignDocs/VisibilityMacros.rst Thu Jul 13 14:35:52 2017<br class="">@@ -98,7 +98,8 @@ Visibility Macros<br class="">   explicit instantiations themselves are marked as exported. Note that this<br class="">   applies *only* to extern *class* templates. Extern *function* templates obey<br class="">   regular import/export semantics, and applying `dllexport` directly to the<br class="">-  extern template declaration is the correct thing to do for them.<br class="">+  extern template declaration (i.e. using `_LIBCPP_FUNC_VIS`) is the correct<br class="">+  thing to do for them.<br class=""><br class=""> **_LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS**<br class="">   Mark the member functions, typeinfo, and vtable of an explicit instantiation<br class=""><br class="">Modified: libcxx/trunk/include/string<br class="">URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/string?rev=307966&r1=307965&r2=307966&view=diff" class="">http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/string?rev=307966&r1=307965&r2=307966&view=diff</a><br class="">==============================================================================<br class="">--- libcxx/trunk/include/string (original)<br class="">+++ libcxx/trunk/include/string Thu Jul 13 14:35:52 2017<br class="">@@ -4006,7 +4006,7 @@ basic_string<_CharT, _Traits, _Allocator<br class=""><br class=""> _LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_string<char>)<br class=""> _LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_string<wchar_t>)<br class="">-_LIBCPP_EXTERN_TEMPLATE(string operator+<char, char_traits<char>, allocator<char> >(char const*, string const&))<br class="">+_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS string operator+<char, char_traits<char>, allocator<char> >(char const*, string const&))<br class=""><br class=""> #if _LIBCPP_STD_VER > 11 <br class=""> // Literal suffixes for basic_string [basic.string.literals]<br class=""><br class=""><br class="">_______________________________________________<br class="">cfe-commits mailing list<br class=""><a href="mailto:cfe-commits@lists.llvm.org" class="">cfe-commits@lists.llvm.org</a><br class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits<br class=""></div></div></blockquote></div><br class=""></div></body></html>