blob: 3f9ea9c3a45118d1c28e69ee3de9b1514573b902 [file] [log] [blame]
Marek Kurdejd5bc4d92020-12-02 08:52:35 +01001.. _ContributingToLibcxx:
2
3======================
4Contributing to libc++
5======================
6
Louis Dionne8096e242021-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 Kurdejd5bc4d92020-12-02 08:52:35 +010010
Louis Dionne8096e242021-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 Kurdejd5bc4d92020-12-02 08:52:35 +010014
Louis Dionnecd770722021-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 Dionne31781652021-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 Dionne8096e242021-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 Dionnea7e94a12021-07-19 12:34:56 -040037- Did you mark all functions and type declarations with the :ref:`proper visibility macro <visibility-macros>`?
Louis Dionne8096e242021-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
Louis Dionne56d5f042022-01-26 15:23:04 -050048The review process
49==================
50
51After uploading your patch, you should see that the "libc++" review group is automatically
52added as a reviewer for your patch. Once the group is marked as having approved your patch,
53you can commit it. However, if you get an approval very quickly for a significant patch,
54please try to wait a couple of business days before committing to give the opportunity for
55other reviewers to chime in. If you need someone else to commit the patch for you, please
56mention it and provide your ``Name <email@domain>`` for us to attribute the commit properly.
57
58Note that the rule for accepting as the "libc++" review group is to wait for two members
59of the group to have approved the patch, excluding the patch author. This is not a hard
60rule -- for very simple patches, use your judgement. The `"libc++" review group <https://reviews.llvm.org/project/members/64/>`__
61consists of frequent libc++ contributors with a good understanding of the project's
62guidelines -- if you would like to be added to it, please reach out on Discord.
63
Louis Dionne8096e242021-07-15 10:19:39 -040064Post-release check list
65=======================
Marek Kurdejd5bc4d92020-12-02 08:52:35 +010066
67After branching for an LLVM release:
68
691. Update ``_LIBCPP_VERSION`` in ``include/__config``
702. Update the ``include/__libcpp_version`` file
713. Update the version number in ``docs/conf.py``
72
Marek Kurdejd5bc4d92020-12-02 08:52:35 +010073Exporting new symbols from the library
74======================================
75
Mark de Wever2bf75c02021-03-24 19:54:40 +010076When exporting new symbols from libc++, you must update the ABI lists located in ``lib/abi``.
Marek Kurdejd5bc4d92020-12-02 08:52:35 +010077To test whether the lists are up-to-date, please run the target ``check-cxx-abilist``.
78To regenerate the lists, use the target ``generate-cxx-abilist``.
Mark de Wever2bf75c02021-03-24 19:54:40 +010079The ABI lists must be updated for all supported platforms; currently Linux and
80Apple. If you don't have access to one of these platforms, you can download an
81updated list from the failed build at
82`Buildkite <https://buildkite.com/llvm-project/libcxx-ci>`__.
83Look for the failed build and select the ``artifacts`` tab. There, download the
84abilist for the platform, e.g.:
85
86* C++20 for the Linux platform.
87* MacOS C++20 for the Apple platform.
Mark de Wevercbb5fd82021-08-05 21:34:52 +020088
89Working on large features
90=========================
91
92Libc++ makes no guarantees about the implementation status or the ABI stability
Mark de Weverbe38c382021-08-11 17:33:54 +020093of features that have not yet been ratified in the C++ Standard. After the C++
Mark de Wevercbb5fd82021-08-05 21:34:52 +020094Standard is ratified libc++ promises a conforming and ABI-stable
95implementation. When working on a large new feature in the ratified version of
96the C++ Standard that can't be finished before the next release branch is
97created, we can't honor this promise. Another reason for not being able to
98promise ABI stability happens when the C++ Standard committee retroactively
99accepts ABI breaking papers as defect reports against the ratified C++
100Standard.
101
102When working on these features it should be possible for libc++ vendors to
103disable these incomplete features, so they can promise ABI stability to their
104customers. This is done by the CMake option
105``LIBCXX_ENABLE_INCOMPLETE_FEATURES``. When start working on a large feature
106the following steps are required to guard the new library with the CMake
107option.
108
Mark de Weverbe38c382021-08-11 17:33:54 +0200109* ``libcxx/CMakeLists.txt``: Add
Mark de Wevercbb5fd82021-08-05 21:34:52 +0200110
111 .. code-block:: cmake
112
113 config_define_if_not(LIBCXX_ENABLE_INCOMPLETE_FEATURES _LIBCPP_HAS_NO_INCOMPLETE_FOO)
114
Mark de Weverbe38c382021-08-11 17:33:54 +0200115* ``libcxx/include/__config_site.in``: Add
Mark de Wevercbb5fd82021-08-05 21:34:52 +0200116
117 .. code-block:: c++
118
119 #cmakedefine _LIBCPP_HAS_NO_INCOMPLETE_FOO
120
Mark de Weverbe38c382021-08-11 17:33:54 +0200121* ``libcxx/include/foo``: The contents of the file should be guarded in an
122 ``ifdef`` and always include ``<version>``
Mark de Wevercbb5fd82021-08-05 21:34:52 +0200123
124 .. code-block:: c++
125
126 #ifndef _LIBCPP_FOO
127 #define _LIBCPP_FOO
128
Mark de Weverbe38c382021-08-11 17:33:54 +0200129 // Make sure all feature-test macros are available.
Mark de Wevercbb5fd82021-08-05 21:34:52 +0200130 #include <version>
Mark de Weverbe38c382021-08-11 17:33:54 +0200131 // Enable the contents of the header only when libc++ was built with LIBCXX_ENABLE_INCOMPLETE_FEATURES.
Mark de Wevercbb5fd82021-08-05 21:34:52 +0200132 #if !defined(_LIBCPP_HAS_NO_INCOMPLETE_FOO)
133
134 ...
135
136 #endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_FO0)
137 #endif // _LIBCPP_FOO
138
Mark de Weverbe38c382021-08-11 17:33:54 +0200139* ``libcxx/src/CMakeLists.txt``: When the library has a file ``foo.cpp`` it
140 should only be added when ``LIBCXX_ENABLE_INCOMPLETE_FEATURES`` is enabled
Mark de Wevercbb5fd82021-08-05 21:34:52 +0200141
142 .. code-block:: cmake
143
144 if(LIBCXX_ENABLE_INCOMPLETE_FEATURES)
145 list(APPEND LIBCXX_SOURCES
146 foo.cpp
147 )
148 endif()
149
Mark de Weverbe38c382021-08-11 17:33:54 +0200150* ``libcxx/utils/generate_feature_test_macro_components.py``: Add to
151 ``lit_markup``
Mark de Wevercbb5fd82021-08-05 21:34:52 +0200152
153 .. code-block:: python
154
155 "foo": ["UNSUPPORTED: libcpp-has-no-incomplete-foo"],
156
Mark de Weverbe38c382021-08-11 17:33:54 +0200157* ``libcxx/utils/generate_header_inclusion_tests.py``: Add to ``lit_markup``
Mark de Wevercbb5fd82021-08-05 21:34:52 +0200158
159 .. code-block:: python
160
161 "foo": ["UNSUPPORTED: libcpp-has-no-incomplete-foo"],
162
Mark de Weverbe38c382021-08-11 17:33:54 +0200163* ``libcxx/utils/generate_header_tests.py``: Add to ``header_markup``
Mark de Wevercbb5fd82021-08-05 21:34:52 +0200164
165 .. code-block:: python
166
167 "foo": ["ifndef _LIBCPP_HAS_NO_INCOMPLETE_FOO"],
168
Mark de Weverbe38c382021-08-11 17:33:54 +0200169* ``libcxx/utils/libcxx/test/features.py``: Add to ``macros``
Mark de Wevercbb5fd82021-08-05 21:34:52 +0200170
171 .. code-block:: python
172
173 '_LIBCPP_HAS_NO_INCOMPLETE_FOO': 'libcpp-has-no-incomplete-foo',
174
175* All tests that include ``<foo>`` should contain
176
177 .. code-block:: c++
178
179 // UNSUPPORTED: libcpp-has-no-incomplete-foo
180
181Once the library is complete these changes and guards should be removed.