Skip to content

Commit 0066a09

Browse files
committed
[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
1 parent acea470 commit 0066a09

File tree

2 files changed

+1
-7
lines changed

2 files changed

+1
-7
lines changed

libcxx/docs/DesignDocs/VisibilityMacros.rst

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,6 @@ Visibility Macros
131131
specified on the primary template and to export the member functions produced
132132
by the explicit instantiation in the dylib.
133133

134-
**GCC Behavior**: GCC ignores visibility attributes applied the type in
135-
extern template declarations and applying an attribute results in a warning.
136-
However since `_LIBCPP_TEMPLATE_VIS` is the same as
137-
`__attribute__((visibility("default"))` the visibility is already correct.
138-
The macro has an empty definition with GCC.
139-
140134
**Windows Behavior**: `extern template` and `dllexport` are fundamentally
141135
incompatible *on a class template* on Windows; the former suppresses
142136
instantiation, while the latter forces it. Specifying both on the same

libcxx/include/__config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,7 @@ typedef __char32_t char32_t;
718718
#endif
719719

720720
#ifndef _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
721-
# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__)
721+
# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
722722
# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __attribute__ ((__visibility__("default")))
723723
# else
724724
# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS

0 commit comments

Comments
 (0)