The MIPSpro compiler system consists of a set of components that enable you to create new 32-bit and 64-bit executable programs (as well as old 32-bit executables) using languages such as C, C++, and Fortran.
A new 32-bit mode, n32, was introduced with the IRIX 6.1 operating system. This new 32-bit mode has the following features:
Full access to all features of the hardware
MIPS III and MIPS IV instruction set architecture (ISA)
Improved calling convention
32 64-bit floating-point registers
32 64-bit general purpose registers
Dwarf debugging format
The new 32-bit mode (n32) provides better performance than the old 32-bit mode available in IRIX releases prior to 6.1. When you compile with the -n32 option, the chip executes in 64-bit mode and the software restricts addresses to 32 bits. For more information about n32, refer to the MIPSpro N32 ABI Handbook.
In addition, the MIPSpro compiler system:
Uses executable and linking format (ELF) for object files. ELF is the format specified by System V Release 4 Applications Binary Interface (SVR4 ABI). Refer to “Executable and Linking Format” in Chapter 2, for additional information.
Uses shared libraries, called dynamic shared objects (DSOs). DSOs are loaded at run time, instead of at link time, by the run-time linker, rld. The code for DSOs is not included in executable files; thus, executables built with DSOs are smaller than those built with non-shared libraries, and multiple programs can use the same DSO at the same time. For more information, see Chapter 3, “Using Dynamic Shared Objects”.
Creates position-independent code (PIC) by default to support dynamic linking. See “Position-Independent Code” in Chapter 2, for additional information.
Table 1-1, summarizes the compiler system components and the task each performs.
Table 1-1. Compiler System Functional Components
Tool | Task | Examples |
---|---|---|
Text editor | Write and edit programs | vi, jot , emacs |
Compiler driver | Compile, link, and load programs | cc, CC , f77, f90, as |
Object file analyzer | Analyze object files | dis, dwarfdump , elfdump, file, nm, size |
SpeedShop/WorkShop | Analyze program performance | cvperf, prof, sscompare, ssrun |
Archiver | Produce object-file libraries | ar |
Linker | Link object files | ld |
Runtime linker | Link Dynamic Shared Objects at runtime | rld |
Debugger | Debug programs | cvd, dbx |
A single program called a compiler driver (such as cc, CC, f77, or f90) invokes the following major components of the compiler system (refer to Figure 1-1)
You can invoke a compiler driver with various options (described in the relevant man page, such as cc(1)) and with one or more source files as arguments. All specified source files are automatically sent to the macro preprocessor. To prevent running the preprocessor, use the -nocpp option on the driver command line.
Your program can take advantage of multiple CPUs (when present) to achieve higher computation rates. The optional parallel analyzers produce parallelized source code from standard source code. For more information about these packages and how to obtain them, contact your dealer or sales representative.
The compiler front end translates the source code into an intermediate tree representation. The compiler back end translates the intermediate code into object code. The language compilers share the same back end, which combines optimization and code generation in one phase. (For more information about optimization, see Chapter 4, “Optimizing Program Performance”).
The linker ld combines several object files into one, performs relocation, and resolves external symbols. The driver automatically runs ld unless you specify the -c option to skip the linking step.
When you compile or link programs, by default the compiler searches specific libraries depending on the compilation mode (shown in Table 1-2). Certain default libraries are automatically linked.
Table 1-2. Compiler Mode and Default Library Search Path
Mode | Path |
---|---|
o32 | /usr/lib, /lib, and /usr/local/lib |
n32 | /usr/lib32, /lib32, and /usr/local/lib |
64 | /usr/lib64, /lib64, and /usr/local/lib |
Compiler drivers and their respective libraries are listed in Table 1-3.
Table 1-3. Compilers and Default Libraries
Compiler | Default Libraries |
---|---|
cc | libc.so |
CC | libC.so, libc.so, libCsup.so |
f77, f90 | libftn.so, libftn90.so, libc.so, libm.so |
To see the various utilities a program passes through during compilation, invoke the appropriate driver with the -show option.
Figure 1-1 shows compilation flow from source file to executable file (a.out).