Apr 20, 2012

openSUSE Factory switched to GCC 4.7

The GNU Compiler Collection (gcc) version 4.7 was released a month ago and comes with the usual optimzation improvements and changes to follow newer standards like the new C11 revision of the ISO C standard and the ISO C+11 standard. A full list of changes is available on the gcc wiki.

The openSUSE project has now changed the compiler settings so that by default gcc 4.7 is used. Over the last several weeks, a couple of engineers led by Dominique Leuenberger have used in the open build service a project where all packages of openSUSE Factory were compiled with gcc 4.7 and then those packages that did not build were fixed. A handful of packages needs still updating but AFAIK more than 100 packages were fixed to build with gcc 4.7 - and some were fixed to build again with current packages in Factory.
At least two packages triggered bugs in gcc, one of them is now fixed in upstream gcc and also our gcc package (thanks to the upstream gcc maintainer Richard G√ľnther who is also the openSUSE gcc package maintainer), the other bug is still being investigated.

The switch to gcc 4.7 will now affect all the packages that built against factory but are not part of factory - once these get rebuild with the new gcc, the better standard conformance of the compiler, might lead to build failures.

For failing packages, the advise is to check first whether there's an upstream patch to fix the failure, then try fixing it yourself (often just a missing include), and then ask on the opensuse-factory mailing list or on the Freenode #opensuse-factory IRC channel for help.

If you like to test a package with several compilers, it's easy to do since openSUSE Factory currently includes a couple of GCC versions that can be installed in parallel.
The gcc package will install gcc 4.7 thus "gcc" is the command to use (or "gcc-4.7"), the gcc46 package contains a gcc 4.6 that can be used with "gcc-4.6" and there are also gcc41 and gcc43 packages. Another compiler that is available is llvm.