JavaScript is required to for searching.
Skip Navigation Links
Exit Print View
Solaris 64-bit Developer's Guide
search filter icon
search icon

Document Information

Preface

1.  64-bit Computing

2.  When to Use 64-bit

3.  Comparing 32-bit Interfaces and 64-bit Interfaces

4.  Converting Applications

5.  The Development Environment

Build Environment

Header Files

Compiler Environments

32-bit and 64-bit Libraries

Linking Object Files

LD_LIBRARY_PATH Environment Variable

$ORIGIN Keyword

Packaging 32-bit and 64-bit Applications

Placement of Libraries and Programs

Packaging Guidelines

Application Naming Conventions

Shell-Script Wrappers

/usr/lib/isaexec Binary File

isaexec(3c) Interface

Debugging 64-bit Applications

6.  Advanced Topics

A.  Changes in Derived Types

B.  Frequently Asked Questions (FAQs)

Index

Build Environment

The build environment includes the system headers, compilation system, and libraries. These are explained in the sections that follow.

Header Files

A single set of system headers supports both 32-bit and 64-bit compilation environments. You do not need to specify a different include path for the 64-bit compilation environment.

To better understand the changes made to the headers for support of the 64-bit environment, you should understand the various definitions in the header <sys/isa_defs.h>. This header contains a group of well known #defines and sets these for each instruction set architecture. Inclusion of <sys/types.h> automatically includes <sys/isa_defs.h>.

The symbols in the following table are defined by the compilation environment:

Symbol
Description
__sparc
Indicates any of the SPARC family of processor architectures. This includes SPARC V7, SPARC V8, and SPARC V9 architectures. The symbol sparc is a deprecated historical synonym for __sparc.
__sparcv8
Indicates the 32-bit SPARC V8 architecture as defined by Version 8 of the SPARC Architecture Manual.
__sparcv9
Indicates the 64-bit SPARC V9 architecture as defined by Version 9 of the SPARC Architecture Manual.
__x86
Indicates any of the x86 family of processor architectures.
__i386
Indicates the 32-bit i386 architecture.
__amd64
Indicates the 64-bit amd64 architecture.

Note - __i386 and __amd64 are mutually exclusive. The symbols __sparcv8 and __sparcv9 are mutually exclusive and are only relevant when the symbol __sparc is defined.


The following symbols are derived from some combination of the symbols above being defined:

Symbol
Description
_ILP32
The data model where sizes of int, long, and pointer are all 32 bits.
_LP64
The data model where sizes of long and pointer are all 64 bits.

Note - The symbols _ILP32 and _LP64 are mutually exclusive.


If writing completely portable code is not possible, and specific 32-bit versus 64-bit code is required, make the code conditional using _ILP32 or _LP64. This makes the compilation environment machine independent and maximizes the portability of the application to all 64-bit platforms.

Compiler Environments

The Sun Studio C, C++, and Fortran compilation environments have been enhanced to support the creation of both 32-bit and 64-bit applications. The 10.0 release of the C compiler from Sun Studio 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 x86 machines, nor x86 objects on SPARC machines with the Sun compilers. In the absence of a specification of the architecture or mode of compilation, the appropriate __sparcv8 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.

Starting with the Sun Studio 8 release, use the cc(1) -xarch=generic64 flag to enable the 64-bit compilation environment.

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=generic64 flag is used to generate 64-bit code on either 32-bit or 64-bit system. Using the 32-bit compiler you can build 64-bit objects on a 32-bit system; however, you cannot run the 64-bit objects 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.

For a description of compiler options, see the Sun Studio 10: C User's Guide.

32-bit and 64-bit Libraries

The Solaris operating environment provides shared libraries for both 32-bit and 64-bit compilation environments.

32-bit applications must link with 32-bit libraries, and 64-bit applications must link with 64-bit libraries. It is not possible to create or execute a 32-bit application using 64-bit libraries. The 32-bit libraries continue to be located in /usr/lib and /usr/ccs/lib. The 64-bit libraries are located in a subdirectory of the appropriate lib directory. Because the placement of the 32-bit libraries has not changed, 32-bit applications built on prior releases are binary compatible. Portable Makefiles should refer to any library directories using the 64 symbolic link.

In order to build 64-bit applications, you need 64-bit libraries. It is possible to do either native or cross-compilation, because the 64-bit libraries are available for both 32-bit and 64-bit environments. The compiler and other miscellaneous tools (for example; ld, ar, and as) are 32–bit programs capable of building 64-bit programs on 32-bit or 64-bit systems. Of course, a 64-bit program built on a system running the 32-bit operating system cannot execute in that 32-bit environment.