blob: 8dc18565405c08e3ab957407695719c8a34e9a6e [file] [log] [blame]
Marek Kurdej1c656e92020-12-02 08:52:35 +01001.. _ContributingToLibcxx:
2
3======================
4Contributing to libc++
5======================
6
Louis Dionne1f8e2862021-07-15 10:19:39 -04007This file contains notes about various tasks and processes specific to contributing
8to libc++. If this is your first time contributing, please also read `this document
9<https://www.llvm.org/docs/Contributing.html>`__ on general rules for contributing to LLVM.
Marek Kurdej1c656e92020-12-02 08:52:35 +010010
Louis Dionne1f8e2862021-07-15 10:19:39 -040011For libc++, please make sure you follow `these instructions <https://www.llvm.org/docs/Phabricator.html#requesting-a-review-via-the-command-line>`_
12for submitting a code review from the command-line using ``arc``, since we have some
13automation (e.g. CI) that depends on the review being submitted that way.
Marek Kurdej1c656e92020-12-02 08:52:35 +010014
Louis Dionneb0345932021-09-22 11:13:47 -040015If you plan on contributing to libc++, it can be useful to join the ``#libcxx`` channel
16on `LLVM's Discord server <https://discord.gg/jzUbyP26tQ>`__.
17
Louis Dionned86e16e2021-01-08 17:23:16 -050018Looking for pre-existing reviews
19================================
20
21Before you start working on any feature, please take a look at the open reviews
22to avoid duplicating someone else's work. You can do that by going to the website
23where code reviews are held, `Differential <https://reviews.llvm.org/differential>`__,
24and clicking on ``Libc++ Open Reviews`` in the sidebar to the left. If you see
25that your feature is already being worked on, please consider chiming in instead
26of duplicating work!
27
Louis Dionne1f8e2862021-07-15 10:19:39 -040028Pre-commit check list
29=====================
30
31Before committing or creating a review, please go through this check-list to make
32sure you don't forget anything:
33
34- Do you have tests for every public class and/or function you're adding or modifying?
35- Did you update the synopsis of the relevant headers?
36- Did you update the relevant files to track implementation status (in ``docs/Status/``)?
Louis Dionned153e7d2021-07-19 12:34:56 -040037- Did you mark all functions and type declarations with the :ref:`proper visibility macro <visibility-macros>`?
Louis Dionne1f8e2862021-07-15 10:19:39 -040038- If you added a header:
39
40 - Did you add it to ``include/module.modulemap``?
41 - Did you add it to ``include/CMakeLists.txt``?
42 - If it's a public header, did you add a test under ``test/libcxx`` that the new header defines ``_LIBCPP_VERSION``? See ``test/libcxx/algorithms/version.pass.cpp`` for an example. NOTE: This should be automated.
43 - If it's a public header, did you update ``utils/generate_header_inclusion_tests.py``?
44
45- Did you add the relevant feature test macro(s) for your feature? Did you update the ``generate_feature_test_macro_components.py`` script with it?
46- Did you run the ``libcxx-generate-files`` target and verify its output?
47
48Post-release check list
49=======================
Marek Kurdej1c656e92020-12-02 08:52:35 +010050
51After branching for an LLVM release:
52
531. Update ``_LIBCPP_VERSION`` in ``include/__config``
542. Update the ``include/__libcpp_version`` file
553. Update the version number in ``docs/conf.py``
56
Marek Kurdej1c656e92020-12-02 08:52:35 +010057Exporting new symbols from the library
58======================================
59
Mark de Wever48fa06f2021-03-24 19:54:40 +010060When exporting new symbols from libc++, you must update the ABI lists located in ``lib/abi``.
Marek Kurdej1c656e92020-12-02 08:52:35 +010061To test whether the lists are up-to-date, please run the target ``check-cxx-abilist``.
62To regenerate the lists, use the target ``generate-cxx-abilist``.
Mark de Wever48fa06f2021-03-24 19:54:40 +010063The ABI lists must be updated for all supported platforms; currently Linux and
64Apple. If you don't have access to one of these platforms, you can download an
65updated list from the failed build at
66`Buildkite <https://buildkite.com/llvm-project/libcxx-ci>`__.
67Look for the failed build and select the ``artifacts`` tab. There, download the
68abilist for the platform, e.g.:
69
70* C++20 for the Linux platform.
71* MacOS C++20 for the Apple platform.
Mark de Wever6f85d9e2021-08-05 21:34:52 +020072
73Working on large features
74=========================
75
76Libc++ makes no guarantees about the implementation status or the ABI stability
Mark de Weverd2bc4fa2021-08-11 17:33:54 +020077of features that have not yet been ratified in the C++ Standard. After the C++
Mark de Wever6f85d9e2021-08-05 21:34:52 +020078Standard is ratified libc++ promises a conforming and ABI-stable
79implementation. When working on a large new feature in the ratified version of
80the C++ Standard that can't be finished before the next release branch is
81created, we can't honor this promise. Another reason for not being able to
82promise ABI stability happens when the C++ Standard committee retroactively
83accepts ABI breaking papers as defect reports against the ratified C++
84Standard.
85
86When working on these features it should be possible for libc++ vendors to
87disable these incomplete features, so they can promise ABI stability to their
88customers. This is done by the CMake option
89``LIBCXX_ENABLE_INCOMPLETE_FEATURES``. When start working on a large feature
90the following steps are required to guard the new library with the CMake
91option.
92
Mark de Weverd2bc4fa2021-08-11 17:33:54 +020093* ``libcxx/CMakeLists.txt``: Add
Mark de Wever6f85d9e2021-08-05 21:34:52 +020094
95 .. code-block:: cmake
96
97 config_define_if_not(LIBCXX_ENABLE_INCOMPLETE_FEATURES _LIBCPP_HAS_NO_INCOMPLETE_FOO)
98
Mark de Weverd2bc4fa2021-08-11 17:33:54 +020099* ``libcxx/include/__config_site.in``: Add
Mark de Wever6f85d9e2021-08-05 21:34:52 +0200100
101 .. code-block:: c++
102
103 #cmakedefine _LIBCPP_HAS_NO_INCOMPLETE_FOO
104
Mark de Weverd2bc4fa2021-08-11 17:33:54 +0200105* ``libcxx/include/foo``: The contents of the file should be guarded in an
106 ``ifdef`` and always include ``<version>``
Mark de Wever6f85d9e2021-08-05 21:34:52 +0200107
108 .. code-block:: c++
109
110 #ifndef _LIBCPP_FOO
111 #define _LIBCPP_FOO
112
Mark de Weverd2bc4fa2021-08-11 17:33:54 +0200113 // Make sure all feature-test macros are available.
Mark de Wever6f85d9e2021-08-05 21:34:52 +0200114 #include <version>
Mark de Weverd2bc4fa2021-08-11 17:33:54 +0200115 // Enable the contents of the header only when libc++ was built with LIBCXX_ENABLE_INCOMPLETE_FEATURES.
Mark de Wever6f85d9e2021-08-05 21:34:52 +0200116 #if !defined(_LIBCPP_HAS_NO_INCOMPLETE_FOO)
117
118 ...
119
120 #endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_FO0)
121 #endif // _LIBCPP_FOO
122
Mark de Weverd2bc4fa2021-08-11 17:33:54 +0200123* ``libcxx/src/CMakeLists.txt``: When the library has a file ``foo.cpp`` it
124 should only be added when ``LIBCXX_ENABLE_INCOMPLETE_FEATURES`` is enabled
Mark de Wever6f85d9e2021-08-05 21:34:52 +0200125
126 .. code-block:: cmake
127
128 if(LIBCXX_ENABLE_INCOMPLETE_FEATURES)
129 list(APPEND LIBCXX_SOURCES
130 foo.cpp
131 )
132 endif()
133
Mark de Weverd2bc4fa2021-08-11 17:33:54 +0200134* ``libcxx/utils/generate_feature_test_macro_components.py``: Add to
135 ``lit_markup``
Mark de Wever6f85d9e2021-08-05 21:34:52 +0200136
137 .. code-block:: python
138
139 "foo": ["UNSUPPORTED: libcpp-has-no-incomplete-foo"],
140
Mark de Weverd2bc4fa2021-08-11 17:33:54 +0200141* ``libcxx/utils/generate_header_inclusion_tests.py``: Add to ``lit_markup``
Mark de Wever6f85d9e2021-08-05 21:34:52 +0200142
143 .. code-block:: python
144
145 "foo": ["UNSUPPORTED: libcpp-has-no-incomplete-foo"],
146
Mark de Weverd2bc4fa2021-08-11 17:33:54 +0200147* ``libcxx/utils/generate_header_tests.py``: Add to ``header_markup``
Mark de Wever6f85d9e2021-08-05 21:34:52 +0200148
149 .. code-block:: python
150
151 "foo": ["ifndef _LIBCPP_HAS_NO_INCOMPLETE_FOO"],
152
Mark de Weverd2bc4fa2021-08-11 17:33:54 +0200153* ``libcxx/utils/libcxx/test/features.py``: Add to ``macros``
Mark de Wever6f85d9e2021-08-05 21:34:52 +0200154
155 .. code-block:: python
156
157 '_LIBCPP_HAS_NO_INCOMPLETE_FOO': 'libcpp-has-no-incomplete-foo',
158
159* All tests that include ``<foo>`` should contain
160
161 .. code-block:: c++
162
163 // UNSUPPORTED: libcpp-has-no-incomplete-foo
164
165Once the library is complete these changes and guards should be removed.