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 libcxx11 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, the classic libcxx98 ABI, and the new libcxx11 (GCC 5 (<< 5.1.1-20) only provides the classic libcxx98 ABI). The bad news is that the (experimental) C++11 support in the classic libcxx98 ABI and the new stable libcxx11 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 allowed, as long as you don't try to pass std::list to something expecting std::__cxx11::list or vice versa. We should rebuild everything with g++-5 (once it is the default). Using g++-4.9 as a fallback won't be possible in many cases.

libstdc++ (>= 5.1.1-20) 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.

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 using -std=c++0x or -std=c++11 may have an ABI change, because the pre GCC 5 libstdc++6 was marked as experimental for c++11. As done with earlier transitions (e.g. 4.8 to 4.9), we ignore these ABI changes.

If the library is incompatible, rename the package, append "v5" to the name of the package (e.g. libfoo2 -> libfoo2v5). Such a change can be avoided, if you have a soversion bump and you upload this version instead of the renamed package. Library packages still having a c2a suffix should be renamed by replacing the c2a suffix with v5 (libbar1c2a -> libbar1v5).

Instead of renaming, a library could support ABI coexistence like libstdc++ itself (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 incompatibilities between the experimental 4.9 c++11 support and the stable 5 libcxx11 ABI is not addressed).

Roadmap for libstdc++

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

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

In some 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).

Backporting packages affected by the libstdc++ ABI transition

Packages in jessie-backports are required to be upgradeable to the version in testing. Packages in Jessie use the classic libcxx98 ABI by default thus changes made for the libcxx98 -> libcxx11 transition need to be reverted.

Library packages which have been renamed to have a "v5" postfix must be backported under their pre-transition name (libfoo2v5 -> libfoo2).

Libraries which have been transitioned with a major version change thus avoiding the "v5" postfix (libfoo2 -> libfoo3) need to be changed first in unstable to properly upgrade from their libcxx98 variant by adding the following fields to their control file:

Package: libfoo3
...
Breaks: libfoo3v4
Replaces: libfoo3v4

After this change made it to testing the library can be uploaded to jessie-backports appending "v4" to its name (libfoo3v4) and making sure that it exports the proper ABI.

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.

Prepare for GCC 6

While GCC 6 isn't yet released, it is already known that g++ will default to a newer C++ standard (c++11 or c++14). Either prepare packages to build using the newer C++ standard, or explicitly pass -std=c++98 or -std=gnu++98 to the compiler for those package builds.

Timeline

TBD ...

Further information

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