May 18, 2007

New GCC 4.2.0 -- boon to developers, bore to distros

Author: Mayank Sharma

Earlier this week, the GNU project announced a major release of the popular GNU Compiler Collection. GCC 4.2.0 introduces new features and several improvements for developers, but most of the distribution developers we spoke with aren't rushing to take advantage of the new release.

GCC began life as a C compiler, but it now has compilers for C, C++, Objective-C, Objective-C++, Java, Fortran, and Ada. GCC is most popular for compiling the Linux kernel and has been ported to more than 60 platforms.

"The most important addition in GCC 4.2.0," says Baishampayan Ghose, an Ubuntu hacker, "is the merge of the GOMP branch into mainline GCC." The GOMP branch of GCC was created a long time back to implement OpenMP in GCC for the C, C++, and Fortran compilers. OpenMP eases the process of creating code that can run in parallel.

Implementation-wise, OpenMP is a platform- and architecture-independent application interface. It lets programmers write parallelized code wherein a master thread creates multiple "slave" threads to execute a code block in parallel and later merge back into the master thread. Ghose explains that the addition of OpenMP is a non-trivial improvement to the GNU Compiler Collection and will make parallel programming simple on Free Software operating systems.

There's also good news on the Java front. "Statically linking to libgcj to create a standalone Java executable has been made much easier with the introduction of the -static-libgcj option for gcj," Ghose says. By doing this, he explains, developers can eliminate the need for libgcj at run time, which can save a lot of space. "But statically linking can cause its own problems," he says, "since sometimes some needed classes may not get loaded automatically. But the feature is useful nevertheless."

GCC 4.2.0 also introduces some interesting options. The -Wextra option will produce a warning for if statements with only a semicolon in the body. Ghose explains that this is useful for catching some odd typo errors. Then there's the -fstrict-overflow optimization option, which will prevent overflows by converting loops with no upper bounds into infinite loops. For example, a for loop for (i=0; i>0; i*=2) will be converted into an infinite loop that terminates on reaching the highest value an integer variable can take, instead of overflowing and chocking the box.

For Mozilla engineer David Baron, the overhaul of the C++ visibility handling is good news. He expects the changes to visibility handling "to make Mozilla on Linux a bit faster."

Mixed reactions from distribution developers

We asked several distribution developers about the new release. Mike Frysinger, Gentoo's toolchain maintainer and council member, says that the OpenMP addition will mainly concern individual developers and not the Gentoo distribution. "For the rest of the distribution," Frysinger says, "it'll be business as usual; a new major GCC release means some packages will no longer compile due to strictness changes or flag changes or some other random thing. But I guess I'll find out for sure as I finish up getting the gcc-4.2.0 package into the Gentoo tree in the next few days."

Meanwhile, derivative distributions have other concerns. Kris Moore, founder and lead developer of PC-BSD, which is based on FreeBSD, says the decision to switch to GCC 4.2.0 lies with FreeBSD. "If they [FreeBSD] add it into the ports/source," says Moore, "then we'll be happy to use it." Moore doesn't see any immediate use for implementing OpenMP support, as PC-BSD's custom tool don't require a lot of horsepower. "However, that being said, again, if FreeBSD starts using it, we will also, especially if some of our important packages start being built to support it, like KDE."

KDE's Asian spokesperson, Pradeepto Bhattacharya, after talking to some core KDE developers, says that KDE will do fine with GCC 4.2.0. He says the KDE developers are happy with the latest version's better features and better warning capabilities. According to Bhattacharya, openSUSE internally uses GCC 4.2.0 regularly to build KDE, and KDE 3.5.6 and 3.5.7 should compile fine with the latest GCC. Even the upcoming KDE 4.0 would have no issues. "Apparently Dirk Mueller, one of the main sysadmins and a very old KDE developer, regularly builds KDE with development versions of GCC, and if issues arise he sends in fixes or fixes himself," Bhattacharya says.

Fedora has no plans to use GCC 4.2.0 immediately, since it is close to Fedora 7's release date. Tom Tromey, a GCJ maintainer who works on several Java related packages for Fedora, agrees that while GCC 4.2.0 is a major release, whether or not a distro picks up a specific new GCC release depends on timing and other factors. "For instance, Fedora 7 is nearing release," says Tromey, "and it is much too late to consider rebasing it on 4.2.0."

But he adds that Fedora typically has backports of important GCC features and bug fixes to its base compiler. "For instance, for gcj in F7," he says, "we back-ported the gcj features that will appear in GCC 4.3 -- and in fact as far as gcj is concerned, GCC 4.2 is already obsolete."

Tromey isn't aware of any discussions about what version of GCC will be used for Fedora 8.

In contrast with other distros, Debian seems to be very interested in the new release. "Most of the Free Software packages included in Debian," says Joey Schulze, a senior Debian developer, "will compile just fine with the new version of GCC." He mentions that the Debian project recompiled its entire archive last year to locate and iron out any issues once GCC 4.2.0 was released. According to Schulze, future binaries distributed with Debian will be compiled with GCC 4.2.0, which will be the base for the next Debian release, codenamed Lenny.

Click Here!