[libcxxabi] r270816 - libc++abi: build with -fvisibility=hidden

Saleem Abdulrasool via cfe-commits cfe-commits at lists.llvm.org
Wed May 25 19:12:21 PDT 2016


Author: compnerd
Date: Wed May 25 21:12:20 2016
New Revision: 270816

URL: http://llvm.org/viewvc/llvm-project?rev=270816&view=rev
Log:
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.

Modified:
    libcxxabi/trunk/CMakeLists.txt
    libcxxabi/trunk/cmake/config-ix.cmake
    libcxxabi/trunk/include/__cxxabi_config.h
    libcxxabi/trunk/src/cxa_default_handlers.cpp
    libcxxabi/trunk/src/cxa_handlers.cpp

Modified: libcxxabi/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/CMakeLists.txt?rev=270816&r1=270815&r2=270816&view=diff
==============================================================================
--- libcxxabi/trunk/CMakeLists.txt (original)
+++ libcxxabi/trunk/CMakeLists.txt Wed May 25 21:12:20 2016
@@ -250,6 +250,8 @@ append_if(LIBCXXABI_CXX_FLAGS LIBCXXABI_
 
 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)

Modified: libcxxabi/trunk/cmake/config-ix.cmake
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/cmake/config-ix.cmake?rev=270816&r1=270815&r2=270816&view=diff
==============================================================================
--- libcxxabi/trunk/cmake/config-ix.cmake (original)
+++ libcxxabi/trunk/cmake/config-ix.cmake Wed May 25 21:12:20 2016
@@ -8,6 +8,7 @@ check_cxx_compiler_flag(-fPIC
 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)

Modified: libcxxabi/trunk/include/__cxxabi_config.h
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/include/__cxxabi_config.h?rev=270816&r1=270815&r2=270816&view=diff
==============================================================================
--- libcxxabi/trunk/include/__cxxabi_config.h (original)
+++ libcxxabi/trunk/include/__cxxabi_config.h Wed May 25 21:12:20 2016
@@ -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")))

Modified: libcxxabi/trunk/src/cxa_default_handlers.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_default_handlers.cpp?rev=270816&r1=270815&r2=270816&view=diff
==============================================================================
--- libcxxabi/trunk/src/cxa_default_handlers.cpp (original)
+++ libcxxabi/trunk/src/cxa_default_handlers.cpp Wed May 25 21:12:20 2016
@@ -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:

Modified: libcxxabi/trunk/src/cxa_handlers.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_handlers.cpp?rev=270816&r1=270815&r2=270816&view=diff
==============================================================================
--- libcxxabi/trunk/src/cxa_handlers.cpp (original)
+++ libcxxabi/trunk/src/cxa_handlers.cpp Wed May 25 21:12:20 2016
@@ -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




More information about the cfe-commits mailing list