Jul 20, 2012

GCC 4.7 C++ ABI changes and openSUSE 12.2

GCC 4.7 introduced two changes that resulted in different ABIs (Application Binary Interface) for files that were compiled with C++98 versus files that were compiled using C++11 options. This could result in crashing applications, like bug bnc#767666 where "a C++98 library picked up a std::list operator= from a c++11 library resulting in a crash."

openSUSE 12.2 has been hit some of these incompatibilities in the update stack and the GCC developers now updated the compiler collection for openSUSE 12.2 to the current GCC 4.7 branch head which includes fixes for the two known issues. Those changes will also be in the upcoming GCC 4.7.2 release.

Every binary that uses std::list or std::pair in C++11 mode was effected and Coolo decided to rebuild the complete openSUSE 12.2 distribution to catch really everything - besides the known problems with the update stack and LibreOffice. This rebuild has been done after RC1 and therefore if you update from openSUSE 12.2 RC1 to RC2, you will see updates for many packages since they were recompiled.

This is also a warning - if you're using GCC 4.7.0 or 4.7.1 without this fix and compile programs using C++11 mode, update your compiler and recompile.

Some background

By default GCC compiles C++ programs using the options "-std=gnu++98" which is the GNU dialect of C++98. To build for the new C++11 standard, you have to specify "-std=c++11".

Details from the GCC changes pagel:
"GCC versions 4.7.0 and 4.7.1 had changes to the C++ standard library which affected the ABI in C++11 mode: a data member was added to std::list changing its size and altering the definitions of some member functions, and std::pair's move constructor was non-trivial which altered the calling convention for functions with std::pair arguments or return types. The ABI incompatibilities have been fixed for GCC version 4.7.2 but as a result C++11 code compiled with GCC 4.7.0 or 4.7.1 may be incompatible with C++11 code compiled with different GCC versions and with C++98/C++03 code compiled with any version."


The fixing included many GCC jdevelopers, I'd like to give a special thank you to Richard Günther und Michael Matz for debugging the issues in openSUSE and helping to get them fixed both upstream for GCC 4.7.2 and in openSUSE's GCC.