Skip to content

Commit 817d897

Browse files
committed
[libc++] Remove _LIBCPP_ABI_UNSTABLE
Previously, _LIBCPP_ABI_UNSTABLE would be used interchangeably with _LIBCPP_ABI_VERSION >= 2. This was confusing and creating unnecessary complexity. This patch removes _LIBCPP_ABI_UNSTABLE -- instead, the LIBCXX_ABI_UNSTABLE CMake option will result in the LIBCXX_ABI_VERSION being set to '2', the current unstable ABI. As a result, in the code, we only have _LIBCPP_ABI_VERSION to check in order to query the current ABI version. As a fly-by, this also defines the ABI namespace during CMake configuration to reduce complexity in __config. I believe it was previously done this way because we used to try to use __config_site as seldom as possible. Now that we always ship a __config_site, it doesn't really matter and I think being explicit about how the library is configured in the __config_site is actually a feature. Differential Revision: https://reviews.llvm.org/D119173
1 parent 506cf6d commit 817d897

File tree

9 files changed

+29
-60
lines changed

9 files changed

+29
-60
lines changed

libcxx/CMakeLists.txt

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,17 @@ cmake_dependent_option(LIBCXX_INSTALL_EXPERIMENTAL_LIBRARY
179179
"Install libc++experimental.a" ON
180180
"LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY;LIBCXX_INSTALL_LIBRARY" OFF)
181181

182-
set(LIBCXX_ABI_VERSION "1" CACHE STRING "ABI version of libc++. Can be either 1 or 2, where 2 is currently not stable. Defaults to 1.")
183-
set(LIBCXX_ABI_NAMESPACE "" CACHE STRING "The inline ABI namespace used by libc++. It defaults to __n where `n` is the current ABI version.")
184-
option(LIBCXX_ABI_UNSTABLE "Unstable ABI of libc++." OFF)
182+
option(LIBCXX_ABI_UNSTABLE "Use the unstable ABI of libc++. This is equivalent to specifying LIBCXX_ABI_VERSION=n, where n is the not-yet-stable version." OFF)
183+
if (LIBCXX_ABI_UNSTABLE)
184+
set(abi_version "2")
185+
else()
186+
set(abi_version "1")
187+
endif()
188+
set(LIBCXX_ABI_VERSION "${abi_version}" CACHE STRING "ABI version of libc++. Can be either 1 or 2, where 2 is currently the unstable ABI. Defaults to 1 unless LIBCXX_ABI_UNSTABLE is specified, in which case this is 2.")
189+
set(LIBCXX_ABI_NAMESPACE "__${LIBCXX_ABI_VERSION}" CACHE STRING "The inline ABI namespace used by libc++. It defaults to __n where `n` is the current ABI version.")
190+
if (NOT LIBCXX_ABI_NAMESPACE MATCHES "__.*")
191+
message(FATAL_ERROR "LIBCXX_ABI_NAMESPACE must be a reserved identifier.")
192+
endif()
185193
option(LIBCXX_ABI_FORCE_ITANIUM "Ignore auto-detection and force use of the Itanium ABI.")
186194
option(LIBCXX_ABI_FORCE_MICROSOFT "Ignore auto-detection and force use of the Microsoft ABI.")
187195

@@ -858,19 +866,8 @@ function(cxx_add_windows_flags target)
858866
endfunction()
859867

860868
# Configuration file flags =====================================================
861-
if (NOT LIBCXX_ABI_VERSION EQUAL 1)
862-
config_define(${LIBCXX_ABI_VERSION} _LIBCPP_ABI_VERSION)
863-
endif()
864-
if (NOT LIBCXX_ABI_NAMESPACE STREQUAL "")
865-
if (NOT LIBCXX_ABI_NAMESPACE MATCHES "__.*")
866-
message(FATAL_ERROR "LIBCXX_ABI_NAMESPACE must be a reserved identifier.")
867-
endif()
868-
if (LIBCXX_ABI_NAMESPACE MATCHES "__[0-9]+$")
869-
message(FATAL_ERROR "LIBCXX_ABI_NAMESPACE '${LIBCXX_ABI_NAMESPACE}' is reserved for use by libc++.")
870-
endif()
871-
config_define(${LIBCXX_ABI_NAMESPACE} _LIBCPP_ABI_NAMESPACE)
872-
endif()
873-
config_define_if(LIBCXX_ABI_UNSTABLE _LIBCPP_ABI_UNSTABLE)
869+
config_define(${LIBCXX_ABI_VERSION} _LIBCPP_ABI_VERSION)
870+
config_define(${LIBCXX_ABI_NAMESPACE} _LIBCPP_ABI_NAMESPACE)
874871
config_define_if(LIBCXX_ABI_FORCE_ITANIUM _LIBCPP_ABI_FORCE_ITANIUM)
875872
config_define_if(LIBCXX_ABI_FORCE_MICROSOFT _LIBCPP_ABI_FORCE_MICROSOFT)
876873
config_define_if(LIBCXX_HIDE_FROM_ABI_PER_TU_BY_DEFAULT _LIBCPP_HIDE_FROM_ABI_PER_TU_BY_DEFAULT)

libcxx/docs/BuildingLibcxx.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -443,10 +443,10 @@ The following options allow building libc++ for a different ABI version.
443443
with other libc++ versions.
444444

445445
.. warning::
446-
When providing a custom namespace, it's the users responsibility to ensure the name won't cause
446+
When providing a custom namespace, it's the user's responsibility to ensure the name won't cause
447447
conflicts with other names defined by libc++, both now and in the future. In particular, inline
448-
namespaces of the form ``__[0-9]+`` are strictly reserved by libc++ and may not be used by users.
449-
Doing otherwise could cause conflicts and hinder libc++ ABI evolution.
448+
namespaces of the form ``__[0-9]+`` could cause conflicts with future versions of the library,
449+
and so should be avoided.
450450

451451
.. option:: LIBCXX_ABI_DEFINES:STRING
452452

libcxx/docs/ReleaseNotes.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ New Features
4141
API Changes
4242
-----------
4343

44+
- The ``_LIBCPP_ABI_UNSTABLE`` macro has been removed in favour of setting
45+
``_LIBCPP_ABI_VERSION=2``. This should not have any impact on users because
46+
they were not supposed to set ``_LIBCPP_ABI_UNSTABLE`` manually, however we
47+
still feel that it is worth mentioning in the release notes in case some users
48+
had been doing it.
49+
4450
ABI Changes
4551
-----------
4652

libcxx/include/__config

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,6 @@
2626

2727
#define _LIBCPP_VERSION 15000
2828

29-
#ifdef _LIBCPP_ABI_UNSTABLE
30-
# define _LIBCPP_ABI_VERSION 2
31-
#endif
32-
33-
#ifndef _LIBCPP_ABI_VERSION
34-
# define _LIBCPP_ABI_VERSION 1
35-
#endif
36-
3729
#if __STDC_HOSTED__ == 0
3830
# define _LIBCPP_FREESTANDING
3931
#endif
@@ -150,13 +142,6 @@
150142
# define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION
151143
#endif
152144

153-
#define _LIBCPP_CONCAT1(_LIBCPP_X,_LIBCPP_Y) _LIBCPP_X##_LIBCPP_Y
154-
#define _LIBCPP_CONCAT(_LIBCPP_X,_LIBCPP_Y) _LIBCPP_CONCAT1(_LIBCPP_X,_LIBCPP_Y)
155-
156-
#ifndef _LIBCPP_ABI_NAMESPACE
157-
# define _LIBCPP_ABI_NAMESPACE _LIBCPP_CONCAT(__,_LIBCPP_ABI_VERSION)
158-
#endif
159-
160145
#if __cplusplus < 201103L
161146
#define _LIBCPP_CXX03_LANG
162147
#endif

libcxx/include/__config_site.in

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#define _LIBCPP_CONFIG_SITE
1111

1212
#cmakedefine _LIBCPP_ABI_VERSION @_LIBCPP_ABI_VERSION@
13-
#cmakedefine _LIBCPP_ABI_UNSTABLE
13+
#cmakedefine _LIBCPP_ABI_NAMESPACE @_LIBCPP_ABI_NAMESPACE@
1414
#cmakedefine _LIBCPP_ABI_FORCE_ITANIUM
1515
#cmakedefine _LIBCPP_ABI_FORCE_MICROSOFT
1616
#cmakedefine _LIBCPP_HIDE_FROM_ABI_PER_TU_BY_DEFAULT
@@ -25,7 +25,6 @@
2525
#cmakedefine _LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS
2626
#cmakedefine _LIBCPP_NO_VCRUNTIME
2727
#cmakedefine _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION @_LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION@
28-
#cmakedefine _LIBCPP_ABI_NAMESPACE @_LIBCPP_ABI_NAMESPACE@
2928
#cmakedefine _LIBCPP_HAS_NO_FILESYSTEM_LIBRARY
3029
#cmakedefine _LIBCPP_HAS_PARALLEL_ALGORITHMS
3130
#cmakedefine _LIBCPP_HAS_NO_RANDOM_DEVICE

libcxx/test/libcxx/utilities/utility/pairs/pairs.pair/non_trivial_copy_move_ABI.pass.cpp

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,9 @@
1414

1515
// template <class T1, class T2> struct pair
1616

17-
// Test that we properly provide the trivial copy operations by default.
18-
19-
// FreeBSD provides the old ABI. This test checks the new ABI so we need
20-
// to manually turn it on.
21-
#undef _LIBCPP_ABI_UNSTABLE
22-
#undef _LIBCPP_ABI_VERSION
23-
#define _LIBCPP_ABI_VERSION 1
24-
#define _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR
17+
// Test that we provide the non-trivial copy operations when _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR
18+
// is specified.
19+
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR
2520

2621
#include <utility>
2722
#include <type_traits>
@@ -31,10 +26,6 @@
3126

3227
#include "test_macros.h"
3328

34-
#if !defined(_LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR)
35-
#error trivial ctor ABI macro defined
36-
#endif
37-
3829
template <class T>
3930
struct HasNonTrivialABI : std::integral_constant<bool,
4031
!std::is_trivially_destructible<T>::value

libcxx/test/libcxx/utilities/utility/pairs/pairs.pair/trivial_copy_move_ABI.pass.cpp

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,8 @@
1212

1313
// Test that we properly provide the trivial copy operations by default.
1414

15-
// FreeBSD provides the old ABI. This test checks the new ABI so we need
16-
// to manually turn it on.
17-
#if defined(__FreeBSD__)
18-
#define _LIBCPP_ABI_UNSTABLE
19-
#endif
15+
// FreeBSD still provides the old ABI for std::pair.
16+
// XFAIL: freebsd
2017

2118
#include <utility>
2219
#include <type_traits>
@@ -26,10 +23,6 @@
2623

2724
#include "test_macros.h"
2825

29-
#if defined(_LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR)
30-
#error Non-trivial ctor ABI macro defined
31-
#endif
32-
3326
template <class T>
3427
struct HasTrivialABI : std::integral_constant<bool,
3528
std::is_trivially_destructible<T>::value

libcxx/utils/gdb/libcxx/printers.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
#===----------------------------------------------------------------------===##
88
"""GDB pretty-printers for libc++.
99
10-
These should work for objects compiled when _LIBCPP_ABI_UNSTABLE is defined
11-
and when it is undefined.
10+
These should work for objects compiled with either the stable ABI or the unstable ABI.
1211
"""
1312

1413
from __future__ import print_function

libcxx/utils/libcxx/test/features.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@
119119
'_LIBCPP_HAS_THREAD_API_PTHREAD': 'libcpp-has-thread-api-pthread',
120120
'_LIBCPP_NO_VCRUNTIME': 'libcpp-no-vcruntime',
121121
'_LIBCPP_ABI_VERSION': 'libcpp-abi-version',
122-
'_LIBCPP_ABI_UNSTABLE': 'libcpp-abi-unstable',
123122
'_LIBCPP_HAS_NO_FILESYSTEM_LIBRARY': 'libcpp-has-no-filesystem-library',
124123
'_LIBCPP_HAS_NO_RANDOM_DEVICE': 'libcpp-has-no-random-device',
125124
'_LIBCPP_HAS_NO_LOCALIZATION': 'libcpp-has-no-localization',

0 commit comments

Comments
 (0)