EricWF created this revision. This patch ensures that `__shared_weak_count` provides a consistent vtable regardless of if RTTI is enabled or if we are targeting a static or shared libc++ build.
This patch is technically ABI breaking, but only for a very specific configuration that neither Apple nor FreeBSD should be shipping. @dexonsmith @emaste can you confirm that you don't ship builds of libc++ that have both (A) RTTI disabled, and (B) Manually define `_LIBCPP_BUILD_STATIC`? Note that `_LIBCPP_BUILD_STATIC` is not normally defined when building `libc++.a`, but instead it must be manually provided by the user or the `__config_site`. https://reviews.llvm.org/D32838 Files: include/memory src/memory.cpp Index: src/memory.cpp =================================================================== --- src/memory.cpp +++ src/memory.cpp @@ -123,16 +123,12 @@ return 0; } -#if !defined(_LIBCPP_NO_RTTI) || !defined(_LIBCPP_BUILD_STATIC) - const void* __shared_weak_count::__get_deleter(const type_info&) const _NOEXCEPT { - return 0; + return nullptr; } -#endif // _LIBCPP_NO_RTTI - #if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER) _LIBCPP_SAFE_STATIC static const std::size_t __sp_mut_count = 16; Index: include/memory =================================================================== --- include/memory +++ include/memory @@ -3523,13 +3523,7 @@ long use_count() const _NOEXCEPT {return __shared_count::use_count();} __shared_weak_count* lock() _NOEXCEPT; - // Define the function out only if we build static libc++ without RTTI. - // Otherwise we may break clients who need to compile their projects with - // -fno-rtti and yet link against a libc++.dylib compiled - // without -fno-rtti. -#if !defined(_LIBCPP_NO_RTTI) || !defined(_LIBCPP_BUILD_STATIC) virtual const void* __get_deleter(const type_info&) const _NOEXCEPT; -#endif private: virtual void __on_zero_shared_weak() _NOEXCEPT = 0; };
Index: src/memory.cpp =================================================================== --- src/memory.cpp +++ src/memory.cpp @@ -123,16 +123,12 @@ return 0; } -#if !defined(_LIBCPP_NO_RTTI) || !defined(_LIBCPP_BUILD_STATIC) - const void* __shared_weak_count::__get_deleter(const type_info&) const _NOEXCEPT { - return 0; + return nullptr; } -#endif // _LIBCPP_NO_RTTI - #if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER) _LIBCPP_SAFE_STATIC static const std::size_t __sp_mut_count = 16; Index: include/memory =================================================================== --- include/memory +++ include/memory @@ -3523,13 +3523,7 @@ long use_count() const _NOEXCEPT {return __shared_count::use_count();} __shared_weak_count* lock() _NOEXCEPT; - // Define the function out only if we build static libc++ without RTTI. - // Otherwise we may break clients who need to compile their projects with - // -fno-rtti and yet link against a libc++.dylib compiled - // without -fno-rtti. -#if !defined(_LIBCPP_NO_RTTI) || !defined(_LIBCPP_BUILD_STATIC) virtual const void* __get_deleter(const type_info&) const _NOEXCEPT; -#endif private: virtual void __on_zero_shared_weak() _NOEXCEPT = 0; };
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits