Sun Studio Express February 2007 Early Access Release
Here is what is new and updated in the Sun Studio C, C++, and
Fortran compilers in this release:
C, C++, and Fortran
New Features and Updates Common To All Compilers on SPARC and x86
Platforms
A New Way To Specify 32-bit or 64-bit Address Model
You no longer need use the -xarch
option to specify a 32-bit or 64-bit address model (LP64 versus
ILP32). Two new options make it easier:
-m32 specifies the
ILP32 model: 32-bit ints, longs, and pointer types.
-m64 specifies the LP64
model: 32-bit ints, 64-bit longs and pointers types.
Deprecated -xarch Flags and Their Replacements Across SPARC and
x86
If you are using -xarch=v9
or -xarch=amd64 to specify a
64-bit address model, use just -m64
instead. No -xarch value is
required.
Deprecated -xarch Flags and
Their Replacements on SPARC Only
Use -xarch=sparc in
place -xarch=v8plus
Use -xarch=sparcvis in
place of -xarch=v8plusa
Use -xarch=sparcvis2 in
place of -xarch=v8plusb
Use -xarch=sparc -m64
in place of -xarch=v9
Use -xarch=sparcvis -m64
in place of -xarch=v9a
Use -xarch=sparcvis2 -m64
in place of -xarch=v9b
Deprecated -xarch Flags and Their Replacements on x86 Only
Disallowed Combinations and Warnings
The compilers do not allow the combination of a deprecated -xarch
value and the new -m32, -m64
options on the command line. For example, specifying -xarch=v9 -m32
is now a fatal error. Specifying -xarch=sparc -xarch=v9
is also a fatal error.
Some older -xarch values do
not have 64-bit counterparts. You cannot combine the following -xarch
options with -m64 on the
command line:
For
SPARC platforms: -xarch=v7, -xarch=v8,
-xarch=v8a
For
x86 platforms: -xarch=386,
-xarch=pentium_pro, -xarch=pentium_proa, -xarch=sse, -xarch=ssea
If you specify a 32-bit -xarch
value followed by -m64, the
compiler does not issue a warning. For example -m64
-fast or -fast -m64
are allowed. However, if you specify a 64-bit -xarch
value followed by -m32, the
compiler issues a warning that -m32
overrides the -xarch value.
This situation does not occur using macro options, only when an
-xarch option has been
explicitly specified.
New x86 Features and Updates Common To All Compilers
The following are new x86 flags for the -xarch
option:
-xarch=sse3 specifies
that the compiler should generate instructions based on both the
SSE3 and SSE2 architectures.
-xarch=sse3a specifies
that the compiler should generate instructions based on the SSE3,
SSE2 and AMD extended architectures as well as the 3DNow extensions.
Changes to -fast Option
The -fast option on x86
now includes -xregs=frameptr,
which means you can use the frameptr register (%ebp
on IA32, %rbp on AMD64) as a
general purpose register to generate code for all the compilation
units. Consequently frame pointers will not be generated in each
function or routine.
However, if you want to override this new behavior, specify
-xregs=no%frameptr after -fast
in the compilation command and the frameptr register will not be used
as a general purpose register. The following example demonstrates how
to override the -fast default
for -xregs:
cc -fast -xregs=no%frameptr foo.c
New Support for MMX Intrinsics
This EA1 release also includes updates to the support for x86 SSE,
SSE2, and SSE3 intrinsics. The C and C++ compiler are now compatible
with gcc/icc on SSE intrinsics. You no longer need to specify the
-xbuiltin option to invoke
these intrinsics. However, it is still necessary to specify the
correct -xarch value. For
example, specify -xarch=sse3 or
-xarch=sse3a to invoke SSE3
intrinsics .
The full set of integral/floating point/caching intrinsics are now
provided in the following header files:
mmintrin.h for MMX
intrinsics
xmmintrin.h for SSE
intrinsics
emmintrin.h for SSE2
intrinsics
pmmintrin.h for SSE3
intrinsics
sunmedia_intrin.h for
Sun specific SSE intrinsics
See the Sun Studio Express Readme
for processor and system requirements.
New SPARC Features and Updates Common To All Compilers
This release of the Sun Studio compilers includes support for the
SPARC64 VI and UltraSPARC T2 processors. Use the following new
options to specify these processors:
-xtarget=sparc64vi
-xtarget=ultraT2
You can also specify the following -xchip
options to generate code for these processors without setting the
-xarch value automatically as
happens when you use -xtarget:
-xchip=sparc64vi
-xchip=ultraT2
You can also specify the -xarch
values explicitly:
New Math and Visual Instruction Set Support in SPARC64 VI
Specify the following new option if you want to use instructions
from the SPARC-V9 instruction set including the UltraSPARC
extensions, the Visual Instruction Set (VIS) version 1.0, the
UltraSPARC-III extensions, the Visual Instruction Set (VIS) version
2.0, and the SPARC64 VI extensions for floating-point multiply-add:
You must also specify -m32
or -m64 when you specify
-xarch=sparcfmaf to get 32-bit
code or 64-bit code respectively . When you specify -xarch=sparcfmaf,
the compiler predefines the following new values:
-D__FP_FAST_FMA__
-D__FP_FAST_FMAF__
Note: You must use -xarch=sparcfmaf
in conjunction with the new -fma=fused
option detailed below and some optimization level in order for the
compiler to find opportunities to use the multiply-add instructions
automatically.
Known Limitation in This Sun Studio Express Release:
There is a conflict between the -xlinkopt and -xarch=sparcfmaf
options when used together on 32-bit SPARC compilations (6523712).
For example:
-xarch=sparcfmaf -xlinkopt
as well as when compiling on platforms where -xarch=sparcfmaf is natively implied, such as:
issues this error message:
postopt: postopt does not support this architecture : sparcfmaf
This limitiation will be removed in the next Sun Studio Express release.
New Option for Floating-Point, Fused or Multiply-Add Instructions
Specify the following new option to enable or disable the
automatic generation of floating-point, fused, multiply-add
instructions:
The none value indicates that the compiler should not generate any
floating-point, fused, or multiply-add instructions. The fused value
allows the compiler to attempt to find opportunities to improve the
performance of the code by using floating-point, fused, or
multiply-add instructions.
Linux Support
This release of the Sun Studio compilers supports the Linux OS.
See the Sun Studio Express Readme
for processor and distro version requirements.
Known Limitation on Linux
-
The -xprofile=collect and -xprofile=tcov options
should not be used when building shared libraries
on Linux.
The New Thread Analyzer
The following new compiler option causes the compiler to
instrument your multi-threaded application for analysis by the new
Thread Analyzer. See the Thread
Analyzer Readme for more information.
The default is -xinstrument=no%datarace.
C Compiler
New C Compiler Options
The following new C compiler options are new in this release .
Options for Finding make-File Dependencies
-xMD Generates makefile dependencies. Same as -xM, plus runs
the compilation.
-xMF <filename> Specifies filename for makefile
dependency output
The -xM, -xM1, -xMD, and -xMMD options are mutually exclusive, and
only one can be in effect. If -xMF is not specified, default filename
derived from input file name with .d suffix should be generated when
either xMD or xMMD is set. Options xM and xM1 would behave as usual
when -xMF is not on. If -xMF is set, all makefile dependency output
is appended to the specified file. There is no way to specify
individual filenames for multiple input files with xMF on one command
line.
Compiler Driver Nicknames
Aliases for the
suncc, sunCC, sunf90, sunf77, sunf95, sunc89, sunc99, sunas compiler
commands have been added to aid in using the Sun compilers across
Solaris and Linux using a common command name that always refers to
the Sun compilers. The cc command will often be satisfied in the user
PATH out of /usr/bin. /usr/bin/cc on linux is typically the gcc
compiler, on Solaris it is the Sun compiler. By placing the Sun
Studio bin directory on the user's PATH and using the suncc command,
there is no ambiguity, the Sun compiler will always be invoked.
Compiler Compatibility
To improve compatibility between options implemented by the Sun Studio C compiler and those implemented by other popular compilers, this release of the compiler supports the following command-line options: -fPIC/-fpic, -shared, -Xlinker.
Performance Improvements
#include_next
Both the C and C++ compilers now support the #include_next
directive. The directive does not distinguish between <filename>
and "filename" inclusion, nor does it check that the file
you specify has the same name as the current file. It looks for the
filename, starting with the directory in the search path after the
one where the current file containing the #include_next directive was
found.
Linux:
The C
compiler is now available on Linux (x86 and x64).
Static data race and deadlock detection with lock_lint
The C compiler option-Zll creates database files (.ll) for use by lock_lint(1).
The -Zll option and the lock_lint command line
utility now available on x86.
New Attributes:
Attributes always_inline, noinline,
pure, const, malloc and aligned
are now supported by the __attributes__
clause.
C compiler
supports attribute aligned
int __attribute__ ((aligned (16))) i = 0;
C compiler
supports attribute visibility
The visibility attribute has been mapped to the linker
scoping specifiers of the Sun Studio C compiler as follows:
The symbol has global linker scoping and is the least
restrictive linker scoping. All references to the symbol bind to the
definition in the first dynamic module that defines the symbol. This
linker scoping is the current linker scoping for extern symbols.
int __attribute__ ((visibility ("default"))) v5 = 0;
int __global v6 = 0;
The symbol has symbolic linker scoping and is more restrictive than
global linker scoping. All references to the symbol from within the
dynamic module being linked bind to the symbol defined within the
module. Outside of the module, the symbol appears as though it were
global.
int __attribute__ ((visibility ("protected"))) v1 = 0;
int __symbolic v2 = 0;
The symbol has hidden linker scoping. Hidden linker scoping is more
restrictive than symbolic and global linker scoping. All references
within a dynamic module bind to a definition within that module. The
symbol will not be visible outside of the module.
int __attribute__ ((visibility ("internal"))) v3 = 0;
int __attribute__ ((visibility ("hidden"))) v4 = 0;
int __hidden l = 0;
Support for value-returning blocks
#define maxint(a,b) \
({int _a = (a), _b = (b); _a > _b ? _a : _b; })
Support for typeof
#define max(a,b) \
({ __typeof__ (a) _a = (a); \
__typeof__ (b) _b = (b); \
_a > _b ? _a : _b; })
Support for zero-length arrays
struct foo {
int a;
int flexarray [0];
int b;
int c;
};
Support for the __alignof__ Operator
The __alignof__ operator returns the alignment associated with a given type or expression. Its syntax is the same as the syntax of the sizeof operator. The following examples demonstrate how to call __alignof__ and supply an argument:
__alignof__(float) /* return 4
__alignof__(double) /* returns 8
char foo;
__alignof__(foo) /* returns 1
__alignof__(1+1) /* returns 4 (default integer alignment)
It's an error to ask for the alignment of an incomplete type or of a bit-field.
Support for Local Labels
The following search-macro example demonstrates a typical use of
local labels. The example incorporates statement expressions and the
typeof operator. A search for an element of a one dimensional array
could be written as follows:
#define SEARCH(array, value,max) \
({ \
__label__ found_it; \
typeof (value) _value =(value); \
typeof (*(array)) *_array = (array); \
typeof (max) _max = (max); \
typeof (max) i, index; \
\
for (i =0; i < max; i++) \
if (_array[i] == _value) \
{ \
index= i; \
goto found_it; \
} index = -1; \
found_it: \
index; \
})
Note the use of the local label
"found_it". Without the ability to declare a local label
(through the __label__ declaration), multiple uses of the macro would
result in multiple definitions for "found_it". Note also
that local labels can be used in any block, not just within statement
expression blocks.
Known Problems and Limitations
The ELF sections of code that are compiled with C++ contain
references to other sections by number. The strip command can remove
entire sections which causes subsequent section to be re-numbered.
However, the strip command does not then update the section numbers
in the affected sections. The references are then incorrect, leaving
an unusable file. (6509873)
C++ Compiler
Support for g++ extensions:
- __typeof__
- __attribute
- __alignof__ now accepts
expressions
- extern template
- long long bitfields,
currently by default only on Linux
Linux:
The C++ compiler is now available on Linux (x86 and x64).
Better function inlining
The C++ compiler will now generate some system functions
inline at high optimization levels, avoiding calls into system
libraries.
Support for popular Open Source libraries
BOOST http://www.boost.org
LOKI http://sourceforge.net/projects/loki-lib
STLport available on Linux
The STLport library that ships with Sun C++ on Solaris is now
available on Linux.
Standard
lifetime of temporary variables
Beginning with Sun Studio Express 2, the compiler default is
standard-conforming lifetime of temporary variables. Previously, a
command-line option was required to get standard-conforming
behavior.
Complex expressions in template parameters
The compiler previously was unable to handle expressions in
non-type template arguments in certain cases. For example:
template<class T, int I, int J>
T func( T (&arr)[I*J] ) { ... } // I*J is a "complex template expression"
The compiler can now handle these usages.
OpenMP debugging
Debugging of OpenMP programs is now considerably enhanced.
Better support for debugging optimized code
Although debugging of optimized code is still limited,
debugging is now easier.
Dwarf by default
The C++ compiler now emits debug information in the dwarf format
by default. This will make it easier for 3rd party debuggers and
other tools to interoperate with Sun compilers. The dwarf format
will also make it easier for Sun Studio to add new debug support for
optimized code in upcoming releases.
-
Fortran Compiler
The Fortran compiler is now available on Linux (x86 and
x64).
-
Support for interval arithmetic on Solaris Intel
platform with the -xarch=sse2 -xia options.
-
CAUTION messages issued when using the same symbols
that are defined in different modules.This enhancement provides
a CAUTION level message when the same symbols defined in different
modules are imported by the USE statement. This helps isolating name
duplication problems in large applications using third-party
modules.
(Last updated February 23, 2007)