Solaris 64-bit Developer's Guide

Compilers

The Sun WorkShop C, C++, and Fortran compilation environments have been enhanced to support the creation of both 32-bit and 64-bit applications. The 5.0 release of the C compiler from Sun WorkShop provides 64-bit compilation support.

Native and cross-compilation modes are supported. The default compilation environment continues to produce 32-bit applications. While both modes are supported, they are still architecture-specific. It is not possible to create SPARC objects on Intel machines, nor Intel objects on SPARC machines with the Sun compilers. In the absence of a specification of the architecture or mode of compilation, the appropriate __sparc or __i386 symbol is defined by default, and as part of this, _ILP32 is also defined. This maximizes interoperability with the existing applications and hardware base.

Using the C compiler from Sun WorkShop as an example, to enable the 64-bit compilation environment on a SPARC machine, the -xarch=v9 flag needs to be given as an argument to cc(1).

This generates LP64 code in ELF64 objects. ELF64 is a 64-bit object file format supporting 64-bit processors and architectures. This is in contrast to the ELF32 object files generated when compiling in the default 32-bit mode.

The -xarch=v9 flag is used to generate code on either 32-bit or 64-bit systems. Using the 32-bit compiler you can build 64-bit objects on a 32-bit system (using -xarch=v9) though you cannot run them on a 32-bit system. You need not specify the library path for the 64-bit libraries. If the -l or -L option is used to specify an additional library or library path and that path points only to 32-bit libraries, the linker detects this and fails with an error.