RealTime IT News

Open Source GCC 4.0: Older, Faster

UPDATED: Open source development got a bit faster this week thanks to the release of the GCC 4.0 compiler . GCC is included in every Linux distribution and has been one of the leading compilers in use over the last 15 years.

GCC, which used to stand for GNU C Compiler and then changed to GNU Compiler Collection as it added languages beyond just C, has a long and critically important history in the free and open source (FOSS) movement.

The first GCC release was written by the "father" of the FOSS movement, Richard Stallman in 1987 as a free software compiler for the GNU project. Compilers are critically important tools that compile source code into object code that can be run on a given platform and, as such, play a fundamental role in building virtually every piece of usable code on a system.

GCC 4.0 offers support for a long list of architectures, including x86, x86-64, IA-64, PowerPC, SPARC and Alpha among others. The GPL-licensed compiler also has front ends for a number of programming languages, including Java, C and C++.

"Without a doubt, the most significant feature in GCC 4.0, and the reason that this version is called 4.0, rather than 3.5, is its new optimization infrastructure," current GCC release maintainer Mark Mitchell told internetnews.com. "Previous versions of GCC did almost all optimizations at, roughly speaking, the level of machine instructions. Unfortunately, by that point a lot of information has been lost. Therefore, GCC 4.0 does a lot of optimizations at a level much closer to the input program."

The new GCC 4.0 includes what the developers have termed "General Optimizer Improvements," as well as specific language improvements. In particular, C++ users will get a significant performance improvement with this new release.

"When compiling without optimizations, the C++ front end is much faster than in any previous versions of GCC," the GCC 4.0 changelog notes. "Independent testers have measured speed-ups up to 25 percent in real-world production code, compared to the 3.4 family, which was already the fastest version to date. Upgrading from older versions might show even bigger improvements."

Another C++ example cited by Mitchell is something called "scalar replacement of aggregates."

"If the compiler can see that an object never has its address taken, it will split the object up into separate pieces, which fit in machine registers," Mitchell explained. "Older versions of the compiler put the entire object into memory, which made operations on it much less efficient."

Cross-platform code re-use also got a boost with this release. The changelog explains that ELF visibility attributes can now be applied to a class type, which means that it now affects all member functions of a class without the need to specify each individually.

"The syntax is deliberately similar to the __declspec() system used by Microsoft Windows-based compilers, allowing cross-platform projects to easily reuse their existing macro system for denoting exports and imports," the GCC 4.0 changelog states.

Apple has already announced that it will ship GCC 4.0 with its next operating system version.

"I know that the GNU/Linux distributors are also excited about the release," Mitchell said. "It generally takes six months to a year before we see all the major distributions pick up the compiler."

Mitchell doesn't expect that GCC will lose its relevance any time soon.

"GCC will certainly be around for the forseeable future," he said. "A lot of other compilers have gone away over the last decade, but GCC is the compiler for GNU/Linux and the BSDs, and it's used with other popular operating systems like OS X and VxWorks."

GCC 4.0 is the base of the next round of optimization, which will be part of GCC 4.1.

"A lot of these focus on making additional use of the optimization infrastructure added in GCC 4.0," Mitchell said. "The goal is to make GCC generate even better code for all of the target architectures."