Author: smeenai Date: Mon Sep 26 22:44:09 2016 New Revision: 282470 URL: http://llvm.org/viewvc/llvm-project?rev=282470&view=rev Log: [libc++abi] Default to DLL annotations on Windows
`__declspec(dllexport)` and `__declspec(dllimport)` should only be used when building libc++abi as a DLL, but that's the more common use case, so default to adding the annotations and add an option to opt out. Similar to r282449, which made the corresponding change for libc++. Differential Revision: https://reviews.llvm.org/D24945 Modified: libcxxabi/trunk/CMakeLists.txt libcxxabi/trunk/include/__cxxabi_config.h Modified: libcxxabi/trunk/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/CMakeLists.txt?rev=282470&r1=282469&r2=282470&view=diff ============================================================================== --- libcxxabi/trunk/CMakeLists.txt (original) +++ libcxxabi/trunk/CMakeLists.txt Mon Sep 26 22:44:09 2016 @@ -249,6 +249,15 @@ if (LIBCXXABI_USE_COMPILER_RT) list(APPEND LIBCXXABI_LINK_FLAGS "-rtlib=compiler-rt") endif() +# Let the library headers know they are currently being used to build the +# library. +add_definitions(-D_LIBCXXABI_BUILDING_LIBRARY) + +# Disable DLL annotations on Windows for static builds. +if (WIN32 AND LIBCXXABI_ENABLE_STATIC AND NOT LIBCXXABI_ENABLE_SHARED) + add_definitions(-D_LIBCXXABI_DISABLE_DLL_IMPORT_EXPORT) +endif() + append_if(LIBCXXABI_COMPILE_FLAGS LIBCXXABI_HAS_WERROR_FLAG -Werror=return-type) # Get warning flags @@ -333,7 +342,6 @@ if (LIBCXXABI_HAS_PTHREAD_API) add_definitions(-D_LIBCPP_HAS_THREAD_API_PTHREAD) endif() -# This is the _ONLY_ place where add_definitions is called. if (MSVC) add_definitions(-D_CRT_SECURE_NO_WARNINGS) endif() Modified: libcxxabi/trunk/include/__cxxabi_config.h URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/include/__cxxabi_config.h?rev=282470&r1=282469&r2=282470&view=diff ============================================================================== --- libcxxabi/trunk/include/__cxxabi_config.h (original) +++ libcxxabi/trunk/include/__cxxabi_config.h Mon Sep 26 22:44:09 2016 @@ -21,8 +21,13 @@ #define __has_attribute(_attribute_) 0 #endif -#if defined(_LIBCXXABI_DLL) - #if defined(cxxabi_EXPORTS) +#if defined(_WIN32) + #if defined(_LIBCXXABI_DISABLE_DLL_IMPORT_EXPORT) + #define _LIBCXXABI_HIDDEN + #define _LIBCXXABI_DATA_VIS + #define _LIBCXXABI_FUNC_VIS + #define _LIBCXXABI_TYPE_VIS + #elif defined(_LIBCXXABI_BUILDING_LIBRARY) #define _LIBCXXABI_HIDDEN #define _LIBCXXABI_DATA_VIS __declspec(dllexport) #define _LIBCXXABI_FUNC_VIS __declspec(dllexport) _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits