OpenSolaris

You are not signed in. Sign in or register.

Flag Day: gcc support and shadow compilation

Date: Thu, 30 Mar 2006 16:22:38 -0800
From: Keith M Wesolowski <keith dot wesolowski at sun dot com>
To: onnv-gate at onnv dot eng dot sun dot com, on-all at eng dot sun dot com
Subject: Flag Day: gcc support and shadow compilation

My putback for

	6242262 ON should be buildable with gcc

is a major flag day for the entire ON extended family.  Please read on to
understand what this change means to you.

Build Machine Maintainers
=========================

You must update your build tools immediately to pick up major changes to
the compiler wrapper.  You may install SUNWonbld (strongly preferred)
from /ws/onnv-gate/public/packages/`uname -p` or update cw directly from
/net/onnv.eng/opt/onbld/bin/`uname -p`.  Old build tools will continue
to work; however, they will not enforce the code quality requirements
described below.  New tools will generate errors when used to
build an old workspace; see the section on Build Tools below for a
workaround.

Note also that if you have not already followed the instructions from
September 2005 for updating gcc
(http://onnv.sfbay/links/flagdays/pages/2005092001.html), or do not have
gcc installed at all (a decent possibility for recent build machines, or on
SPARC, which has not yet required it) then you will get errors from the gcc
back-end, including:

    cc1: error: invalid option `save-args'
    cc1: error: unrecognized command line option "-fno-constant-pools"
    cc1: error: unrecognized command line option "-fno-dwarf2-indirect-strings"
    cc1: error: unrecognized command line option "-fno-jump-tables"
    cc1: note: -fwritable-strings is deprecated; see documentation for details

Please make sure that gcc is installed and up-to-date.  gcc --version should
contain the line:

    gcc (GCC) 3.4.3 (csl-sol210-3_4-20050802)

or otherwise indicate a newer version.  In particular, the version used to
build ON10 -- csl-sol210-3_4-branch -- is too old.


All Engineers
=============

Shadow Compilation
------------------
This putback introduces the concept of primary and shadow compilers.
Both will be executed by the compiler wrapper when compiling most files
in ON.  This is done automatically and requires no special steps on your
part.  In your nightly log, you will see something like:

/builds2/wesolows/gcc/usr/src/tools/proto/opt/onbld//bin/i386/cw -_cc
[flags]
+ /usr/sfw/bin/gcc [flags] -o /tmp/.cwhvG.tt.o
+ /ws/onnv-tools/SUNWspro/SOS10/bin/cc -O [flags]

Note that both compilers are executed instead of only the primary,
designated by the "-_cc" argument to cw.  The shadow compiler is used
only to compile, never to link.  At this time, Studio 10 remains the
primary compiler, and gcc is the shadow compiler, on both x86 and SPARC.

Warnings and Errors
-------------------
The effect of shadow compilation is to expand the set of warnings and
errors emitted by the compiler to include those issued by gcc.
Therefore, you may see warnings or errors in your code that you did not
see previously.  As before, these must be fixed before putback.  The
ONNV C-team will enforce this policy[0].  For information on the
rationale and background for this policy, see
http://solaris.eng/onnv/Agendas/Meeting_Materials/03.20.06/d-compilers.txt.
A detailed description of Shadow Compilation is also provided by
http://solaris.eng/onnv/Agendas/Meeting_Materials/03.20.06/d-compilers-impl.txt.

Because many of these warnings may be unfamiliar, we have prepared a
document describing some of the common ones, as well as how to avoid
them.  See
http://opensolaris.org/os/community/tools/gcc/bug_fixing_notes/.

Incremental Builds
------------------
You should perform a clobber build after the first bringover containing
these changes.  Incrementals will work but will not cause the shadow
compiler to be run on active files you have not changed since your last
build.  This could cause you to miss errors or warnings that would be
issued by the shadow compiler.  Afterward, incrementals will work
normally.

Compiler Bugs
-------------
If you believe a warning or error you are seeing is the result of a bug
in gcc, please file the bug against solaris/utility/gnu_compiler.  If
the bug is in fact in the compiler, there is no workaround, and it is
blocking you from putting back, the C-team may issue you a waiver.

Build Tools
-----------
If your build machine has not yet been updated, you must either build
a copy of the tools containing my changes (such as with nightly's 't'
option) or use the tools in /ws/onnv-tools/onbld.  You can find out
whether your build tools are current by doing:

	$ strings /path/to/cw | grep SHADOW

You should see:

	CW_SHADOW_SERIAL
	CW_NO_SHADOW

If not, your tools are too old and do not support shadow compilation.

Building a workspace that does not contain my changes with the new tools
will cause build failures due to gcc errors and warnings.  You can avoid
these until you resync by setting:

	CW_NO_SHADOW=1

in your environment (either in your shell or in your nightly env file).

The compiler wrapper now has a man page.  See cw(1).

Build Times
-----------
Both compilers are executed in parallel by default.  Therefore the
increase in build time caused by shadow compilation will vary from
machine to machine.  In general, expect a 20-30% increase in build
times.  This is somewhat less than the time taken by lint.

Building with GCC as the Primary Compiler
-----------------------------------------
You can build with gcc as the primary compiler (Studio will be the
shadow compiler) by setting the __GNUC environment variable to the empty
value.  Note that you are not yet required to do this, nor are you
required to test any gcc-built objects.

References
==========

[0]
http://solaris.eng/onnv/Agendas/Meeting_Materials/03.20.06/compiler-policy.txt


-- 
Keith M Wesolowski		"Sir, we're surrounded!" 
Solaris Kernel Team		"Excellent; we can attack in any direction!"