User:Maffblaster/Archives/Maintaining C++ ABIs
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++ 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.
The standard fix, unless the buildsystem itself ensures C++11 support, is by adding
append-cxxflags -std=c++11 from flag-o-matic.eclass to
The ABI of dev-libs/boost also depends on the
-std= 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
-std= flags and are then linked together.
See for instance.
Starting with version 1.62.0, Gentoo will start switching to building boost with
-std=c++14. This is to ensure that packages utilizing 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
-std=c++14 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
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
-std=gnu++98 when compiling C++ code. With GCC 6.1, this has been switched to
-std=gnu++14. 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
-std=gnu++11, 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.