[libcxx] r285531 - Fix _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY to always have default visibility.

Eric Fiselier via cfe-commits cfe-commits at lists.llvm.org
Sun Oct 30 19:07:24 PDT 2016


Author: ericwf
Date: Sun Oct 30 21:07:23 2016
New Revision: 285531

URL: http://llvm.org/viewvc/llvm-project?rev=285531&view=rev
Log:
Fix _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY to always have default visibility.

This prevent the symbols from being both externally available and hidden, which
causes them to be linked incorrectly. This is only a problem when the address
of the function is explicitly taken since it will always be inlined otherwise.

This patch fixes the issues that caused r285456 to be reverted, and can
now be reapplied.

Modified:
    libcxx/trunk/docs/DesignDocs/VisibilityMacros.rst
    libcxx/trunk/include/__config
    libcxx/trunk/test/std/strings/basic.string/string.cons/dtor_noexcept.pass.cpp

Modified: libcxx/trunk/docs/DesignDocs/VisibilityMacros.rst
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/docs/DesignDocs/VisibilityMacros.rst?rev=285531&r1=285530&r2=285531&view=diff
==============================================================================
--- libcxx/trunk/docs/DesignDocs/VisibilityMacros.rst (original)
+++ libcxx/trunk/docs/DesignDocs/VisibilityMacros.rst Sun Oct 30 21:07:23 2016
@@ -92,14 +92,13 @@ Visibility Macros
   On all other platforms, this macro has an empty definition.
 
 **_LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY**
-  Mark a member function of a class template as hidden and inline except when
-  building the libc++ library where it marks the symbol as being exported by
-  the library.
+  Mark a member function of a class template as visible and always inline. This
+  macro should only be applied to member functions of class templates that are
+  externally instantiated. It is important that these symbols are not marked
+  as hidden as that will prevent the dylib definition from being found.
 
   This macro is used to maintain ABI compatibility for symbols that have been
-  historically exported by the libc++ library but are now marked inline. It
-  should only be applied to member functions of class templates that are
-  externally instantiated.
+  historically exported by the libc++ library but are now marked inline.
 
 **_LIBCPP_EXCEPTION_ABI**
   Mark the member functions, typeinfo, and vtable of the type as being exported

Modified: libcxx/trunk/include/__config
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=285531&r1=285530&r2=285531&view=diff
==============================================================================
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Sun Oct 30 21:07:23 2016
@@ -609,11 +609,7 @@ namespace std {
 #endif
 
 #ifndef _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY
-# ifdef _LIBCPP_BUILDING_LIBRARY
-#   define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY __attribute__((__visibility__("default"), __always_inline__))
-# else
-#   define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
-# endif
+# define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY __attribute__((__visibility__("default"), __always_inline__))
 #endif
 
 #ifndef _LIBCPP_PREFERRED_OVERLOAD

Modified: libcxx/trunk/test/std/strings/basic.string/string.cons/dtor_noexcept.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/basic.string/string.cons/dtor_noexcept.pass.cpp?rev=285531&r1=285530&r2=285531&view=diff
==============================================================================
--- libcxx/trunk/test/std/strings/basic.string/string.cons/dtor_noexcept.pass.cpp (original)
+++ libcxx/trunk/test/std/strings/basic.string/string.cons/dtor_noexcept.pass.cpp Sun Oct 30 21:07:23 2016
@@ -27,6 +27,11 @@ struct some_alloc
     ~some_alloc() noexcept(false);
 };
 
+// Test that it's possible to take the address of basic_string's destructors
+// by creating globals which will register their destructors with cxa_atexit.
+std::string s;
+std::wstring ws;
+
 int main()
 {
     {




More information about the cfe-commits mailing list