[llvm-branch-commits] [libcxx] 0066a09 - [libc++] Give extern templates default visibility on gcc
Shoaib Meenai via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Jan 12 18:36:07 PST 2021
Author: Shoaib Meenai
Date: 2021-01-12T18:30:56-08:00
New Revision: 0066a09579ca90f60cb1947691e5a441f9f57a5d
URL: https://github.com/llvm/llvm-project/commit/0066a09579ca90f60cb1947691e5a441f9f57a5d
DIFF: https://github.com/llvm/llvm-project/commit/0066a09579ca90f60cb1947691e5a441f9f57a5d.diff
LOG: [libc++] Give extern templates default visibility on gcc
Contrary to the current visibility macro documentation, it appears that
gcc does handle visibility attribute on extern templates correctly, e.g.
https://godbolt.org/g/EejuV7. We need this so that extern template
instantiations of classes not marked _LIBCPP_TEMPLATE_VIS (e.g.
__vector_base_common) are correctly exported with gcc when building with
hidden visibility.
Reviewed By: ldionne
Differential Revision: https://reviews.llvm.org/D35388
Added:
Modified:
libcxx/docs/DesignDocs/VisibilityMacros.rst
libcxx/include/__config
Removed:
################################################################################
diff --git a/libcxx/docs/DesignDocs/VisibilityMacros.rst b/libcxx/docs/DesignDocs/VisibilityMacros.rst
index d0d4f0adb220..20237b74de6a 100644
--- a/libcxx/docs/DesignDocs/VisibilityMacros.rst
+++ b/libcxx/docs/DesignDocs/VisibilityMacros.rst
@@ -131,12 +131,6 @@ Visibility Macros
specified on the primary template and to export the member functions produced
by the explicit instantiation in the dylib.
- **GCC Behavior**: GCC ignores visibility attributes applied the type in
- extern template declarations and applying an attribute results in a warning.
- However since `_LIBCPP_TEMPLATE_VIS` is the same as
- `__attribute__((visibility("default"))` the visibility is already correct.
- The macro has an empty definition with GCC.
-
**Windows Behavior**: `extern template` and `dllexport` are fundamentally
incompatible *on a class template* on Windows; the former suppresses
instantiation, while the latter forces it. Specifying both on the same
diff --git a/libcxx/include/__config b/libcxx/include/__config
index f1606c6d3b1c..a6ed66857d75 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -718,7 +718,7 @@ typedef __char32_t char32_t;
#endif
#ifndef _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
-# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__)
+# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __attribute__ ((__visibility__("default")))
# else
# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
More information about the llvm-branch-commits
mailing list