xref: /openbsd-src/gnu/llvm/libcxx/docs/DesignDocs/ABIVersioning.rst (revision 76d0caaeb19ae0808d90af1d0b3b7b50b3e5383f)
146035553Spatrick
246035553Spatrick====================
346035553SpatrickLibc++ ABI stability
446035553Spatrick====================
546035553Spatrick
6*76d0caaeSpatrickLibc++ aims to preserve a stable ABI to avoid subtle bugs when code built under the old ABI
7*76d0caaeSpatrickis linked with code built under the new ABI. At the same time, libc++ wants to make
8*76d0caaeSpatrickABI-breaking improvements and bugfixes in scenarios where the user doesn't mind ABI breaks.
946035553Spatrick
10*76d0caaeSpatrickTo support both cases, libc++ allows specifying an ABI version at
11*76d0caaeSpatrickbuild time. The version is defined with CMake option ``LIBCXX_ABI_VERSION``.
12*76d0caaeSpatrickCurrently supported values are ``1`` (the stable default)
13*76d0caaeSpatrickand ``2`` (the unstable "next" version). At some point "ABI version 2" will be
14*76d0caaeSpatrickfrozen and new ABI-breaking changes will start being applied to version ``3``;
15*76d0caaeSpatrickbut this has not happened yet.
1646035553Spatrick
17*76d0caaeSpatrickTo always use the most cutting-edge, most unstable ABI (which is currently ``2``
18*76d0caaeSpatrickbut at some point will become ``3``), set the CMake option ``LIBCXX_ABI_UNSTABLE``.
19*76d0caaeSpatrick
20*76d0caaeSpatrickInternally, each ABI-changing feature is placed under its own C++ macro,
21*76d0caaeSpatrick``_LIBCPP_ABI_XXX``. These macros' definitions are controlled by the C++ macro
22*76d0caaeSpatrick``_LIBCPP_ABI_VERSION``, which is controlled by the ``LIBCXX_ABI_VERSION`` set
23*76d0caaeSpatrickat build time. Libc++ does not intend users to interact with these C++ macros
24*76d0caaeSpatrickdirectly.
25