Updated 2004/12/10

Sun[tm] Studio 10: C 5.7 Compiler Readme

Contents

  1. Introduction
  2. About the Sun Studio 10, C 5.7 Compiler
  3. New and Changed Features
  4. Software Corrections
  5. Problems and Workarounds
  6. Limitations and Incompatibilities
  7. 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

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.html

Note - 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.

Sun Studio 10 C 5.7 Changed Features

Sun Studio 9 C 5.6 Compiler New Features

The New -xarch Default: v8plus

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 Expansion

The -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:

You can determine which combination of the new -xarch, -xchip, and -xtarget flags is appropriate for your needs by following these guidelines:

For more information on -xarch, -xtarget, and -xchip, see the C man page cc(1).

The New -xlibmopt and -xnolibmopt Options

The -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 Option

Use 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 Option

Use 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 -xpch

This 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 Functions

Inline 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 Initializers

Designated 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:

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 lint

This 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:

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:

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:

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.


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.