|< Day Day Up >|
11.1. Compiler Differences
GCC is supported on a wide range of platforms, and it is the default compiler on Mac OS X. There are, however, some important differences between the version of GCC that ships with Mac OS X and those found on other Unix systems.
One difference that experienced GCC users may notice, particularly if they have extensive experience with mathematical and scientific programming, is that the Xcode Tools do not include FORTRAN . However, both Fink (http://fink.sourceforge.net) and DarwinPorts (http://darwinports.opendarwin.org) include g77, the GNU FORTRAN '77 compiler. (For information on using Fink and DarwinPorts, see Chapters 13 and 14, respectively.) Also, the Darwin archive includes the source code for g77, which you can use to compile FORTRAN code. Additionally, two open source FORTRAN 95 projects are available for Mac OS X, the GNU FORTRAN 95, or gfortran, which is a compiler frontend to GCC 4.0 (http://gcc.gnu.org/fortran) and the g95 project (http://g95.sourceforge.net). g95 can be installed on Mac OS X with the binaries provided on its home site or with Fink. At the time of this writing, gfortran for GCC 4 is listed among Fink's unsupported packages.
As of this writing, Apple's cc compiler is based on GCC 4.0. However, GCC 3.3 is also available as /usr/bin/gcc-3.3. By default, invoking cc or gcc invokes GCC 4.0; both /usr/bin/cc and /usr/bin/gcc are symbolic links to /usr/bin/gcc-4.0. You can change the default GCC to GCC 3.3 by running the command gcc_select 3.3. Similarly, you can change it back to GCC 4.0 with gcc_select 4.0. The gcc_select command (used with one of the options 3.3 or 4.0) changes the symbolic links /usr/bin/cc and /usr/bin/gcc to point to the desired version of gcc. Since files in /usr/bin are changed by this command, you must execute it with sudo.
You can see the current settings by running gcc_select with no arguments:
$ gcc_select Current default compiler: gcc version 4.0.0 20041026 (Apple Computer, Inc. build 4039)
Perhaps the most important improvement in GCC 4.0 is the incorporation of Tree Single Static Assignment (SSA) optimization rather than Register Transfer Language, used in older versions of GCC. SSA was available in some earlier versions, but was experimental and had to be switched on by special compiler flags, for example, -fssa. Although we haven't tested them thoroughly, according to the Apple's Xcode2 web site (http://www.apple.com/macosx/features/xcode), the incorporation of Tree SSA has improved the following optimizations:
See http://gcc.gnu.org/projects/tree-ssa for more details on SSA.
Additional improvements in GCC 4.0 include a more efficient C++ parser and a dynamic C++ standard library, libstdc++; in pre-Tiger releases of Mac OS X you could only statically link it. There's also support for 128-bit long double floating-point types and 64-bit computing.
|< Day Day Up >|