Tim, a technical editor for SCO World magazine, is the author of Linux Unleashed (Sams, 1995). He can be contacted at tparker@tpci.com.
Choosing a C compiler is both simple and difficult: simple, in that most compilers on the market are robust and mature enough to offer solid C handling; difficult, in that certain minor differences between them may be relevant to your needs. To ferret out these fine points, we recently examined five C compilers for the Sparcstation 5.
Each compiler was supplied by the vendor for a Sparcstation 5 machine running Solaris 2.4. We installed the compilers on newly formatted hard drives on which only Solaris was loaded. We compiled five test programs with each compiler, measuring time to compile, problems encountered, and any changes necessary for a clean compilation. The test programs were not of the simple "hello world" ilk, but real-world applications that we use in-house, for tracking project time and inventory, and at client sites, for accounting and time management.
We also wrote SPECint92 programs and ran them against each compiler. This is not, however, a very fair test of a compiler, as it measures only integer performance and programmer skill. We tried to optimize compilation by using compiler flags and options where applicable, but we don't claim to have tweaked each compiler to its optimum performance. Still, the numbers we measured are representative.
Table 1 and Table 2 present our findings, which also include extra tools, features, and notable add-ons. In this article, we'll describe these features and our experiences with each compiler.
The MetaWare High C/C++ compiler is a combination package, offering both C and C++ capabilities. Much of the material included with the High C/C++ system applies to C++ only; to keep the comparison fair, we concentrated only on the C-language portion.
Our version of MetaWare C/C++ was supplied on eight 3.5-inch diskettes: six for the compiler and two for patches. Installation proceeded smoothly, and after the patch diskettes were installed, the system was ready. Installation lasted about ten minutes. A compiler demo file is included to ensure all the components were properly installed. Several environment variables must be massaged to identify paths and libraries.
High C/C++ allows you to turn off extensions in the package with a compiler option, forcing the core ANSI Standard C language only. High C/C++ also complies with proposed C++ standards still under development. MetaWare supplies both an internal ANSI-C preprocessor and the option to use a UNIX external preprocessor (which may be K&R instead of ANSI C). High C/C++ is not K&R compatible, but it can be forced to compile K&R code by relying heavily on external libraries and the preprocessor.
By default, the system supports the extensions MetaWare has added to both C and C++. In many ways, these extensions provide the best features of other languages to C and C++ programmers, albeit at the cost of portability to other compiler products that lack the extensions. For example, High C/C++ lets you nest functions with up-level references and pass nested functions as parameters to other functions (a Pascal strong point). Many in-line library function calls are offered, as well as iterators that help handle and move through data structures.
You can use either the default UNIX system libraries or those provided with High C/C++. The latter is necessary if you use any High C/C++ extensions. Slight problems can occur if you use the MetaWare libraries but need a function in the UNIX library. Dependency problems may arise as one function calls another, or there may be duplicate symbols. Since data structures of the internal and external libraries are different but the names remain the same, these errors are often not caught during compilation and cause core dumps when executed.
High C/C++ uses configuration and profile files to specify values for the compiler. This can save a lot of command-line typing, especially if you maintain several configuration setups for different purposes and copy those you need into the default filenames when necessary. Of course, makefiles can be used to specify most parameters, too.
High C/C++ includes the GNU Debugger (gdb), which is automatically installed with the compilers. gdb is quite good, and is widely used. It did not seem to have been customized for the High C/C++ compiler.
As a C compiler, High C/C++ behaves very well, and is extremely difficult to fluster. In fact, it's about as robust a C compiler as we've seen. It has a few neat features for typical C programmers: Warnings come in a variety of levels and can be set to verbose, brief, or somewhere in between. The warning and error messages are very good, almost invariably pointing you to the problem location. It would be nice if the offending source code were displayed, but that's a minor quibble. (The C++ aspect of the High C/C++ package includes the Rogue Wave Tools.h++ and I/O streams library. As a C++ compiler, MetaWare scores strongly.)
Support for the product is extraordinary in today's market. MetaWare offers lifetime tech support with the package (although the support is restricted to standard business hours and e-mail).
We found High C/C++ very easy to work with, and it gave us no problems at all during testing. However, High C/C++ is relatively slow compared to the rest of the compilers reviewed here, even when heavily optimized. Indeed, it scored lowest on nearly every test. How much of a difference is there? Our large compilation tests revealed several minutes' difference, although with smaller programs, the difference was much less significant.
If you can handle slower speeds and the lack of K&R C, MetaWare High C/C++ is a solid, attractive compiler package. The extensions are useful although not standard, and the combination of a C and C++ compiler in one package may appeal to some. We liked High C/C++, but wonder if the performance would annoy us in the long run.
Cygnus may not be as familiar a name as say, Microsoft, but the company nonetheless has a loyal user base. The Cygnus Developer's Kit is a collection of GNU tools that is bundled together and documented as a complete set, then ported to many different platforms. Indeed, the ported versions have made Cygnus quite a name among cross-platform developers. Cygnus's testing and integration services add value to the GNU tools, and Cygnus is the organization authorized to make general releases of available GNU C tools (although GNU products can be obtained from many different sources).
Our copy of the Cygnus Developer's Kit was supplied on QIC tapes for both Solaris and HP/UX (many other distribution formats are available). Installation is simple, using tar to extract an installation script that does the rest. It's straightforward and applies to all target machines. Considering Cygnus's wide platform support, customizing installation scripts for each platform would probably be a headache.
The Cygnus Developer's Kit includes the GNU C compiler (gcc), the GNU C++ compiler (g++), the GNU debugger (gdn), the GNU assembler (as), GNU assembler preprocessor (gasp), and GNU linker (ld). There is the usual host of GNU utilities (byacc, flex, make, diff, and so on), as well as some text utilities (TeX). Libraries in the package include ANSI C run time (for cross-development platforms), C math subroutines (again for cross development), C++ class library, C++ iostreams, and, for Solaris platforms, a performance analyzer (gprof).
The GNU debugger is good, but not worth getting too excited about. Performance-wise, the GNU C compiler is unremarkable. It was about average in speed tests during our first trials. It has no optimizing capability, so we spent a couple of days playing with flags and options. Eventually, we managed to find several useful tweaks that improved performance a little, but the compiler still didn't win any prizes.
There is more to the Cygnus package than just the GNU material. The C subroutine library supplied by the Free Software Foundation has some nasty licensing restrictions, so Cygnus developed its own freely distributable, royalty-free library. Also, Cygnus's tech support has a reputation for excellence. Many of the Cygnus developers helped write the GNU material in the first place.
For a solid distribution source for the GNU compiler, good documentation, and excellent technical support, Cygnus is probably the place to go. You pay for the add-ons, of course (especially the tech support), but then you don't get much for free these days.
Still closer to the "free" level than Cygnus is Ready to Run Software's LanguagePak 1. LanguagePak 1 comprises gcc, G++, gdb, and a collection of libraries to support the compiler. LanguagePaks are available for over a dozen popular UNIX platforms. Ready to Run Software offers collections of utilities on many subjects besides the C compiler, such as Fax software, X, Internet tools, and utilities.
There's no real documentation with the LanguagePak. It has a few pages of installation notes and a catalog of Ready to Run Software's offerings in a smallish, three-ring binder. A zip-top page insert holds the distribution media. Manuals and documents are provided in soft-copy only.
Installation, which uses tar and an installation script, ran smoothly for us, installing the entire tape's contents.
Ready to Run Software offers no technical support, per se, as it is mainly a bundling company. The GNU software is the same as that offered by Cygnus, but the Cygnus package contains a lot more material (as well as printed documentation and technical support).
If you like warning messages, this compiler will be your favorite. It generated more error and warning messages than any other compiler we've seen. There were also a few compilation problems (mainly portability errors) that required quite a bit of tweaking.
As a bare-bones, easy source of GNU compilers, Ready to Run Software looks promising. You don't have to look for the latest version on the Internet or worry about compatible tools. The GNU compiler is good but not the best. Its price of $275.00, however, is definitely attractive.
The SunSoft SPARCompiler comes bundled with the SPARCworks GUI-driven development environment. To maintain an even playing field, we limited our examination to the C portion of the SPARCompiler package (which is physically separate from the SPARCworks package).
The documentation for SPARCompiler C is very well written--the best we saw. Some newcomers to C may be overwhelmed by the wealth of material, but good organization and layout make it manageable.
Installation is from a CD-ROM and could be handled with the pkgadd or swmtool utilities. You select the components to be installed from a list of all SunSoft tools, then start the routine. We would have preferred a single installation to worrying whether we got all the parts installed properly, but the entire installation went smoothly and required only a few minutes. The license manager was a pain, but we mastered that, too.
The SPARCompiler is an extension of the older C compiler included as part of the SunOS distribution and should be familiar to Sun users. We compared SPARCompiler to our older Sparcstation 1 installation running a pre-Solaris version of SunOS and found little difference. The error and warning messages are a little better and the performance is improved, but it's still the same beastie in fancier wrapping. Messages are just as cryptic and annoying as they always have been, although you now get a line number.
As far as we can tell, the SPARCompiler uses the same debugger as SPARCworks; it's capable and worth sticking with. Technical support costs extra after the first 30 days, but it's available 24 hours a day. The SPARCompiler's forte is performance, whether optimized or not. Code optimization with SPARCompiler is a bit hit-and-miss: Specific optimization methods tend to yield variable results, and we usually defaulted to the system's basic optimization routines.
We would have considered the SPARCompiler a winner if it hadn't been for the error messages, which were simply annoying. Still, the compiler is very fast and has good documentation, a strong feature set, and a lot of loyal users who still think the compiler should be included free with the operating system.
According to its literature, EPC was started by a group of University of Edinburgh faculty members as a means of selling their compilers and development tools. Although its U.S. presence is still small, the most recent version of its compiler may make people start to pay more attention. This compiler is the only one that struck us as noticeably different from the rest.
The documentation includes a copy of Kenneth Barclay's C Problem Solving and Programming (Prentice-Hall, 1990), a very interesting and worthy addition to the package.
Installation of the EPC C compiler proceeded smoothly from a QIC tape and used tar (some earlier versions used pkgadd). One annoying aspect of tar that applies to many products is that a tarred distribution media doesn't allow you to change destination directories. All you can do is let it extract to the default destination, then manually copy files to your preferred directory, and try to correct all the pointers to the files. We couldn't get this to work with the EPC compiler and finally used the default /opt directory. A license manager must be invoked after the installation to enable the compiler.
The Motif-based debugger is quite talented, and we could easily have been happy with it as our default debugger. It has several advantages over the GNU Debugger, and is somewhat integrated with the compiler.
Technical support is provided for 30 days, with access to both the Scotland and California offices (providing essentially a 16-hour support period).
The compiler itself is very good. We looked at an earlier release in the preliminary stages of this evaluation, and we worked with a much earlier release a couple of years ago. The current version is noticeably faster and more robust. One of the EPC C compiler's most important advantages is its ease of use. There are no 100-character-long command-line options, no digging through cabalistic lists for some magic optimize. A single flag provides all the optimization that EPC considers stable and useful.
Unoptimized, the compiler produced good, tight code quite quickly. When the optimizer was turned on, compilation took a little longer. The code was a little faster, but not by much, which points to a solid compiler design right from the start. The EPC C compiler produces both ANSI and K&R C code and provides some extensions. Other useful features are very good multiprocessing and thread support. The optimizers are quite clever, handling instruction migration, register renaming, redundant-access elimination, and very clean loop analysis.
We found the EPC C compiler the most friendly and easiest to work with, and it is our top choice for a straightforward, command-line driven C compiler. Our only complaint is the inflexible installation routine.
All of the compilers discussed here are solid performers with relatively minor differences. Choosing a C compiler on performance alone is usually folly, as the fastest compiler may not have the library or compilation options that make your task easier. The performance spread averages only a few percent. What makes the difference is the ease of use, compiler options, and availability of different libraries and support tools.
The Cygnus GNU distribution tape contains every type of GNU utility and library, available free of charge (as well as some Cygnus-developed libraries) and is the most cost-effective solution for a full-featured system.
The LanguagePak is a winner from the cost viewpoint: If your only requirement is a compiler with basic support tools (debugger and libraries), LanguagePak is easier than surfing the net to find the GNU system.
MetaWare High C/C++ is definitely the package for those who want top-notch support, libraries, and both C and C++ compilers in one box. Its only poor rating was in performance. It's lack of K&R may be a sore point with some users, but most of the world is now using ANSI C.
The latest version of the SunSoft SPARCompiler C is the fastest compiler we tested. However, the poor error and warning messages may annoy some. On the whole, this is an excellent offering, which makes it difficult to rank second.
Our preference was EPC's compiler. The Motif-based debugger was a winner, and the compiler's pure ease of use and fine handling made it one of the fastest turn-around compilers. We could run through more code-compile-link-debug cycles with EPC C than with any of the others in the same amount of time, and with much less annoyance. The documentation is very good, the performance was top-notch, and the optimizations excellent. As a stand-alone C compiler, we'll stay with EPC C.
LanguagePak 1
Ready To Run Software
4 Pleasant Street
P.O. Box 2038
Forge Village, MA 01886
508-692-9922
EPC C Compiler for SPARC v. 3.1.2
Edinburgh Portable Compilers Ltd.
14531 Big Basin Way
Saratoga, CA 95070
408-867-1039
SPARCompiler C 3.0.1
SunSoft
2550 Garcia Avenue
Mountain View, CA 94043
415-336-6848
MetaWare High C/C++ 3.2
MetaWare
2161 Delaware Avenue
Santa Cruz, CA 95060
408-429-6382
Cygnus Developer's Kit
Cygnus
1937 Landings Drive
Mountain View, CA 94043
415-903-1400
Table 1: Overall compiler ratings. (a) General; (b) C compiler. All ratings are the average of scores from 1 (poor) to 10 (excellent) given by each reviewer. No attempt has been made to weight the individual categories or to total the results based on the categories shown. The overall score is determined by each reviewer based on each category score and personal biases.
Copyright © 1995, Dr. Dobb's Journal
MetaWare EPC Ready to Run Cygnus SunSoft
(a)
Documentation 8 9 1 6 9
Installation 9 7 3 4 9
Features 7 8 3 6 8
Support 10 7 1 9 7
User Interface 7 7 3 5 6
Debugger 6 9 6 6 8
Libraries 9 8 6 7 7
(b)
Perf. Unoptimized* 6 8 7 7 10
Perf. Optimized* 8 9 8 8 10
Configurability 9 6 6 6 8
Ease of Use 8 9 6 6 6
Overall Rating: 8 9 6 7 9
*Performance ratings for optimized and unoptimized code determined by averaging five different-sized test program compilation and execution times and assigning a value from 1 to 10.
Table 2: SPECint92 measurements.
MetaWare EPC Ready to Run Cygnus SunSoft
Compilation Times (SPECint92 tests)
Unoptimized 52.2 60.6 58.4* 58.4* 61.9
Optimized 56.8 62.7 60.8 60.8 67.4
*These are both GNU compilers, so they're rated the same.