Eric Fiselier | d720d1f | 2015-08-22 19:40:49 +0000 | [diff] [blame] | 1 | .. _index: |
| 2 | |
| 3 | ============================= |
| 4 | "libc++" C++ Standard Library |
| 5 | ============================= |
| 6 | |
| 7 | Overview |
| 8 | ======== |
| 9 | |
Mehdi Amini | 032f15a | 2017-01-25 17:00:30 +0000 | [diff] [blame] | 10 | libc++ is a new implementation of the C++ standard library, targeting C++11 and |
| 11 | above. |
Eric Fiselier | d720d1f | 2015-08-22 19:40:49 +0000 | [diff] [blame] | 12 | |
| 13 | * Features and Goals |
| 14 | |
| 15 | * Correctness as defined by the C++11 standard. |
| 16 | * Fast execution. |
| 17 | * Minimal memory use. |
| 18 | * Fast compile times. |
| 19 | * ABI compatibility with gcc's libstdc++ for some low-level features |
| 20 | such as exception objects, rtti and memory allocation. |
| 21 | * Extensive unit tests. |
| 22 | |
| 23 | * Design and Implementation: |
| 24 | |
| 25 | * Extensive unit tests |
| 26 | * Internal linker model can be dumped/read to textual format |
| 27 | * Additional linking features can be plugged in as "passes" |
| 28 | * OS specific and CPU specific code factored out |
| 29 | |
| 30 | |
| 31 | Getting Started with libc++ |
| 32 | --------------------------- |
| 33 | |
| 34 | .. toctree:: |
| 35 | :maxdepth: 2 |
| 36 | |
Louis Dionne | 743b1c0 | 2018-09-06 15:05:43 +0000 | [diff] [blame] | 37 | ReleaseNotes |
Eric Fiselier | d720d1f | 2015-08-22 19:40:49 +0000 | [diff] [blame] | 38 | UsingLibcxx |
| 39 | BuildingLibcxx |
| 40 | TestingLibcxx |
Marek Kurdej | d5bc4d9 | 2020-12-02 08:52:35 +0100 | [diff] [blame] | 41 | Contributing |
Marek Kurdej | 906116e | 2020-11-26 09:03:50 +0100 | [diff] [blame] | 42 | Cxx1yStatus |
| 43 | Cxx1zStatus |
| 44 | Cxx2aStatus |
Marek Kurdej | 176140d | 2020-12-03 09:17:14 +0100 | [diff] [blame] | 45 | Cxx2bStatus |
Zoe Carver | a720e2c | 2021-04-13 17:56:55 -0700 | [diff] [blame] | 46 | RangesStatus |
Mark de Wever | fffa08e | 2021-04-17 18:49:37 +0200 | [diff] [blame] | 47 | FormatStatus |
Eric Fiselier | d720d1f | 2015-08-22 19:40:49 +0000 | [diff] [blame] | 48 | |
Eric Fiselier | a28db90 | 2015-09-05 05:29:23 +0000 | [diff] [blame] | 49 | |
Eric Fiselier | 4e86049 | 2019-01-16 01:37:43 +0000 | [diff] [blame] | 50 | .. toctree:: |
| 51 | :hidden: |
| 52 | |
Louis Dionne | f34ac04 | 2020-11-19 14:22:28 -0500 | [diff] [blame] | 53 | AddingNewCIJobs |
Eric Fiselier | 4e86049 | 2019-01-16 01:37:43 +0000 | [diff] [blame] | 54 | FeatureTestMacroTable |
| 55 | |
Louis Dionne | f34ac04 | 2020-11-19 14:22:28 -0500 | [diff] [blame] | 56 | |
Eric Fiselier | d720d1f | 2015-08-22 19:40:49 +0000 | [diff] [blame] | 57 | Current Status |
| 58 | -------------- |
| 59 | |
| 60 | After its initial introduction, many people have asked "why start a new |
| 61 | library instead of contributing to an existing library?" (like Apache's |
| 62 | libstdcxx, GNU's libstdc++, STLport, etc). There are many contributing |
| 63 | reasons, but some of the major ones are: |
| 64 | |
Eric Fiselier | 98596ba | 2015-09-05 06:50:03 +0000 | [diff] [blame] | 65 | * From years of experience (including having implemented the standard |
| 66 | library before), we've learned many things about implementing |
| 67 | the standard containers which require ABI breakage and fundamental changes |
| 68 | to how they are implemented. For example, it is generally accepted that |
| 69 | building std::string using the "short string optimization" instead of |
| 70 | using Copy On Write (COW) is a superior approach for multicore |
| 71 | machines (particularly in C++11, which has rvalue references). Breaking |
| 72 | ABI compatibility with old versions of the library was |
| 73 | determined to be critical to achieving the performance goals of |
| 74 | libc++. |
Eric Fiselier | d720d1f | 2015-08-22 19:40:49 +0000 | [diff] [blame] | 75 | |
Eric Fiselier | 98596ba | 2015-09-05 06:50:03 +0000 | [diff] [blame] | 76 | * Mainline libstdc++ has switched to GPL3, a license which the developers |
| 77 | of libc++ cannot use. libstdc++ 4.2 (the last GPL2 version) could be |
| 78 | independently extended to support C++11, but this would be a fork of the |
| 79 | codebase (which is often seen as worse for a project than starting a new |
| 80 | independent one). Another problem with libstdc++ is that it is tightly |
| 81 | integrated with G++ development, tending to be tied fairly closely to the |
| 82 | matching version of G++. |
Eric Fiselier | d720d1f | 2015-08-22 19:40:49 +0000 | [diff] [blame] | 83 | |
Eric Fiselier | 98596ba | 2015-09-05 06:50:03 +0000 | [diff] [blame] | 84 | * STLport and the Apache libstdcxx library are two other popular |
| 85 | candidates, but both lack C++11 support. Our experience (and the |
| 86 | experience of libstdc++ developers) is that adding support for C++11 (in |
| 87 | particular rvalue references and move-only types) requires changes to |
| 88 | almost every class and function, essentially amounting to a rewrite. |
| 89 | Faced with a rewrite, we decided to start from scratch and evaluate every |
| 90 | design decision from first principles based on experience. |
| 91 | Further, both projects are apparently abandoned: STLport 5.2.1 was |
| 92 | released in Oct'08, and STDCXX 4.2.1 in May'08. |
Eric Fiselier | d720d1f | 2015-08-22 19:40:49 +0000 | [diff] [blame] | 93 | |
| 94 | Platform and Compiler Support |
| 95 | ----------------------------- |
| 96 | |
Louis Dionne | 678dc85 | 2020-02-12 17:01:19 +0100 | [diff] [blame] | 97 | For using the libc++ headers |
| 98 | ############################ |
| 99 | The libc++ headers are known to work on the following platforms, using GCC and |
| 100 | Clang. Note that functionality provided by ``<atomic>`` is only functional with |
| 101 | Clang and GCC. |
Eric Fiselier | d720d1f | 2015-08-22 19:40:49 +0000 | [diff] [blame] | 102 | |
Louis Dionne | 678dc85 | 2020-02-12 17:01:19 +0100 | [diff] [blame] | 103 | ============ ==================== ============ |
| 104 | OS Arch Compilers |
| 105 | ============ ==================== ============ |
| 106 | macOS 10.9+ i386, x86_64 Clang, GCC |
| 107 | FreeBSD 10+ i386, x86_64, ARM Clang, GCC |
| 108 | Linux i386, x86_64 Clang, GCC |
| 109 | ============ ==================== ============ |
Eric Fiselier | d720d1f | 2015-08-22 19:40:49 +0000 | [diff] [blame] | 110 | |
Louis Dionne | 678dc85 | 2020-02-12 17:01:19 +0100 | [diff] [blame] | 111 | The following minimum compiler versions are required: |
Eric Fiselier | d720d1f | 2015-08-22 19:40:49 +0000 | [diff] [blame] | 112 | |
Louis Dionne | 60481d6 | 2020-03-23 11:37:40 -0400 | [diff] [blame] | 113 | * Clang 4.0 and above |
Eric Fiselier | 75c0556 | 2019-06-13 00:37:25 +0000 | [diff] [blame] | 114 | * GCC 5.0 and above. |
Eric Fiselier | d720d1f | 2015-08-22 19:40:49 +0000 | [diff] [blame] | 115 | |
Louis Dionne | 678dc85 | 2020-02-12 17:01:19 +0100 | [diff] [blame] | 116 | The C++03 dialect is only supported with Clang. |
| 117 | |
| 118 | For building the libc++ library |
| 119 | ############################### |
| 120 | Building the libc++ library (static or shared) requires some features from |
| 121 | the operating system. As such, it has its own set of (slightly different) |
| 122 | system requirements. |
| 123 | |
| 124 | ============ ==================== ============ ======================== |
| 125 | OS Arch Compilers ABI Library |
| 126 | ============ ==================== ============ ======================== |
| 127 | macOS 10.12+ i386, x86_64 Clang, GCC libc++abi |
| 128 | FreeBSD 10+ i386, x86_64, ARM Clang, GCC libcxxrt, libc++abi |
| 129 | Linux i386, x86_64 Clang, GCC libc++abi |
| 130 | ============ ==================== ============ ======================== |
| 131 | |
| 132 | The following minimum compiler versions are required: |
| 133 | |
| 134 | * Clang 4.0 and above |
| 135 | * GCC 5.0 and above. |
| 136 | |
Eric Fiselier | d720d1f | 2015-08-22 19:40:49 +0000 | [diff] [blame] | 137 | |
| 138 | C++ Dialect Support |
| 139 | --------------------- |
| 140 | |
| 141 | * C++11 - Complete |
Marek Kurdej | 906116e | 2020-11-26 09:03:50 +0100 | [diff] [blame] | 142 | * :ref:`C++14 - Complete <cxx1y-status>` |
| 143 | * :ref:`C++17 - In Progress <cxx1z-status>` |
| 144 | * :ref:`C++20 - In Progress <cxx2a-status>` |
Mark de Wever | 8b38f96 | 2021-01-22 19:03:14 +0100 | [diff] [blame] | 145 | * :ref:`C++2b - In Progress <cxx2b-status>` |
Eric Fiselier | 4f9062a | 2015-09-06 23:09:54 +0000 | [diff] [blame] | 146 | * `Post C++14 Technical Specifications - In Progress <http://libcxx.llvm.org/ts1z_status.html>`__ |
Eric Fiselier | 4e86049 | 2019-01-16 01:37:43 +0000 | [diff] [blame] | 147 | * :ref:`C++ Feature Test Macro Status <feature-status>` |
Eric Fiselier | d720d1f | 2015-08-22 19:40:49 +0000 | [diff] [blame] | 148 | |
| 149 | Notes and Known Issues |
| 150 | ---------------------- |
| 151 | |
| 152 | This list contains known issues with libc++ |
| 153 | |
| 154 | * Building libc++ with ``-fno-rtti`` is not supported. However |
| 155 | linking against it with ``-fno-rtti`` is supported. |
Eric Fiselier | d720d1f | 2015-08-22 19:40:49 +0000 | [diff] [blame] | 156 | |
| 157 | |
Eric Fiselier | a72fd80 | 2015-09-06 23:22:02 +0000 | [diff] [blame] | 158 | A full list of currently open libc++ bugs can be `found here`__. |
Eric Fiselier | d720d1f | 2015-08-22 19:40:49 +0000 | [diff] [blame] | 159 | |
Eric Fiselier | 5d60401 | 2017-02-17 08:37:03 +0000 | [diff] [blame] | 160 | .. __: https://bugs.llvm.org/buglist.cgi?component=All%20Bugs&product=libc%2B%2B&query_format=advanced&resolution=---&order=changeddate%20DESC%2Cassigned_to%20DESC%2Cbug_status%2Cpriority%2Cbug_id&list_id=74184 |
Eric Fiselier | d720d1f | 2015-08-22 19:40:49 +0000 | [diff] [blame] | 161 | |
| 162 | Design Documents |
| 163 | ---------------- |
| 164 | |
Eric Fiselier | 5cf9a82 | 2015-10-13 22:12:02 +0000 | [diff] [blame] | 165 | .. toctree:: |
| 166 | :maxdepth: 1 |
| 167 | |
Eric Fiselier | 1a1c74b | 2015-10-14 00:22:05 +0000 | [diff] [blame] | 168 | DesignDocs/ABIVersioning |
Louis Dionne | 0df08db | 2021-06-08 11:15:27 -0400 | [diff] [blame] | 169 | DesignDocs/AtomicDesign |
| 170 | DesignDocs/CapturingConfigInfo |
| 171 | DesignDocs/DebugMode |
Louis Dionne | 3767713 | 2019-06-11 14:48:40 +0000 | [diff] [blame] | 172 | DesignDocs/ExperimentalFeatures |
Eric Fiselier | f995453 | 2019-06-11 22:53:49 +0000 | [diff] [blame] | 173 | DesignDocs/ExtendedCXX03Support |
Louis Dionne | 0df08db | 2021-06-08 11:15:27 -0400 | [diff] [blame] | 174 | DesignDocs/FeatureTestMacros |
| 175 | DesignDocs/FileTimeType |
zoecarver | 08de816 | 2021-02-05 11:24:38 -0800 | [diff] [blame] | 176 | DesignDocs/NoexceptPolicy |
Louis Dionne | 0df08db | 2021-06-08 11:15:27 -0400 | [diff] [blame] | 177 | DesignDocs/ThreadingSupportAPI |
| 178 | DesignDocs/UniquePtrTrivialAbi |
| 179 | DesignDocs/VisibilityMacros |
Eric Fiselier | 5cf9a82 | 2015-10-13 22:12:02 +0000 | [diff] [blame] | 180 | |
Eric Fiselier | 44451cb | 2015-10-15 03:27:02 +0000 | [diff] [blame] | 181 | Build Bots and Test Coverage |
| 182 | ---------------------------- |
Eric Fiselier | 98596ba | 2015-09-05 06:50:03 +0000 | [diff] [blame] | 183 | |
Louis Dionne | f34ac04 | 2020-11-19 14:22:28 -0500 | [diff] [blame] | 184 | * `Buildkite CI pipeline <https://buildkite.com/llvm-project/libcxx-ci>`_ |
| 185 | * `LLVM Buildbot Builders <http://lab.llvm.org:8011>`_ |
| 186 | * :ref:`Adding New CI Jobs <AddingNewCIJobs>` |
Eric Fiselier | 98596ba | 2015-09-05 06:50:03 +0000 | [diff] [blame] | 187 | |
Eric Fiselier | d720d1f | 2015-08-22 19:40:49 +0000 | [diff] [blame] | 188 | Getting Involved |
| 189 | ================ |
| 190 | |
Sylvestre Ledru | b09c938 | 2020-03-22 22:42:03 +0100 | [diff] [blame] | 191 | First please review our `Developer's Policy <https://llvm.org/docs/DeveloperPolicy.html>`__ |
| 192 | and `Getting started with LLVM <https://llvm.org/docs/GettingStarted.html>`__. |
Eric Fiselier | d720d1f | 2015-08-22 19:40:49 +0000 | [diff] [blame] | 193 | |
| 194 | **Bug Reports** |
| 195 | |
| 196 | If you think you've found a bug in libc++, please report it using |
Eric Fiselier | 98596ba | 2015-09-05 06:50:03 +0000 | [diff] [blame] | 197 | the `LLVM Bugzilla`_. If you're not sure, you |
Eric Fiselier | fa90b7f | 2018-09-22 19:49:29 +0000 | [diff] [blame] | 198 | can post a message to the `libcxx-dev mailing list`_ or on IRC. |
Eric Fiselier | d720d1f | 2015-08-22 19:40:49 +0000 | [diff] [blame] | 199 | |
| 200 | **Patches** |
| 201 | |
| 202 | If you want to contribute a patch to libc++, the best place for that is |
Sylvestre Ledru | b09c938 | 2020-03-22 22:42:03 +0100 | [diff] [blame] | 203 | `Phabricator <https://llvm.org/docs/Phabricator.html>`_. Please add `libcxx-commits` as a subscriber. |
Eric Fiselier | fa90b7f | 2018-09-22 19:49:29 +0000 | [diff] [blame] | 204 | Also make sure you are subscribed to the `libcxx-commits mailing list <http://lists.llvm.org/mailman/listinfo/libcxx-commits>`_. |
Eric Fiselier | d720d1f | 2015-08-22 19:40:49 +0000 | [diff] [blame] | 205 | |
| 206 | **Discussion and Questions** |
| 207 | |
Eric Fiselier | 4f9062a | 2015-09-06 23:09:54 +0000 | [diff] [blame] | 208 | Send discussions and questions to the |
Eric Fiselier | fa90b7f | 2018-09-22 19:49:29 +0000 | [diff] [blame] | 209 | `libcxx-dev mailing list <http://lists.llvm.org/mailman/listinfo/libcxx-dev>`_. |
Eric Fiselier | d720d1f | 2015-08-22 19:40:49 +0000 | [diff] [blame] | 210 | |
Eric Fiselier | d720d1f | 2015-08-22 19:40:49 +0000 | [diff] [blame] | 211 | |
Eric Fiselier | d720d1f | 2015-08-22 19:40:49 +0000 | [diff] [blame] | 212 | |
Eric Fiselier | 98596ba | 2015-09-05 06:50:03 +0000 | [diff] [blame] | 213 | Quick Links |
| 214 | =========== |
Sylvestre Ledru | b09c938 | 2020-03-22 22:42:03 +0100 | [diff] [blame] | 215 | * `LLVM Homepage <https://llvm.org/>`_ |
Eric Fiselier | 4f9062a | 2015-09-06 23:09:54 +0000 | [diff] [blame] | 216 | * `libc++abi Homepage <http://libcxxabi.llvm.org/>`_ |
Eric Fiselier | 5d60401 | 2017-02-17 08:37:03 +0000 | [diff] [blame] | 217 | * `LLVM Bugzilla <https://bugs.llvm.org/>`_ |
Eric Fiselier | fa90b7f | 2018-09-22 19:49:29 +0000 | [diff] [blame] | 218 | * `libcxx-commits Mailing List`_ |
| 219 | * `libcxx-dev Mailing List`_ |
xgupta | 482d587 | 2021-02-01 12:54:21 +0530 | [diff] [blame] | 220 | * `Browse libc++ Sources <https://github.com/llvm/llvm-project/tree/main/libcxx/>`_ |