Marek Kurdej | 1c656e9 | 2020-12-02 08:52:35 +0100 | [diff] [blame] | 1 | .. _ContributingToLibcxx: |
| 2 | |
| 3 | ====================== |
| 4 | Contributing to libc++ |
| 5 | ====================== |
| 6 | |
Louis Dionne | 1f8e286 | 2021-07-15 10:19:39 -0400 | [diff] [blame] | 7 | This file contains notes about various tasks and processes specific to contributing |
| 8 | to 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 Kurdej | 1c656e9 | 2020-12-02 08:52:35 +0100 | [diff] [blame] | 10 | |
Louis Dionne | 1f8e286 | 2021-07-15 10:19:39 -0400 | [diff] [blame] | 11 | For libc++, please make sure you follow `these instructions <https://www.llvm.org/docs/Phabricator.html#requesting-a-review-via-the-command-line>`_ |
| 12 | for submitting a code review from the command-line using ``arc``, since we have some |
| 13 | automation (e.g. CI) that depends on the review being submitted that way. |
Marek Kurdej | 1c656e9 | 2020-12-02 08:52:35 +0100 | [diff] [blame] | 14 | |
Louis Dionne | b034593 | 2021-09-22 11:13:47 -0400 | [diff] [blame] | 15 | If you plan on contributing to libc++, it can be useful to join the ``#libcxx`` channel |
| 16 | on `LLVM's Discord server <https://discord.gg/jzUbyP26tQ>`__. |
| 17 | |
Louis Dionne | d86e16e | 2021-01-08 17:23:16 -0500 | [diff] [blame] | 18 | Looking for pre-existing reviews |
| 19 | ================================ |
| 20 | |
| 21 | Before you start working on any feature, please take a look at the open reviews |
| 22 | to avoid duplicating someone else's work. You can do that by going to the website |
| 23 | where code reviews are held, `Differential <https://reviews.llvm.org/differential>`__, |
| 24 | and clicking on ``Libc++ Open Reviews`` in the sidebar to the left. If you see |
| 25 | that your feature is already being worked on, please consider chiming in instead |
| 26 | of duplicating work! |
| 27 | |
Louis Dionne | 1f8e286 | 2021-07-15 10:19:39 -0400 | [diff] [blame] | 28 | Pre-commit check list |
| 29 | ===================== |
| 30 | |
| 31 | Before committing or creating a review, please go through this check-list to make |
| 32 | sure 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 Dionne | d153e7d | 2021-07-19 12:34:56 -0400 | [diff] [blame] | 37 | - Did you mark all functions and type declarations with the :ref:`proper visibility macro <visibility-macros>`? |
Louis Dionne | 1f8e286 | 2021-07-15 10:19:39 -0400 | [diff] [blame] | 38 | - 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 | |
| 48 | Post-release check list |
| 49 | ======================= |
Marek Kurdej | 1c656e9 | 2020-12-02 08:52:35 +0100 | [diff] [blame] | 50 | |
| 51 | After branching for an LLVM release: |
| 52 | |
| 53 | 1. Update ``_LIBCPP_VERSION`` in ``include/__config`` |
| 54 | 2. Update the ``include/__libcpp_version`` file |
| 55 | 3. Update the version number in ``docs/conf.py`` |
| 56 | |
Marek Kurdej | 1c656e9 | 2020-12-02 08:52:35 +0100 | [diff] [blame] | 57 | Exporting new symbols from the library |
| 58 | ====================================== |
| 59 | |
Mark de Wever | 48fa06f | 2021-03-24 19:54:40 +0100 | [diff] [blame] | 60 | When exporting new symbols from libc++, you must update the ABI lists located in ``lib/abi``. |
Marek Kurdej | 1c656e9 | 2020-12-02 08:52:35 +0100 | [diff] [blame] | 61 | To test whether the lists are up-to-date, please run the target ``check-cxx-abilist``. |
| 62 | To regenerate the lists, use the target ``generate-cxx-abilist``. |
Mark de Wever | 48fa06f | 2021-03-24 19:54:40 +0100 | [diff] [blame] | 63 | The ABI lists must be updated for all supported platforms; currently Linux and |
| 64 | Apple. If you don't have access to one of these platforms, you can download an |
| 65 | updated list from the failed build at |
| 66 | `Buildkite <https://buildkite.com/llvm-project/libcxx-ci>`__. |
| 67 | Look for the failed build and select the ``artifacts`` tab. There, download the |
| 68 | abilist for the platform, e.g.: |
| 69 | |
| 70 | * C++20 for the Linux platform. |
| 71 | * MacOS C++20 for the Apple platform. |
Mark de Wever | 6f85d9e | 2021-08-05 21:34:52 +0200 | [diff] [blame] | 72 | |
| 73 | Working on large features |
| 74 | ========================= |
| 75 | |
| 76 | Libc++ makes no guarantees about the implementation status or the ABI stability |
Mark de Wever | d2bc4fa | 2021-08-11 17:33:54 +0200 | [diff] [blame] | 77 | of features that have not yet been ratified in the C++ Standard. After the C++ |
Mark de Wever | 6f85d9e | 2021-08-05 21:34:52 +0200 | [diff] [blame] | 78 | Standard is ratified libc++ promises a conforming and ABI-stable |
| 79 | implementation. When working on a large new feature in the ratified version of |
| 80 | the C++ Standard that can't be finished before the next release branch is |
| 81 | created, we can't honor this promise. Another reason for not being able to |
| 82 | promise ABI stability happens when the C++ Standard committee retroactively |
| 83 | accepts ABI breaking papers as defect reports against the ratified C++ |
| 84 | Standard. |
| 85 | |
| 86 | When working on these features it should be possible for libc++ vendors to |
| 87 | disable these incomplete features, so they can promise ABI stability to their |
| 88 | customers. This is done by the CMake option |
| 89 | ``LIBCXX_ENABLE_INCOMPLETE_FEATURES``. When start working on a large feature |
| 90 | the following steps are required to guard the new library with the CMake |
| 91 | option. |
| 92 | |
Mark de Wever | d2bc4fa | 2021-08-11 17:33:54 +0200 | [diff] [blame] | 93 | * ``libcxx/CMakeLists.txt``: Add |
Mark de Wever | 6f85d9e | 2021-08-05 21:34:52 +0200 | [diff] [blame] | 94 | |
| 95 | .. code-block:: cmake |
| 96 | |
| 97 | config_define_if_not(LIBCXX_ENABLE_INCOMPLETE_FEATURES _LIBCPP_HAS_NO_INCOMPLETE_FOO) |
| 98 | |
Mark de Wever | d2bc4fa | 2021-08-11 17:33:54 +0200 | [diff] [blame] | 99 | * ``libcxx/include/__config_site.in``: Add |
Mark de Wever | 6f85d9e | 2021-08-05 21:34:52 +0200 | [diff] [blame] | 100 | |
| 101 | .. code-block:: c++ |
| 102 | |
| 103 | #cmakedefine _LIBCPP_HAS_NO_INCOMPLETE_FOO |
| 104 | |
Mark de Wever | d2bc4fa | 2021-08-11 17:33:54 +0200 | [diff] [blame] | 105 | * ``libcxx/include/foo``: The contents of the file should be guarded in an |
| 106 | ``ifdef`` and always include ``<version>`` |
Mark de Wever | 6f85d9e | 2021-08-05 21:34:52 +0200 | [diff] [blame] | 107 | |
| 108 | .. code-block:: c++ |
| 109 | |
| 110 | #ifndef _LIBCPP_FOO |
| 111 | #define _LIBCPP_FOO |
| 112 | |
Mark de Wever | d2bc4fa | 2021-08-11 17:33:54 +0200 | [diff] [blame] | 113 | // Make sure all feature-test macros are available. |
Mark de Wever | 6f85d9e | 2021-08-05 21:34:52 +0200 | [diff] [blame] | 114 | #include <version> |
Mark de Wever | d2bc4fa | 2021-08-11 17:33:54 +0200 | [diff] [blame] | 115 | // Enable the contents of the header only when libc++ was built with LIBCXX_ENABLE_INCOMPLETE_FEATURES. |
Mark de Wever | 6f85d9e | 2021-08-05 21:34:52 +0200 | [diff] [blame] | 116 | #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 Wever | d2bc4fa | 2021-08-11 17:33:54 +0200 | [diff] [blame] | 123 | * ``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 Wever | 6f85d9e | 2021-08-05 21:34:52 +0200 | [diff] [blame] | 125 | |
| 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 Wever | d2bc4fa | 2021-08-11 17:33:54 +0200 | [diff] [blame] | 134 | * ``libcxx/utils/generate_feature_test_macro_components.py``: Add to |
| 135 | ``lit_markup`` |
Mark de Wever | 6f85d9e | 2021-08-05 21:34:52 +0200 | [diff] [blame] | 136 | |
| 137 | .. code-block:: python |
| 138 | |
| 139 | "foo": ["UNSUPPORTED: libcpp-has-no-incomplete-foo"], |
| 140 | |
Mark de Wever | d2bc4fa | 2021-08-11 17:33:54 +0200 | [diff] [blame] | 141 | * ``libcxx/utils/generate_header_inclusion_tests.py``: Add to ``lit_markup`` |
Mark de Wever | 6f85d9e | 2021-08-05 21:34:52 +0200 | [diff] [blame] | 142 | |
| 143 | .. code-block:: python |
| 144 | |
| 145 | "foo": ["UNSUPPORTED: libcpp-has-no-incomplete-foo"], |
| 146 | |
Mark de Wever | d2bc4fa | 2021-08-11 17:33:54 +0200 | [diff] [blame] | 147 | * ``libcxx/utils/generate_header_tests.py``: Add to ``header_markup`` |
Mark de Wever | 6f85d9e | 2021-08-05 21:34:52 +0200 | [diff] [blame] | 148 | |
| 149 | .. code-block:: python |
| 150 | |
| 151 | "foo": ["ifndef _LIBCPP_HAS_NO_INCOMPLETE_FOO"], |
| 152 | |
Mark de Wever | d2bc4fa | 2021-08-11 17:33:54 +0200 | [diff] [blame] | 153 | * ``libcxx/utils/libcxx/test/features.py``: Add to ``macros`` |
Mark de Wever | 6f85d9e | 2021-08-05 21:34:52 +0200 | [diff] [blame] | 154 | |
| 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 | |
| 165 | Once the library is complete these changes and guards should be removed. |