Tuesday December 19, 2006
Sun Studio Express Program December 2006 Build available
Sun Studio Express Program December 2006 Build available
Want a peek at the latest Sun Studio Compilers and Tools under development from Sun?
The Sun Studio Express Program provides the Sun developer community with an early look at new features and technologies of the Sun Studio Compilers and Tools. The Sun developer community can assess the benefits of the most current compiler and tools innovations. Through the Sun Studio forums, the Sun developer community can ask question and give feedback, long before they are released as products.
Wonder if the next revision of the Sun Studio Compilers is going to give your application a performance boost? Now you can find out.
The December 2006 Build includes a new Integrated Development Environment (IDE). The new Sun Studio IDE is based on NetBeans 5.5.1 and adds many new features. It supports C and C++ projects, and includes appropriate project templates for applications, dynamic and static libraries, and projects with existing code. The IDE includes a C and C++ class browser. The powerful language-aware built-in editor supports code completion. This build also includes C, C++, and Fortran compilers for the Linux platform, and improvements to the previously released Data Race Detection Tool, which has been renamed the Sun Studio Thread Analyzer.
So go check out the Sun Studio Express Program at:
http://developers.sun.com/prodtech/cc/downloads/express.jsp
Some of the other features being introduces with the June 2006 Build include:
What About Binary Compatibility?
»What will happen if I try to run my application on a newer Solaris OS release?
»What will happen if I try to compile my application using one version of the Sun Studio compilers and link it with libraries compiled with earlier compiler versions?
Important questions to consider, and luckily both Solaris and the Sun Studio compilers guarantee a certain degree of binary compatibility between releases.
Here are some things to keep in mind
f95
compiler
are not guaranteed to be compatible
with future releasesSpecific Questions I get often:
»Can I compile my application on Solaris 10 and run it on Solaris 9 and Solaris 8?
No. Might work, but since you compiled it on Solaris 10, it might also be using system interfaces that did not exist on Solaris 8 and 9 or have changed in Solaris 10.
»Can I compile my application on Solaris 8 and run it on Solaris 9 and Solaris 10?
Yes! This is what binary compatibility is all about. (See above)
»Can I compile and build my shared library on Solaris 10 and use it on Solaris 9 and Solaris 8?
No. Might work, but since you compiled it on Solaris 10, it might also be using system interfaces that did not exist on Solaris 8 and 9 or have changed in Solaris 10.
»If I compile the code in my shared library using the Sun Studio 11 compilers, can my customers who are still using Forte 6 Update 1 compilers link with these shared libraries?
No. You must always link with the same compiler used to create the newest objects in your application or library. So, if Sun Studio 11 compilers are used to compile the code in a shared library, Sun Studio 11 compilers must be used when linking with that shared library.
October 23-27 meeting of ISO SC22 WG14, the C programming language committee (Part 3 of 3)
Highlights of the October 23-27 meeting of ISO SC22 WG14, the C programming language committee:
Here are the details on Decimal Floating Point, Bounds Checking, and couple of DRs.
Details (Part III):
DTR 24732, Decimal Floating Point.
Discussion of the National Bodies comments on the draft were reviewed in detail. This lead to some minor changes to the draft. There will be a small review committee to incorporate these changes. The WG14 convenor will then forward that draft to SC22 for final ballot.
IBM is the only company known to have hardward to support Decimal Floating Point at this time ...
This document is a proposed Part II to TR24731, Bounds Checking via dynamic allocation. There is no invention here. All of the functions already exist in implementations, particularly in POSIX. The document is organized the same way as Part I. The intent of this document is to provide programmers with an additional mechanism to address issues of buffer overflow, etc., as does Part I. A key difference is that the mechanisms are via dynamic memory allocation, and heavily dependent on malloc. There are some minor changes that need to be made, the document is still a working draft, but it has sufficient substance to be ready for CD registration. Small editorial group to go over the document.
DR 329 (N1181) Math functions and directed rounding
The result is DBL_MIN*DBL_EPSILON, a subnormal number. But, if the implementation does not support subnormal numbers, such as IBM S/360 hex floating-point, then it is either zero or DBL_MIN, depending upon the current rounding direction mode. Hence, the sentence "Thus, the remainder is always exact." in footnote 204 in C99+TC1+TC2 (N1124) is wrong. This problem also applies to remquo and fmod.
Issue for non-754 implementations.
remove the sentence from the footnote, move the rest of the edits to annex f, instead of section 7
DR 332 (N1194) gets is generally unsafe
Committee consensus to have words crafted to deprecate gets. This is a political issue in response to lots of bashing of the committee being non responsive to the security issues. Which of course is not true, but WG14 wants to soften the rhetoric.
Proposed Technical Corrigendum:
Add to subclause 7.26.9 (future library directions for ):
The gets function is obsolescent, and its use is deprecated.
[Note: Rationale wording might be useful.] [Editorial note: add a forward reference to this from gets subclause 7.19.7.7.]
Reviewed state in Portland 10/06 Expedited, will include in TC3 pending results of the disposition of this DR (DR 332) by WG14
This effort is essentially in the 'stalled' proposal list within the Evolution Working Group (EWG) in C++ (WG21/J16). Tom believes it solves real problems with the preprocessor. There is opposition within this committee to changing the C Standard.
October 23-27 meeting of ISO SC22 WG14, the C programming language committee (Part 2 of 3)
Highlights of the October 23-27 meeting of ISO SC22 WG14, the C programming language committee:
Here are the details on augmenting the interface of malloc, modeling sequence points to aid C++ work on concurrency, and committee discussions on revising the C standard.
Details (Part II):
Tom Plum Report #2, WG21/N1085 C++ Proposal to augment the interface of malloc, et al.
WG21/N1085 is a proposal by Howard Hinnant. Ulrich wants to add alignment considerations to this C++ proposal. POSIX is now using a function called posix_memalign() that seems suitable for the original proposal. That function came from an X/Open function named memalign(). Some of the members of J11 believe a function of this sort would be useful for C as well. Ulrich expressed concern that C++ might put a different spin on this. Bill Plauger prefers that we not push this work on to C++. Sees it as simply adding to layers of complexity. It's not clear whether or not C++ will even ever adopt this. Bill Plauger sees it as low on the list of things to do.
After much debate and several straw polls we agreed to this Liaison Report
WG14 urges WG21 to incorporate into the next C++ revision ("C++0x"):
N1188 is a paper that explains the C language sequence point model, and may be suitable as an addition to the C99 rationale. The difficulty seems to be in determining all the possible orderings of sequence point, which makes teaching it difficult.
Making use of the model here is important in providing liaison input to C++ for their concurrency model. We want to make sure our underlying model does not get broken by C++ concurrency. We have plenty of time to get this in the C99 rationale, but there is more urgency in nailing down our model for C++ concurrency.
Ulrich believes that the state of C compiler development is such that the C Standard is well behind the technology being used by the community. Virtually all major C compiler developers have developed extensions to the language that go well beyond the Standard. We can either subsume ourselves to C++, or plan on revising the C Standard to adopt existing technologies. Bill Plauger pointed out that our pace has been deliberate, and that adoption of C99 has been slow. We probably should consider reopening the Standard soon, and look at adopting things like multi-treading, security features, and others. Ulrich believes we should focus on existing practice, features that are in wide use, minimize the risk of standardizing features that no one will use. Doug Gwyn believes that C will have longevity in embedded programming, but that if we work on a 5 year schedule we should probably consider starting now. There are a number of things that C can probably do better than other languages. Round table discussion on whether or not we should consider revising the C Standard. David Keaton believes that are real commercial needs that C can address, such as security. General feeling that making a decision to revise the C Standard with a focus on existing practice would be a good thing. Many developers make use of extensions to the language, some do not. Invention of new feature sets is not a good idea. John Benito: No one is saying no. If we are going to do this we will need to work on our charter, and proceed from there.
The next step. John Benito (WG14 Convenor): We need to start putting a charter together that will define the scope a revision to the C Standard. Tom Plum is in favor of using the wiki as a vehicle to propose ideas. Bill Plauger suggests using a full day in London to process such a list. Start by generating a list, filter it based on criteria, then let the world know what we are doing. We are not ruling out proposals from the outside.
October 23-27 meeting of ISO SC22 WG14, the C programming language committee (Part 1 of 3) Highlights of the October 23-27 meeting of ISO SC22 WG14, the C programming language committee:
I'll cover the other topics in some future postings
Sun Studio 11 Training Now Available!
href=http://www.sun.com/training/catalog/courses/WP-100-S10.xml
This web based training introduces Solaris software platform developers
to Sun Studio software. It provides developers with an overview of how
to compile, edit, debug, and analyze performance with Sun Studio.
( Sep 05 2006, 11:34:58 AM PDT )
Permalink
Comments [0]
Resolving problems creating reproducible binaries using Sun Studio Compilers
Certain flags (-g, -xipo, -xcrossfile) invoke features of the Sun
Studio Compilers and tools that must make static data global. To avoid
namespace collisions, the data is globalized using a unique
globalization prefix. The drawback of using a unique globalization
prefix is that the resulting object files will be different every time
the source file is compiled, even though the sources and compilation
options are identical. So, if you compare the resulting object files
from two identical compilations they will differ.
If you are in an environment that requires the ability to reproduce
identical object files, this becomes a problem.
Both C and C++ have an undocumented flag (-xglobalstatic) that can be
passed to the compiler front-end which will force the use of a static
globalization prefix based on the source filepath, instead of the usual
algorithm that guarantees a unique prefix. To pass the flag to cc use
the -W0 option as follows:
cc -W0,-xglobalstatic
To pass the flag to CC use the -Qoption ccfe option as follows:
CC -Qoption ccfe -xglobalstatic
The drawback to using the filepath to generate the globalization prefix
is the increased risk of a namespace collision at link time between
static data with the same name that has been globalized from two files
with the same filepaths. Though rare it does occur more often than
using a randomly generated prefix.
If you do run into namespace collisions, you might need to assign
the globalization prefix. For C this can be done with the
wizard option -W0,-xp<prefix>, for example:
-W0,-xp\$XAqalkBBa5_D2Mo
For C++ this can be done with the wizard options
-Qoption ccfe -prefix -Qoption ccfe <prefix>, for example:
-Qoption ccfe -prefix -Qoption ccfe \$XA0ZlkBtDTxEGkV.
( Jul 24 2006, 02:45:48 PM PDT )
Permalink
Comments [1]
Linux Technology Preview, Build 24 - June 2006
Sun Studio Express Program June 2006 Build
Sun Studio Express Program June 2006 Build
Want a peek at the latest Sun Studio Compilers and Tools under
development from Sun? The Sun Studio Express Program provides the Sun
developer community with an early look at new features and technologies
of the Sun Studio Compilers and Tools. The Sun developer
community can assess the benefits of the most current compiler and
tools innovations. Through the Sun Studio forums, the Sun
developer community can ask question and give feedback, long before
they are released as products.
Wonder if the next revision of the Sun Studio Compilers is going to
give your application a performance boost? Now you can find out.
With the June 2006 Build, the Sun Studio Express Program is featuring
the Data Race Detection Tool (DRDT), a cool new tool for datarace
detection in OpenMP, threaded and parallel programs. DRDT works
with code written using the POSIX thread API, the Solaris Operating
System(R) thread API, OpenMP directives, Sun parallel directives,
Cray(R) parallel directives, or a mix of these.
So go check out the Sun Studio Express Program at:
http://developers.sun.com/prodtech/cc/downloads/express.jsp
Some of the other features being introduces with the June 2006 Build include:
Report bugs on Sun Studio Compilers and Tools at bugs.sun.com
You can now report bugs on Sun Studio Compilers and Tools at bugs.sun.com.
Here is how:
The real story on the cc command and the -xregs=frameptr option
Alas the Sun Studio 11 C User's Guide documentation about
-xregs=frameptr and -fast expansion that includes -xregs=frameptr is
incorrect to the point of being completely confusing.
http://docs.sun.com/source/819-3688/cc_ops.app.html Appendix B 2.16,
Table B-5 -fast option description incorrectly list -fast on x86 as
expanding to -xregs=no%frameptr. That is not correct. The
-fast macro option on x86 expansion includes -xregs=frameptr.
Later in Appendix B at 2.129, near the end of the description of -xregs, exists the following incorrect sentence:
C99 inline function and the Sun C Compiler
Note, the C standard says that inline is only a suggestion to the C
compiler. The C compiler can choose not to inline anything, and
attempt to call the actual function.
The Sun C compiler does not inline C function calls unless optimizing
at -xO3 or above. And that inlining is done by the
backends. And then only if the backend's heuristics decide it is
profitable to do so. The Sun C compiler gives no way to force a
function to be inlined.
For static inline functions it is simple. Either a function
defined with the inline function specifier is inlined at a reference or
a call is made to the actual function. The compiler can choose
which to do at each reference. The Sun C compiler decides if it
is profitable to inline at -xO3 and above. When not profitable to
inline, or at an optimization of less than -xO3 a reference to the
actual function will be generated. If any reference to the actual
function is generated the function definition will be generated in the
object code. Note if the address of the function is taken, the
actual function will be generated in the object code.
Extern inline functions are more complicated. There are two types
of extern inline functions, an inline definition which never provides
an extern (global) definition of the function and an extern
inline function which always provide a global definition of the
function. To quote the C99 standard:
[#6] Any function with internal linkage can be an inline
function. For a function with external linkage, the
following restrictions apply: If a function is declared with
an inline function specifier, then it shall also be defined
in the same translation unit. If all of the file scope
declarations for a function in a translation unit include
the inline function specifier without extern, then the
definition in that translation unit is an inline definition.
An inline definition does not provide an external definition
for the function, and does not forbid an external definition
in another translation unit. An inline definition provides
an alternative to an external definition, which a translator
may use to implement any call to the function in the same
translation unit. It is unspecified whether a call to the
function uses the inline definition or the external
definition.
[#7] EXAMPLE The declaration of an inline function with
external linkage can result in either an external
definition, or a definition available for use only within
the translation unit. A file scope declaration with extern
creates an external definition. The following example shows
an entire translation unit.
inline double fahr(double t)
{
return (9.0 * t) / 5.0 + 32.0;
}
inline double cels(double t)
{
return (5.0 * (t - 32.0)) / 9.0;
}
extern double fahr(double); // creates an external definition
double convert(int is_fahr, double temp)
{
/* A translator may perform inline substitutions */
return is_fahr ? cels(temp) : fahr(temp);
}
[#8] Note that the definition of fahr is an external
definition because fahr is also declared with extern, but
the definition of cels is an inline definition. Because
cels has external linkage and is referenced, an external
definition has to appear in another translation unit (see
6.9); the inline definition and the external definition are
distinct and either may be used for the call.
So, for an inline definition, the programmer is required to
supply an extern definition of the function in another translation-unit for references to the function that are not inlined.
For an inline definition, the compiler must not
create a global definition of the function. That means any
reference to an inline definition that is not inlined must be a
reference to a global
function defined elsewhere. Put another way, the object file
produced by compiling this translation unit will not contain a global
symbol for the inline definition. And any reference to
the function that is not inlined will be to an extern
(global) symbol provided by some other object file or library at link
time.
For an extern inline function declared by a file scope declaration with
the extern storage-class-specifier (i.e. the function definition and/or
prototype), the compiler must provide a global definition of the function in the resulting object file. The
compiler can choose to inline any references to that function seen in
the translation unit where the function definition has been provided,
or the compiler can choose to call the global function.
The behavior of any program that relies on whether or not a function call is actually inlined, is undefined.
Note also an inline function with external linkage may not declare or
reference a static variable anywhere in the translation-unit.
Definition of translation-unit: A source file and all of its includes, recursively.
Like it does for static functions, the Sun C compiler decides if it is
profitable to inline a reference to an inline definition or an
extern inline function at -xO3 and above. When not profitable to
inline, or at an optimization of less than -xO3 a reference to the
global function will be generated. Likewise a reference to the
address of the function is always a reference to the global function.
The rules for C++ differ: a function which is inline anywhere must be
inline everywhere and must be defined identically in all the
translation units that use it.
The GNU C rules differ and are described in the GNU C manual, which can be found here http://gcc.gnu.org.
To obtain behavior from the Sun C compiler that is compatible with
gcc's implementation of extern inline functions for most programs, use
the -features=no%extinl flag. When this flag is specified the Sun
C compiler will treat the function as if it was declared as a static
inline function.
The one place this is not compatible will be when the address of the
function is taken. With gcc this will be an address of a global function, and with Sun's compiler the local static
definition address will be used.
Finding the canonical path to an executable
Below is a coding example of how an executable can determine the
canonical path to itself on the file system. Compiler drivers,
like cc, CC, f95 need to do this in order to exec the component
executables that compile a program. For example, the compiler
front-end, an optimizer, and a linker.
% cat findself.c
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#ifndef MAXPATHLEN
#define MAXPATHLEN 1024
#endif
/* find_run_directory - find executable file in PATH
* PARAMETERS:
* cmd filename as typed by user
* cwd where to return working directory
* dir where to return program's directory
* run where to return final resolution name
* RETURNS:
* returns zero for success,
* -1 for error (with errno set properly).
*/
int
find_run_directory (char *cmd, char *cwd, char *dir, char **run)
{
char *s;
if (!cmd || !*cmd || !cwd || !dir) {
errno = EINVAL; /*
stupid arguments! */
return -1;
}
if (*cwd != '/')
if (getcwd (cwd, MAXPATHLEN - 1) == NULL )
return -1; /*
cant get working directory */
if (strchr (cmd, '/') != NULL) {
if (realpath(cmd, dir) == NULL) {
int lerrno = errno;
if (chdir((const char *)cwd) == NULL)
errno = lerrno;
return -1;
}
} else {
#ifdef __linux__
/* getexecname() not available on Linux */
if (readlink("/proc/self/exe", dir, MAXPATHLEN) == -1) {
#else
if (realpath(getexecname(), dir) == NULL) {
#endif
int lerrno = errno;
if (chdir((const char *)cwd) == NULL)
errno = lerrno;
return -1;
}
}
s = strrchr (dir, '/');
*s++ = 0;
if (run) /* user wants resolution name */
*run = s;
return 0;
}
char current_working_directory[MAXPATHLEN];
char run_directory[MAXPATHLEN];
char * run_exec_name = NULL;
int
main(int argc, char **argv)
{
if ( !find_run_directory (argv[0],
current_working_directory,
run_directory, &run_exec_name) ) {
(void)printf("argv[0] = %s\n"
"cwd = %s\n"
"run_dir = %s\n"
"run_exec = %s\n",
argv[0],
current_working_directory,
run_directory,
run_exec_name);
} else {
(void) printf("%s\n", "Unaable to find run directory.");
}
exit (0);
}
% cc findself.c -O -o prod/bin/findself
% ls
bin findself.c prod
% ls bin
findself
% ls -laF bin
total 6
drwxr-xr-x
2 me
staff 512 Mar 5 10:37 ./
drwxr-xr-x
4 me
staff 512 Mar 5 10:37
../
lrwxrwxrwx
1 me
staff 20 Mar 5
10:37 findself -> ../prod/bin/findself*
% ls -laF prod/bin
total 22
drwxr-xr-x
2 me
staff 512 Mar 5 10:37 ./
drwxr-xr-x
3 me
staff 512 Mar 5 10:37
../
-rwxr-xr-x
1 me
staff 8992 Mar 5 10:37
findself*
% bin/findself
argv[0] = bin/findself
cwd = /home/me/blog
run_dir = /home/me/blog/prod/bin
run_exec = findself
% prod/bin/findself
argv[0] = prod/bin/findself
cwd = /home/me/blog
run_dir = /home/me/blog/prod/bin
run_exec = findself
% setenv PATH /home/me/bin:${PATH}
% findself
argv[0] = findself
cwd = /home/me/blog
run_dir = /home/me/blog/prod/bin
run_exec = findself
%
( May 08 2006, 06:36:27 PM PDT )
Permalink
Comments [0]
Special Math Functions Draft Technical Report
There were three major items to come out of the Berlin ISO C standard
committee meeting which will move forward in the process of becoming
Technical Reports.
Linux Technology Preview #3
While in Berlin at the ISO C standards meeting Sun announced:
Linux Compiler Technology Preview (TP) #3
The announcement went out to the Sun Studio Forum for Linux users, here.
TP #3 has some interesting features: