1 CW(1ONBLD)                    illumos Build Tools                   CW(1ONBLD)
   2 
   3 NAME
   4      cw - invoke one or more compilers with argument translation
   5 
   6 SYNOPSIS
   7      cw [-C] [--versions] [--noecho] --primary compiler
   8         [--shadow compiler ...] -- compiler args ...
   9 
  10 DESCRIPTION
  11      cw is a facility for invoking one or more compilers, providing
  12      translation from Sun style arguments as appropriate.  This allows the use
  13      of arbitrary compilers without the need to alter large numbers of
  14      makefiles.  A mode called shadow compilation invokes multiple compilers
  15      so that warnings and errors may be obtained from both.  See SHADOW
  16      COMPILATION for details.  This version of cw supports compilers with both
  17      Sun Studio 12 and GCC-style command lines.
  18 
  19 ARGUMENTS
  20      Both the --primary and --secondary parameters take a compiler
  21      specification.  This is a comma-separated list of the form
  22      name,executable,style Where name is a name for the compiler, executable
  23      is the full path to the compiler executable, and style is the style of
  24      command-line options the compiler expects, either sun or gnu.
  25 
  26      --primary compiler
  27              Specify the compiler to be used primarily (that which is used for
  28              link-editing and pre-processing, and whos objects we deliver).
  29 
  30      --shadow compiler
  31              Specify a shadow compiler, which builds sources for the sake of
  32              checking code quality and compatibility, but has its output
  33              discarded.
  34 
  35      --noecho
  36              Do not echo the actual command line of any compilers invoked.
  37 
  38      --versions
  39              Request from each configured primary and shadow compiler its
  40              version information.
  41 
  42      -C      The sources being compiled are C++.  This is necessary as it
  43              affects the translation of compiler arguments.
  44 
  45      --      Arguments intended for the compilers themselves must be separated
  46              from those of cw by a --.
  47 
  48      -_name=
  49 
  50      -_style=
  51              Parameters intended for the compiler be guarded with options of
  52              the form -_name= and -_style= Where name and style are those
  53              passed to --primary and --shadow this allows certain flags to be
  54              passed only to certain classes of compiler.
  55 
  56              For historical reasons, the -_style= option is also translated
  57              such that a style of sun may use the flag -_cc= and a style of
  58              gnu may use the flag -_gcc=, and when the -C option is given and
  59              C++ is in use the style of sun may use the flag -_CC= and the
  60              style of gnu may use the flag -_g++=.
  61 
  62 SHADOW COMPILATION
  63      If --shadow compilers are specified cw will invoke shadow compiler, with
  64      the outputs modified (as well as any translation for compiler style) as
  65      follows:
  66 
  67      1.   If none of -c, -E, -P, or -S appears in the argument list (that is,
  68           linking is attempted), the shadow compilers will not be invoked.
  69           This is because the objects built with that compiler which would be
  70           linked have been previously discarded.
  71 
  72      2.   If the -o filename option was provided, with or without a separating
  73           space, it will be replaced with -o tempfile
  74 
  75      3.   If the option -o was not provided, -o tempfile will be added to the
  76           end of the argument list used to invoke the shadow compilers.
  77      When shadow compilation is in effect, cw writes to standard error each
  78      compiler's standard error output following its argument list.  Messages
  79      from the compilers will not be interleaved.  If cw is used to invoke the
  80      preprocessor and no output location is specified, cw will write to
  81      standard output the primary compiler's standard output, and the secondary
  82      compiler's standard output will be discarded.
  83 
  84      Because the Sun compilers write intermediate objects to fixed filenames
  85      in the current directory when instructed to compile and link multiple
  86      source files via a single command line, it would be unsafe to invoke more
  87      than one compiler in this fashion.  Therefore cw does not accept multiple
  88      source files unless the preprocessor is to be invoked.  An attempt to
  89      invoke cw in this manner will result in an error.
  90 
  91 ARGUMENT TRANSLATION
  92      If the compiler to be invoked is a GNU-style C or C++ compiler, a set of
  93      default flags is added to the beginning of the argument list, and the
  94      remaining arguments are translated to their closest appropriate semantic
  95      equivalents and passed in the same order as their counterparts given to
  96      cw.  See the comments at the head of usr/src/tools/cw/cw.c for a detailed
  97      list of translations.
  98 
  99 ENVIRONMENT
 100      CW_SHADOW_SERIAL
 101              If this variable is set in the environment, invoke the primary
 102              compiler, wait for it to complete, then invoke the shadow
 103              compilers.  Normally the primary and shadow compilers are invoked
 104              in parallel.
 105 
 106      CW_NO_EXEC
 107              If this variable is set in the environment, write the usual
 108              output to standard error but do not actually invoke any compiler.
 109              This is useful for debugging the translation engine.
 110 
 111 EXIT STATUS
 112      The following exit status values are returned:
 113 
 114      0       The primary compiler, and shadow compilers if invoked, both
 115              completed successfully.
 116 
 117      >0           A usage error occurred, or one or more compilers returned a
 118              nonzero exit status.
 119 
 120 SEE ALSO
 121      cc(1), CC(1), gcc(1)
 122 
 123 BUGS
 124      The translations provided for gcc are not always exact and in some cases
 125      reflect local policy rather than actual equivalence.
 126 
 127      Additional compiler types should be supported.
 128 
 129      The translation engine is hacky.
 130 
 131 illumos                        February 10, 2018                       illumos