Introduction to the C Compiler
|
This chapter provides information about the C compiler, including operating environments, standards conformance, organization of the compiler, and C-related programming tools.
1.1 Standards Conformance
The compiler conforms to the following standards:
- The ISO/IEC 9899:1990, Programming Languages - C standard. For information on implementation-specific behavior, see Appendix C.
- The FIPS 160 standard.
This release also supports some of the features specified in the following standard:
- The ISO/IEC 9899:1999, Programming Language - C standard. For more information on supported features, see Appendix D.
Because the compiler also supports traditional K&R C (Kernighan and Ritchie, or pre-ANSI C), it can ease your migration to ISO C.
The term C99 used in this book refers to the ISO/IEC 9899:1999 C programming language. There term C90 refers to the ISO/IEC 9899:1990 C programming language.
1.2 C Readme File
The C compiler's readme file highlights important information about the compiler, including:
- Information discovered after the manuals were printed
- New and changed features
- Software corrections
- Problems and workarounds
- Limitations and incompatibilities
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.3 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:
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.4 New Features
The C compiler introduces the following new features in this release.
1.4.1 General Enhancements
- Linker mapfiles are no longer needed for variable scoping: -xldscope
There are now two different ways you can control the exporting of symbols in dynamic libraries. This facility is called linker scoping, and has been supported by linker mapfiles for some time. First, you can now embed new declaration specifiers in code.
By embedding __global, __symbolic, and __hidden directly in code, you no longer need to use mapfiles. Second, you can override the default setting for variable scoping by specifying -xldscope at the command line.
For details, see Linker Scoping Specifiers and -xldscope={v}.
- Implementation of additional C99 features
This release adds support for the following ISO/IEC 9899:1999 (referred to as C99 in this document) features. The following list only details the C99 features implemented in this release, which is a subset of all the implemented C99 features. See Appendix D Supported Features of C99 for a complete listing of all C99 features implemented over the past and current release of the C compiler. The sub-section number of the C99 standard is listed for each item.
- 6.2.5 _Bool
- 6.2.5 _Complex type
This release supports a partial implementation of _Complex. You must link with -lcplxsupp on the Solaris 7 operating environment, the Solaris 8 operating environment, and the Solaris 9 operating environment. Static initialization of _Complex data does not yet work.
- 6.3.2.1 Conversion of arrays to pointers not limited to lvalues
- 6.4.4.2 Hexadecimal floating-point literals
- 6.5.2.5 Compound literals
- 6.7.2 Type specifiers
- 6.10.6 STDC pragmas
- 6.10.8 __STDC_IEC_559 and __STDC_IEC_559_COMPLEX macros
- Support for the VIS
Developers Kit: -xvis (SPARC)
Use the -xvis=[yes|no] option when you are using the assembly-language templates defined in the VIS instruction set Software Developers Kit (VSDK).
The VIS instruction set is an extension to the SPARC v9 instruction set. Even though the UltraSPARC processors are 64-bit, there are many cases, especially in multimedia applications, when the data are limited to eight or 16 bits in size. The VIS instructions can process four 16-bit data with one instruction so they greatly improve the performance of applications that handle new media such as imaging, linear algebra, signal processing, audio, video and networking.
For more information on the VSDK, see http://www.sun.com/processors/vis. See -xvis.
- Larger default stack size for slave threads
The default stack size for slave threads is now larger. All slave threads have the same stack size, which is four megabytes for 32-bit applications and eight megabytes for 64-bit applications by default. The size is set with the STACKSIZE environment variable.
See STACKSIZE.
- Improved -xprofile (SPARC)
The -xprofile option offers the following improvements:
- Support for profiling shared libraries
- Thread-safe profile collection using -xprofile=collect -mt
- Improved support for profiling multiple programs in a single profile directory.
With -xprofile=use, the compiler can now find profile data in profile directories that contain data for multiple object files with nonunique basenames. For cases where the compiler is unable to find an object file's profile data, the compiler provides a new option -xprofile_pathmap=collect-prefix: use-prefix.
See -xprofile=p and -xprofile_pathmap.
- Support for UTF-16 string literals: -xustr
Specify -xustr=ascii_utf16_ushort if you need to support an internationalized application that uses ISO10646 UTF-16 string literals. This option enables recognition of the U"ASCII_string" string literals as an array of type unsigned short.
See -xustr={ascii_utf16_ushort|no}.
See -Xustr={ascii_utf16_ushort|no} for the equivalent option to the lint utility.
1.4.2 Faster Compilation
- Faster profiling: -xprofile_ircache (SPARC)
Use -xprofile_ircache[=path] with -xprofile=collect|use to improve compilation time during the use phase by reusing compilation data saved from the collect phase.
With large programs, compilation time in the use phase can improve significantly because the intermediate data is saved. Note that the saved data could increase disk space requirements considerably.
See -xprofile_ircache[=path].
- Precompiled headers: -xpch
This release of the compiler introduces the new precompiled-header feature. The precompiled-header file is designed to reduce compile time for applications whose source files share a common set of include files containing a large amount of source code. A precompiled header works by collecting information about a sequence of header files from one source file, and then using that information when recompiling that source file, and when compiling other source files that have the same sequence of headers. You can take advantage of this feature through the -xpch and -xpchstop options in combination with the #pragma hdrstop directive.
See -xpch=v, -xpchstop=file, and hdrstop.
- Using multiple processors: -xjobs=n (SPARC)
Specify the -xjobs=n option to set how many processes the compiler creates to complete its work. This option can reduce the build time on a multi-cpu machine. Currently, -xjobs works only with the -xipo option. When you specify -xjobs=n, the interprocedural optimizer uses n as the maximum number of code generator instances it can invoke to compile different files.
See -xjobs=n.
1.4.3 Improved Performance
- Improving run-time with linker supported thread-local storage: -xthreadvar
Use the new linker supported thread-local storage facility of the compiler to do the following:
- Utilize a fast implementation for the POSIX interfaces for allocating thread-specific data.
- Convert multi-process programs to multi-thread programs.
- Port Windows applications using thread-local storage to Solaris operating environments.
- Utilize a fast implementation for the thread private variables in OpenMP.
Thread-local storage is now available in the compiler through the declaration of thread-local variables. The declaration consists of a normal variable declaration with the addition of the variable specifier __thread and the command line option -xthreadvar.
For more information, see Thread Local Storage Specifier and -xthreadvar[=o].
- Improving run-time by reducing page faults: -xF
Use the new functionality of -xF to enable the optimal reordering of variables and functions by the linker. This can help solve the following problems which negatively impact run-time performance:
- Cache and page contention caused by unrelated variables that are near each other in memory.
- Unnecessarily large work-set size as a result of related variables which are not near each other in memory.
- Unnecessarily large work-set size as a result of unused copies of weak variables that decrease the effective data density.
- Improving run-time: -xlinkopt (SPARC)
The C++ compiler can now perform link-time optimization on relocatable object files when you specify the -xlinkopt command.
Specify -xlinkopt and the compiler performs some additional optimizations at link time without modifying the .o files that are linked. The optimizations appear only in the executable program. The -xlinkopt option is most effective when you use it to compile the whole program, and with profile feedback.
See -xlinkopt[=level].
- Improving run-time: -xpagesize=n (SPARC)
Set the page size in memory for the stack. n can be 8K, 64K, 512K, 4M, 32M, 256M, 2G, 16G, or default. You must specify a valid page size for the Solaris operating environment on the target platform, as returned by getpagesize(3C). If you do not specify a valid page size, the request is silently ignored at run-time. You can use pmap(1) or meminfo(2) to determine page size at the target platform.
Note - This feature is only available on Solaris 9 software. A program compiled with this option will not link in earlier Solaris operating environments.
|
This option is a macro for -xpagesize_stack and -xpagesize_heap.
See -xpagesize=n, -xpagesize_heap=n, and -xpagesize_stack=n.
- Hardware counter-based profiling: -xhwcprof (SPARC)
Use the -xhwcprof=[enable|disable] option to enable compiler support for hardware counter-based profiling.
When -xhwcprof is enabled, the compiler generates information that helps tools match hardware counter data reference and miss events with associated instructions. Corresponding data-types and structure-members may also be identified in conjunction with symbolic information (produced with -g). This information can be useful in performance analysis because it is not easily identified from profiles based on code addresses, source statements, or routines.
See -xhwcprof.
1.4.4 Easier Debugging
- Dwarf-format debugger-information: -xdebugformat
The C compiler is migrating the format of debugger information from the stabs format to the dwarf format as specified in DWARF Debugging Information Format. If you maintain software which reads debugging information, you now have the option to transition your tools from the stabs format to the dwarf format. The default setting for this release is -xdebugformat=stabs.
Use the -xdebugformat=dwarf option as a way of accessing the new format for the purpose of porting tools. There is no need to use this option unless you maintain software which reads debugger information, or unless a specific tool tells you that it requires debugger information in one of these formats.
See -xdebugformat=[stabs|dwarf].
- Support for debugging OpenMP programs: -xopenmp=noopt
If you are debugging an OpenMP program with dbx, compile with -g and -xopenmp=noopt so you can breakpoint within parallel regions and display the contents of variables.
See -xopenmp[=i].
1.5 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 A 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
[ 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
|
(SPARC) -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
|
(INTEL)
|
ube
|
Code generator
|
(INTEL)
|
ube_ipa
|
Interprocedure analyzer
|
(INTEL)
|
ld
|
Linker
|
|
ild
|
Incremental linker
|
(SPARC) -g, -xildon
|
mcs
|
Manipulate comment section
|
-mr
|
1.6 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 See Accessing Compiler Collection Documentation for more information.
C User's Guide
| 817-0924-10
|   
|
Copyright © 2003, Sun Microsystems, Inc. All rights reserved.