Updated 2004/12/10 |
Sun[tm] Studio 10: C 5.7 Compiler Readme |
Contents
- Introduction
- About the Sun Studio 10, C 5.7 Compiler
- New and Changed Features
- Software Corrections
- Problems and Workarounds
- Limitations and Incompatibilities
- Documentation Errors
A. Introduction
This document contains information about the Sun Studio 10, C 5.7 Compiler. This document describes the new features, software corrections, known problems, limitations, and incompatibilities addressed by this release. Information in this document overrides information in the manuals for this release.
Product Documentation
- Release Notes: Available on the Sun Studio 10 web site at http://developers.sun.com/tools/cc/documentation/ss10_docs/release_notes.html. Information in the release notes updates and extends information in all readme files.
- Sun Studio 10 Documentation: Product man pages, HTML versions of readmes, and manuals can be accessed from /installation_directory/SUNWspro/docs/index.html. The default installation directory is /opt. You can access the following documents as well as others from the index.html page:
- C User's Guide
- C++ User's Guide
- Math Libraries Readme
- Numerical Computation Guide
- Incremental Link Editor Readme
- Sun Performance Library Readme
- Sun Performance Library Reference Manual
- Sun Performance Library User's Guide for Fortran and C
- Integrated Development Environment (IDE) Documentation: Online help for all components of the Sun Studio 10 IDE can be accessed from the Help menu in the IDE.
- Developer Resources Portal: For technical articles, code samples, documentation, and a knowledge base, see the developers portal at http://developers.sun.com/prodtech/cc.
To view the text version of this readme, type the following at a command prompt:
cc -xhelp=readme
To view the HTML version of this readme, point your browser to the default installation directory:
file:/opt/SUNWspro/docs/index.htmlNote - If your Sun Studio 10 software is not installed in the default /opt directory, ask your system administrator for the equivalent path on your system.
B. About the Sun Studio 10: C 5.7 Compiler
This release of the C compiler is available on the Solaris[tm] Operating System: versions 8, 9, and 10.
This compiler supports most of the language features specified in ISO/IEC 9899:1999, Programming Language - C on operating systems earlier than Solaris 10. On Solaris 10, this compiler is in full compliance with the C99 standard when you specify -xc99=all,lib. This compiler also conforms with the ISO/IEC 9899:1990, Programming Languages - C standard.
The 64-bit SPARC architecture features in this development release are support for the C International Standard and for -xarch=v9.
C. New and Changed Features
This section describes the new and changed features for both the Sun Studio 9 C 5.6 compiler and the Sun Studio 10 C 5.7 compiler.
Sun Studio 10 C 5.7 Compiler New Features
This release supports the compilation of 64-bit code for Solaris x86 platforms. The following is a brief summary of the new option flags. See the cc(1) man page for complete descriptions of -xarch and -xtarget options.
A new -xarch option, -xarch=amd64, specifies compilation for the 64-bit AMD instruction set.
A new -xtarget option, -xtarget=opteron, specifies the -xarch, -xchip, and -xcache settings for 32-bit AMD compilation.
You must specify -xarch=amd64 to the right of -fast and -xtarget on the command line to generate 64-bit code. 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. All the current -xtarget values, with the exception of -xtarget=native64 and -xtarget=generic64, result in 32-bit code. You must specify -xarch=amd64 after (to the right of) -fast or -xtarget to compile 64-bit code, as in:
cc -fast -xarch=amd64orcc -xtarget=opteron -xarch=amd64The existing -xarch=generic64 option now supports the x86 platform in addition to the traditional SPARC platform.
The C compiler now predefines __amd64 and __x86_64 when you specify -xarch=amd64.
A new x86-only flag for the -xregs option, -xregs=[no%]frameptr, lets you use the frame-pointer register as an unallocated callee-saves register to increase the run-time performance of applications. See the cc.1 man page for full details.
Sun Studio 10 C 5.7 Changed Features
-xopenmp=stubs
This option is no longer supported. An OpenMP stubs library is provided for users' convenvience. To compile an OpenMP program that calls OpenMP library functions but ignores the OpenMP pragmas, compile the program without an -xopenmp option, and link the object files with the libompstubs.a library. For example,
% cc omp_ignore.c -lompstubs
Linking with both libompstubs.a and the OpenMP runtime library libmtsk.so is unsupported and may result in unexpected behavior.Sun Studio 9 C 5.6 Compiler New Features
The New -xarch Default: v8plus
- Improved performance through new defaults for the -xarch, -xcode, -xmemalign, and -xprefetch options and through new expansions for the -fast and -O options.
- New -xarch, -xtarget, and -xchip, flags as well as the new -flteval option on the x86 platform.
- Improved runtime performance through the -xlibmopt, -xnolibmopt, -xipo_archive, and -xprefetch_auto_type options.
- Improved compile-time performance through automatically-generated precompiled-headers with -xpch .
- Expanded SPARC support with new -xchip and -xtarget flags.
- Full support on Solaris 10 for 1999 C ISO features including extern inline functions, designated initializers, and universal character names.
- New security checks through the lint utility.
The default architecture for which the C compiler produces code is now v8plus (UltraSPARC). Support for v7 will be dropped in a future release.
The new default yields higher run-time performance for nearly all machines in current use. However, applications that are intended for deployment on pre-UltraSPARC computers no longer execute by default on those computers. Compile with -xarch=v8 to ensure that the applications execute on those computers.
If you want to deploy on v8 systems, you must specify the option -xarch=v8 explicitly on every compiler command line as well as any link-time commands. The provided system libraries run on v8 architectures.
If you want to deploy on v7 systems, you must specify the option -xarch=v7 explicitly on every compiler command line as well as any link-time commands. The provided system libraries use the v8 instruction set. For the Sun Studio 10 release, the only supported operating system for v7 is the Solaris 8 release. When a v8 instruction is encountered, the Solaris 8 operating system interprets the instruction in software. The program runs, but performance is degraded.
For x86, -xarch defaults to generic. Note that -fast on x86 expands to -xarch=native.
For more information on -xarch, see the C man page cc(1).
The New -xcode Default(SPARC) The default on V9 is -xcode=abs44. The default on V8 is still -xcode=abs32.
For more information on -xcode, see the C man page cc(1) .
The New -xmemalign Default(SPARC) The default of -xmemalign is -xmemalign=8i for all v8 architectures. The default for all v9 architectures is -xmemalign=8s .
For more information on -xmemalign, see the C man page cc(1) .
The New -xprefetch Default(SPARC) The default of -xprefetch is now -xprefetch=auto,explicit. This change adversely affects applications that have essentially non-linear memory access patterns. To disable the change, specify -xprefetch=no%auto,no%explicit.
For more information on -xprefetch, see the C man page cc(1) .
The New -fast ExpansionThe -fast option now includes the new option -xlibmopt in its expansion.
The New -O Expansion(SPARC and x86) The -O macro now expands to -xO3 instead of -xO2.
The change in default yields higher run-time performance. However, -x03 may be inappropriate for programs that rely on all variables being automatically considered volatile. Typical programs that might have this assumption are device drivers and older multi-threaded applications that implement their own synchronization primitives. The work around is to compile with -xO2 instead of -O.
For more information on -O, see the C man page cc(1) .
New -xarch, -xtarget, and -xchip Flags on the x86 Platform.The C compiler supports new flags for -xarch, -xtarget, and -xchip on Intel. These new flags are designed to take advantage of Pentium 3 and Pentium 4 chips in combination with Solaris software support for SSE and SSE2 instructions on the x86 platform. The new options are as follows:
- -xchip=pentium3 optimizes for Pentium 3 style processor.
- -xchip=pentium4 optimizes for Pentium 4 style processor.
- -xtarget=pentium3 sets -xarch=sse, -xchip=pentium3, and -xcache=16/32/4:256/32/4.
- -xtarget=pentium4 sets -xarch=sse2, -xchip=pentium4, and -xcache=8/64/4:256/128/8.
- -xarch=sse adds the SSE instruction set to the pentium_pro instruction set.
- -xarch=sse2 adds the SSE2 instruction set to those permitted by SSE.
SPECIAL NOTE
Programs that are compiled with -xarch={sse | sse2} to run on Solaris x86 SSE/SSE2 Pentium 4-compatible platforms must be run only on platforms that are SSE/SSE2 enabled. Running such programs on platforms that are not SSE/SSE2-enabled could result in segmentation faults or incorrect results occurring without any explicit warning messages. Patches to the Solaris operating system and compilers to prevent execution of SSE/SSE2-compiled binaries on platforms not SSE/SSE2-enabled might be made available at a later date.OS releases starting with Solaris 9 4/04 software are SSE/SSE2-enabled on Pentium 4-compatible platforms. Earlier versions of Solaris software are not SSE/SSE2-enabled.
This warning extends also to programs that employ .il inline assembly language functions or __asm() assembler code that utilize SSE/SSE2 instructions.
If you compile and link in separate steps, always link using the compiler and with -xarch={sse | sse2} to ensure that the correct startup routine is linked.
You can determine which combination of the new -xarch, -xchip, and -xtarget flags is appropriate for your needs by following these guidelines:
Are you building on a Pentium 3 or Pentium 4 machine that is running a version of Solaris software that is earlier than Solaris 9 4/04 software and are you specifying -fast, -xarch=native or -xtarget=native?
If so, the compiler makes the following expansions:
-xarch is set to pentium_pro (not pentium3 or pentium4 as you might expect) because versions of Solaris 9 software earlier than Solaris 9 4/04 software do not support SSE and SSE2 instructions.
Note: You can specify -xarch=sse or -xarch=sse2 despite using these versions of Solaris software, but you must run the executable that results from your build on a machine that is running Solaris 9 4/04 or later because these versions of Solaris software support SSE and SSE2 instructions.
- -xchip is set to pentium3 or pentium4 as appropriate.
-xcache is set to 16/32/4:256/32/4 for a Pentium 3 processor or 8/64/4:256/128/8 for a Pentium 4 processor.
Are you building on a Pentium 3 or Pentium 4 machine running Solaris 9 4/04 software or later and are you specifying -fast, -xarch=native or -xtarget=native?
If so, the compiler makes the following expansions:
- -xarch is set to sse for Pentium 3 or sse2 for Pentium 4.
- -xchip is set to pentium3 or pentium4 as appropriate.
- -xcache is set to 16/32/4:256/32/4 for Pentium 3 or 8/64/4:256/128/8 for Pentium 4.
For more information on -xarch, -xtarget, and -xchip, see the C man page cc(1).
The New -xlibmopt and -xnolibmopt OptionsThe -xlibmopt option enables the compiler to use a library of optimized math routines. You must use default rounding mode by specifying -fround=nearest when you specify this option. The math routine library is optimized for performance and usually generates faster code. The results may be slightly different from those produced by the normal math library. If so, they usually differ in the last bit.
You can explicitly turn off this library by specifying the new -xnolibmopt option on the command line.
For more information on -xlibmopt, and -xnolibmopt, see the C man page cc(1).
The New -xipo_archive OptionUse the new -xipo_archive option to enable the compiler to optimize object files that are passed to the linker with object files that were compiled with -xipo and that reside in the archive library (.a) before producing an executable. Any object files contained in the library that were optimized during the compilation are replaced with their optimized version.
For more information on the -xipo_archive option, see the cc(1) man page.
The New -xprefetch_auto_type OptionUse the new -xprefetch_auto_type option to generate indirect prefetches for the loops indicated by the option -xprefetch_level=[1|2|3] in the same fashion that the prefetches for direct memory accesses are generated.
Options such as -xdepend, -xrestrict, and -xalias_level can improve the optimization benefits of -xprefetch_auto_type. They affect the aggressiveness of computing the indirect prefetch candidates and therefore the aggressiveness of the automatic indirect prefetch insertion because they help produce better memory alias disambiguation information.
For more information on the -xprefetch_auto_type option, see the cc(1) man page.
Automatically Generated Precompiled Headers With -xpchThis release of the C compiler expands the precompiled header facility to include an automatic capability on the part of the compiler to generate the precompiled header file. You still have the option to manually generate the precompiled header file, but if you are interested in the new capability of the compiler, see the explanation for the -xpch option in the cc(1) man page for more information. See also the CCadmin(1) man page.
Expanded SPARC Support With New -xchip and -xtarget Flags.(SPARC) The -xchip and -xtarget options now support ultra3i and ultra4 as values so you can build applications that are optimized for the UltraSPARC IIIi and UltraSPARC IV processors.
Support For Extern Inline FunctionsInline function definitions and extern inline functions now work as specified by the 1999 C ISO standard.
An inline function definition is a function defined with the keyword inline, and without either the keywords static or extern, and all prototypes appearing within the source (or included files) also contain the keyword inline without either the keywords static or extern.
An inline function definition does not provide an external definition for the function. Any function call appearing in the source file containing an inline definition will either be satisfied by inlining the function definition at the call site, or by a reference to an externally defined function.
The compiler will only inline calls to inline definitions when -xO3 or higher has been specified, and the compiler optimizer believes it is profitable to do so. Otherwise a call to an external function will be made. Therefore any program containing inline definitions should link with an object file containing an extern function definition.
Use of both the keywords extern and inline with a function definition (or on any prototype in the file continuing the function definition) will result in an external function being defined in that object file. To be compatible with C++ linking with objects that contain multiple definitions of extern inline functions will result in the linker choosing just one of these functions to satisfy any external references.
To get standard conforming behavior, old code must be recompiled using the current compiler. However, if you have instances of extern inline function definitions in old C and C++ binaries (pre C/C++ 5.6) and you wish to link those binaries with new C and C++ binaries without changing the behavior of the old binaries, specify -features=no%extinl.
For more information on -features, see the C man page cc(1) .
Designated InitializersDesignated initializers provide a mechanism for initializing sparse arrays, a practice common in numerical programming.
Designated initializers allows initialization of sparse structures, common in systems programming, and allows initialization of unions via any member, regardless of whether or not it is the first member.
Consider these examples. This first example shows how designated initializers are used to initialize an array:
enum { first, second, third }; const char *nm[] = { [third] = "third member", [first] = "first member", [second] = "second member", };This example demonstrates how designated initializers are used to initialize the fields of a struct object:
division_t result = { .quot = 2, .rem = -1 };This example shows how designated initializers can be used to initialize complicated structures that might otherwise be misunderstood:
struct { int z[3], count; } w[] = { [0].z = {1}, [1].z[0] = 2 };An array can be created from both ends by using a single designator:
int z[MAX] = {1, 3, 5, 7, 9, [MAX-5] = 8, 6, 4, 2, 0};If MAX is greater than ten, the array will contain zero-valued elements in the middle; if MAX is less than ten, some of the values provided by the first five initializers will be overridden by the second five.Any member of a union can be initialized:
union { /* ... */ } u = { .any_member = 42 };Universal Character Names (UCN)UCN allows the use of any character in a C source, not just English characters. A UCN has the format:
- \u 4_hex_digits_value
- \U 8_hex_digits_value
A UCN must not specify a value less than 00A0 other than 0024 ($), 0040 (@), or 0060 (?), nor a value in the range D800 through DFFF inclusive.
UCN may be used in identifiers, character constants, and string literals to designate characters that are not in the C basic character set.
The UCN \Unnnnnnnn designates the character whose eight-digit short identifier (as specified by ISO/IEC 10646 is nnnnnnnn. Similarly, the universal character name \unnnn designates the character whose four-digit short identifier is nnnn (and whose eight-digit short identifier is 0000nnnn.
The New -flteval Option(Intel) Use this option to control how floating point expressions are evaluated.
For more information on the -flteval option, see the cc(1) man page.
New Security Checks with lintThis release of the lint utility features a new security-checking facility. You can use the new -errsecurity option before compilation to check your code for security liabilities.
-errsecurity[={core, standard, extended, %none}]
lint -errsecurity=core This level checks for source code constructs that are almost always either unsafe or difficult to verify. Checks at this level include:
- Use of variable format strings with the printf() and scanf() family of functions
- Use of unbounded string (%s) formats in scanf() functions
- Use of functions with no safe usage: gets(), cftime(), ascftime(), creat()
- Incorrect use of open() with O_CREAT
Consider source code that produces warnings at this level to be a bug. The source code in question should be changed. In all cases, straightforward safer alternatives are available.
lint -errsecurity=standard This level includes all checks from the core level plus constructs that may be safe, but have better alternatives available. This level is recommended when checking newly-written code. Additional checks at this level include:
- Use of string copy functions other than strlcpy()
- Use of weak random number functions
- Use of unsafe functions to generate temporary files
- Use of fopen() to create files
- Use of functions that invoke the shell
Replace source code that produces warnings at this level with new or significantly modified code. Balance addressing these warnings in legacy code against the risks of destabilizing the application.
lint -errsecurity=extended This level contains the most complete set of checks, including everything from the Core and Standard levels. In addition, a number of warnings are generated about constructs that may be unsafe in some situations. The checks at this level are useful as an aid in reviewing code, but need not be used as a standard with which acceptable source code must comply. Additional checks at this level include:
- Calls to getc() or fgetc() inside a loop
- Use of functions prone to pathname race conditions
- Use of the exec() family of functions
- Race conditions between stat() and other functions
Review source code which produces warnings at this level to determine if the potential security issue is present.
If you do not specify a setting for -errsecurity, the compiler sets it to -errsecury=%none. If you do specify -errsecurity, but not an argument, the compiler sets it to -errsecurity=standard.
D. Software Corrections
There is no new information at this time.
E. Problems and Workarounds
This section discusses known software problems and possible workarounds for those problems. For updates or patches, check the updated information at http://developers.sun.com/prodtech/cc/support_index.html. Also check the release notes at http://developers.sun.com/tools/cc/documentation/ss10_docs/release_notes.html
There is no new information as of this printing.
F. Limitations and Incompatibilities
This section discusses limitations and incompatibilities with systems or other software. For last minute information for this Sun Studio 10 release, see the Sun Studio 10 Release Notes. The release notes are on the Sun Studio 10 web site at http://developers.sun.com/tools/cc/documentation/ss10_docs/release_notes.html.
x86 only: Compiling and Linking in Separate Steps With-xipo and -xO
If you are specifying -xipo and also specifying optimization at -xO4 or -xO5, make sure you specify the same level of optimization at both compile time and link time. For example, you can specify the following command
cc foo.c -xipo -xO4 -cto produce the foo.o object file. Later, when you link in a separate step, make sure the level of optimiztion is the same:cc foo.o -xipo -xO4
G. Documentation Errors
There is no new information at this time.
Copyright © 2004 Sun Microsystems, Inc., All rights reserved. Use is subject to license terms.