libc++abi: build with -fvisibility=hidden

Enable building libc++abi with hidden visibility by default.  The ABI mandated
interfaces (and a few extra) are already set up to be externally visible.  This
allows us to ensure that any implementation details are not leaked.

llvm-svn: 270816
This commit is contained in:
Saleem Abdulrasool 2016-05-26 02:12:20 +00:00
parent ee77a4828e
commit 18ef564c8b
5 changed files with 12 additions and 3 deletions

View File

@ -250,6 +250,8 @@ append_if(LIBCXXABI_CXX_FLAGS LIBCXXABI_HAS_EHSC_FLAG -EHsc)
append_if(LIBCXXABI_C_FLAGS LIBCXXABI_HAS_FUNWIND_TABLES -funwind-tables)
append_if(LIBCXXABI_COMPILE_FLAGS LIBCXXABI_HAS_FVISIBILITY_HIDDEN_FLAG -fvisibility=hidden)
# Assert
string(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE)
if (LIBCXXABI_ENABLE_ASSERTIONS)

View File

@ -8,6 +8,7 @@ check_cxx_compiler_flag(-fPIC LIBCXXABI_HAS_FPIC_FLAG)
check_cxx_compiler_flag(-fno-exceptions LIBCXXABI_HAS_NO_EXCEPTIONS_FLAG)
check_cxx_compiler_flag(-fno-rtti LIBCXXABI_HAS_NO_RTTI_FLAG)
check_cxx_compiler_flag(-fstrict-aliasing LIBCXXABI_HAS_FSTRICT_ALIASING_FLAG)
check_cxx_compiler_flag(-fvisibility=hidden LIBCXXABI_HAS_FVISIBILITY_HIDDEN_FLAG)
check_cxx_compiler_flag(-nodefaultlibs LIBCXXABI_HAS_NODEFAULTLIBS_FLAG)
check_cxx_compiler_flag(-nostdinc++ LIBCXXABI_HAS_NOSTDINCXX_FLAG)
check_cxx_compiler_flag(-Wall LIBCXXABI_HAS_WALL_FLAG)

View File

@ -24,15 +24,18 @@
#if defined(_LIBCXXABI_DLL)
#if defined(cxxabi_EXPORTS)
#define _LIBCXXABI_HIDDEN
#define _LIBCXXABI_DATA_VIS __declspec(dllexport)
#define _LIBCXXABI_FUNC_VIS __declspec(dllexport)
#define _LIBCXXABI_TYPE_VIS __declspec(dllexport)
#else
#define _LIBCXXABI_HIDDEN
#define _LIBCXXABI_DATA_VIS __declspec(dllimport)
#define _LIBCXXABI_FUNC_VIS __declspec(dllimport)
#define _LIBCXXABI_TYPE_VIS __declspec(dllimport)
#endif
#else
#define _LIBCXXABI_HIDDEN __attribute__((__visibility__("hidden")))
#define _LIBCXXABI_DATA_VIS __attribute__((__visibility__("default")))
#define _LIBCXXABI_FUNC_VIS __attribute__((__visibility__("default")))
#if __has_attribute(__type_visibility__)
#define _LIBCXXABI_TYPE_VIS __attribute__((__type_visibility__("default")))

View File

@ -88,7 +88,10 @@ static void default_unexpected_handler()
//
// Global variables that hold the pointers to the current handler
//
std::terminate_handler __cxa_terminate_handler = default_terminate_handler;
_LIBCXXABI_DATA_VIS
std::terminate_handler __cxa_terminate_handler = default_terminate_handler;
_LIBCXXABI_DATA_VIS
std::unexpected_handler __cxa_unexpected_handler = default_unexpected_handler;
// In the future these will become:

View File

@ -102,9 +102,9 @@ terminate() _NOEXCEPT
__terminate(get_terminate());
}
extern "C" new_handler __cxa_new_handler = 0;
// In the future these will become:
// In the future this will become:
// std::atomic<std::new_handler> __cxa_new_handler(0);
extern "C" _LIBCXXABI_DATA_VIS new_handler __cxa_new_handler = 0;
new_handler
set_new_handler(new_handler handler) _NOEXCEPT