blob: 8d645426138a2507d91edeebf80447e1e6151ce2 [file] [log] [blame]
Hans Wennborg003a9982019-07-18 11:51:05 +00001=========================================
Tom Stellardce41e662021-07-27 21:51:07 -07002Libc++ 14.0.0 (In-Progress) Release Notes
Hans Wennborg003a9982019-07-18 11:51:05 +00003=========================================
Louis Dionne42222072018-09-06 14:46:22 +00004
5.. contents::
6 :local:
7 :depth: 2
8
Hans Wennborg3329a842018-09-10 08:57:12 +00009Written by the `Libc++ Team <https://libcxx.llvm.org>`_
Louis Dionne42222072018-09-06 14:46:22 +000010
11.. warning::
12
Tom Stellardce41e662021-07-27 21:51:07 -070013 These are in-progress notes for the upcoming libc++ 14 release.
Louis Dionne42222072018-09-06 14:46:22 +000014 Release notes for previous releases can be found on
Hans Wennborg3329a842018-09-10 08:57:12 +000015 `the Download Page <https://releases.llvm.org/download.html>`_.
Louis Dionne42222072018-09-06 14:46:22 +000016
17Introduction
18============
19
20This document contains the release notes for the libc++ C++ Standard Library,
Tom Stellardce41e662021-07-27 21:51:07 -070021part of the LLVM Compiler Infrastructure, release 14.0.0. Here we describe the
Louis Dionne42222072018-09-06 14:46:22 +000022status of libc++ in some detail, including major improvements from the previous
23release and new feature work. For the general LLVM release notes, see `the LLVM
Hans Wennborg3329a842018-09-10 08:57:12 +000024documentation <https://llvm.org/docs/ReleaseNotes.html>`_. All LLVM releases may
25be downloaded from the `LLVM releases web site <https://llvm.org/releases/>`_.
Louis Dionne42222072018-09-06 14:46:22 +000026
27For more information about libc++, please see the `Libc++ Web Site
Hans Wennborg3329a842018-09-10 08:57:12 +000028<https://libcxx.llvm.org>`_ or the `LLVM Web Site <https://llvm.org>`_.
Louis Dionne42222072018-09-06 14:46:22 +000029
Hans Wennborgfc14f4e2020-01-15 10:02:56 +010030Note that if you are reading this file from a Git checkout or the
Louis Dionne42222072018-09-06 14:46:22 +000031main Libc++ web page, this document applies to the *next* release, not
32the current one. To see the release notes for a specific release, please
Hans Wennborg3329a842018-09-10 08:57:12 +000033see the `releases page <https://llvm.org/releases/>`_.
Louis Dionne42222072018-09-06 14:46:22 +000034
Tom Stellardce41e662021-07-27 21:51:07 -070035What's New in Libc++ 14.0.0?
Hans Wennborg003a9982019-07-18 11:51:05 +000036============================
Louis Dionne42222072018-09-06 14:46:22 +000037
38New Features
39------------
40
Mark de Wever9eccfe22021-12-18 15:03:26 +010041- There's support for the C++20 header ``<format>``. Some parts are still
42 missing, most notably the compile-time format string validation. Some
43 functions are known to be inefficient, both in memory usage and performance.
44 The implementation isn't API- or ABI-stable and therefore considered
45 experimental. (Some not-yet-implemented papers require an API-break.)
46 Vendors can still disable this header by turning the CMake option
47 `LIBCXX_ENABLE_INCOMPLETE_FEATURES` off.
Louis Dionne14918c82021-10-18 13:58:31 -040048
Mark de Weverebbd3b62021-05-25 20:11:08 +020049- There's a new CMake option ``LIBCXX_ENABLE_UNICODE`` to disable Unicode
50 support in the ``<format>`` header. This only affects the estimation of the
51 output width of the format functions.
Raul Tambreafcedea2020-06-19 12:43:33 +053052
Louis Dionne89258142021-08-23 15:32:36 -040053- Support for building libc++ on top of a C Standard Library that does not support ``wchar_t`` was
54 added. This is useful for building libc++ in an embedded setting, and it adds itself to the various
55 freestanding-friendly options provided by libc++.
Sylvestre Ledrub6e1b312021-10-04 11:06:45 +020056
Mark de Wever0d008be2022-01-22 12:34:44 +010057- Defining ``_LIBCPP_DEBUG`` to ``1`` enables the randomization of unspecified
58 behavior in standard algorithms (e.g. the ordering of equal elements in ``std::sort``, or
59 the ordering of both sides of the partition in ``std::nth_element``).
Danila Kutenina9cbea12021-11-16 15:48:59 -050060
Mark de Weverfa36ec72021-02-09 17:52:41 +010061- Floating-point support for ``std::to_chars`` support has been added.
Stephan T. Lavavejb15d54a2021-12-13 16:08:18 -080062 Thanks to Stephan T. Lavavej and Microsoft for providing their implementation
Mark de Weverfa36ec72021-02-09 17:52:41 +010063 to libc++.
64
Mark de Wever0d008be2022-01-22 12:34:44 +010065- The C++20 ``<coroutine>`` implementation has been completed.
66
67- More C++20 features have been implemented. :doc:`Status/Cxx20` has the full
68 overview of libc++'s C++20 implementation status.
69
70- More C++2b features have been implemented. :doc:`Status/Cxx2b` has the full
71 overview of libc++'s C++2b implementation status.
72
Louis Dionne14918c82021-10-18 13:58:31 -040073API Changes
74-----------
Mark de Wever494905b2021-06-09 20:26:34 +020075
76- The functions ``std::atomic<T*>::fetch_(add|sub)`` and
77 ``std::atomic_fetch_(add|sub)`` no longer accept a function pointer. While
78 this is technically an API break, the invalid syntax isn't supported by
Stephan T. Lavavejb15d54a2021-12-13 16:08:18 -080079 libstdc++ and MSVC STL. See https://godbolt.org/z/49fvzz98d.
Mark de Wever494905b2021-06-09 20:26:34 +020080
81- The call of the functions ``std::atomic_(add|sub)(std::atomic<T*>*, ...)``
82 with the explicit template argument ``T`` are now ill-formed. While this is
Stephan T. Lavavejb15d54a2021-12-13 16:08:18 -080083 technically an API break, the invalid syntax isn't supported by libstdc++ and
Mark de Wever494905b2021-06-09 20:26:34 +020084 MSVC STL. See https://godbolt.org/z/v9959re3v.
85
86 Due to this change it's now possible to call these functions with the
87 explicit template argument ``T*``. This allows using the same syntax on the
88 major Standard library implementations.
89 See https://godbolt.org/z/oEfzPhTTb.
90
91 Calls to these functions where the template argument was deduced by the
92 compiler are unaffected by this change.
Louis Dionne076fd0c2021-10-07 16:19:11 -040093
Mikhail Maltsevd93a8772021-10-18 19:12:42 +010094- The functions ``std::allocator<T>::allocate`` and
95 ``std::experimental::pmr::polymorphic_allocator<T>::allocate`` now throw
96 an exception of type ``std::bad_array_new_length`` when the requested size
97 exceeds the maximum supported size, as required by the C++ standard.
98 Previously the type ``std::length_error`` was used.
99
Martin Storsjö5e511f22021-11-02 16:32:09 +0000100- Removed the nonstandard methods ``std::chrono::file_clock::to_time_t`` and
101 ``std::chrono::file_clock::from_time_t``; neither libstdc++ nor MSVC STL
Louis Dionneb35fab82021-11-08 15:30:32 -0500102 had such methods. Instead, in C++20, you can use ``std::chrono::file_clock::from_sys``
103 and ``std::chrono::file_clock::to_sys``, which are specified in the Standard.
104 If you are not using C++20, you should move to it.
Martin Storsjö5e511f22021-11-02 16:32:09 +0000105
Nikolas Klauser883bf172021-11-11 18:57:25 +0100106- The declarations of functions ``declare_reachable``, ``undeclare_reachable``, ``declare_no_pointers``,
107 ``undeclare_no_pointers``, and ``get_pointer_safety`` have been removed not only from C++2b but
108 from all modes. Their symbols are still provided by the dynamic library for the benefit of
109 existing compiled code. All of these functions have always behaved as no-ops.
110
Arthur O'Dwyere4d7b842022-01-01 19:39:16 -0500111- ``std::filesystem::path::iterator``, which (in our implementation) stashes
112 a ``path`` value inside itself similar to ``istream_iterator``, now sets its
113 ``reference`` type to ``path`` and its ``iterator_category`` to ``input_iterator_tag``,
114 so that it is a conforming input iterator in C++17 and a conforming
115 ``std::bidirectional_iterator`` in C++20. Before this release, it had set its
116 ``reference`` type to ``const path&`` and its ``iterator_category`` to
117 ``bidirectional_iterator_tag``, making it a non-conforming bidirectional iterator.
118 After this change, ``for`` loops of the form ``for (auto& c : path)`` must be rewritten
119 as either ``for (auto&& c : path)`` or ``for (const auto& c : path)``.
120 ``std::reverse_iterator<path::iterator>`` is no longer rejected.
121
Casey Carterde2bcc42022-01-18 22:50:15 -0800122- Removed the nonstandard default constructor from ``std::chrono::month_weekday``.
123 You must now explicitly initialize with a ``chrono::month`` and
124 ``chrono::weekday_indexed`` instead of "meh, whenever".
Arthur O'Dwyere4d7b842022-01-01 19:39:16 -0500125
Louis Dionne05b6d3e2022-01-14 12:30:22 -0500126- C++20 requires that ``std::basic_string::reserve(n)`` never reduce the capacity
127 of the string. (For that, use ``shrink_to_fit()``.) Prior to this release, libc++'s
128 ``std::basic_string::reserve(n)`` could reduce capacity in C++17 and before, but
129 not in C++20 and later. This caused ODR violations when mixing code compiled under
130 different Standard modes. After this change, libc++'s ``std::basic_string::reserve(n)``
131 never reduces capacity, even in C++17 and before.
132 C++20 deprecates the zero-argument overload of ``std::basic_string::reserve()``,
133 but specifically permits it to reduce capacity. To avoid breaking existing code
134 assuming that ``std::basic_string::reserve()`` will shrink, libc++ maintains
135 the behavior to shrink, even though that makes ``std::basic_string::reserve()`` not
136 a synonym for ``std::basic_string::reserve(0)`` in any Standard mode anymore.
137
Mark de Wever0d008be2022-01-22 12:34:44 +0100138- The ``<experimental/coroutine>`` header is deprecated, as is any
139 use of coroutines without C++20. Use C++20's ``<coroutine>`` header
140 instead. The ``<experimental/coroutine>`` header will be removed
141 in LLVM 15.
142
Nikolas Klauser46ed0bb2022-02-01 22:38:27 +0100143- ``_VSTD`` is now an alias for ``std`` instead of ``std::_LIBCPP_ABI_NAMESPACE``.
144 This is technically not a functional change, except for folks that might have been
145 using ``_VSTD`` in creative ways (which has never been officially supported).
146
Joe Loser8fcb1d92021-10-28 15:38:02 -0400147ABI Changes
148-----------
149
150- The C++17 variable templates ``is_error_code_enum_v`` and
151 ``is_error_condition_enum_v`` are now of type ``bool`` instead of ``size_t``.
152
Louis Dionne495e9ad2021-11-29 16:20:48 -0500153- The C++03 emulation type for ``std::nullptr_t`` has been removed in favor of
154 using ``decltype(nullptr)`` in all standard modes. This is an ABI break for
155 anyone compiling in C++03 mode and who has ``std::nullptr_t`` as part of their
156 ABI. However, previously, these users' ABI would be incompatible with any other
157 binary or static archive compiled with C++11 or later. If you start seeing linker
158 errors involving ``std::nullptr_t`` against previously compiled binaries, this may
159 be the cause. You can define the ``_LIBCPP_ABI_USE_CXX03_NULLPTR_EMULATION`` macro
160 to return to the previous behavior. That macro will be removed in LLVM 15. Please
Arthur O'Dwyerbf1105a2022-01-17 14:29:09 -0500161 comment `on D109459 <https://reviews.llvm.org/D109459>`_ if you are broken by this change
Louis Dionne495e9ad2021-11-29 16:20:48 -0500162 and need to define the macro.
163
Louis Dionne1eb0c9d2021-12-21 11:49:04 -0500164- On Apple platforms, ``std::random_device`` is now implemented on top of ``arc4random()``
165 instead of reading from ``/dev/urandom``. Any implementation-defined token used when
166 constructing a ``std::random_device`` will now be ignored instead of interpreted as a
167 file to read entropy from.
168
Arthur O'Dwyer4440c322021-12-28 17:51:55 -0500169- ``std::lognormal_distribution::param_type`` used to store a data member of type
170 ``std::normal_distribution``; now this member is stored in the ``lognormal_distribution``
171 class itself, and the ``param_type`` stores only the mean and standard deviation,
172 as required by the Standard. This changes ``sizeof(std::lognormal_distribution::param_type)``.
173 You can define the ``_LIBCPP_ABI_OLD_LOGNORMAL_DISTRIBUTION`` macro to return to the
174 previous behavior. That macro will be removed in LLVM 15. Please comment
Arthur O'Dwyerbf1105a2022-01-17 14:29:09 -0500175 `on PR52906 <https://llvm.org/PR52906>`_ if you are broken by this change and need to
Arthur O'Dwyer4440c322021-12-28 17:51:55 -0500176 define the macro.
177
Louis Dionne14918c82021-10-18 13:58:31 -0400178Build System Changes
179--------------------
180
181- Building the libc++ shared or static library requires a C++ 20 capable compiler.
182 Consider using a Bootstrapping build to build libc++ with a fresh Clang if you
183 can't use the system compiler to build libc++ anymore.
184
Mark de Wever0d008be2022-01-22 12:34:44 +0100185- Historically, there have been numerous ways of building libc++ and libc++abi. This has
186 led to at least 5 different ways to build the runtimes, which was impossible to
187 maintain with a good level of support. Starting with this release, libc++ and libc++abi support
Louis Dionne076fd0c2021-10-07 16:19:11 -0400188 exactly two ways of being built, which should cater to all use-cases. Furthermore,
Stephan T. Lavavejb15d54a2021-12-13 16:08:18 -0800189 these builds are as lightweight as possible and will work consistently even when targeting
Mark de Wever0d008be2022-01-22 12:34:44 +0100190 embedded platforms, which used not to be the case. :doc:`BuildingLibcxx` describes
191 those two ways of building. Please migrate over to the appropriate build instructions
Louis Dionne076fd0c2021-10-07 16:19:11 -0400192 as soon as possible.
193
194 All other ways to build are deprecated and will not be supported in the next release.
195 We understand that making these changes can be daunting. For that reason, here's a
196 summary of how to migrate from the two most common ways to build:
197
198 - If you were rooting your CMake invocation at ``<monorepo>/llvm`` and passing ``-DLLVM_ENABLE_PROJECTS=<...>``
199 (which was the previously advertised way to build the runtimes), please simply root your CMake invocation at
200 ``<monorepo>/runtimes`` and pass ``-DLLVM_ENABLE_RUNTIMES=<...>``.
201
202 - If you were doing two CMake invocations, one rooted at ``<monorepo>/libcxx`` and one rooted at
203 ``<monorepo>/libcxxabi`` (this used to be called a "Standalone build"), please move them to a
204 single invocation like so:
205
206 .. code-block:: bash
207
208 $ cmake -S <monorepo>/libcxx -B libcxx-build <LIBCXX-OPTIONS>
209 $ cmake -S <monorepo>/libcxxabi -B libcxxabi-build <LIBCXXABI-OPTIONS>
210
211 should become
212
213 .. code-block:: bash
214
215 $ cmake -S <monorepo>/runtimes -B build -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi" <LIBCXX-OPTIONS> <LIBCXXABI-OPTIONS>
Louis Dionnedcd11052021-11-23 16:34:09 -0500216
Louis Dionne68b7ec12021-12-06 13:44:15 -0500217- Support for building the runtimes using the GCC 32 bit multilib flag (``-m32``) has been removed. Support
218 for this had been flaky for a while, and we didn't know of anyone depending on this. Instead, please perform
219 a normal cross-compilation of the runtimes using the appropriate target, such as passing the following to
220 your bootstrapping build:
Louis Dionnedcd11052021-11-23 16:34:09 -0500221
Louis Dionne68b7ec12021-12-06 13:44:15 -0500222 .. code-block:: bash
Louis Dionnedcd11052021-11-23 16:34:09 -0500223
Louis Dionne68b7ec12021-12-06 13:44:15 -0500224 -DLLVM_RUNTIME_TARGETS=i386-unknown-linux
Louis Dionnecca45892021-09-22 12:09:07 -0400225
Mark de Wever0d008be2022-01-22 12:34:44 +0100226- Libc++, libc++abi, and libunwind will not be built with ``-fPIC`` by default anymore.
227 If you want to build those runtimes with position-independent code, please specify
Louis Dionnecca45892021-09-22 12:09:07 -0400228 ``-DCMAKE_POSITION_INDEPENDENT_CODE=ON`` explicitly when configuring the build, or
229 ``-DRUNTIMES_<target-name>_CMAKE_POSITION_INDEPENDENT_CODE=ON`` if using the
230 bootstrapping build.