Project:C++/Maintaining ABI

Due to Gentoo's source-based nature, we generally do not have the liberty of compiling against multiple ABIs and having them work concurrently. A significant part of this effort is keeping up to date with the ABI of C++ (or rather libstdc++). Currently, two important dependencies require some care when writing ebuilds:

>=dev-libs/libsigc++-2.6
dev-libs/libsigc++ has overhauled its internals significantly with the release of version 2.6. One of these changes involves using C++11 lambdas. As a result, any ebuild (R)DEPENDing on >=dev-libs/libsigc++-2.6 needs to also be compiled with C++11 support.

See also: https://bugs.gentoo.org/show_bug.cgi?id=566328

The standard fix, unless the buildsystem itself ensures C++11 support, is by adding  from   to.

>=dev-libs/boost-1.62.0
The ABI of dev-libs/boost also depends on the  setting given to the compiler at build-time. Furthermore, pure binary-less template code in headers also changes its ABI depending on the C++ standard. Problems arise, if two dependencies are compiled with different  flags and are then linked together.

See for instance: https://bugs.gentoo.org/show_bug.cgi?id=582696

Starting with version 1.62.0, Gentoo will start switching to building boost with. This is to ensure that packages utilising boost and C++11/14 features all use the same ABI. It is strongly recommended that any ebuild (R)DEPENDing on dev-libs/boost should in future DEPEND and RDEPEND on >=dev-libs/boost-1.62.0:= (don't forget the sub-slot operator!) and ensure either the buildsystem adds C++14 support or the ebuild adds  using the same fix as with >=dev-libs/libsigc++-2.6. The roadmap for switching to C++14 for the boost-dependent ecosystem is documented in https://bugs.gentoo.org/show_bug.cgi?id=587012#c3

In addition, starting with dev-libs/boost-1.62.0, if your compiler is GCC, some version of 4.9 of GCC will at least be required. However, you cannot have GCC 4.9 and GCC 5.1 or beyond installed together with GCC 4.9 as the active compiler because linking will fail due to the dual-ABI employed by GCC 5.1 and beyond.

The choice of the -std= setting
GCC has historically used  when compiling C++ code. With GCC 6.1, this has been switched to. As Gentoo is the distribution of user choice, we aim to ultimately be able to build the whole tree using another compiler, which will most likely be Clang/LLVM. In order to so, we need to minimize deviations from the official ISO C++ Standard and therefore prefer if package maintainers use  over , in order to avoid relying on GNUtensions, unless the package's buildsystem explicitly requests it.

On the choice between C++11 and C++14, we strongly advise using C++14, as C++14 has become the default standard with GCC in versions 6.1 and beyond.