This chapter describes the SGI C++ compiler environment and contains the following major sections:
“The Compiler Programming Environment”, discusses the different elements included in the compiler environment.
“The SGI C++ Compilers”, discusses the compilers that SGI provides for IRIX 6.x systems.
“OpenMP API Multiprocessing Directives”, discusses the OpenMP features available with the MIPSpro C++ compilers.
“C++ Libraries”, discusses the C++ libraries in the SGI C++ environment.
“Debugging”, discusses the SGI C++ debugging environment.
|Note: The MIPSpro C++ compiler is based on the Edison Design Group (EDG) C++ Front End, Version 2.45.|
The compiling environment allows you to develop, debug, and run C++ codes on your computer system. It includes the following products:
A compiler, including the C++ front end, the language-independent optimizing back end, the linker, and other compiling elements.
The libraries. SGI supports the C++ Standard Library as well as the C library, including the interface for C++ embedded in such header files as cstdlib. Information on the individual C library functions can be found in the online man pages for each function.
An archiving tool. An archive library is a file that contains one or more routines in object file format (file.o). When a program calls an object file that is not explicitly included in the program, the linker, ld(1), looks for that object file in an archive library. The scheduler then loads only that object file, not the whole library, and loads it with the calling program.
The archiver creates and maintains archive libraries. It allows you to copy new objects into the library, replace existing objects in the library, move objects within the library, and copy individual objects from the library into individual object files. For more information on the archive library, see the ar(1) man page.
Object file tools, which allow you to disassemble object files into machine instructions, print information about archive files, and perform other tasks. For more information on these tools, see the following man pages: dis(1), elfdump(1), file(1), nm(1), size(1), and strip(1).
Online documentation utilities. The man(1) command allows you to retrieve online man pages. Prose reference text, such as this manual, can be retrieved through the Web browser supported at your site. See http://www.techpubs.sgi.com for all online documentation.
Modules. The compiler can be installed with the modules utility. This utility allows you to access different versions of the compiler and runtime environment. For more information on using the modules utility, see the modules(1) man page or enter the following command:
% relnotes modules
The message system. This system lets you obtain more comprehensive explanations of messages generated by the compiler and tools in the compiling environment. When a message condition occurs, both a message number and a verbal summary of the problem is generated. If you need more information on the error condition described in the summary, you can enter the explain(1) command to retrieve a more detailed description.
Environment variables. For more information, see the pe_environ(5) man page, which describes many environment variables that can be used when compiling C++ programs.
The SGI C++ environment provides three C++ compilers for IRIX 6.x systems. As shown in Figure 1-1, there are two MIPSpro C++ compilers, a 32-bit version and a 64-bit version. They are known as the N32 and 64 compilers because of the application binary interfaces (ABIs) they generate. These compilers implement the C++ dialect as documented in the the ANSI/ISO C++ standard (hereafter referred to as “The Standard”).
The 32-bit ucode C++ compiler (O32 ABI) is also available. The O32 compiler is an older compiler that is no longer being enhanced. It is included to support legacy code. The C++ compiler based on Cfront is now unavailable and is no longer supported. See the C++ release notes for the latest information about the status of these compilers.
32-bit native MIPSpro compiler. Generates N32 ABI objects.
64-bit native MIPSpro compiler. Generates 64 ABI objects.
|CC -o32 or CC -32|
32-bit native ucode compiler. Generates O32 ABI objects.
For more information about the compilers and ABIs, see the CC(1) and ABI(5) man pages, or the MIPSpro N32/64 Compiling and Performance and Tuning Guide.
The focus of discussion in this document centers on the 32-bit and the 64-bit native MIPSpro compilers. For details about the 32-bit ucode compiler, see the MIPS O32 Compiling and Performance Tuning Guide.
Supported instruction set architectures (ISAs)
Size of the address space
Object file formats
Number of registers
The three ABIs that are relevant to MIPSpro C++ are N32, 64, and O32. This document discuss the N32 and 64 ABIs. See Table 1-1, for a summary of these ABIs, their features, and their relationships to the MIPS ISAs. The O32 ABI is not discussed in detail in this document.
Alternate ISA (Option)
MIPS IV (-mips4)
MIPS III (-mips3)
Floating Point Registers
The instruction set architecture (ISA) is the set of instructions recognized by a processor. It is the interface between the lowest level software and the processor. Table 1-2 shows the MIPS ISAs and the MIPS processors for which they were designed.
R5000, R8000, R10000, R12000, R14000
R4000 (Rev 2.2 and later), R4400, R46000
R4000 (Rev. 2.1 and earlier)
Table 1-1 and Table 1-2 are intended to give an overview of ABIs and MIPS ISAs. They do not show details (such as an R10000-based, IRIX 6.3 Silicon Graphics O2 system does not support 64 MIPS IV, but an R10000-based, IRIX 6.4 Silicon Graphics Octane system does support it).
For more information about ABIs and ISAs, see the release notes for your system, the MIPSpro N32/64 Compiling and Performance and Tuning Guide, the MIPSpro N32 ABI Handbook and the cc(1) and ABI(5) man pages.
The following are the default compilation modes for the different supported ABIs:
CC -64 is -mips4
CC -n32 is -mips3
SGI recommends that most of your development be for the N32 ABI: -n32 -mips3 for R4x00 systems and -n32 -mips4 for R5000, R8000, R10000, and R12000 systems. This gives your program access to the full MIPS III instruction set for R4x00 systems. On systems that use the R5000 or above, it allows your program to use the MIPS IV instruction set with the lower overhead of a 32-bit address space. You can reserve the higher overhead -64 -mips4 option for those applications that need the 64-bit address space on R8000, R10000, and R12000 systems.
The general relationship between the N32 and 64 ABIs, ISAs, and the CPUs that can run them is shown in Table 1-3. Again, because of system variations, there are some exceptions to the combinations shown. Consult your system's man pages and release notes for more information.
R14000, R12000, R10000, R8000, R5000
R12000, R10000, R8000
R10000, R8000, R5000, R4600, R4400, R4000 (>=Rev. 2.2)
|Note: The objects of one ABI are incompatible with those of another; they cannot be linked together.|
See the MIPSpro N32 ABI Handbook for a primer on N32.
See the MIPSpro 64-Bit Porting and Transition Guide for more information on N32 and 64 compilers.
MIPSpro C and C++ compilers support directives based on the OpenMP C/C++ Application Program Interface (API) standard. Programs that use these directives are portable and can be compiled by other compilers that support the OpenMP standard.
To enable recognition of the OpenMP directives, specify -mp on the cc or CC command line.
In addition to directives, the OpenMP C/C++ API describes several library functions and environment variables. Information on the library functions can be found on the omp_lock(3), omp_nested(3), and omp_threads(3) man pages. Information on the environment variables can be found on the pe_environ(5) man page.
See the MIPSpro C and C++ Pragmas manual for definitions and details about how to use the OpenMP #pragma directives.
In addtion to the compiler itself, the MIPSpro C++ product includes the C++ Standard Library, as described in Clauses 17-27 of the Standard. It consists of the following components:
The runtime library, packaged as the dynamic shared object libC.so, provides support for language features such as storage allocation and deallocation, exception handling, and runtime type identification.
The Standard Template Library (STL) comprises the headers that support the standard containers, iterators, and algorithms described in Clauses 23-25 of the Standard.
The iostream, string, and locale libraries provide components for manipulation of character and wide character strings and input/output, including interationalization support. These components are made into templates and are packaged primarily as standard headers, but there is a runtime component packaged as the dynamic shared object libCio.so.
The valarray and complex components provide support for potentially parallelizable vector arithmetic and for complex numbers, respectively.
MIPSpro C++ also provides the standard C headers, which are the interface between C++ and the C library. For backward compatibility, MIPSpro C++ continues to provide the old iostream and complex libraries, but their use is deprecated and only limited support is provided for them.
SGI also provides the C99 library of extended functions for version 7.4 (and later versions) of the MIPSpro compilers. The C99 library includes the following features:
_bool, _complex, and _imaginary data types
support for the inline keyword
variable declaration in for loops
support for compound literals
support for the _func_ predefined identifier
use of designated initializers
support for the restrict keyword
See the release notes provided with your compiler for a detailed list of C99 features.
For general information about the Standard Template Library (STL) (a library of container classes, algorithms, and iterators for generic programming), see the HTML document available at http://www.sgi.com/tech/stl/.
You can debug your C++ programs by using dbx (a source-level debugger for C, C++, Fortran, and assembly language) or the MIPSpro WorkShop Debugger (a graphical, interactive, source-level debugging tool). For more information on the different available debugging tools, see the ProDev WorkShop: Overview.