11.2. Compiling Unix Source Code

 < 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.

Mac OS X's C compiler contains a number of Mac-specific features that have not been folded into the main GCC distribution. (It is up to the Free Software Foundation (FSF) to accept and merge Apple's patches.) For information on how Apple's compiler differs from the GNU version, see the README.Apple file in the Darwin CVS archive's gcc4 subdirectory.

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) 

The Mac OS X Compiler Release Notes (/Developer/ADC Reference Library/Documentation/releasenotes) should be consulted for details on the most currently known problems, issues, and features.

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:

  • Scalar replacement of aggregates

  • Constant propagation

  • Value range propagation

  • Partial redundancy elimination

  • Load and store motion

  • Strength reduction

  • Dead store elimination

  • Dead and unreachable code elimination

  • Auto-vectorization to take advantage of the Velocity Engine

  • Loop interchange

  • Tail recursion by accumulation

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 > 

    Mac OS X Tiger for Unix Geeks
    Mac OS X Tiger for Unix Geeks
    ISBN: 0596009127
    EAN: 2147483647
    Year: 2006
    Pages: 176

    Similar book on Amazon

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net