Skip to content

Commit 0cc34ca

Browse files
committed
[libc++] Define legacy symbols for inline functions at a finer-grained level
When we build the library with the stable ABI, we need to include some functions in the dylib that were made inline in later versions of the library (to avoid breaking code that might be relying on those symbols). However, those methods were made non-inline whenever we'd be building the library, which means that all translation units would end up using the old out-of-line definition of these methods, as opposed to the new inlined version. This patch makes it so that only the translation units that actually define the out-of-line methods use the old definition, opening up potential optimization opportunities in other translation units. This should solve some of the issues encountered in D65667. Differential Revision: https://reviews.llvm.org/D123519
1 parent cfa4fe7 commit 0cc34ca

File tree

4 files changed

+16
-10
lines changed

4 files changed

+16
-10
lines changed

libcxx/include/__memory/shared_ptr.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,7 @@ class _LIBCPP_TYPE_VIS __shared_count
162162
explicit __shared_count(long __refs = 0) _NOEXCEPT
163163
: __shared_owners_(__refs) {}
164164

165-
#if defined(_LIBCPP_BUILDING_LIBRARY) && \
166-
defined(_LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS)
165+
#if defined(_LIBCPP_SHARED_PTR_DEFINE_LEGACY_INLINE_FUNCTIONS)
167166
void __add_shared() noexcept;
168167
bool __release_shared() noexcept;
169168
#else
@@ -200,8 +199,7 @@ class _LIBCPP_TYPE_VIS __shared_weak_count
200199
virtual ~__shared_weak_count();
201200

202201
public:
203-
#if defined(_LIBCPP_BUILDING_LIBRARY) && \
204-
defined(_LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS)
202+
#if defined(_LIBCPP_SHARED_PTR_DEFINE_LEGACY_INLINE_FUNCTIONS)
205203
void __add_shared() noexcept;
206204
void __add_weak() noexcept;
207205
void __release_shared() noexcept;

libcxx/include/system_error

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,7 @@ class _LIBCPP_TYPE_VIS error_category
202202
public:
203203
virtual ~error_category() _NOEXCEPT;
204204

205-
#if defined(_LIBCPP_BUILDING_LIBRARY) && \
206-
defined(_LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS)
205+
#if defined(_LIBCPP_ERROR_CATEGORY_DEFINE_LEGACY_INLINE_FUNCTIONS)
207206
error_category() noexcept;
208207
#else
209208
_LIBCPP_INLINE_VISIBILITY

libcxx/src/memory.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9+
#include <__config>
10+
#ifdef _LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS
11+
# define _LIBCPP_SHARED_PTR_DEFINE_LEGACY_INLINE_FUNCTIONS
12+
#endif
13+
914
#include <memory>
1015

1116
#ifndef _LIBCPP_HAS_NO_THREADS
@@ -38,7 +43,7 @@ __shared_weak_count::~__shared_weak_count()
3843
{
3944
}
4045

41-
#if defined(_LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS)
46+
#if defined(_LIBCPP_SHARED_PTR_DEFINE_LEGACY_INLINE_FUNCTIONS)
4247
void
4348
__shared_count::__add_shared() noexcept
4449
{
@@ -75,7 +80,7 @@ __shared_weak_count::__release_shared() noexcept
7580
__release_weak();
7681
}
7782

78-
#endif // _LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS
83+
#endif // _LIBCPP_SHARED_PTR_DEFINE_LEGACY_INLINE_FUNCTIONS
7984

8085
void
8186
__shared_weak_count::__release_weak() noexcept

libcxx/src/system_error.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,12 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#include <__assert>
109
#include <__config>
10+
#ifdef _LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS
11+
# define _LIBCPP_ERROR_CATEGORY_DEFINE_LEGACY_INLINE_FUNCTIONS
12+
#endif
13+
14+
#include <__assert>
1115
#include <cerrno>
1216
#include <cstdio>
1317
#include <cstdlib>
@@ -26,7 +30,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2630

2731
// class error_category
2832

29-
#if defined(_LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS)
33+
#if defined(_LIBCPP_ERROR_CATEGORY_DEFINE_LEGACY_INLINE_FUNCTIONS)
3034
error_category::error_category() noexcept
3135
{
3236
}

0 commit comments

Comments
 (0)