[libc++] Add _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS
It's useful to be able to disable visibility annotations entirely; for example, if we're building libc++ static to include in another library, and we don't want any libc++ functions getting exported out of that library. This is a generalization of _LIBCPP_DISABLE_DLL_IMPORT_EXPORT. Differential Revision: https://reviews.llvm.org/D26934 git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@288690 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -518,7 +518,7 @@ config_define_if(LIBCXX_HAS_MUSL_LIBC _LIBCPP_HAS_MUSL_LIBC)
|
|||||||
# static library only we modify the headers to disable DLL import/export.
|
# static library only we modify the headers to disable DLL import/export.
|
||||||
if (DEFINED WIN32 AND LIBCXX_ENABLE_STATIC AND NOT LIBCXX_ENABLE_SHARED)
|
if (DEFINED WIN32 AND LIBCXX_ENABLE_STATIC AND NOT LIBCXX_ENABLE_SHARED)
|
||||||
message(STATUS "Generating custom __config for non-DLL Windows build")
|
message(STATUS "Generating custom __config for non-DLL Windows build")
|
||||||
config_define(ON _LIBCPP_DISABLE_DLL_IMPORT_EXPORT)
|
config_define(ON _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (LIBCXX_NEEDS_SITE_CONFIG)
|
if (LIBCXX_NEEDS_SITE_CONFIG)
|
||||||
|
|||||||
@@ -149,3 +149,9 @@ thread safety annotations.
|
|||||||
This macro is used to enable -Wthread-safety annotations on libc++'s
|
This macro is used to enable -Wthread-safety annotations on libc++'s
|
||||||
``std::mutex`` and ``std::lock_guard``. By default these annotations are
|
``std::mutex`` and ``std::lock_guard``. By default these annotations are
|
||||||
disabled and must be manually enabled by the user.
|
disabled and must be manually enabled by the user.
|
||||||
|
|
||||||
|
**_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS**:
|
||||||
|
This macro is used to disable all visibility annotations inside libc++.
|
||||||
|
Defining this macro and then building libc++ with hidden visibility gives a
|
||||||
|
build of libc++ which does not export any symbols, which can be useful when
|
||||||
|
building statically for inclusion into another library.
|
||||||
|
|||||||
@@ -510,7 +510,7 @@ namespace std {
|
|||||||
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#if defined(_LIBCPP_DISABLE_DLL_IMPORT_EXPORT)
|
#if defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
|
||||||
# define _LIBCPP_DLL_VIS
|
# define _LIBCPP_DLL_VIS
|
||||||
# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
|
# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
|
||||||
# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
|
# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
|
||||||
@@ -546,18 +546,30 @@ namespace std {
|
|||||||
#endif // _WIN32
|
#endif // _WIN32
|
||||||
|
|
||||||
#ifndef _LIBCPP_HIDDEN
|
#ifndef _LIBCPP_HIDDEN
|
||||||
|
#if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
|
||||||
#define _LIBCPP_HIDDEN __attribute__ ((__visibility__("hidden")))
|
#define _LIBCPP_HIDDEN __attribute__ ((__visibility__("hidden")))
|
||||||
|
#else
|
||||||
|
#define _LIBCPP_HIDDEN
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef _LIBCPP_FUNC_VIS
|
#ifndef _LIBCPP_FUNC_VIS
|
||||||
|
#if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
|
||||||
#define _LIBCPP_FUNC_VIS __attribute__ ((__visibility__("default")))
|
#define _LIBCPP_FUNC_VIS __attribute__ ((__visibility__("default")))
|
||||||
|
#else
|
||||||
|
#define _LIBCPP_FUNC_VIS
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef _LIBCPP_TYPE_VIS
|
#ifndef _LIBCPP_TYPE_VIS
|
||||||
# if __has_attribute(__type_visibility__)
|
# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
|
||||||
# define _LIBCPP_TYPE_VIS __attribute__ ((__type_visibility__("default")))
|
# if __has_attribute(__type_visibility__)
|
||||||
|
# define _LIBCPP_TYPE_VIS __attribute__ ((__type_visibility__("default")))
|
||||||
|
# else
|
||||||
|
# define _LIBCPP_TYPE_VIS __attribute__ ((__visibility__("default")))
|
||||||
|
# endif
|
||||||
# else
|
# else
|
||||||
# define _LIBCPP_TYPE_VIS __attribute__ ((__visibility__("default")))
|
# define _LIBCPP_TYPE_VIS
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -574,11 +586,15 @@ namespace std {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef _LIBCPP_EXCEPTION_ABI
|
#ifndef _LIBCPP_EXCEPTION_ABI
|
||||||
|
#if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
|
||||||
#define _LIBCPP_EXCEPTION_ABI __attribute__ ((__visibility__("default")))
|
#define _LIBCPP_EXCEPTION_ABI __attribute__ ((__visibility__("default")))
|
||||||
|
#else
|
||||||
|
#define _LIBCPP_EXCEPTION_ABI
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef _LIBCPP_ENUM_VIS
|
#ifndef _LIBCPP_ENUM_VIS
|
||||||
# if __has_attribute(__type_visibility__)
|
# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__)
|
||||||
# define _LIBCPP_ENUM_VIS __attribute__ ((__type_visibility__("default")))
|
# define _LIBCPP_ENUM_VIS __attribute__ ((__type_visibility__("default")))
|
||||||
# else
|
# else
|
||||||
# define _LIBCPP_ENUM_VIS
|
# define _LIBCPP_ENUM_VIS
|
||||||
@@ -586,7 +602,7 @@ namespace std {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
|
#ifndef _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
|
||||||
# if __has_attribute(__type_visibility__)
|
# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__)
|
||||||
# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __attribute__ ((__type_visibility__("default")))
|
# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __attribute__ ((__type_visibility__("default")))
|
||||||
# else
|
# else
|
||||||
# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
|
# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
|
||||||
@@ -598,15 +614,27 @@ namespace std {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef _LIBCPP_INLINE_VISIBILITY
|
#ifndef _LIBCPP_INLINE_VISIBILITY
|
||||||
|
#if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
|
||||||
#define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__visibility__("hidden"), __always_inline__))
|
#define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__visibility__("hidden"), __always_inline__))
|
||||||
|
#else
|
||||||
|
#define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__always_inline__))
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef _LIBCPP_ALWAYS_INLINE
|
#ifndef _LIBCPP_ALWAYS_INLINE
|
||||||
|
#if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
|
||||||
#define _LIBCPP_ALWAYS_INLINE __attribute__ ((__visibility__("hidden"), __always_inline__))
|
#define _LIBCPP_ALWAYS_INLINE __attribute__ ((__visibility__("hidden"), __always_inline__))
|
||||||
|
#else
|
||||||
|
#define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__))
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY
|
#ifndef _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY
|
||||||
# define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY __attribute__((__visibility__("default"), __always_inline__))
|
# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
|
||||||
|
# define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY __attribute__((__visibility__("default"), __always_inline__))
|
||||||
|
# else
|
||||||
|
# define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY __attribute__((__always_inline__))
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef _LIBCPP_PREFERRED_OVERLOAD
|
#ifndef _LIBCPP_PREFERRED_OVERLOAD
|
||||||
|
|||||||
@@ -21,6 +21,6 @@
|
|||||||
#cmakedefine _LIBCPP_HAS_MUSL_LIBC
|
#cmakedefine _LIBCPP_HAS_MUSL_LIBC
|
||||||
#cmakedefine _LIBCPP_HAS_THREAD_API_PTHREAD
|
#cmakedefine _LIBCPP_HAS_THREAD_API_PTHREAD
|
||||||
#cmakedefine _LIBCPP_HAS_THREAD_API_EXTERNAL
|
#cmakedefine _LIBCPP_HAS_THREAD_API_EXTERNAL
|
||||||
#cmakedefine _LIBCPP_DISABLE_DLL_IMPORT_EXPORT
|
#cmakedefine _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS
|
||||||
|
|
||||||
#endif // _LIBCPP_CONFIG_SITE
|
#endif // _LIBCPP_CONFIG_SITE
|
||||||
|
|||||||
Reference in New Issue
Block a user