Updated 2001/06/07 |
Sun WorkShop[tm] 6 update 2 C Compiler Readme |
Contents
- Introduction
- About the C Compiler
- New Features
- Software Corrections
- Problems and Workarounds
- Limitations and Incompatibilities
- Documentation Errata
A. Introduction
This document contains last-minute information about the C compiler. This document describes the software corrections addressed by this release and lists known problems, limitations, and incompatibilities.
For installation-related and late-breaking information about this release, see the Sun WorkShop 6 update 2 Release Notes. Information in the release notes overrides information in all readme files.
To access the release notes and the full Forte[tm] Developer/Sun WorkShop[tm] documentation set, point your Netscape[tm] Communicator 4.0 or compatible browser to the documentation index (file:/opt/SUNWspro/docs/index.html).
To view the text version of this readme, type the following at a command prompt:
example% cc -xhelp=readmeTo access the HTML version of this readme, point your Netscape Communicator 4.0 or compatible browser to:
file:/opt/SUNWspro/docs/index.htmlNote - If your Sun WorkShop software is not installed in the /opt directory, ask your system administrator for the equivalent path on your system.
B. About the C Compiler
The Sun WorkShop 6 update 2 C (cc) compiler runs on SPARC[tm] processors running Solaris[tm] SPARC Platform Edition, and Intel processors running Solaris Intel Platform Edition, versions 2.6, 7, and 8. Information unique to one or more platforms is identified as "(SPARC)" or "(IA)."
This compiler is fully compliant with the ANSI/ISO C language and environment standard (ANSI/ISO 9899-1990), and it also supports traditional K&R C.
The 64-bit SPARC architecture features in this development release are support for the C International Standard and for -xarch=v9.
C. New Features
This section describes the new and changed features for this release of the Sun WorkShop 6 update 2 C compiler. In addition, it lists the new features that were introduced in the Sun WorkShop 6 and Sun WorkShop 6 update 1 releases of the C compiler.
- Sun WorkShop 6 update 2 New Features
- Sun WorkShop 6 update 1 New Features
- Sun WorkShop 6 New Features
Sun WorkShop 6 update 2 New Features
The Sun WorkShop 6 update 2 C compiler includes the following new and changed features.
- Interprocedural Optimization (-xipo) (SPARC)
- OpenMP (SPARC)
- Lint Support for Type-based Alias-Analysis
- Code Set Independence Via -xcsi
- Partial Support for C99 Standard
- Lint Support for Implemented C99 Features
- Identifying Whether a Plain char Is Signed
- New and Changed Values for -xchip and -xtarget
- Interprocedural Optimization (-xipo) (SPARC)
This new compiler flag performs whole-program optimizations by invoking an interprocedural analysis pass. Unlike -xcrossfile, -xipo performs optimizations across all object files in the link step, and is not limited to just the source files on the compile command.
-xipo is particularly useful when compiling and linking large multi-file applications. Object files compiled with this flag have analysis information compiled within them that enables interprocedural analysis across source and pre-compiled program files. However, analysis and optimization is limited to the object files compiled with -xipo, and does not extend to object files in the libraries.
-xipo is multiphased, so you need to specify -xipo for each step if you compile and link in separate steps.
In this example, compilation and linking occur in a single step:
cc -xipo -xO4 -o prog part1.c part2.c part3.cThe optimizer performs crossfile inlining across all three source files. This is done in the final link step, so the compilation of the source files need not all take place in a single compilation and could take place over a number of separate compilations, each specifying -xipo.In this example, compilation and linking occur in separate steps:
cc -xipo -xO4 -c part1.c part2.c cc -xipo -xO4 -c part3.c cc -xipo -xO4 -o prog part1.o part2.o part3.oThe object files created in the compilation steps have additional analysis information compiled within them to permit crossfile optimizations to take place at the link step.
A restriction is that libraries, even if compiled with -xipo do not participate in crossfile interprocedural analysis, as shown in this example:
cc -xipo -xO4 one.c two.c three.c ar -r mylib.a one.o two.o three.o ... cc -xipo -xO4 -o myprog main.c four.c mylib.aHere interprocedural optimizations are performed between one.c, two.c and three.c, and between main.c and four.c, but not between main.c or four.c and the routines on mylib.a. (The first compilation may generate warnings about undefined symbols, but the interprocedural optimizations are performed because it is a compile and link step.)
Other important information about -xipo:
- It requires an optimization level of at least -xO4.
- It conflicts with -xcrossfile. If you use these together, the result is a compilation error.
- Objects that are compiled without -xipo can be linked freely with objects that are compiled with -xipo.
- OpenMP (SPARC)
This release of the C compiler implements the OpenMP interface for explicit parallelization including a set of source code directives, run-time library routines, and environment variables with the following new option:
cc -xopenmp
Note: If you issue the -xopenmp option and optimization is not at -xO3 or higher, optimization is raised to -xO3 and a warning is issued.
You can view the OpenMP specifications at http://www.openmp.org/specs (Parallelization features require a Forte for High Performance Computing (HPC) license.)
- Lint support for type-based alias-analysis
The Lint program now support type-based alias-analysis through the following command:
- -Xalias_level[=l]
This option has the same defaults and arguments as cc -xalias_level. See cc.1 or The C User's Guide for more information.
- Code Set Independence Via -xcsi
-xcsi
Allows the C compiler to accept source code written in locales that do not conform to the ISO C source character code requirements. These locales include: ja_JP.PCK.
Note, the compiler translation phases required to handle such locales may result in significantly longer compile times. You should only use this option when you compile source files that contain source characters from one of these locales.
The compiler does not recognize source code written in locales that do not conform to the ISO C source character code requirements unless you issue -xcsi.
- Partial Support for C99 Standard
The -xc99 flag controls compiler recognition of the implemented features from the C99 standard (ISO/IEC 9899:1999, Programming Language - C).
-xc99=[%all|%none]
If you issue -xc99 without =%none, the compiler assumes -xc99=%all. -xc99=%all turns on recognition of the C99 features implemented so far.
Sun WorkShop 6 update 2 supports the following C99 features:
- C99 Keywords
The C99 standard introduces the following new keywords:
- inline
- restrict
- _Imaginary
- _Complex
- _Bool
The compiler issues a warning if you use these keywords as identifiers while compiling with -xc99=%none. Without -xc99=%none the compiler issues a warning or an error message for use of these keywords as identifiers depending on context.
- __func__ Support
The compiler provides support for the predefined identifier __func__ .
- Variable Length Arrays
VLAs are allocated on the stack as if by calling the alloca function. Their lifetime, regardless of their scope, is the same as any data allocated on the stack by calling alloca; until the function returns. The space allocated is freed when the stack is released upon returning from the function in which the VLA is allocated.
The compiler provides C99 support for Varaible Length Arrays. Not all constraints are yet enforced. Constraint violations will lead to undefined results.
- inline Specifier For Static Functions
The C99 function-specifier inline has been added. inline is fully functional for functions with internal linkage. For functions defined with external linkage use of the inline function-specifier creates an inline definition only, no external definition of the function is created. Thus pointers to inline functions with external linkage are unique to each translation unit and will not compare equal.
- Commenting Code With //
Code preceeded by a set of forward slashes is recognized as a comment when you issue -xc99=%all. One set of forward slashes is required per line of commentary.
- Lint Support for Implemented C99 Features
lint's -Xc99 flag enables you to check whether or not your code is properly calling supported C99 featues.
- Identifying Whether a Plain char Is Signed
The -xchar[={signed|s|unsigned|u}] option is provided solely for the purpose of easing the migration of code from systems where the char type is defined as unsigned. Do not use this option unless you are migrating from such a system. Only code that relies on the sign of a char type needs to be rewritten to explicitly specify signed or unsigned.
signed Treat character constants and variables declared as char as signed. This impacts the behavior of compiled code, it does not affect the behavior of library routines. s Equivalent to signed unsigned Treat character constants and variables declared as char as unsigned. This impacts the behavior of compiled code, it does not affect the behavior of library routines. u Equivalent to unsigned If you do not specify -xchar, the compiler assumes -xchar=s. If you specify -xchar, but do not specify a value, the compiler assumes -xchar=s.
The -xchar option changes the range of values for the type char only for code compiled with -xchar. This option does not change the range of values for type char in any system routine or header file. In particular, the value of CHAR_MAX and CHAR_MIN, as defined by limits.h, do not change when this option is specified. Therefor, CHAR_MAX and CHAR_MIN no longer represent the range of values encodable in a plain char.
If you use -xchar, be particularly careful when you compare a char against a predefined system macro because the value in the macro may be signed. This is most common for any routine that returns an error code which is accessed through a macro. Error codes are typically negative values so when you compare a char against the value from such a macro, the result is always false. A negative number can never be equal to any value of an unsigned type.
It is strongly recommended that you never use -xcharto compile routines for any interface exported through a library. By default, the C compiler defines char as signed as per the Solaris ABI and -xchar does not change that. Therefore, any users of such a library needs to be cautioned to also use this option or otherwise deal with any char values being passed or returned.
- New and Changed Values for -xchip and -xtarget
The -xchip option now accepts the value ultra2e for specifying the UltraSPARCIIe processor.
Also the implied -xarch setting for the following -xtarget values has changed from v8 to v8plusa:
- entr2/1170
- entr2/1200
- entr2/2170
- entr2/2200
- entr3000
- entr4000
- entr5000
- entr6000
- ultra
- ultra/140
- ultra/170
- ultra/200
- ultra2
- ultra2/1170
- ultra2/1200
- ultra2/1300
- ultra2/2170
- ultra2/2200
- ultra2/2300
- ultra2e
- ultra2i
- ultra3
Sun WorkShop 6 update 1 New Features
Sun WorkShop 6 update 1 C Compiler included the following new and changed features.
- Support for the UltraSPARC III Processor
The -xtarget and -xchip flags now accept ultra3.
- Optimizing Through Type-Based Analysis
The C compiler now accepts the -xalias_level option and several pragmas which allow it to perform type-based alias analysis and optimizations.
- Enhancing Math Routine Performance With New Pragmas
cc -fast now expands to include the macro __MATHERR_ERRNO_DONTCARE. This macro causes math.h on Solaris 8 to assert performance-related pragmas for some of the math routines prototyped in math.h.
- Using Built-in Standard -Library Functions
Use the new -xbuiltin command when you want the compiler to improve performance of generated code through substitution of intrinsics, or inlining, of standard library functions as the compiler determines it is profitable.
- Enabling or Disabling Trigraph Interpretation
Use the -xtrigraphs command when you want to enable or disable trigraph translation.
- Prefetch Latency
Use -xprefetch=latx:n.n to specify a factor to adjust the prefetch-to-load and prefetch-to-store latencies.
- Overriding the Default Search Path
The new -I- option gives you more control over the algorithm that the compiler uses when searching for include files.
Sun WorkShop 6 New Features
The Sun WorkShop 6 C compiler included the following new and changed features.
- Incremental Link Editor Chapter
This version of the C User's Guide includes a full chapter about the incremental link editor.
- __func__
The C compiler now predefines a static, constant, char array named __func__ for every function definition. The array is initialized with the name of the function and can be used anywhere a static function scope array can be used, such as when printing the name of the enclosing function.
- Variable argument macro
You can now issue a #define preprocessor directive in the following form:
#define <identifier> (...) <replacement-list> new-line
#define <identifier> (<identifier-list> , ...) <replacement-list> new-lineThe C preprocessor accepts a variable number of arguments for a #define preprocessor directive. If the macro definition includes an ellipsis as part of the identifier list, then there will be more arguments when the macro is invoked then there were parameters in the macro definition.
- SUNW_MP_THR_IDLE
You can now use the SUNW_MP_THR_IDLE environment variable to control whether a thread continues to use system resources after it finishes its task or it "sleeps."
- Large arrays
The C compiler now supports significantly larger array objects. For specifics, see Appendix A of the C User's Guide.
- -errchk=locfmtchk
lint now accepts a new flag, -errchk=locfmtchk, that checks for printf-like format strings during lint's first pas s.
- New lint directive (PRINTFLIKE(n))
lint now accepts a new directive that identifies all calls to the printf() family through a pointer. All such calls through the pointer can now be checked for argument consistency by lint.
- -errwarn=t
The C compiler and the lint source code checker now support a new opti on -errwarn=t, which causes the compiler to exit with a failure st atus if any of the specified warnings are issued.
- -errchk
The -errchk option of lint now has a new value signext that you can use in conjunction with the longptr64 option: -errchk=longptr64,signext. This new option warns about sign extension in order to facilitate migration to the 64-bit development environment.
- -xchar_byte_order
The -xchar_byte_order option produces an integer constant by placing t he characters of a multi-character character-constant in the specified byte ord er.
- -xinline
The -xinline option now accepts two new values: %auto and no%function_name. The %auto value takes effect at the -x04 level of optimization and allows the compiler to automatically inline functions in addition to those listed in -xinline. The no%function_name value tells the compiler to not inline the function function_name.
- -xmemalign
The C compiler now offers a new option called -xmemalign. This option controls code generated for potentially misaligned memory accesses and controls program behavior in the event of a misaligned access.
- -xprefetch
SPARC only - You can use the new option -xprefetch, in conjunction with the header file, sun_prefetch.h to specify prefetch instructions on those architectures that support prefetch, such as UltraSPARC II.
- -xvector
The -xvector option enables automatic generation of calls to the ve ctor library functions.
D. Software Corrections
There is no new information at this time.
E. Problems and Workarounds
This section discusses the following software bugs that could not be fixed in time for this release. For updates, check the Forte Developer Hot Product News link at http://www.sun.com/forte/developer/hotnews.html.
- VLA parameter fails when passed an array of apporpriate dimensions
The following code does not yield correct results. It should print the following but does not:
1 2 3 4 5 6 7 8 9 10 11 12#include <stdio.h> #define M 3 #define N 4 int a[M][N] = { { 1, 2, 3, 4}, { 5, 6, 7, 8}, { 9, 10, 11, 12} }; void foo(int m, int n, int a[m][n]) { int i, j; for(i=0; i<m; i++) { for(j=0; j<n; j++) { printf("%d ", a[i][j]); } printf("\n"); } printf("\n"); } void bar(int m, int n) { int a[m][n]; int i, j; int k = 1; for(i=0; i<m; i++) { for(j=0; j<n; j++) { a[i][j] = k++; } } foo(m, n, a); return; } main() { bar(M, N); return 0; }- OpenMP-C: There is no warning on break/continue branching out of openmp sturctured block
Compiler fails to issue error message if break statement seen in a parallel for. The following example does note generate an error message:
#pragma omp parallel for for (i = 1; i < n; i++) { if (i == n/2) break; /* Missing error message */ }- OpenMP-C: Not all openmp pragma nesting restrictions are checked
The OpenMP standard prohibits nesting #pragma openmp for, #pragma openmp sections, and #pragma openmp single inside #pragma openmp critical, #pragma openmp ordered, or #pragma openmp master.
The following example should result in a warning:
#pragma omp critical ( test ) { #pragma omp sections { ; } }- OpenMP-C: atomic expression syntax is not being checked
The OpenMP standard states that the expression statement for atomic must have one of the following forms:
x binop = expr x++ ++x x-- --xThe following example should have an error (or at least a warning that it does not conform to the standard):
#include <omp.h> #include <stdio.h> void main(void) { int i; #pragma omp parallel { #pragma omp atomic i = i + 1; /* expression error */ printf("t#: %i i: %i\n", omp_get_thread_num(), i); } }- OpenMP-C: directive processing is not allowing # pragma
The space between the '#' symbol and the word pragma should be accepted, but it is causing an error.
test case: #include <omp.h> void main(void) { int a[100]; int i; # pragma omp parallel for for (i = 0; i < 100; i++) a[i] = omp_get_thread_num(); printf("a:"); for (i = 0; i < 100; i++) printf(" %i", a[i]); printf("\n"); } cc -xopenmp c.c cc: Warning: Optimizer level changed from 0 to 3 to support parallelized code. "c.c", line 8: invalid source character: '#' "c.c", line 8: undefined symbol: pragma "c.c", line 8: syntax error before or at: omp "c.c", line 9: syntax error before or at: ) cc: acomp failed for c.c- OpenMP-C: canonical shape of for loop not fully checked
The right hand side of each of the for-loop expressions (init-expr, "bound" expression, and the incr-expr) are all suppose to be integer expressions (by the standard). Currently, as shown by the example, we only seem to be checking the incr-expr.
#include <omp.h> #include <stdio.h> void main (void) { float c; int lp; int buf[10]; c = 0.0; #pragma omp parallel for for (lp=c; lp<10; lp++) { /** line 12 **/ buf[lp] += omp_get_num_threads (); } c = 10.0; #pragma omp parallel for for (lp=0; lp<c; lp++) { /** line 18 **/ buf[lp] += omp_get_num_threads (); } /****/ c = 1.0; #pragma omp parallel for for (lp=0; lp<10; lp += c) { /** line 24 **/ buf[lp] += omp_get_num_threads (); } /****/ } cc -xopenmp a.c "a.c", line 24: iteration expression of omp for loop does not have a canonical shape cc: acomp failed for a.cIf you comment out the last for block (lines 22-26), the compiler generates a fatal error.
- OpenMP-C: Compilation aborts if the upper bound of a parallel loop is computed using an if statement, as in the following example:
#define max(a,b) ((a>=b) ? a:b) void main(void) { double a[10]; int i, x, y; x = 5; y = 10; #pragma omp parallel for shared(a) private(i) for (i=0; i < max(x,y);i++) { a[i] = i; } }
- OpenMP-C: ordered does not work correctly (produces wrong results or causes program to hang), if the loop step is negative, as in the following examples:
void main(void) { int i; #pragma omp parallel for ordered for (i=30; i >= 1; i--) { #pragma omp ordered { printf ("%d\n", i); } } }
F. Limitations and Incompatibilities
There is no new information at this time.
G. Documentation Errata
There is no new information at this time.
Copyright 2001 Sun Microsystems, Inc., 901 San Antonio Road, Palo Alto, CA 94303, U.S.A. All rights reserved.
Sun, Sun Microsystems, the Sun logo, docs.sun.com, and Solaris are trademarks, registered trademarks, or service marks of Sun Microsystems, Inc. in the U.S. and other countries.