blob: 9ff7d6c5d2aea5c78c75fc6cceaae721b39d84a1 [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 Dionne31781652021-01-08 17:23:16 -050015Looking for pre-existing reviews
16================================
17
18Before you start working on any feature, please take a look at the open reviews
19to avoid duplicating someone else's work. You can do that by going to the website
20where code reviews are held, `Differential <https://reviews.llvm.org/differential>`__,
21and clicking on ``Libc++ Open Reviews`` in the sidebar to the left. If you see
22that your feature is already being worked on, please consider chiming in instead
23of duplicating work!
24
Louis Dionne8096e242021-07-15 10:19:39 -040025Pre-commit check list
26=====================
27
28Before committing or creating a review, please go through this check-list to make
29sure you don't forget anything:
30
31- Do you have tests for every public class and/or function you're adding or modifying?
32- Did you update the synopsis of the relevant headers?
33- Did you update the relevant files to track implementation status (in ``docs/Status/``)?
Louis Dionnea7e94a12021-07-19 12:34:56 -040034- Did you mark all functions and type declarations with the :ref:`proper visibility macro <visibility-macros>`?
Louis Dionne8096e242021-07-15 10:19:39 -040035- If you added a header:
36
37 - Did you add it to ``include/module.modulemap``?
38 - Did you add it to ``include/CMakeLists.txt``?
39 - 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.
40 - If it's a public header, did you update ``utils/generate_header_inclusion_tests.py``?
41
42- 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?
43- Did you run the ``libcxx-generate-files`` target and verify its output?
44
45Post-release check list
46=======================
Marek Kurdejd5bc4d92020-12-02 08:52:35 +010047
48After branching for an LLVM release:
49
501. Update ``_LIBCPP_VERSION`` in ``include/__config``
512. Update the ``include/__libcpp_version`` file
523. Update the version number in ``docs/conf.py``
53
Marek Kurdejd5bc4d92020-12-02 08:52:35 +010054Exporting new symbols from the library
55======================================
56
Mark de Wever2bf75c02021-03-24 19:54:40 +010057When exporting new symbols from libc++, you must update the ABI lists located in ``lib/abi``.
Marek Kurdejd5bc4d92020-12-02 08:52:35 +010058To test whether the lists are up-to-date, please run the target ``check-cxx-abilist``.
59To regenerate the lists, use the target ``generate-cxx-abilist``.
Mark de Wever2bf75c02021-03-24 19:54:40 +010060The ABI lists must be updated for all supported platforms; currently Linux and
61Apple. If you don't have access to one of these platforms, you can download an
62updated list from the failed build at
63`Buildkite <https://buildkite.com/llvm-project/libcxx-ci>`__.
64Look for the failed build and select the ``artifacts`` tab. There, download the
65abilist for the platform, e.g.:
66
67* C++20 for the Linux platform.
68* MacOS C++20 for the Apple platform.
Mark de Wevercbb5fd82021-08-05 21:34:52 +020069
70Working on large features
71=========================
72
73Libc++ makes no guarantees about the implementation status or the ABI stability
Mark de Weverbe38c382021-08-11 17:33:54 +020074of features that have not yet been ratified in the C++ Standard. After the C++
Mark de Wevercbb5fd82021-08-05 21:34:52 +020075Standard is ratified libc++ promises a conforming and ABI-stable
76implementation. When working on a large new feature in the ratified version of
77the C++ Standard that can't be finished before the next release branch is
78created, we can't honor this promise. Another reason for not being able to
79promise ABI stability happens when the C++ Standard committee retroactively
80accepts ABI breaking papers as defect reports against the ratified C++
81Standard.
82
83When working on these features it should be possible for libc++ vendors to
84disable these incomplete features, so they can promise ABI stability to their
85customers. This is done by the CMake option
86``LIBCXX_ENABLE_INCOMPLETE_FEATURES``. When start working on a large feature
87the following steps are required to guard the new library with the CMake
88option.
89
Mark de Weverbe38c382021-08-11 17:33:54 +020090* ``libcxx/CMakeLists.txt``: Add
Mark de Wevercbb5fd82021-08-05 21:34:52 +020091
92 .. code-block:: cmake
93
94 config_define_if_not(LIBCXX_ENABLE_INCOMPLETE_FEATURES _LIBCPP_HAS_NO_INCOMPLETE_FOO)
95
Mark de Weverbe38c382021-08-11 17:33:54 +020096* ``libcxx/include/__config_site.in``: Add
Mark de Wevercbb5fd82021-08-05 21:34:52 +020097
98 .. code-block:: c++
99
100 #cmakedefine _LIBCPP_HAS_NO_INCOMPLETE_FOO
101
Mark de Weverbe38c382021-08-11 17:33:54 +0200102* ``libcxx/include/foo``: The contents of the file should be guarded in an
103 ``ifdef`` and always include ``<version>``
Mark de Wevercbb5fd82021-08-05 21:34:52 +0200104
105 .. code-block:: c++
106
107 #ifndef _LIBCPP_FOO
108 #define _LIBCPP_FOO
109
Mark de Weverbe38c382021-08-11 17:33:54 +0200110 // Make sure all feature-test macros are available.
Mark de Wevercbb5fd82021-08-05 21:34:52 +0200111 #include <version>
Mark de Weverbe38c382021-08-11 17:33:54 +0200112 // Enable the contents of the header only when libc++ was built with LIBCXX_ENABLE_INCOMPLETE_FEATURES.
Mark de Wevercbb5fd82021-08-05 21:34:52 +0200113 #if !defined(_LIBCPP_HAS_NO_INCOMPLETE_FOO)
114
115 ...
116
117 #endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_FO0)
118 #endif // _LIBCPP_FOO
119
Mark de Weverbe38c382021-08-11 17:33:54 +0200120* ``libcxx/src/CMakeLists.txt``: When the library has a file ``foo.cpp`` it
121 should only be added when ``LIBCXX_ENABLE_INCOMPLETE_FEATURES`` is enabled
Mark de Wevercbb5fd82021-08-05 21:34:52 +0200122
123 .. code-block:: cmake
124
125 if(LIBCXX_ENABLE_INCOMPLETE_FEATURES)
126 list(APPEND LIBCXX_SOURCES
127 foo.cpp
128 )
129 endif()
130
Mark de Weverbe38c382021-08-11 17:33:54 +0200131* ``libcxx/utils/generate_feature_test_macro_components.py``: Add to
132 ``lit_markup``
Mark de Wevercbb5fd82021-08-05 21:34:52 +0200133
134 .. code-block:: python
135
136 "foo": ["UNSUPPORTED: libcpp-has-no-incomplete-foo"],
137
Mark de Weverbe38c382021-08-11 17:33:54 +0200138* ``libcxx/utils/generate_header_inclusion_tests.py``: Add to ``lit_markup``
Mark de Wevercbb5fd82021-08-05 21:34:52 +0200139
140 .. code-block:: python
141
142 "foo": ["UNSUPPORTED: libcpp-has-no-incomplete-foo"],
143
Mark de Weverbe38c382021-08-11 17:33:54 +0200144* ``libcxx/utils/generate_header_tests.py``: Add to ``header_markup``
Mark de Wevercbb5fd82021-08-05 21:34:52 +0200145
146 .. code-block:: python
147
148 "foo": ["ifndef _LIBCPP_HAS_NO_INCOMPLETE_FOO"],
149
Mark de Weverbe38c382021-08-11 17:33:54 +0200150* ``libcxx/utils/libcxx/test/features.py``: Add to ``macros``
Mark de Wevercbb5fd82021-08-05 21:34:52 +0200151
152 .. code-block:: python
153
154 '_LIBCPP_HAS_NO_INCOMPLETE_FOO': 'libcpp-has-no-incomplete-foo',
155
156* All tests that include ``<foo>`` should contain
157
158 .. code-block:: c++
159
160 // UNSUPPORTED: libcpp-has-no-incomplete-foo
161
162Once the library is complete these changes and guards should be removed.