— invoke one
or more compilers with argument translation
-- compiler args
is a facility for invoking one or more
compilers, providing translation from Sun style arguments as appropriate. This
allows the use of arbitrary compilers without the need to alter large numbers
of makefiles. A mode called shadow compilation invokes multiple compilers so
that warnings and errors may be obtained from both. See SHADOW COMPILATION for
details. This version of cw supports compilers with both Sun Studio 12 and
GCC-style command lines.
Both the --primary
parameters take a
. This is a comma-separated
list of the form name,executable,style
is a name for the compiler,
is the full path to the compiler
executable, and style
is the style of
command-line options the compiler expects, either
- Specify the compiler to be used primarily (that which is
used for link-editing and pre-processing, and whos objects we
- Specify a shadow compiler, which builds sources for the
sake of checking code quality and compatibility, but has its output
- Do not echo the actual command line of any compilers
- Request from each configured primary and shadow compiler
its version information.
- The sources being compiled are C++. This is necessary as it
affects the translation of compiler arguments.
- Arguments intended for the compilers themselves must be
separated from those of cw by a
- Parameters intended for the compiler be guarded with
options of the form -_name= and
name and style
are those passed to --primary and
--shadow this allows certain flags to be
passed only to certain classes of compiler.
For historical reasons, the -_style= option is
also translated such that a style of sun may
use the flag -_cc= and a style of
gnu may use the flag
-_gcc=, and when the
-C option is given and C++ is in use the
style of sun may use the flag
-_CC= and the style of
gnu may use the flag
compilers are specified
will invoke shadow compiler, with the outputs
modified (as well as any translation for compiler style) as follows:
- If none of -c,
-E, -P, or
-S appears in the argument list (that is,
linking is attempted), the shadow compilers will not be invoked. This is
because the objects built with that compiler which would be linked have
been previously discarded.
- If an option of the form -o
filename was provided, it will be
replaced by two options of the form -o
- If the option -o was not
tempfile will be added to the end of the
argument list used to invoke the shadow compilers.
When shadow compilation is in effect, cw
standard error each compiler's standard error output following its argument
list. Messages from the compilers will not be interleaved. If
is used to invoke the preprocessor and no
output location is specified, cw
will write to
standard output the primary compiler's standard output, and the secondary
compiler's standard output will be discarded.
Because the Sun compilers write intermediate objects to fixed filenames in the
current directory when instructed to compile and link multiple source files
via a single command line, it would be unsafe to invoke more than one compiler
in this fashion. Therefore cw
does not accept
multiple source files unless the preprocessor is to be invoked. An attempt to
in this manner will result in an error.
If the compiler to be invoked is a GNU-style C or C++ compiler, a set of default
flags is added to the beginning of the argument list, and the remaining
arguments are translated to their closest appropriate semantic equivalents and
passed in the same order as their counterparts given to
. See the comments at the head of
for a detailed list of
- If this variable is set in the environment, invoke the
primary compiler, wait for it to complete, then invoke the shadow
compilers. Normally the primary and shadow compilers are invoked in
- If this variable is set in the environment, write the usual
output to standard error but do not actually invoke any compiler. This is
useful for debugging the translation engine.
The following exit status values are returned:
- The primary compiler, and shadow compilers if invoked, both
- A usage error occurred, or one or more compilers returned a
nonzero exit status.
The translations provided for gcc are not always exact and in some cases reflect
local policy rather than actual equivalence.
Additional compiler types should be supported.
The translation engine is hacky.