C H A P T E R  1

Introduction to the C Compiler

This chapter provides information about the following:


1.1 New Features and Functionality of the Sun Studio 10 C 5.8 Compiler

This section provides a brief overview of the new C compiler features and functionality introduced in the Sun Studio 10 C 5.8 Compiler release. For specific explanations, follow the cross references provided for each item.

The -xarch option now supports the following new flags for development on the x86 platform: amd64a, pentium_proa, ssea, sse2a. See -xarch=isa for more information.

The -xpagesize, -xpagesize_heap, -xpagesize_stack options are now enabled for x86 platforms as well as SPARC. See -xpagesize=n.

The new -xmodel option lets you specify the kernel, small, or medium memory models on the 64-bit AMD architecture. If the size of your global and static variables exceeds two gigabytes, specify -xmodel=medium. Otherwise, use the default -xmodel=small setting. See -xmodel=[a] for more information.

This release supports intrinsic functions for SSE2 128-bit XMM register integral media-instructions. Include the sunmedia_intrin.h header file in the source code and specify the -xbuiltin option to take advantage of these functions. Furthermore, these intrinsic functions require SSE2 support so specify options such as

          -xarch=sse2, -xarch=amd64, or -xtarget=opteron.

Essentially, the compiler generates inline code for these instrinsic functions. This is easier than manipulating the instructions through assembly language and it can be optimized by the compiler.

For more information about intrinsics, explanations for the function prototypes contained in the header files, and the data types used by these functions, see the 'Intel C++ Intrinsics Reference' section of the Intel(R) C++ Compiler for Linux Systems manual.

The -xvector option enables automatic generation of calls to the vector library functions and/or the generation of the SIMD (Single Instruction Multiple Data) instructions. See -xvector[=a] for more information.

A new -xbinopt option allows the compiler to prepare the binary file for further optimization by the binopt(1) binary optimizer. See -xbinopt={prepare|off} for more information.

The new -xtarget flags ultra3iplus, ultra4plus, and ultraT1 along with the new -xchip flags ultra3iplus, ultra4plus, and ultraT1 provide code generation for the UltraSPARC IIIiplus, UltraSPARC T1, and UltraSPARC IVplus processors. See -xchip[=c] and -xtarget=t for more information.

The C compiler now generates debugger information in the dwarf format by default. This change should be transparent, as the dbx and Performance Analyzer software readily accept and prefer the dwarf format. You can still generate debugger information in the stabs format by specifying -xdebugformat=stabs.

The syntax of the STACKSIZE environment variable has been enhanced to accept a units keyword for denoting the slave thread stacksize: B for Bytes, K for Kilo- bytes, M for Megabytes, G for Gigabytes.

For example, setenv STACKSIZE 8192 sets the slave thread stack size to 8 MB. 1235B sets the slave thread stack size for 1235 Bytes. 1235G sets it for 1235 Gigabytes. The default for an integer value without a suffix letter is still Kilobytes.

Autoscoping is now available for C programs. This feature is described in chapter 3 of the Sun Studio OpenMP API User's Guide.

There are two new pragmas in this release of the C compiler:

Use the c99 (implicit | no%implicit) pragma to find implicit function declarations.

Use the [no_]warn_missing_parameter_info pragma to find function declarations which contain no parameter-type information.


1.2 New Features and Functionality of the Sun Studio 10 C 5.7 Compiler

This section provides a brief overview of the new C compiler features and functionality introduced in the Sun Studio 10 C 5.7 Compiler release. For specific explanations, follow the cross references provided for each item.



Note - You must specify -xarch=amd64 to the right of -fast and -xtarget on the command line to generate 64-bit code. For example, specify cc -fast -xarch=amd64 or cc -xtarget=opteron -xarch=amd64. The new -xtarget=opteron option does not automatically generate 64-bit code. It expands to -xarch=sse2, -xchip=opteron, and -xcache=64/64/2:1024/64/16 which results in 32-bit code. The -fast option also results in 32-bit code because it is a macro which also defines -xtarget=native.




1.3 Standards Conformance

The term C99 used in this book refers to the ISO/IEC 9899:1999 C programming language. The term C90 refers to the ISO/IEC 9899:1990 C programming language.

This compiler supports most of the language features specified in the ISO/IEC 9899:1999, Programming Language - C standard on operating systems earlier than Solaris 10 software. This compiler is in full compliance with the C99 standard on Solaris 10 software when you specify -xc99=all,lib.

This compiler also conforms with the ISO/IEC 9899:1990, Programming Languages - C standard.

Because the compiler also supports traditional K&R C (Kernighan and Ritchie, or pre-ANSI C), it can ease your migration to ISO C.

For information on C90 implementation-specific behavior, see Appendix E.

For more information on supported C99 features, see Appendix D.


1.4 C Readme File

The C compiler's readme file highlights important information about the compiler, including:

To view the text version of the C readme file, type the following at a command prompt:


example% cc -xhelp=readme

To access the HTML version of the readme, in your Netscape Communicator 4.0 or compatible version browser, open the following file:

/opt/SUNWspro/docs/index.html

(If your C compiler-software is not installed in the /opt directory, ask your system administrator for the equivalent path on your system.) Your browser displays an index of HTML documents. To open the readme, find its entry in the index, then click the title.


1.5 Man Pages

Online manual (man) pages provide immediate documentation about a command, function, subroutine, or collection of such things.

You can display a man page by running the command:


example% man topic

Throughout the C documentation, man page references appear with the topic name and man section number: cc(1) is accessed with man cc. Other sections, denoted by ieee_flags(3M) for example, are accessed using the -s option on the man command:


example% man -s 3M ieee_flags


1.6 Organization of the Compiler

The C compilation system consists of a compiler, an assembler, and a link editor. The cc command invokes each of these components automatically unless you use command-line options to specify otherwise.

Appendix B discusses all the options available with cc.

The following figure shows the organization of the C compilation system.


FIGURE 1-1 Organization of the C Compilation System

Diagram showing the components of the C compilation system.[ D ]


The following table summarizes the components of the compilation system.


TABLE 1-1 Components of the C Compilation System

Component

Description

Notes on Use

cpp

Preprocessor

-Xs only

acomp

Compiler (preprocessor built in for non-Xs modes)

 

ssbd

Static synchronization bug detection

(SPARC)

iropt

Code optimizer

-O, -xO2, -xO3, -xO4, -xO5, -fast

fbe

Assembler

 

cg

Code generator, inliner, assembler

(SPARC)

ipo

Interprocedural Optimizer

(SPARC)

postopt

Postoptimizer

(SPARC)

ir2hf

Intermediate code translator

(x86)

ube

Code generator

(x86)

ube_ipa

Interprocedure analyzer

(x86)

ld

Linker

 

mcs

Manipulate comment section

-mr



1.7 C-Related Programming Tools

There are a number of tools available to aid in developing, maintaining, and improving your C programs. The two most closely tied to C, cscope and lint, are described in this book. In addition, a man page exists for each of these tools.

Other tools for source browsing, debugging and performance analysis are available. See Accessing Sun Studio Documentation for more information.