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 ...] [--linker linker] -- 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 all of them.  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 --shadow parameters take a compiler specification.
  21      This is a comma-separated list of the form name,executable,style Where
  22      name is a name for the compiler, executable is the full path to the
  23      compiler executable, and style is the style of command-line options the
  24      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      --linker linker
  36              Specify a link-editor to use in place of /usr/bin/ld.  ld(1)
  37              itself arranges for this to be executed by any subprocesses.
  38 
  39      --noecho
  40              Do not echo the actual command line of any compilers invoked.
  41 
  42      --versions
  43              Request from each configured primary and shadow compiler its
  44              version information.
  45 
  46      -C      The sources being compiled are C++.  This is necessary as it
  47              affects the translation of compiler arguments.
  48 
  49      --      Arguments intended for the compilers themselves must be separated
  50              from those of cw by a --.
  51 
  52      -_name=
  53 
  54      -_style=
  55              Parameters intended for the compiler be guarded with options of
  56              the form -_name= and -_style= Where name and style are those
  57              passed to --primary and --shadow this allows certain flags to be
  58              passed only to certain classes of compiler.
  59 
  60              For historical reasons, the -_style= option is also translated
  61              such that a style of sun may use the flag -_cc= and a style of
  62              gnu may use the flag -_gcc=, and when the -C option is given and
  63              C++ is in use the style of sun may use the flag -_CC= and the
  64              style of gnu may use the flag -_g++=.
  65 
  66 SHADOW COMPILATION
  67      If --shadow compilers are specified cw will invoke each shadow compiler,
  68      with the outputs modified (as well as any translation for compiler style)
  69      as follows:
  70 
  71      1.   If cw is invoked to link-edit without compilation (the input files
  72           are all objects), the shadow compiler is not invoked.
  73 
  74      2.   If the -o filename option was provided, with or without a separating
  75           space, it will be replaced with -o tempfile
  76 
  77      3.   If the option -o was not provided, -o tempfile will be added to the
  78           end of the argument list used to invoke the shadow compilers.
  79      When shadow compilation is in effect, cw writes to standard error each
  80      compiler's standard error output following its argument list.  Messages
  81      from the compilers will not be interleaved.  If cw is used to invoke the
  82      preprocessor and no output location is specified, cw will write to
  83      standard output the primary compiler's standard output.
  84 
  85      Because the Sun compilers write intermediate objects to fixed filenames
  86      in the current directory when instructed to compile and link multiple
  87      source files via a single command line, it would be unsafe to invoke more
  88      than one compiler in this fashion.  Therefore cw does not accept multiple
  89      source files unless the preprocessor is to be invoked.  An attempt to
  90      invoke cw in this manner will result in an error.
  91 
  92 ARGUMENT TRANSLATION
  93      If the compiler to be invoked is a GNU-style C or C++ compiler, a set of
  94      default flags is added to the beginning of the argument list, and the
  95      remaining arguments are translated to their closest appropriate semantic
  96      equivalents and passed in the same order as their counterparts given to
  97      cw.  See the comments at the head of usr/src/tools/cw/cw.c for a detailed
  98      list of translations.
  99 
 100 ENVIRONMENT
 101      CW_SHADOW_SERIAL
 102              If this variable is set in the environment, invoke the primary
 103              compiler, wait for it to complete, then invoke the shadow
 104              compilers.  Normally the primary and shadow compilers are invoked
 105              in parallel.
 106 
 107      CW_NO_EXEC
 108              f this variable is set in the environment, write the usual output
 109              to standard error but do not actually invoke any compiler.  This
 110              is useful for debugging the translation engine.
 111 
 112 EXIT STATUS
 113      The following exit status values are returned:
 114 
 115      0       The primary compiler, and shadow compilers if invoked, all
 116              completed successfully.
 117 
 118      >0           A usage error occurred, or one or more compilers returned a
 119              nonzero exit status.
 120 
 121 SEE ALSO
 122      cc(1), CC(1), gcc(1), ld(1)
 123 
 124 BUGS
 125      The translations provided for gcc are not always exact and in some cases
 126      reflect local policy rather than actual equivalence.
 127 
 128      Additional compiler types should be supported.
 129 
 130      The translation engine is hacky.
 131 
 132 illumos                        September 4, 2018                       illumos