Update to GCC 5

GCC 5 was released in April 2015, and is available in Debian unstable. There are again the usual quirks with new standards versions and older software, and as a major change, the update / introduction of a new libstdc++ ABI.

Two test rebuilds of Debian testing/unstable on amd64 were done in January and April, and bug reports filed for the packages. These issues are tracked in http://bugs.debian.org/cgi-bin/pkgreport.cgi?tag=ftbfs-gcc-5;users=debian-gcc@lists.debian.org When submitting new reports, please tag these:

Two other test rebuilds were done in Ubuntu in February and April, covering other architectures than amd64. See the links at the bottom of the page.

TODO list

libstdc++ ABI transition

The good news is, that GCC 5 now provides a stable libstdc++ 11 ABI, and stable support for C++11 (GCC version before 5 called this supported experimental). This required some changes in the libstdc++ ABI, and now libstdc++6 provides a dual ABI, for libstdc++98, and libstdc++11 (FIXME: 5.1.1-5 only provides the libstdc++98 ABI). The bad news is that old experimental C++11 libstdc++ ABI and the new stable libstdc++11 ABIs are not compatible, and upstream doesn't provide an upgrade path except for rebuilding. Note that even in the past there were incompatibilities between g++ versions, but not as fundamental ones as found in the g++-5 update to stable C++11 support.

Using different libstdc++ ABIs in the same object or in the same library is not allowed. Therefore we have to rebuild everything with g++-5 (once it is the default). Using g++-4.9 as a fallback won't be possible in most cases.

libstdc++ doesn't change the soname, provides a dual ABI. Existing C++98 binary packages will continue to work. Building these packages using g++-5 is expected to work after build failures are fixed. FIXME: Will they only work when built with _GLIBCXX_USE_CXX11_ABI set to 0? By default they will use the new libstdc++ ABI.

GCC 6 is expected to change the c++ standard default to c++11 or c++14, so either prepare these packages for the new standard, or explicitly pass -std=c++98.

Library packages built in c++0x or c++11 may have an ABI change (unknown yet how many). How to find out about these?

If the library is incompatible, rename the package, append "c++11" to the name of the package (e.g. libfoo2 -> libfoo2c++11). Such a change can be avoided, if you have a soversion bump and you upload this version instead of the renamed package.

Instead of renaming, support ABI coexistence like libstdc++ (maybe some upstreams will do that, nothing to do on the packaging level).

To build code with gcc-5 which is compatible with the old ABI, define the macro _GLIBCXX_USE_CXX11_ABI to 0 before including any C++ standard library headers. Should only be used for leaf packages, not for libraries as a last resort.

The notes from Fedora describe this issue more in depth (however the incompatibility between the experimental 4.9 c++11 ABI and the stable 5 c++11 ABI is not addressed).

Roadmap for libstdc++

The goal is to have a dual ABI libstdc++ defaulting to the libstdc++11 ABI, building everything using g++-5, and then removing g++-4.9 from the distribution.

libstdc++ c++11 incompatibilities (4.9 and 5)

In many (?) cases, there are a few ... Upstream's position is, if C++11 from GCC 5 is used, then compiling with GCC 5 and linking to libstdc++.so from GCC 5 is needed (note that this is not the case in unstable, g++-4.9 is used to build, and link with libstdc++ from GCC 5).

Porting help

General porting help https://gcc.gnu.org/gcc-5/porting_to.html

Add pointers to porting efforts of other distributions (e.g. Fedora, OpenSUSE underway).

Add porting recipes here.

Timeline

Further information

Ubuntu test rebuild results (amd64, i386, arm64, armhf, powerpc, ppc64el).