[project @ 2001-02-15 17:33:53 by simonmar]
authorsimonmar <unknown>
Thu, 15 Feb 2001 17:33:53 +0000 (17:33 +0000)
committersimonmar <unknown>
Thu, 15 Feb 2001 17:33:53 +0000 (17:33 +0000)
More documentation rewriting...  I'm particularly proud of the "flag
reference" section, please check it out.

ghc/docs/users_guide/debugging.sgml
ghc/docs/users_guide/flags.sgml [new file with mode: 0644]
ghc/docs/users_guide/glasgow_exts.sgml
ghc/docs/users_guide/packages.sgml [new file with mode: 0644]
ghc/docs/users_guide/phases.sgml [new file with mode: 0644]
ghc/docs/users_guide/separate_compilation.sgml [new file with mode: 0644]
ghc/docs/users_guide/ug-ent.sgml
ghc/docs/users_guide/using.sgml

index fde6973..e6e8029 100644 (file)
@@ -11,123 +11,6 @@ HACKER TERRITORY. HACKER TERRITORY.
 (You were warned.)
 </Para>
 
-<Sect2 id="replacing-phases">
-<Title>Replacing the program for one or more phases.
-</Title>
-
-<Para>
-<IndexTerm><Primary>GHC phases, changing</Primary></IndexTerm>
-<IndexTerm><Primary>phases, changing GHC</Primary></IndexTerm>
-You may specify that a different program be used for one of the phases
-of the compilation system, in place of whatever the driver <Command>ghc</Command> has
-wired into it.  For example, you might want to try a different
-assembler.  The
-<Option>-pgm&lt;phase-code&gt;&lt;program-name&gt;</Option><IndexTerm><Primary>-pgm&lt;phase&gt;&lt;stuff&gt;
-option</Primary></IndexTerm> option to <Command>ghc</Command> will cause it to use <Literal>&lt;program-name&gt;</Literal>
-for phase <Literal>&lt;phase-code&gt;</Literal>, where the codes to indicate the phases are:
-</Para>
-
-<Para>
-<InformalTable>
-<TGroup Cols="2">
-<ColSpec Align="Left" Colsep="0">
-<ColSpec Align="Left" Colsep="0">
-<TBody>
-<Row>
-<Entry><Emphasis>code</Emphasis> </Entry>
-<Entry><Emphasis>phase</Emphasis> </Entry>
-</Row>
-
-<Row>
-<Entry>
-L </Entry>
-<Entry> literate pre-processor </Entry>
-</Row>
-<Row>
-<Entry>
-P </Entry>
-<Entry> C pre-processor (if -cpp only) </Entry>
-</Row>
-<Row>
-<Entry>
-C </Entry>
-<Entry> Haskell compiler </Entry>
-</Row>
-<Row>
-<Entry>
-c </Entry>
-<Entry> C compiler</Entry>
-</Row>
-<Row>
-<Entry>
-a </Entry>
-<Entry> assembler </Entry>
-</Row>
-<Row>
-<Entry>
-l </Entry>
-<Entry> linker </Entry>
-</Row>
-<Row>
-<Entry>
-dep </Entry>
-<Entry> Makefile dependency generator </Entry>
-</Row>
-
-</TBody>
-
-</TGroup>
-</InformalTable>
-</Para>
-
-</Sect2>
-
-<Sect2 id="forcing-options-through">
-<Title>Forcing options to a particular phase.
-</Title>
-
-<Para>
-<IndexTerm><Primary>forcing GHC-phase options</Primary></IndexTerm>
-</Para>
-
-<Para>
-The preceding sections describe driver options that are mostly
-applicable to one particular phase.  You may also <Emphasis>force</Emphasis> a
-specific option <Option>&lt;option&gt;</Option> to be passed to a particular phase
-<Literal>&lt;phase-code&gt;</Literal> by feeding the driver the option
-<Option>-opt&lt;phase-code&gt;&lt;option&gt;</Option>.<IndexTerm><Primary>-opt&lt;phase&gt;&lt;stuff&gt;
-option</Primary></IndexTerm> The codes to indicate the phases are the same as in the
-previous section.
-</Para>
-
-<Para>
-So, for example, to force an <Option>-Ewurble</Option> option to the assembler, you
-would tell the driver <Option>-opta-Ewurble</Option> (the dash before the E is
-required).
-</Para>
-
-<Para>
-Besides getting options to the Haskell compiler with <Option>-optC&lt;blah&gt;</Option>,
-you can get options through to its runtime system with
-<Option>-optCrts&lt;blah&gt;</Option><IndexTerm><Primary>-optCrts&lt;blah&gt; option</Primary></IndexTerm>.
-</Para>
-
-<Para>
-So, for example: when I want to use my normal driver but with my
-profiled compiler binary, I use this script:
-
-<ProgramListing>
-#! /bin/sh
-exec /local/grasp_tmp3/simonpj/ghc-BUILDS/working-alpha/ghc/driver/ghc \
-     -pgmC/local/grasp_tmp3/simonpj/ghc-BUILDS/working-hsc-prof/hsc \
-     -optCrts-i0.5 \
-     -optCrts-PT \
-     "$@"
-</ProgramListing>
-
-</Para>
-
-</Sect2>
 
 <Sect2 id="dumping-output">
 <Title>Dumping out compiler intermediate structures
@@ -196,31 +79,6 @@ renamer output
 </VarListEntry>
 
 <VarListEntry>
-<Term><Option>-ddump-minimal-imports</Option>:</Term>
-<ListItem>
-<Para>
-Dump to the file "M.imports" (where M is the module being compiled)
-a "minimal" set of import declarations.  You can safely replace
-all the import declarations in "M.hs" with those found in "M.imports".
-Why would you want to do that?  Because the "minimal" imports (a) import
-everything explicitly, by name, and (b) import nothing that is not required.
-It can be quite painful to maintain this property by hand, so this flag is
-intended to reduce the labour.
-</Para>
-</ListItem>
-</VarListEntry>
-
-<VarListEntry>
-<Term><Option>-ddump-hi-diffs</Option>:</Term>
-<ListItem>
-<Para>
-Dump to stdout a summary of the differences between the existing interface file (if any)
-for this module, and the new one.
-</Para>
-</ListItem>
-</VarListEntry>
-
-<VarListEntry>
 <Term><Option>-ddump-tc</Option>:</Term>
 <ListItem>
 <Para>
diff --git a/ghc/docs/users_guide/flags.sgml b/ghc/docs/users_guide/flags.sgml
new file mode 100644 (file)
index 0000000..751221d
--- /dev/null
@@ -0,0 +1,1577 @@
+  <sect1>
+    <title>Flag reference</title>
+
+    <sect2>
+      <title>Help and verbosity options (<xref linkend="options-help">)</title>
+
+      <informaltable>
+       <tgroup cols=3 align=left colsep=1 rowsep=1>
+         <thead>
+           <row>
+             <entry>Flag</entry>
+             <entry>Description</entry>
+             <entry>Static/Dynamic</entry>
+             <entry>Reverse</entry>
+           </row>
+         </thead>
+         <tbody>
+           <row>
+             <entry><option>-?</option></entry>
+             <entry>help</entry>
+             <entry>static</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-help</option></entry>
+             <entry>help</entry>
+             <entry>static</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-v</option></entry>
+             <entry>verbose mode (equivalent to <option>-v3</option>)</entry>
+             <entry>dynamic</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-v</option><replaceable>n</replaceable></entry>
+             <entry>set verbosity level</entry>
+             <entry>dynamic</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>--version</option></entry>
+             <entry>display GHC version</entry>
+             <entry>static</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>--numeric-version</option></entry>
+             <entry>display GHC version (numeric only)</entry>
+             <entry>static</entry>
+             <entry>-</entry>
+           </row>
+         </tbody>
+       </tgroup>
+      </informaltable>
+
+    </sect2>
+    <sect2>
+      <title>Which phases to run (<xref linkend="options-order">)</title>
+      
+      <informaltable>
+       <tgroup cols=3 align=left colsep=1 rowsep=1>
+         <thead>
+           <row>
+             <entry>Flag</entry>
+             <entry>Description</entry>
+             <entry>Static/Dynamic</entry>
+             <entry>Reverse</entry>
+           </row>
+         </thead>
+         <tbody>
+           <row>
+             <entry><option>-cpp</option></entry>
+             <entry>Run the C pre-processor on the Haskell source</entry>
+             <entry>dynamic</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-E</option></entry>
+             <entry>Stop after preprocessing (<literal>.hspp</literal> file)</entry>
+             <entry>static</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-C</option></entry>
+             <entry>Stop after generating C (<literal>.hc</literal> file)</entry>
+             <entry>static</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-S</option></entry>
+             <entry>Stop after generating assembly (<literal>.s</literal> file)</entry>
+             <entry>static</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-c</option></entry>
+             <entry>Stop after compiling to object code (<literal>.o</literal> file)</entry>
+             <entry>static</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-fasm</option></entry>
+             <entry>Use the native code generator</entry>
+             <entry>dynamic</entry>
+             <entry>-fvia-C</entry>
+           </row>
+           <row>
+             <entry><option>-fvia-C</option></entry>
+             <entry>Compile via C</entry>
+             <entry>dynamic</entry>
+             <entry>-fasm</entry>
+           </row>
+         </tbody>
+       </tgroup>
+      </informaltable>
+    </sect2>
+
+    <sect2>
+      <title>Redirecting output (<xref linkend="options-output">)</title>
+      
+      <informaltable>
+       <tgroup cols=3 align=left colsep=1 rowsep=1>
+         <thead>
+           <row>
+             <entry>Flag</entry>
+             <entry>Description</entry>
+             <entry>Static/Dynamic</entry>
+             <entry>Reverse</entry>
+           </row>
+         </thead>
+         <tbody>
+           <row>
+             <entry><option>-hisuf</option> <replaceable>suffix</replaceable></entry>
+             <entry>set the suffix to use for interface files</entry>
+             <entry>static</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-o</option> <replaceable>filename</replaceable></entry>
+             <entry>set output filename</entry>
+             <entry>static</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-odir</option> <replaceable>dir</replaceable></entry>
+             <entry>set output directory</entry>
+             <entry>static</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-ohi</option> <replaceable>filename</replaceable></entry>
+             <entry>set the filename in which to put the interface</entry>
+             <entry>static</entry>
+             <entry></entry>
+           </row>
+           <row>
+             <entry><option>-osuf</option> <replaceable>suffix</replaceable></entry>
+             <entry>set the output file suffix</entry>
+             <entry>static</entry>
+             <entry>-</entry>
+           </row>
+         </tbody>
+       </tgroup>
+      </informaltable>
+    </sect2>
+
+    <sect2>
+      <title>Keeping intermediate files (<xref linkend="keeping-intermediates">)</title>
+      
+      <informaltable>
+       <tgroup cols=3 align=left colsep=1 rowsep=1>
+         <thead>
+           <row>
+             <entry>Flag</entry>
+             <entry>Description</entry>
+             <entry>Static/Dynamic</entry>
+             <entry>Reverse</entry>
+           </row>
+         </thead>
+         <tbody>
+           <row>
+             <entry><option>-keep-hc-file</option></entry>
+             <entry>retain intermediate <literal>.hc</literal> files</entry>
+             <entry>static</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-keep-s-file</option></entry>
+             <entry>retain intermediate <literal>.s</literal> files</entry>
+             <entry>static</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-keep-raw-s-file</option></entry>
+             <entry>retain intermediate <literal>.raw_s</literal> files</entry>
+             <entry>static</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-keep-tmp-files</option></entry>
+             <entry>retain all intermediate temporary files</entry>
+             <entry>static</entry>
+             <entry>-</entry>
+           </row>
+         </tbody>
+       </tgroup>
+      </informaltable>
+    </sect2>
+
+    <sect2>
+      <title>Temporary files (<xref linkend="temp-files">)</title>
+      
+      <informaltable>
+       <tgroup cols=3 align=left colsep=1 rowsep=1>
+         <thead>
+           <row>
+             <entry>Flag</entry>
+             <entry>Description</entry>
+             <entry>Static/Dynamic</entry>
+             <entry>Reverse</entry>
+           </row>
+         </thead>
+         <tbody>
+           <row>
+             <entry><option>-tmpdir</option></entry>
+             <entry>set the directory for temporary files</entry>
+             <entry>static</entry>
+             <entry>-</entry>
+           </row>
+         </tbody>
+       </tgroup>
+      </informaltable>
+    </sect2>
+
+    <sect2>
+      <title>Finding imports (<xref linkend="options-finding-imports">)</title>
+
+      <informaltable>
+       <tgroup cols=3 align=left colsep=1 rowsep=1>
+         <thead>
+           <row>
+             <entry>Flag</entry>
+
+             <entry>Description</entry>
+             <entry>Static/Dynamic</entry>
+             <entry>Reverse</entry>
+           </row>
+         </thead>
+         <tbody>
+           <row>
+             <entry><option>-i</option><replaceable>dir1</replaceable>:<replaceable>dir2</replaceable>:...</entry>
+             <entry>add <replaceable>dir</replaceable>,
+                 <replaceable>dir2</replaceable>, etc. to import path</entry>
+             <entry>static</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-i</option></entry>
+             <entry>Empty the import directory list</entry>
+             <entry>static</entry>
+             <entry>-</entry>
+           </row>
+         </tbody>
+       </tgroup>
+      </informaltable>
+    </sect2>
+
+    <sect2>
+      <title>Interface file options (<xref linkend="hi-options">)</title>
+
+      <informaltable>
+       <tgroup cols=3 align=left colsep=1 rowsep=1>
+         <thead>
+           <row>
+             <entry>Flag</entry>
+
+             <entry>Description</entry>
+             <entry>Static/Dynamic</entry>
+             <entry>Reverse</entry>
+           </row>
+         </thead>
+         <tbody>
+           <row>
+             <entry><option>-ohi</option> <replaceable>file</replaceable></entry>
+             <entry>Put the interface file in <replaceable>file</replaceable></entry>
+             <entry>static</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-ddump-hi</option></entry>
+             <entry>Dump the new interface to stdout</entry>
+             <entry>dynamic</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-ddump-hi-diffs</option></entry>
+             <entry>Show the differences vs. the old interface</entry>
+             <entry>dynamic</entry>
+             <entry>-</entry>
+           </row>
+         </tbody>
+       </tgroup>
+      </informaltable>
+    </sect2>
+    
+    <sect2>
+      <title>Recompilation checking (<xref linkend="recomp">)</title>
+
+      <informaltable>
+       <tgroup cols=3 align=left colsep=1 rowsep=1>
+         <thead>
+           <row>
+             <entry>Flag</entry>
+
+             <entry>Description</entry>
+             <entry>Static/Dynamic</entry>
+             <entry>Reverse</entry>
+           </row>
+         </thead>
+         <tbody>
+           <row>
+             <entry><option>-no-recomp</option></entry>
+             <entry>Turn off recompilation checking</entry>
+             <entry>static</entry>
+             <entry>-recomp</entry>
+           </row>
+         </tbody>
+       </tgroup>
+      </informaltable>
+    </sect2>
+
+    <sect2>
+      <title>Packages (<xref linkend="packages">)</title>
+      <informaltable>
+       <tgroup cols=3 align=left colsep=1 rowsep=1>
+         <thead>
+           <row>
+             <entry>Flag</entry>
+             <entry>Description</entry>
+             <entry>Static/Dynamic</entry>
+             <entry>Reverse</entry>
+           </row>
+         </thead>
+         <tbody>
+           <row>
+             <entry><option>--add-package</option></entry>
+             <entry>Install a new package</entry>
+             <entry>static</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>--delete-package</option> <replaceable>name</replaceable></entry>
+             <entry>Delete package entry <replaceable>name</replaceable></entry>
+             <entry>static</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>--list-packages</option></entry>
+             <entry>List installed packages</entry>
+             <entry>static</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-package</option> <replaceable>name</replaceable></entry>
+             <entry>Use package <replaceable>name</replaceable></entry>
+             <entry>static</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-package-name</option> <replaceable>name</replaceable></entry>
+             <entry>Compile code for package <replaceable>name</replaceable></entry>
+             <entry>static</entry>
+             <entry>-</entry>
+           </row>
+         </tbody>
+       </tgroup>
+      </informaltable>
+    </sect2>
+
+    <sect2>
+      <title>Language options (<xref linkend="options-language">)</title>
+
+      <informaltable>
+       <tgroup cols=3 align=left colsep=1 rowsep=1>
+         <thead>
+           <row>
+             <entry>Flag</entry>
+             <entry>Description</entry>
+             <entry>Static/Dynamic</entry>
+             <entry>Reverse</entry>
+           </row>
+         </thead>
+         <tbody>
+           <row>
+             <entry><option>-fallow-overlapping-instances</option></entry>
+             <entry></entry>
+             <entry>dynamic</entry>
+             <entry><option>-fno-allow-overlapping-instances</option></entry>
+           </row>
+           <row>
+             <entry><option>-fallow-undecidable-instances</option></entry>
+             <entry>Enable undecidable instances</entry>
+             <entry>dynamic</entry>
+             <entry><option>-fno-allow-undecidable-instances</option></entry>
+           </row>
+           <row>
+             <entry><option>-fgenerics</option></entry>
+             <entry>Enable generics</entry>
+             <entry>dynamic</entry>
+             <entry><option>-fno-fgenerics</option></entry>
+           </row>
+           <row>
+             <entry><option>-fglasgow-exts</option></entry>
+             <entry>Enable most language extensions</entry>
+             <entry>dynamic</entry>
+             <entry><option>-fno-glasgow-exts</option></entry>
+           </row>
+           <row>
+             <entry><option>-fignore-asserts</option></entry>
+             <entry>Ignore assertions</entry>
+             <entry>dynamic</entry>
+             <entry><option>-fno-ignore-asserts</option></entry>
+           </row>
+           <row>
+             <entry><option>-fno-implicit-prelude</option></entry>
+             <entry>Don't implicitly <literal>import Prelude</literal></entry>
+             <entry>dynamic</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-fno-monomorphism-restriction</option></entry>
+             <entry>Disable the monomorphism restriction</entry>
+             <entry>dynamic</entry>
+             <entry><option>-</option></entry>
+           </row>
+           <row>
+             <entry><option>-firrefutable-tuples</option></entry>
+             <entry>Make tuple pattern matching irrefutable</entry>
+             <entry>dynamic</entry>
+             <entry><option>-fno-irrefutable-tuples</option></entry>
+           </row>
+           <row>
+             <entry><option>-fcontext-stack</option><replaceable>n</replaceable></entry>
+             <entry>set the limit for context reduction</entry>
+             <entry>dynamic</entry>
+             <entry><option>-</option></entry>
+           </row>
+         </tbody>
+       </tgroup>
+      </informaltable>
+    </sect2>
+
+    <sect2>
+      <title>Warnings (<xref linkend="options-sanity">)</title>
+      
+    <informaltable>
+      <tgroup cols=3 align=left colsep=1 rowsep=1>
+       <thead>
+         <row>
+           <entry>Flag</entry>
+           <entry>Description</entry>
+           <entry>Static/Dynamic</entry>
+           <entry>Reverse</entry>
+         </row>
+       </thead>
+       <tbody>
+         <row>
+           <entry><option>-W</option></entry>
+           <entry>enable normal warnings</entry>
+           <entry>static</entry>
+           <entry><option>-w</option></entry>
+         </row>
+         <row>
+           <entry><option>-w</option></entry>
+           <entry>disable all warnings</entry>
+           <entry>static</entry>
+           <entry>-</entry>
+         </row>
+         <row>
+           <entry><option>-Wall</option></entry>
+           <entry>enable all warnings</entry>
+           <entry>static</entry>
+           <entry><option>-w</option></entry>
+         </row>
+
+         <row>
+           <entry><option>-fwarn-deprecations</option></entry>
+           <entry>warn about uses of functions & types that are deprecated</entry>
+           <entry>dynamic</entry>
+           <entry><option>-fno-warn-deprecations</option></entry>
+         </row>
+
+         <row>
+           <entry><option>-fwarn-duplicate-exports</option></entry>
+           <entry>warn when an entity is exported multiple times</entry>
+           <entry>dynamic</entry>
+           <entry><option>-fno-warn-duplicate-exports</option></entry>
+         </row>
+
+         <row>
+           <entry><option>-fwarn-hi-shadowing</option></entry>
+           <entry>warn when a <literal>.hi</literal> file in the
+           current directory shadows a library</entry>
+           <entry>dynamic</entry>
+           <entry><option>-fno-warn-hi-shadowing</option></entry>
+         </row>
+
+         <row>
+           <entry><option>-fwarn-incomplete-patterns</option></entry>
+           <entry>warn when a pattern match could fail</entry>
+           <entry>dynamic</entry>
+           <entry><option>-fno-warn-incomplete-patterns</option></entry>
+         </row>
+
+         <row>
+           <entry><option>-fwarn-missing-fields</option></entry>
+           <entry>warn when fields of a record are uninitialised</entry>
+           <entry>dynamic</entry>
+           <entry><option>-fno-warn-missing-fields</option></entry>
+         </row>
+
+         <row>
+           <entry><option>-fwarn-missing-methods</option></entry>
+           <entry>warn when class methods are undefined</entry>
+           <entry>dynamic</entry>
+           <entry><option>-fno-warn-missing-methods</option></entry>
+         </row>
+
+         <row>
+           <entry><option>-fwarn-missing-signatures</option></entry>
+           <entry>warn about top-level functions without signatures</entry>
+           <entry>dynamic</entry>
+           <entry><option>-fno-warn-missing-signatures</option></entry>
+         </row>
+
+         <row>
+           <entry><option>-fwarn-name-shadowing</option></entry>
+           <entry>warn when names are shadowed</entry>
+           <entry>dynamic</entry>
+           <entry><option>-fno-warn-name-shadowing</option></entry>
+         </row>
+
+         <row>
+           <entry><option>-fwarn-overlapping-patterns</option></entry>
+           <entry>warn about overlapping patterns</entry>
+           <entry>dynamic</entry>
+           <entry><option>-fno-warn-overlapping-patterns</option></entry>
+         </row>
+
+         <row>
+           <entry><option>-fwarn-simple-patterns</option></entry>
+           <entry>warn about lambda-patterns that can fail</entry>
+           <entry>dynamic</entry>
+           <entry><option>-fno-warn-simple-patterns</option></entry>
+         </row>
+
+         <row>
+           <entry><option>-fwarn-type-defaults</option></entry>
+           <entry>warn when defaulting happens</entry>
+           <entry>dynamic</entry>
+           <entry><option>-fno-warn-type-defaults</option></entry>
+         </row>
+
+         <row>
+           <entry><option>-fwarn-unused-binds</option></entry>
+           <entry>warn about bindings that are unused</entry>
+           <entry>dynamic</entry>
+           <entry><option>-fno-warn-unused-binds</option></entry>
+         </row>
+
+         <row>
+           <entry><option>-fwarn-unused-imports</option></entry>
+           <entry>warn about unnecessary imports</entry>
+           <entry>dynamic</entry>
+           <entry><option>-fno-warn-unused-imports</option></entry>
+         </row>
+
+         <row>
+           <entry><option>-fwarn-unused-matches</option></entry>
+           <entry>warn about variables in patterns that aren't used</entry>
+           <entry>dynamic</entry>
+           <entry><option>-fno-warn-unused-matches</option></entry>
+         </row>
+
+         </tbody>
+       </tgroup>
+      </informaltable>
+
+    </sect2>
+    <sect2>
+      <title>Optimisation levels (<xref linkend="options-optimise">)</title>
+
+      <informaltable>
+       <tgroup cols=3 align=left colsep=1 rowsep=1>
+         <thead>
+           <row>
+             <entry>Flag</entry>
+             <entry>Description</entry>
+             <entry>Static/Dynamic</entry>
+             <entry>Reverse</entry>
+           </row>
+         </thead>
+         <tbody>
+           <row>
+             <entry><option>-O</option></entry>
+             <entry>Enable default optimisation (level 1)</entry>
+             <entry>static</entry>
+             <entry><option>-O0</option></entry>
+           </row>
+           <row>
+             <entry><option>-O</option><replaceable>n</replaceable></entry>
+             <entry>Set optimisation level <replaceable>n</replaceable></entry>
+             <entry>static</entry>
+             <entry><option>-O0</option></entry>
+           </row>
+           <row>
+             <entry><option>-O2-for-C</option></entry>
+             <entry>Run <command>gcc</command> with <option>-O2</option></entry>
+             <entry>static</entry>
+             <entry>-</entry>
+           </row>
+         </tbody>
+       </tgroup>
+      </informaltable>
+             
+    </sect2>
+    <sect2>
+      <title>Individual optimisations (<xref linkend="options-f">)</title>
+
+      <informaltable>
+       <tgroup cols=3 align=left colsep=1 rowsep=1>
+         <thead>
+           <row>
+             <entry>Flag</entry>
+             <entry>Description</entry>
+             <entry>Static/Dynamic</entry>
+             <entry>Reverse</entry>
+           </row>
+         </thead>
+         <tbody>
+           <row>
+             <entry><option>-fall-strict</option></entry>
+             <entry>Make everything strict</entry>
+             <entry>dynamic</entry>
+             <entry><option>-fno-all-strict</option></entry>
+           </row>
+
+           <row>
+             <entry><option>-fcase-merge</option></entry>
+             <entry>Enable case-merging</entry>
+             <entry>static</entry>
+             <entry><option>-fno-case-merge</option></entry>
+           </row>
+
+           <row>
+             <entry><option>-fdicts-strict</option></entry>
+             <entry>Make dictionaries strict</entry>
+             <entry>dynamic</entry>
+             <entry><option>-fno-dicts-strict</option></entry>
+           </row>
+
+           <row>
+             <entry><option>-fdo-eta-reduction</option></entry>
+             <entry>Enable eta-reduction</entry>
+             <entry>static</entry>
+             <entry><option>-fno-do-eta-reduction</option></entry>
+           </row>
+
+           <row>
+             <entry><option>-fdo-lambda-eta-expansion</option></entry>
+             <entry>Enable lambda eta-reduction</entry>
+             <entry>static</entry>
+             <entry><option>-fno-do-lambda-eta-expansion</option></entry>
+           </row>
+
+           <row>
+             <entry><option>-fexcess-precision</option></entry>
+             <entry>Enable excess intermediate precision</entry>
+             <entry>static</entry>
+             <entry><option>-fno-excess-precision</option></entry>
+           </row>
+
+           <row>
+             <entry><option>-ffoldr-build-on</option></entry>
+             <entry>Enable foldr-build optimisation</entry>
+             <entry>static</entry>
+             <entry><option>-fno-foldr-build-on</option></entry>
+           </row>
+
+           <row>
+             <entry><option>-fignore-asserts</option></entry>
+             <entry>Ignore assertions in the source</entry>
+             <entry>static</entry>
+             <entry><option>-fno-ignore-asserts</option></entry>
+           </row>
+
+           <row>
+             <entry><option>-fignore-interface-pragmas</option></entry>
+             <entry>Ignore pragmas in interface files</entry>
+             <entry>static</entry>
+             <entry><option>-fno-ignore-interface-pragmas</option></entry>
+           </row>
+
+           <row>
+             <entry><option>-flet-no-escape</option></entry>
+             <entry>Enable let-no-escape optimisation</entry>
+             <entry>static</entry>
+             <entry><option>-fno-let-no-escape</option></entry>
+           </row>
+
+           <row>
+             <entry><option>-fliberate-case-threshold</option></entry>
+             <entry>Tweak the liberate-case optimisation</entry>
+             <entry>static</entry>
+             <entry><option>-fno-liberate-case-threshold</option></entry>
+           </row>
+
+           <row>
+             <entry><option>-fomit-interface-pragmas</option></entry>
+             <entry>Don't generate interface pragmas</entry>
+             <entry>static</entry>
+             <entry><option>-fno-omit-interface-pragmas</option></entry>
+           </row>
+
+           <row>
+             <entry><option>-fmax-simplifier-iterations</option></entry>
+             <entry>Set the max iterations for the simplifier</entry>
+             <entry>static</entry>
+             <entry>-</entry>
+           </row>
+
+           <row>
+             <entry><option>-fno-cpr</option></entry>
+             <entry>Turn off CPR analysis</entry>
+             <entry>static</entry>
+             <entry>-</entry>
+           </row>
+
+           <row>
+             <entry><option>-fno-cse</option></entry>
+             <entry>Turn off common sub-expression</entry>
+             <entry>static</entry>
+             <entry>-</entry>
+           </row>
+
+           <row>
+             <entry><option>-fno-pre-inlining</option></entry>
+             <entry>Turn off pre-inlining</entry>
+             <entry>static</entry>
+             <entry>-</entry>
+           </row>
+
+           <row>
+             <entry><option>-fno-strictness</option></entry>
+             <entry>Turn off strictness analysis</entry>
+             <entry>static</entry>
+             <entry>-</entry>
+           </row>
+
+           <row>
+             <entry><option>-fnumbers-strict</option></entry>
+             <entry>Make numbers strict</entry>
+             <entry>dynamic</entry>
+             <entry><option>-fno-numbers-strict</option></entry>
+           </row>
+
+           <row>
+             <entry><option>-funbox-strict-fields</option></entry>
+             <entry>Flatten strict constructor fields</entry>
+             <entry>static</entry>
+             <entry><option>-fno-unbox-strict-fields</option></entry>
+           </row>
+
+           <row>
+             <entry><option>-funfolding-creation-threshold</option></entry>
+             <entry>Tweak unfolding settings</entry>
+             <entry>static</entry>
+             <entry><option>-fno-unfolding-creation-threshold</option></entry>
+           </row>
+
+           <row>
+             <entry><option>-funfolding-fun-discount</option></entry>
+             <entry>Tweak unfolding settings</entry>
+             <entry>static</entry>
+             <entry><option>-fno-unfolding-fun-discount</option></entry>
+           </row>
+
+           <row>
+             <entry><option>-funfolding-keeness-factor</option></entry>
+             <entry>Tweak unfolding settings</entry>
+             <entry>static</entry>
+             <entry><option>-fno-unfolding-keeness-factor</option></entry>
+           </row>
+
+           <row>
+             <entry><option>-funfolding-interface-threshold</option></entry>
+             <entry>Tweak unfolding settings</entry>
+             <entry>static</entry>
+             <entry><option>-fno-unfolding-interface-threshold</option></entry>
+           </row>
+
+           <row>
+             <entry><option>-funfolding-update-in-place</option></entry>
+             <entry>Tweak unfolding settings</entry>
+             <entry>static</entry>
+             <entry><option>-fno-unfolding-update-in-place</option></entry>
+           </row>
+
+           <row>
+             <entry><option>-funfolding-use-threshold</option></entry>
+             <entry>Tweak unfolding settings</entry>
+             <entry>static</entry>
+             <entry><option>-fno-unfolding-use-threshold</option></entry>
+           </row>
+
+           <row>
+             <entry><option>-fusagesp</option></entry>
+             <entry>Turn on UsageSP analysis</entry>
+             <entry>static</entry>
+             <entry><option>-fno-usagesp</option></entry>
+           </row>
+         </tbody>
+       </tgroup>
+      </informaltable>
+    </sect2>
+
+    <sect2>
+      <title>Profiling options (<xref linkend="profiling">)</title>
+
+      <informaltable>
+       <tgroup cols=3 align=left colsep=1 rowsep=1>
+         <thead>
+           <row>
+             <entry>Flag</entry>
+             <entry>Description</entry>
+             <entry>Static/Dynamic</entry>
+             <entry>Reverse</entry>
+           </row>
+         </thead>
+         <tbody>
+           <row>
+             <entry><option>-auto</option></entry>
+             <entry>Auto-add <literal>_scc_</literal>s to all
+             exported functions</entry>
+             <entry>static</entry>
+             <entry><option>-no-auto</option></entry>
+           </row>
+           <row>
+             <entry><option>-auto-all</option></entry>
+             <entry>Auto-add <literal>_scc_</literal>s to all
+             top-level functions</entry>
+             <entry>static</entry>
+             <entry><option>-no-auto-all</option></entry>
+           </row>
+           <row>
+             <entry><option>-auto-dicts</option></entry>
+             <entry>Auto-add <literal>_scc_</literal>s to all dictionaries</entry>
+             <entry>static</entry>
+             <entry><option>-no-auto-dicts</option></entry>
+           </row>
+           <row>
+             <entry><option>-caf-all</option></entry>
+             <entry>Auto-add <literal>_scc_</literal>s to all CAFs</entry>
+             <entry>static</entry>
+             <entry><option>-no-caf-all</option></entry>
+           </row>
+           <row>
+             <entry><option>-prof</option></entry>
+             <entry>Turn on profiling</entry>
+             <entry>static</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-ticky</option></entry>
+             <entry>Turn on ticky-ticky profiling</entry>
+             <entry>static</entry>
+             <entry>-</entry>
+           </row>
+         </tbody>
+       </tgroup>
+      </informaltable>
+    </sect2>
+
+    <sect2>
+      <title>Parallelism options (<xref linkend="sec-using-parallel">)</title>
+
+      <informaltable>
+       <tgroup cols=3 align=left colsep=1 rowsep=1>
+         <thead>
+           <row>
+             <entry>Flag</entry>
+             <entry>Description</entry>
+             <entry>Static/Dynamic</entry>
+             <entry>Reverse</entry>
+           </row>
+         </thead>
+         <tbody>
+           <row>
+             <entry><option>-gransim</option></entry>
+             <entry>Enable GRANSIM</entry>
+             <entry>static</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-parallel</option></entry>
+             <entry>Enable Parallel Haskell</entry>
+             <entry>static</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-smp</option></entry>
+             <entry>Enable SMP support</entry>
+             <entry>static</entry>
+             <entry>-</entry>
+           </row>
+         </tbody>
+       </tgroup>
+      </informaltable>
+    </sect2>
+
+    <sect2>
+      <title>C pre-processor options (<xref linkend="c-pre-processor">)</title>
+
+      <informaltable>
+       <tgroup cols=3 align=left colsep=1 rowsep=1>
+         <thead>
+           <row>
+             <entry>Flag</entry>
+             <entry>Description</entry>
+             <entry>Static/Dynamic</entry>
+             <entry>Reverse</entry>
+           </row>
+         </thead>
+         <tbody>
+           <row>
+             <entry><option>-D</option><replaceable>symbol</replaceable><optional>=<replaceable>value</replaceable></optional></entry>
+             <entry>Define a symbol in the C pre-processor</entry>
+             <entry>dynamic</entry>
+             <entry><option>-U</option><replaceable>symbol</replaceable></entry>
+           </row>
+           <row>
+             <entry><option>-U</option><replaceable>symbol</replaceable></entry>
+             <entry>Undefine a symbol in the C pre-processor</entry>
+             <entry>dynamic</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-I</option><replaceable>dir</replaceable></entry>
+             <entry>Add <replaceable>dir</replaceable> to the
+             directory search list for <literal>#include</literal> files</entry>
+             <entry>static</entry>
+             <entry>-</entry>
+           </row>
+         </tbody>
+       </tgroup>
+      </informaltable>
+    </sect2>
+
+    <sect2>
+      <title>C compiler options (<xref linkend="options-C-compiler">)</title>
+      <informaltable>
+       <tgroup cols=3 align=left colsep=1 rowsep=1>
+         <thead>
+           <row>
+             <entry>Flag</entry>
+             <entry>Description</entry>
+             <entry>Static/Dynamic</entry>
+             <entry>Reverse</entry>
+           </row>
+         </thead>
+         <tbody>
+           <row>
+             <entry><option>-#include</option> <replaceable>file</replaceable></entry>
+             <entry>Include <replaceable>file</replaceable> when
+             compiling the <filename>.hc</filename> file</entry>
+             <entry>dynamic</entry>
+             <entry>-</entry>
+           </row>
+         </tbody>
+       </tgroup>
+      </informaltable>
+    </sect2>
+
+    <sect2>
+      <title>Linking options (<xref linkend="options-linker">)</title>
+
+      <informaltable>
+       <tgroup cols=3 align=left colsep=1 rowsep=1>
+         <thead>
+           <row>
+             <entry>Flag</entry>
+             <entry>Description</entry>
+             <entry>Static/Dynamic</entry>
+             <entry>Reverse</entry>
+           </row>
+         </thead>
+         <tbody>
+           <row>
+             <entry><option>-dynamic</option></entry>
+             <entry>Use dynamic Haskell libraries (if available)</entry>
+             <entry>static</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-l</option><replaceable>lib</replaceable></entry>
+             <entry>Link in library <replaceable>lib</replaceable></entry>
+             <entry>static</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-L</option><replaceable>dir</replaceable></entry>
+             <entry>Add <replaceable>dir</replaceable> to the list of
+             directories searched for libraries</entry>
+             <entry>static</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-package</option> <replaceable>name</replaceable></entry>
+             <entry>Link in package <replaceable>name</replaceable></entry>
+             <entry>static</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-split-objs</option></entry>
+             <entry>Split objects (for libraries)</entry>
+             <entry>static</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-static</option></entry>
+             <entry>Use static Haskell libraries</entry>
+             <entry>static</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-no-hs-main</option></entry>
+             <entry>Don't asssume this program contains <literal>main</literal></entry>
+             <entry>static</entry>
+             <entry>-</entry>
+           </row>
+         </tbody>
+       </tgroup>
+      </informaltable>
+    </sect2>
+
+    <sect2>
+      <title>Replacing phases (<xref linkend="replacing-phases">)</title>
+
+      <informaltable>
+       <tgroup cols=3 align=left colsep=1 rowsep=1>
+         <thead>
+           <row>
+             <entry>Flag</entry>
+             <entry>Description</entry>
+             <entry>Static/Dynamic</entry>
+             <entry>Reverse</entry>
+           </row>
+         </thead>
+         <tbody>
+           <row>
+             <entry><option>-pgmL</option> <replaceable>cmd</replaceable></entry>
+             <entry>Use <replaceable>cmd</replaceable> as the literate pre-processor</entry>
+             <entry>static</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-pgmP</option> <replaceable>cmd</replaceable></entry>
+             <entry>Use <replaceable>cmd</replaceable> as the C
+             pre-processor (with <option>-cpp</option> only)</entry>
+             <entry>static</entry> <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-pgmc</option> <replaceable>cmd</replaceable></entry>
+             <entry>Use <replaceable>cmd</replaceable> as the C compiler</entry>
+             <entry>static</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-pgma</option> <replaceable>cmd</replaceable></entry>
+             <entry>Use <replaceable>cmd</replaceable> as the assembler</entry>
+             <entry>static</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-pgml</option> <replaceable>cmd</replaceable></entry>
+             <entry>Use <replaceable>cmd</replaceable> as the linker</entry>
+             <entry>static</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-pgmdll</option> <replaceable>cmd</replaceable></entry>
+             <entry>Use <replaceable>cmd</replaceable> as the DLL generator</entry>
+             <entry>static</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-pgmdep</option> <replaceable>cmd</replaceable></entry>
+             <entry>Use <replaceable>cmd</replaceable> as the dependency generator</entry>
+             <entry>static</entry>
+             <entry>-</entry>
+           </row>
+         </tbody>
+       </tgroup>
+      </informaltable>
+      <indexterm><primary><option>-pgmL</option></primary></indexterm>
+      <indexterm><primary><option>-pgmP</option></primary></indexterm>
+      <indexterm><primary><option>-pgmc</option></primary></indexterm>
+      <indexterm><primary><option>-pgma</option></primary></indexterm>
+      <indexterm><primary><option>-pgml</option></primary></indexterm>
+      <indexterm><primary><option>-pgmdll</option></primary></indexterm>
+      <indexterm><primary><option>-pgmdep</option></primary></indexterm>
+
+    </sect2>
+
+    <sect2>
+      <title>Forcing options to particular phases (<xref linkend="forcing-options-through">)</title>
+
+      <informaltable>
+       <tgroup cols=3 align=left colsep=1 rowsep=1>
+         <thead>
+           <row>
+             <entry>Flag</entry>
+             <entry>Description</entry>
+             <entry>Static/Dynamic</entry>
+             <entry>Reverse</entry>
+           </row>
+         </thead>
+         <tbody>
+           <row>
+             <entry><option>-optL</option> <replaceable>option</replaceable></entry>
+             <entry>pass <replaceable>option</replaceable> to the literate pre-processor</entry>
+             <entry>dynamic</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-optP</option> <replaceable>option</replaceable></entry>
+             <entry>pass <replaceable>option</replaceable> to cpp (with
+             <option>-cpp</option> only)</entry>
+             <entry>dynamic</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-optc</option> <replaceable>option</replaceable></entry>
+             <entry>pass <replaceable>option</replaceable> to the C compiler</entry>
+             <entry>dynamic</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-opta</option> <replaceable>option</replaceable></entry>
+             <entry>pass <replaceable>option</replaceable> to the assembler</entry>
+             <entry>dynamic</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-optl</option> <replaceable>option</replaceable></entry>
+             <entry>pass <replaceable>option</replaceable> to the linker</entry>
+             <entry>static</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-optdll</option> <replaceable>option</replaceable></entry>
+             <entry>pass <replaceable>option</replaceable> to the DLL generator</entry>
+             <entry>static</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-optdep</option> <replaceable>option</replaceable></entry>
+             <entry>pass <replaceable>option</replaceable> to the dependency generator</entry>
+             <entry>static</entry>
+             <entry>-</entry>
+           </row>
+         </tbody>
+       </tgroup>
+      </informaltable>
+    </sect2>
+
+    <sect2>
+      <title>Platform-specific options (<xref linkend="options-platform">)</title>
+      
+      <informaltable>
+       <tgroup cols=3 align=left colsep=1 rowsep=1>
+         <thead>
+           <row>
+             <entry>Flag</entry>
+             <entry>Description</entry>
+             <entry>Static/Dynamic</entry>
+             <entry>Reverse</entry>
+           </row>
+         </thead>
+         <tbody>
+           <row>
+             <entry><option>-mv8</option></entry>
+             <entry>(SPARC only) enable version 8 support</entry>
+             <entry>static</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-mlong-calls</option></entry>
+             <entry>(HPPA only) enable long call support</entry>
+             <entry>static</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-monly-[32]-regs</option></entry>
+             <entry>(x86 only) give some registers back to the C compiler</entry>
+             <entry>dynamic</entry>
+             <entry>-</entry>
+           </row>
+         </tbody>
+       </tgroup>
+      </informaltable>
+    </sect2>
+
+    <sect2>
+      <title>Compiler debugging options (<xref linkend="options-debugging">)</title>
+
+      <informaltable>
+       <tgroup cols=3 align=left colsep=1 rowsep=1>
+         <thead>
+           <row>
+             <entry>Flag</entry>
+             <entry>Description</entry>
+             <entry>Static/Dynamic</entry>
+             <entry>Reverse</entry>
+           </row>
+         </thead>
+         <tbody>
+           <row>
+             <entry><option>-dcore-lint</option></entry>
+             <entry>Turn on internal sanity checking</entry>
+             <entry>dynamic</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-ddump-absC</option></entry>
+             <entry>Dump abstract C</entry>
+             <entry>dynamic</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-ddump-asm</option></entry>
+             <entry>Dump assembly</entry>
+             <entry>dynamic</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-ddump-bcos</option></entry>
+             <entry>Dump interpreter byte code</entry>
+             <entry>dynamic</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-ddump-cpranal</option></entry>
+             <entry>Dump output from CPR analysis</entry>
+             <entry>dynamic</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-ddump-cse</option></entry>
+             <entry>Dump CSE output</entry>
+             <entry>dynamic</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-ddump-deriv</option></entry>
+             <entry>Dump deriving output</entry>
+             <entry>dynamic</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-ddump-ds</option></entry>
+             <entry>Dump desugarer output</entry>
+             <entry>dynamic</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-ddump-flatC</option></entry>
+             <entry>Dump &ldquo;flat&rdquo; C</entry>
+             <entry>dynamic</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-ddump-foreign</option></entry>
+             <entry>Dump FFI-related output</entry>
+             <entry>dynamic</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-ddump-inlinings</option></entry>
+             <entry>Dump inlining info</entry>
+             <entry>dynamic</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-ddump-occur-anal</option></entry>
+             <entry>Dump occurrence analysis output</entry>
+             <entry>dynamic</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-ddump-parsed</option></entry>
+             <entry>Dump parse tree</entry>
+             <entry>dynamic</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-ddump-realC</option></entry>
+             <entry>Dump &ldquo;real&rdquo; C</entry>
+             <entry>dynamic</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-ddump-rn</option></entry>
+             <entry>Dump renamer output</entry>
+             <entry>dynamic</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-ddump-rules</option></entry>
+             <entry>Dump rules</entry>
+             <entry>dynamic</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-ddump-sat</option></entry>
+             <entry>Dump saturated output</entry>
+             <entry>dynamic</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-ddump-simpl</option></entry>
+             <entry>Dump final simplifier output</entry>
+             <entry>dynamic</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-ddump-simpl-iterations</option></entry>
+             <entry>Dump output from each simplifier iteration</entry>
+             <entry>dynamic</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-ddump-spec</option></entry>
+             <entry>Dump specialiser output</entry>
+             <entry>dynamic</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-ddump-stg</option></entry>
+             <entry>Dump final STG</entry>
+             <entry>dynamic</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-ddump-stranal</option></entry>
+             <entry>Dump strictness analyser output</entry>
+             <entry>dynamic</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-ddump-tc</option></entry>
+             <entry>Dump typechecker output</entry>
+             <entry>dynamic</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-ddump-types</option></entry>
+             <entry>Dump type signatures</entry>
+             <entry>dynamic</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-ddump-usagesp</option></entry>
+             <entry>Dump UsageSP analysis output</entry>
+             <entry>dynamic</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-ddump-worker-wrapper</option></entry>
+             <entry>Dump worker-wrapper output</entry>
+             <entry>dynamic</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-dshow-passes</option></entry>
+             <entry>(equivalent to <option>-v2</option>)</entry>
+             <entry>dynamic</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-ddump-rn-trace</option></entry>
+             <entry>Trace renamer</entry>
+             <entry>dynamic</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-ddump-rn-stats</option></entry>
+             <entry>Renamer stats</entry>
+             <entry>dynamic</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-ddump-stix</option></entry>
+             <entry>Native code generator intermediate form</entry>
+             <entry>dynamic</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-ddump-simpl-stats</option></entry>
+             <entry>Dump simplifier stats</entry>
+             <entry>dynamic</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-dppr-debug</option></entry>
+             <entry>Turn on debug printing (more verbose)</entry>
+             <entry>static</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-dppr-noprags</option></entry>
+             <entry>Don't output pragma info in dumps</entry>
+             <entry>static</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-dppr-user-length</option></entry>
+             <entry>Set the depth for printing expressions in error msgs</entry>
+             <entry>static</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-dsource-stats</option></entry>
+             <entry>Dump haskell source stats</entry>
+             <entry>dynamic</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-dstg-lint</option></entry>
+             <entry>STG pass sanity checking</entry>
+             <entry>dynamic</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-dstg-stats</option></entry>
+             <entry>Dump STG stats</entry>
+             <entry>dynamic</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-dusagesp-lint</option></entry>
+             <entry>UsageSP sanity checker</entry>
+             <entry>dynamic</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-dverbose-core2core</option></entry>
+             <entry>Show output from each core-to-core pass</entry>
+             <entry>dynamic</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-dverbose-stg2stg</option></entry>
+             <entry>Show output from each STG-to-STG pass</entry>
+             <entry>dynamic</entry>
+             <entry>-</entry>
+           </row>
+         </tbody>
+       </tgroup>
+      </informaltable>
+    </sect2>
+      
+    <sect2>
+      <title>Misc compiler options</title>
+
+      <informaltable>
+       <tgroup cols=3 align=left colsep=1 rowsep=1>
+         <thead>
+           <row>
+             <entry>Flag</entry>
+             <entry>Description</entry>
+             <entry>Static/Dynamic</entry>
+             <entry>Reverse</entry>
+           </row>
+         </thead>
+         <tbody>
+           <row>
+             <entry><option>-funfold-casms-in-hi-file</option></entry>
+             <entry>Allow casms in unfoldings</entry>
+             <entry>static</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-femit-extern-decls</option></entry>
+             <entry>???</entry>
+             <entry>static</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-fglobalise-toplev-names</option></entry>
+             <entry>Make all top-level names global (for <option>-split-objs</option>)</entry>
+             <entry>static</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-fno-hi-version-check</option></entry>
+             <entry>Don't complain about <literal>.hi</literal> file mismatches</entry>
+             <entry>static</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-dno-black-holing</option></entry>
+             <entry>Turn off black holing (probably doesn't work)</entry>
+             <entry>static</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-fno-method-sharing</option></entry>
+             <entry>???</entry>
+             <entry>static</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-fno-prune-decls</option></entry>
+             <entry>Renamer: don't prune declarations</entry>
+             <entry>static</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-fno-prune-tydecls</option></entry>
+             <entry>Renamer: don't prune type declarations</entry>
+             <entry>static</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-fhistory-size</option></entry>
+             <entry>Set simplification history size</entry>
+             <entry>static</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-funregisterised</option></entry>
+             <entry>Unregisterised compilation (use <option>-unreg</option> instead)</entry>
+             <entry>static</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-fno-asm-mangling</option></entry>
+             <entry>Turn off assembly mangling (use <option>-unreg</option> instead)</entry>
+             <entry>static</entry>
+             <entry>-</entry>
+           </row>
+         </tbody>
+       </tgroup>
+      </informaltable>
+    </sect2>
+  </sect1>
+
+
+<!--
+Still to document:
+
+Misc:
+  ,  ( "H"                 , HasArg (setHeapSize . fromIntegral . decodeSize) )
+  ,  ( "Rghc-timing"      , NoArg  (enableTimingStats) )
+
+  ,  ( "unreg"         , NoArg (addNoDups v_Ways       WayUnreg) )
+-->
+
+<!-- Emacs stuff:
+     ;;; Local Variables: ***
+     ;;; mode: sgml ***
+     ;;; sgml-parent-document: ("users_guide.sgml" "book" "chapter") ***
+     ;;; End: ***
+ -->
index b11bbb1..bedbc08 100644 (file)
@@ -139,63 +139,142 @@ program), you may wish to check if there are libraries that provide a
 <xref linkend="book-hslibs">.
 </Para>
 
-<Sect1 id="language-options">
-<Title>Language variations
-</Title>
-
-<Para> There are several flags that control what variation of the language are permitted.
-Leaving out all of them gives you standard Haskell 98.</Para>
-
-<VariableList>
-
-<VarListEntry>
-<Term><Option>-fglasgow-exts</Option>:</Term>
-<ListItem>
-<Para>This simultaneously enables all of the extensions to Haskell 98 described in this
-chapter, except where otherwise noted. </Para>
-</ListItem> </VarListEntry>
-
-<VarListEntry>
-<Term><Option>-fno-monomorphism-restriction</Option>:</Term>
-<ListItem>
-<Para> Switch off the Haskell 98 monomorphism restriction.  Independent of the <Option>-fglasgow-exts</Option>
-flag. </Para>
-</ListItem> </VarListEntry>
-
-<VarListEntry>
-<Term><Option>-fallow-overlapping-instances</Option>,
-      <Option>-fallow-undecidable-instances</Option>,  
-      <Option>-fcontext-stack</Option>:</Term>
-<ListItem>
-<Para> See <XRef LinkEnd="instance-decls">. 
-Only relevant if you also use <Option>-fglasgow-exts</Option>.
-</Para>
-</ListItem> </VarListEntry>
-
-<VarListEntry>
-<Term><Option>-fignore-asserts</Option>:</Term>
-<ListItem>
-<Para> See <XRef LinkEnd="sec-assertions">.
-Only relevant if you also use <Option>-fglasgow-exts</Option>.
-</Para>
-</ListItem> </VarListEntry>
-
-<VarListEntry>
-<Term> <Option>-finline-phase</Option>:</Term>
-<ListItem>
-<Para> See <XRef LinkEnd="rewrite-rules">.
-Only relevant if you also use <Option>-fglasgow-exts</Option>.</para>
-</ListItem> </VarListEntry>
+  <sect1 id="options-language">
+    <title>Language options</title>
+
+    <indexterm><primary>language</primary><secondary>option</secondary>
+    </indexterm>
+    <indexterm><primary>options</primary><secondary>language</secondary>
+    </indexterm>
+    <indexterm><primary>extensions</primary><secondary>options controlling</secondary>
+    </indexterm>
+
+    <para> These flags control what variation of the language are
+    permitted.  Leaving out all of them gives you standard Haskell
+    98.</Para>
+
+    <variablelist>
+
+      <varlistentry>
+       <term><option>-fglasgow-exts</option>:</term>
+       <indexterm><primary><option>-fglasgow-exts</option></primary></indexterm>
+       <listitem>
+         <para>This simultaneously enables all of the extensions to
+          Haskell 98 described in <xref
+          linkend="ghc-language-features">, except where otherwise
+          noted. </para>
+       </listitem>
+      </varlistentry>
+
+      <varlistentry>
+       <term><option>-fno-monomorphism-restriction</option>:</term>
+       <indexterm><primary><option>-fno-monomorphism-restriction</option></primary></indexterm>
+       <listitem>
+         <para> Switch off the Haskell 98 monomorphism restriction.
+          Independent of the <Option>-fglasgow-exts</Option>
+          flag. </para>
+       </listitem>
+      </varlistentry>
+
+      <varlistentry>
+       <term><option>-fallow-overlapping-instances</option></term>
+       <term><option>-fallow-undecidable-instances</option></term>
+       <term><option>-fcontext-stack</option></term>
+       <indexterm><primary><option>-fallow-overlapping-instances</option></primary></indexterm>
+       <indexterm><primary><option>-fallow-undecidable-instances</option></primary></indexterm>
+       <indexterm><primary><option>-fcontext-stack</option></primary></indexterm>
+       <listitem>
+         <para> See <XRef LinkEnd="instance-decls">.  Only relevant
+          if you also use <option>-fglasgow-exts</option>.</para>
+       </listitem>
+      </varlistentry>
+
+      <varlistentry>
+       <term><option>-fignore-asserts</option>:</term>
+       <indexterm><primary><option>-fignore-asserts</option></primary></indexterm>
+       <listitem>
+         <para>See <XRef LinkEnd="sec-assertions">.  Only relevant if
+          you also use <option>-fglasgow-exts</option>.</Para>
+       </listitem>
+      </varlistentry>
+
+      <varlistentry>
+       <term><option>-finline-phase</option></term>
+       <indexterm><primary><option>-finline-phase</option></primary></indexterm>
+       <listitem>
+         <para>See <XRef LinkEnd="rewrite-rules">.  Only relevant if
+          you also use <Option>-fglasgow-exts</Option>.</para>
+       </listitem>
+      </varlistentry>
+
+      <varlistentry>
+       <term><option>-fgenerics</option></term>
+       <indexterm><primary><option>-fgenerics</option></primary></indexterm>
+       <listitem>
+         <para>See <XRef LinkEnd="generic-classes">.  Independent of
+          <Option>-fglasgow-exts</Option>.</para>
+       </listitem>
+      </varlistentry>
+
+       <varlistentry>
+         <term><option>-fno-implicit-prelude</option></term>
+         <listitem>
+           <para><indexterm><primary>-fno-implicit-prelude
+            option</primary></indexterm> GHC normally imports
+            <filename>Prelude.hi</filename> files for you.  If you'd
+            rather it didn't, then give it a
+            <option>-fno-implicit-prelude</option> option.  The idea
+            is that you can then import a Prelude of your own.  (But
+            don't call it <literal>Prelude</literal>; the Haskell
+            module namespace is flat, and you must not conflict with
+            any Prelude module.)</para>
+
+           <para>Even though you have not imported the Prelude, all
+            the built-in syntax still refers to the built-in Haskell
+            Prelude types and values, as specified by the Haskell
+            Report.  For example, the type <literal>[Int]</literal>
+            still means <literal>Prelude.[] Int</literal>; tuples
+            continue to refer to the standard Prelude tuples; the
+            translation for list comprehensions continues to use
+            <literal>Prelude.map</literal> etc.</para>
+
+           <para> With one group of exceptions!  You may want to
+            define your own numeric class hierarchy.  It completely
+            defeats that purpose if the literal "1" means
+            "<literal>Prelude.fromInteger 1</literal>", which is what
+            the Haskell Report specifies.  So the
+            <option>-fno-implicit-prelude</option> flag causes the
+            following pieces of built-in syntax to refer to whatever
+            is in scope, not the Prelude versions:</para>
+
+           <itemizedlist>
+             <listitem>
+               <para>Integer and fractional literals mean
+                "<literal>fromInteger 1</literal>" and
+                "<literal>fromRational 3.2</literal>", not the
+                Prelude-qualified versions; both in expressions and in
+                patterns.</para>
+             </listitem>
+
+             <listitem>
+               <para>Negation (e.g. "<literal>- (f x)</literal>")
+               means "<literal>negate (f x)</literal>" (not
+               <literal>Prelude.negate</literal>).</para>
+             </listitem>
+
+             <listitem>
+               <para>In an n+k pattern, the standard Prelude
+                <literal>Ord</literal> class is used for comparison,
+                but the necessary subtraction uses whatever
+                "<literal>(-)</literal>" is in scope (not
+                "<literal>Prelude.(-)</literal>").</para>
+             </listitem>
+           </itemizedlist>
 
-<VarListEntry>
-<Term> <Option>-fgenerics</Option>:</Term>
-<ListItem>
-<Para> See <XRef LinkEnd="generic-classes">.
-Independent of <Option>-fglasgow-exts</Option>.
-</Para>
-</ListItem> </VarListEntry>
+         </listitem>
+       </varlistentry>
 
-</VariableList>
+    </variablelist>
   </sect1>
 
 <Sect1 id="primitives">
diff --git a/ghc/docs/users_guide/packages.sgml b/ghc/docs/users_guide/packages.sgml
new file mode 100644 (file)
index 0000000..0228996
--- /dev/null
@@ -0,0 +1,359 @@
+  <sect1 id="packages">
+    <title>Packages</title>
+    <indexterm><primary>packages</primary></indexterm>
+
+    <para>Packages are collections of libraries, conveniently grouped
+    together as a single entity.  The package system is flexible: a
+    package may consist of Haskell code, foreign language code (eg. C
+    libraries), or a mixture of the two.  A package is a good way to
+    group together related Haskell modules, and is essential if you
+    intend to make the modules into a Windows DLL (see below).</para>
+
+    <para>Because packages can contain both Haskell and C libraries, they
+    are also a good way to provide convenient access to a Haskell
+    layer over a C library.</para>
+
+    <para>GHC comes with several packages (see <xref
+    linkend="book-hslibs">), and packages can be added/removed from an
+    existing GHC installation.</para>
+
+    <sect2 id="listing-packages">
+      <title>Listing the available packages</title>
+      <indexterm><primary>packages</primary>
+       <secondary>listing</secondary></indexterm>
+
+      <para>To see what packages are currently installed, use the
+      <literal>--list-packages</literal> option:</para>
+      <indexterm><primary><literal>--list-packages</literal></primary>
+      </indexterm>
+
+<screen>
+  $ ghc --list-packages
+  gmp, rts, std, lang, concurrent, data, net, posix, text, util
+</screen>
+
+      <para>Note that your GHC installation might have a slightly
+      different set of packages installed.</para>
+
+      <para>The <literal>gmp</literal> and <literal>rts</literal>
+      packages are always present, and represent the multi-precision
+      integer and runtime system libraries respectively.  The
+      <literal>std</literal> package contains the Haskell prelude.
+      The rest of the packages are optional libraries.</para>
+
+    </sect2>
+
+    <sect2 id="using-packages">
+      <title>Using a package</title>
+      <indexterm><primary>packages</primary>
+       <secondary>using</secondary></indexterm>
+      
+      <para>To use a package, add the <literal>-package</literal> flag
+      to the command line:</para>
+
+      <variablelist>
+       <varlistentry>
+         <term><option>-package &lt;lib&gt;</option></term>
+         <indexterm><primary>-package &lt;lib&gt; option</primary></indexterm>
+         <listitem>
+           <para>This option brings into scope all the modules from
+           package <literal>&lt;lib&gt;</literal> (they still have to
+           be imported in your Haskell source, however).  It also
+           causes the relevant libraries to be linked when linking is
+           being done.</para>
+         </listitem>
+       </varlistentry>
+      </variablelist>
+
+      <para>Some packages depend on other packages, for example the
+      <literal>text</literal> package makes use of some of the modules
+      in the <literal>lang</literal> package.  The package system
+      takes care of all these dependencies, so that when you say
+      <literal>-package text</literal> on the command line, you
+      automatically get <literal>-package lang</literal> too.</para>
+    </sect2>
+
+    <sect2 id="building-packages">
+      <title>Building a package from Haskell source</title>
+      <indexterm><primary>packages</primary>
+       <secondary>building</secondary></indexterm>
+
+      <para>It takes some special considerations to build a new
+      package:</para>
+
+      <itemizedlist>
+       <listitem>
+         <para>A package may contain several Haskell modules. A
+          package may span many directories, or many packages may
+          exist in a single directory. Packages may not be mutually
+          recursive.</para>
+       </listitem>
+
+       <listitem>
+         <para>A package has a name
+         (e.g. <filename>std</filename>)</para>
+       </listitem>
+
+       <listitem>
+         <para>The Haskell code in a package may be built into one or
+         more Unix libraries (e.g. <filename>libHSfoo.a</filename>),
+         or a single DLL on Windows
+         (e.g. <filename>HSfoo.dll</filename>).  The restriction to a
+         single DLL on Windows is that the package system is used to
+         tell the compiler when it should make an inter-DLL call
+         rather than an intra-DLL call (inter-DLL calls require an
+         extra indirection).</para>
+       </listitem>
+
+       <listitem>
+         <para>GHC does not maintain detailed cross-package
+          dependency information.  It does remember which modules in
+          other packages the current module depends on, but not which
+          things within those imported things.</para>
+       </listitem>
+      </itemizedlist>
+
+      <para>To compile a module which is to be part of a new package,
+      use the <literal>-package-name</literal> option:</para>
+
+      <variablelist>
+       <varlistentry>
+         <term><option>-package-name &lt;foo&gt;</option></term>
+         <indexterm><primary><literal>-package-name</literal></primary>
+           <secondary>option</secondary></indexterm>
+         <listitem>
+           <para>This option is added to the command line when
+           compiling a module that is destined to be part of package
+           <literal>foo</literal>.  If this flag is omitted then the
+           default package <literal>Main</literal> is assumed.</para>
+         </listitem>
+       </varlistentry>
+      </variablelist>
+
+      <para>Failure to use the <literal>-package-name</literal> option
+      when compiling a package will result in disaster on Windows, but
+      is relatively harmless on Unix at the moment (it will just cause
+      a few extra dependencies in some interface files).  However,
+      bear in mind that we might add support for Unix shared libraries
+      at some point in the future.</para>
+
+      <para>It is worth noting that on Windows, because each package
+      is built as a DLL, and a reference to a DLL costs an extra
+      indirection, intra-package references are cheaper than
+      inter-package references. Of course, this applies to the
+      <filename>Main</filename> package as well.</para>
+
+    </sect2>
+    <sect2 id="package-management">
+      <title>Package management</title>
+      <indexterm><primary>packages</primary>
+       <secondary>management</secondary></indexterm>
+      
+      <para>GHC uses a package configuration file, called
+      <literal>packages.conf</literal>, which can be found in your GHC
+      install directory.  This file isn't intended to be edited
+      directly, instead GHC provides options for adding & removing
+      packages:</para>
+
+      <variablelist>
+       <varlistentry>
+         <term><option>--add-package</option></term>
+         <indexterm><primary><literal>--add-package</literal></primary>
+             <secondary>option</secondary></indexterm>
+         <listitem>
+           <para>Reads a package specification (see below) on stdin,
+           and adds it to the database of installed packages.  The
+           package specification must be a package that isn't already
+           installed.</para>
+         </listitem>
+       </varlistentry>
+
+       <varlistentry>
+         <term><option>--delete-package &lt;foo&gt;</option></term>
+         <indexterm><primary><literal>--delete-package</literal></primary>
+             <secondary>option</secondary></indexterm>
+         <listitem>
+           <para>Removes the specified package from the installed
+           configuration.</para>
+         </listitem>
+       </varlistentry>
+      </variablelist>
+
+      <para>In both cases, the old package configuration file is saved
+      in <literal>packages.conf.old</literal> in your GHC install
+      directory, so in an emergency you can always copy this file into
+      <literal>package.conf</literal> to restore the old
+      settings.</para>
+
+      <para>A package specification looks like this:</para>
+
+<screen>
+  Package {
+     name            = "mypkg",
+     import_dirs     = ["/usr/local/lib/imports/mypkg"],
+     library_dirs    = ["/usr/local/lib"],
+     hs_libraries    = ["HSmypkg" ],
+     extra_libraries = ["HSmypkg_cbits"],
+     include_dirs    = [],
+     c_includes      = ["HsMyPkg.h"],
+     package_deps    = ["text", "data"],
+     extra_ghc_opts  = [],
+     extra_cc_opts   = [],
+     extra_ld_opts   = ["-lmy_clib"]
+  }
+</screen>
+
+      <para>Components of a package specification may be specified in
+      any order, and are:</para>
+
+      <variablelist>
+       <varlistentry>
+         <term><literal>name</literal></term>
+         <indexterm><primary><literal>name</literal></primary>
+           <secondary>package specification</secondary></indexterm>
+         <listitem>
+            <para>The package's name, for use with
+            the <literal>-package</literal> flag and as listed in the
+            <literal>--list-packages</literal> list. 
+            </para>
+         </listitem>
+       </varlistentry>
+
+       <varlistentry>
+         <term><literal>import_dirs</literal></term>
+         <indexterm><primary><literal>import_dirs</literal></primary>
+           <secondary>package specification</secondary></indexterm>
+         <listitem>
+           <para>A list of directories containing interface files
+           (<literal>.hi</literal> files) for this package.</para>
+         </listitem>
+       </varlistentry>
+
+       <varlistentry>
+         <term><literal>library_dirs</literal></term>
+         <indexterm><primary><literal>library_dirs</literal></primary>
+           <secondary>package specification</secondary></indexterm>
+         <listitem>
+           <para>A list of directories containing libraries for this
+           package.</para>
+         </listitem>
+       </varlistentry>
+
+       <varlistentry>
+         <term><literal>hs_libraries</literal></term>
+         <indexterm><primary><literal>hs_libraries</literal></primary>
+           <secondary>package specification</secondary></indexterm>
+         <listitem>
+           <para>A list of libraries containing Haskell code for this
+           package, with the <literal>.a</literal> or
+           <literal>.dll</literal> suffix omitted.  On Unix, the
+           <literal>lib</literal> prefix is also omitted.</para>
+         </listitem>
+       </varlistentry>
+
+       <varlistentry>
+         <term><literal>extra_libraries</literal></term>
+         <indexterm><primary><literal>extra_libraries</literal></primary>
+           <secondary>package specification</secondary></indexterm>
+         <listitem>
+           <para>A list of extra libraries for this package.  The
+           difference between <literal>hs_libraries</literal> and
+           <literal>extra_libraries</literal> is that
+           <literal>hs_libraries</literal> normally have several
+           versions, to support profiling, parallel and other build
+           options.  The various versions are given different
+           suffixes to distinguish them, for example the profiling
+           version of the standard prelude library is named
+           <filename>libHSstd_p.a</filename>, with the
+           <literal>_p</literal> indicating that this is a profiling
+           version.  The suffix is added automatically by GHC for
+           <literal>hs_libraries</literal> only, no suffix is added
+           for libraries in
+           <literal>extra_libraries</literal>.</para>
+
+           <para>Also, <literal>extra_libraries</literal> are placed
+           on the linker command line before the
+           <literal>hs_libraries</literal> for the same package.  If
+           your package has dependencies in the other direction, you
+           might need to make two separate packages.</para>
+         </listitem>
+       </varlistentry>
+
+       <varlistentry>
+         <term><literal>include_dirs</literal></term>
+         <indexterm><primary><literal>include_dirs</literal></primary>
+           <secondary>package specification</secondary></indexterm>
+         <listitem>
+           <para>A list of directories containing C includes for this
+           package (maybe the empty list).</para>
+         </listitem>
+       </varlistentry>
+
+       <varlistentry>
+         <term><literal>c_includes</literal></term>
+         <indexterm><primary><literal>c_includes</literal></primary>
+           <secondary>package specification</secondary></indexterm>
+         <listitem>
+           <para>A list of files to include for via-C compilations
+           using this package.  Typically this include file will
+           contain function prototypes for any C functions used in
+           the package, in case they end up being called as a result
+           of Haskell functions from the package being
+           inlined.</para>
+         </listitem>
+       </varlistentry>
+
+       <varlistentry>
+         <term><literal>package_deps</literal></term>
+         <indexterm><primary><literal>package_deps</literal></primary>
+           <secondary>package specification</secondary></indexterm>
+         <listitem>
+           <para>A list of packages which this package depends
+           on.</para>
+         </listitem>
+       </varlistentry>
+
+       <varlistentry>
+         <term><literal>extra_ghc_opts</literal></term>
+         <indexterm><primary><literal>extra_ghc_opts</literal></primary>
+           <secondary>package specification</secondary></indexterm>
+         <listitem>
+           <para>Extra arguments to be added to the GHC command line
+           when this package is being used.</para>
+         </listitem>
+       </varlistentry>
+
+       <varlistentry>
+         <term><literal>extra_cc_opts</literal></term>
+         <indexterm><primary><literal>extra_cc_opts</literal></primary>
+           <secondary>package specification</secondary></indexterm>
+         <listitem>
+           <para>Extra arguments to be added to the gcc command line
+           when this package is being used (only for via-C
+           compilations).</para>
+         </listitem>
+       </varlistentry>
+
+       <varlistentry>
+         <term><literal>extra_ld_opts</literal></term>
+         <indexterm><primary><literal>extra_ld_opts</literal></primary>
+           <secondary>package specification</secondary></indexterm>
+         <listitem>
+           <para>Extra arguments to be added to the gcc command line
+           (for linking) when this package is being used.</para>
+         </listitem>
+       </varlistentry>
+      </variablelist>
+
+      <para>For examples of more package specifications, take a look
+      at the <literal>package.conf</literal> in your GHC
+      installation.</para>
+    </sect2>
+  </sect1>
+
+<!-- Emacs stuff:
+     ;;; Local Variables: ***
+     ;;; mode: sgml ***
+     ;;; sgml-parent-document: ("using.sgml" "book" "chapter") ***
+     ;;; End: ***
+ -->
diff --git a/ghc/docs/users_guide/phases.sgml b/ghc/docs/users_guide/phases.sgml
new file mode 100644 (file)
index 0000000..a0e1994
--- /dev/null
@@ -0,0 +1,363 @@
+  <sect1 id="options-phases">
+    <title>Options related to a particular phase</title>
+
+    <sect2 id="replacing-phases">
+      <title>Replacing the program for one or more phases.</title>
+      <indexterm><primary>phases, changing</primary></indexterm>
+
+      <para>You may specify that a different program be used for one
+      of the phases of the compilation system, in place of whatever
+      the <Command>ghc</Command> has wired into it.  For example, you
+      might want to try a different assembler.  The following options
+      allow you to change the external program used for a given
+      compilation phases:</para>
+
+    </sect2>
+
+    <sect2 id="forcing-options-through">
+      <title>Forcing options to a particular phase.</title>
+      <indexterm><primary>forcing GHC-phase options</primary></indexterm>
+
+      <para>Options can be forced through to a particlar compilation
+      phase, using the following flags:</para>
+
+
+      <para>So, for example, to force an <option>-Ewurble</option>
+      option to the assembler, you would tell the driver
+      <option>-opta-Ewurble</option> (the dash before the E is
+      required).</para>
+
+      <para>GHC is itself a Haskell program, so if you need to pass
+      options directly to GHC's runtime system you can enclose them in
+      <literal>+RTS ... -RTS</literal> (see <xref
+      linkend="runtime-control">).</para>
+
+    </sect2>
+
+    <sect2 id="c-pre-processor">
+      <title>Options affecting the C pre-processor</title>
+
+      <indexterm><primary>pre-processing: cpp</primary></indexterm>
+      <indexterm><primary>C pre-processor options</primary></indexterm>
+      <indexterm><primary>cpp, pre-processing with</primary></indexterm>
+
+      <para>The C pre-processor <command>cpp</command> is run over
+      your Haskell code only if the <option>-cpp</option> option
+      <indexterm><primary>-cpp option</primary></indexterm> is given.
+      Unless you are building a large system with significant doses of
+      conditional compilation, you really shouldn't need it.</para>
+
+      <variablelist>
+
+       <varlistentry>
+         <term><option>-D</option><replaceable>symbol</replaceable><optional>=<replaceable>value</replaceable></optional></term>
+         <indexterm><primary><option>-D</option></primary></indexterm>
+         <listitem>
+           <para>Define macro <replaceable>symbol</replaceable> in the
+            usual way.  NB: does <emphasis>not</emphasis> affect
+            <option>-D</option> macros passed to the C&nbsp;compiler
+            when compiling via C!  For those, use the
+            <option>-optc-Dfoo</option> hack&hellip; (see <xref
+            linkend="forcing-options-through">).</para>
+         </listitem>
+       </varlistentry>
+
+       <varlistentry>
+         <term><option>-U</option><replaceable>symbol</replaceable></term>
+         <indexterm><primary><option>-U</option></primary></indexterm>
+         <listitem>
+           <para> Undefine macro <replaceable>symbol</replaceable> in the
+           usual way.</para>
+         </listitem>
+       </varlistentry>
+
+       <varlistentry>
+         <term><option>-I</option><replaceable>dir</replaceable></term>
+         <indexterm><primary><option>-I</option></primary></indexterm>
+         <listitem>
+           <para> Specify a directory in which to look for
+            <literal>&num;include</literal> files, in the usual C
+            way.</para>
+         </listitem>
+       </varlistentry>
+      </variablelist>
+
+      <para>The GHC driver pre-defines several macros when processing
+      Haskell source code (<filename>.hs</filename> or
+      <filename>.lhs</filename> files):</para>
+
+      <variablelist>
+
+       <varlistentry>
+         <term><constant>&lowbar;&lowbar;HASKELL98&lowbar;&lowbar;</constant></term>
+         <indexterm><primary><literal>&lowbar;&lowbar;HASKELL98&lowbar;&lowbar;</literal></primary></indexterm>
+         <listitem>
+           <para>If defined, this means that GHC supports the
+            language defined by the Haskell 98 report.</para>
+         </listitem>
+       </varlistentry>
+
+       <varlistentry>
+         <term><constant>&lowbar;&lowbar;HASKELL&lowbar;&lowbar;=98</constant></term>
+         <indexterm><primary><constant>&lowbar;&lowbar;HASKELL&lowbar;&lowbar;=98</constant></primary></indexterm>
+         <listitem>
+           <para>In GHC 4.04 and later, the
+            <constant>&lowbar;&lowbar;HASKELL&lowbar;&lowbar;</constant>
+            macro is defined as having the value
+            <constant>98</constant>.</para>
+         </listitem>
+       </varlistentry>
+
+       <varlistentry>
+         <term><constant>&lowbar;&lowbar;HASKELL1&lowbar;&lowbar;</constant></term>
+         <indexterm><primary><constant>&lowbar;&lowbar;HASKELL1&lowbar;&lowbar;
+         </constant></primary></indexterm>
+         <listitem>
+           <para>If defined to <replaceable>n</replaceable>, that
+            means GHC supports the Haskell language defined in the
+            Haskell report version <emphasis>1.n</emphasis>.
+            Currently 5.  This macro is deprecated, and will probably
+            disappear in future versions.</para>
+         </listitem>
+       </varlistentry>
+
+       <varlistentry>
+         <term><constant>&lowbar;&lowbar;GLASGOW&lowbar;HASKELL&lowbar;&lowbar;</constant></term>
+         <indexterm><primary><constant>&lowbar;&lowbar;GLASGOW&lowbar;HASKELL&lowbar;&lowbar;</constant></primary></indexterm>
+         <listitem>
+           <para>For version <replaceable>n</replaceable> of the GHC
+            system, this will be <literal>&num;define</literal>d to
+            <replaceable>100n</replaceable>.  For example, for version
+            5.00, it is 500.</para>
+
+           <para>With any luck,
+            <constant>&lowbar;&lowbar;GLASGOW&lowbar;HASKELL&lowbar;&lowbar;</constant>
+            will be undefined in all other implementations that
+            support C-style pre-processing.</para>
+
+           <para>(For reference: the comparable symbols for other
+            systems are:
+            <constant>&lowbar;&lowbar;HUGS&lowbar;&lowbar;</constant>
+            for Hugs and
+            <constant>&lowbar;&lowbar;HBC&lowbar;&lowbar;</constant>
+            for Chalmers.)</para>
+
+           <para>NB. This macro is set when pre-processing both
+            Haskell source and C source, including the C source
+            generated from a Haskell module
+            (i.e. <filename>.hs</filename>, <filename>.lhs</filename>,
+            <filename>.c</filename> and <filename>.hc</filename>
+            files).</para>
+         </listitem>
+       </varlistentry>
+
+       <varlistentry>
+         <term><constant>&lowbar;&lowbar;CONCURRENT&lowbar;HASKELL&lowbar;&lowbar;</constant></term>
+         <indexterm><primary><constant>&lowbar;&lowbar;CONCURRENT&lowbar;HASKELL&lowbar;&lowbar;</constant></primary></indexterm>
+         <listitem>
+           <para>This symbol is defined when pre-processing Haskell
+            (input) and pre-processing C (GHC output).  Since GHC from
+            verion 4.00 now supports concurrent haskell by default,
+            this symbol is always defined.</para>
+         </listitem>
+       </varlistentry>
+
+       <varlistentry>
+         <term><constant>&lowbar;&lowbar;PARALLEL&lowbar;HASKELL&lowbar;&lowbar;</constant></term>
+         <indexterm><primary><constant>&lowbar;&lowbar;PARALLEL&lowbar;HASKELL&lowbar;&lowbar;</constant></primary></indexterm>
+         <listitem>
+           <para>Only defined when <option>-parallel</option> is in
+            use!  This symbol is defined when pre-processing Haskell
+            (input) and pre-processing C (GHC output).</para>
+         </listitem>
+       </varlistentry>
+      </variablelist>
+
+      <para>A small word of warning: <option>-cpp</option> is not
+      friendly to &ldquo;string gaps&rdquo;.<indexterm><primary>-cpp
+      vs string gaps</primary></indexterm><indexterm><primary>string
+      gaps vs -cpp</primary></indexterm>.  In other words, strings
+      such as the following:</para>
+
+<ProgramListing>
+strmod = "\
+\ p \
+\ "
+</ProgramListing>
+
+      <para>don't work with <option>-cpp</option>;
+      <filename>/usr/bin/cpp</filename> elides the backslash-newline
+      pairs.</para>
+
+      <para>However, it appears that if you add a space at the end of
+      the line, then <command>cpp</command> (at least GNU
+      <command>cpp</command> and possibly other
+      <command>cpp</command>s) leaves the backslash-space pairs alone
+      and the string gap works as expected.</para>
+    </sect2>
+
+    <sect2 id="options-C-compiler">
+      <title>Options affecting the C compiler (if applicable)</title>
+
+      <indexterm><primary>include-file options</primary></indexterm>
+      <indexterm><primary>C compiler options</primary></indexterm>
+      <indexterm><primary>GCC options</primary></indexterm>
+
+      <informaltable>
+       <tgroup cols=3 align=left colsep=1 rowsep=1>
+         <thead>
+           <row>
+             <entry>Flag</entry>
+             <entry>Description</entry>
+             <entry>Static/Dynamic</entry>
+             <entry>Reverse</entry>
+           </row>
+         </thead>
+         <tbody>
+           <row>
+             <entry><option>-#include</option> <replaceable>file</replaceable></entry>
+             <entry>Include <replaceable>file</replaceable> when
+             compiling the <filename>.hc</filename> file</entry>
+             <entry>dynamic</entry>
+             <entry>-</entry>
+           </row>
+         </tbody>
+       </tgroup>
+      </informaltable>
+
+      <para>If you are compiling with lots of foreign calls, you may
+      need to tell the C&nbsp;compiler about some
+      <literal>&num;include</literal> files.  There is no real pretty
+      way to do this, but you can use this hack from the
+      command-line:</para>
+
+<Screen>
+% ghc -c '-#include &lt;X/Xlib.h&gt;' Xstuff.lhs
+</Screen>
+
+    </sect2>
+
+    <sect2 id="options-linker">
+      <title>Options affecting linking</title>
+
+      <indexterm><primary>linker options</primary></indexterm>
+      <indexterm><primary>ld options</primary></indexterm>
+
+
+      <para>GHC has to link your code with various libraries, possibly
+      including: user-supplied, GHC-supplied, and system-supplied
+      (<option>-lm</option> math library, for example).</para>
+
+      <variablelist>
+
+       <varlistentry>
+         <term><option>-l</option><replaceable>lib</replaceable></term>
+         <indexterm><primary><option>-l</option></primary></indexterm>
+         <listitem>
+           <para>Link in the <replaceable>lib</replaceable> library.
+           On Unix systems, this will be in a file called
+           <filename>lib<replaceable>lib</replaceable>.a</filename>
+           or
+           <filename>lib<replaceable>lib</replaceable>.so</filename>
+           which resides somewhere on the library directories path.</para>
+
+           <para>Because of the sad state of most UNIX linkers, the
+            order of such options does matter.  If library
+            <replaceable>foo</replaceable> requires library
+            <replaceable>bar</replaceable>, then in general
+            <option>-l</option><replaceable>foo</replaceable> should
+            come <emphasis>before</emphasis>
+            <option>-l</option><replaceable>bar</replaceable> on the
+            command line.</para>
+         </listitem>
+       </varlistentry>
+
+       <varlistentry>
+         <term><option>-package</option> <replaceable>name</replaceable></term>
+         <indexterm><primary><option>-package</option></primary></indexterm>
+         <listitem>
+           <para>If you are using a Haskell &ldquo;package&rdquo;
+            (see <xref linkend="packages">), don't forget to add the
+            relevant <option>-package</option> option when linking the
+            program too: it will cause the appropriate libraries to be
+            linked in with the program.  Forgetting the
+            <option>-package</option> option will likely result in
+            several pages of link errors.</para>
+         </listitem>
+       </varlistentry>
+
+       <varlistentry>
+         <term><option>-L</option><replaceable>dir</replaceable></term>
+         <indexterm><primary><option>-L</option></primary></indexterm>
+         <listitem>
+           <para>Where to find user-supplied libraries&hellip;
+            Prepend the directory <replaceable>dir</replaceable> to
+            the library directories path.</para>
+         </listitem>
+       </varlistentry>
+
+       <varlistentry>
+         <term><option>-split-objs</option></term>
+         <indexterm><primary><option>-split-objs</option></primary></indexterm>
+         <listitem>
+           <para>Tell the linker to split the single object file that
+            would normally be generated into multiple object files,
+            one per top-level Haskell function or type in the module.
+            We use this feature for building GHC's libraries libraries
+            (warning: don't use it unless you know what you're
+            doing!).</para>
+         </listitem>
+       </varlistentry>
+
+       <varlistentry>
+         <term><option>-static</option></term>
+         <indexterm><primary><option>-static</option></primary></indexterm>
+         <listitem>
+           <para>Tell the linker to avoid shared Haskell libraries,
+           if possible.  This is the default.</para>
+         </listitem>
+       </varlistentry>
+
+       <varlistentry>
+         <term><option>-dynamic</option></term>
+         <indexterm><primary><option>-dynamic</option></primary></indexterm>
+         <listitem>
+           <para>Tell the linker to use shared Haskell libraries, if
+           available (this option is only supported on Windows at the
+           moment, and also note that your distribution of GHC may
+           not have been supplied with shared libraries).</para>
+         </listitem>
+       </varlistentry>
+
+       <varlistentry>
+         <term><option>-no-hs-main</option></term>
+         <indexterm><primary><option>-no-hs-main</option></primary></indexterm>
+         <indexterm><primary>linking Haskell libraries with foreign code</primary></indexterm>
+         <listitem>
+           <para>In the event you want to include ghc-compiled code
+            as part of another (non-Haskell) program, the RTS will not
+            be supplying its definition of <function>main()</function>
+            at link-time, you will have to. To signal that to the
+            driver script when linking, use
+            <option>-no-hs-main</option>.</para>
+
+           <para>Notice that since the command-line passed to the
+            linker is rather involved, you probably want to use
+            <command>ghc</command> to do the final link of your
+            `mixed-language' application. This is not a requirement
+            though, just try linking once with <option>-v</option> on
+            to see what options the driver passes through to the
+            linker.</para>
+         </listitem>
+       </varlistentry>
+      </variablelist>
+    </sect2>
+
+  </sect1>
+
+<!-- Emacs stuff:
+     ;;; Local Variables: ***
+     ;;; mode: sgml ***
+     ;;; sgml-parent-document: ("users_guide.sgml" "book" "chapter") ***
+     ;;; End: ***
+ -->
diff --git a/ghc/docs/users_guide/separate_compilation.sgml b/ghc/docs/users_guide/separate_compilation.sgml
new file mode 100644 (file)
index 0000000..c124eb2
--- /dev/null
@@ -0,0 +1,613 @@
+  <sect1 id="separate-compilation">
+    <title>Separate compilation</title>
+    
+    <indexterm><primary>separate compilation</primary></indexterm>
+    <indexterm><primary>recompilation checker</primary></indexterm>
+    <indexterm><primary>make and recompilation</primary></indexterm>
+    
+    <para>This section describes how GHC supports separate
+    compilation.</para>
+    
+    <sect2 id="hi-files">
+      <title>Interface files</title>
+      
+      <indexterm><primary>interface files</primary></indexterm>
+      <indexterm><primary><literal>.hi</literal> files</primary></indexterm>
+      
+      <para>When GHC compiles a source file <filename>A.hs</filename>
+      which contains a module <literal>A</literal>, say, it generates
+      an object <filename>A.o</filename>, <emphasis>and</emphasis> a
+      companion <emphasis>interface file</emphasis>
+      <filename>A.hi</filename>.  The interface file is not intended
+      for human consumption, as you'll see if you take a look at one.
+      It's merely there to help the compiler compile other modules in
+      the same program.</para>
+
+      <para>NOTE: In general, the name of a file containing module
+      <literal>M</literal> should be named <filename>M.hs</filename>
+      or <literal>M.lhs</literal>.  The only exception to this rule is
+      module <literal>Main</literal>, which can be placed in any
+      file.<indexterm><primary>filenames</primary><secondary>for
+      modules</secondary> </indexterm></para>
+      
+      <para>The interface file for <literal>A</literal> contains
+      information needed by the compiler when it compiles any module
+      <literal>B</literal> that imports <literal>A</literal>, whether
+      directly or indirectly.  When compiling <literal>B</literal>,
+      GHC will read <filename>A.hi</filename> to find the details that
+      it needs to know about things defined in
+      <literal>A</literal>.</para>
+
+      <para>The interface file may contain all sorts of things that
+      aren't explicitly exported from <literal>A</literal> by the
+      programmer.  For example, even though a data type is exported
+      abstractly, <filename>A.hi</filename> will contain the full data
+      type definition.  For small function definitions,
+      <filename>A.hi</filename> will contain the complete definition
+      of the function.  For bigger functions,
+      <filename>A.hi</filename> will contain strictness information
+      about the function.  And so on.  GHC puts much more information
+      into <filename>.hi</filename> files when optimisation is turned
+      on with the <option>-O</option> flag (see <xref
+      linkend="options-optimise">).  Without <option>-O</option> it
+      puts in just the minimum; with <option>-O</option> it lobs in a
+      whole pile of stuff.  <indexterm><primary>optimsation, effect on
+      .hi files</primary></indexterm></para>
+
+      <para><filename>A.hi</filename> should really be thought of as a
+      compiler-readable version of <filename>A.o</filename>.  If you
+      use a <filename>.hi</filename> file that wasn't generated by the
+      same compilation run that generates the <filename>.o</filename>
+      file the compiler may assume all sorts of incorrect things about
+      <literal>A</literal>, resulting in core dumps and other
+      unpleasant happenings.</para>
+
+    </sect2>
+
+    <sect2 id="options-finding-imports">
+      <title>Finding interface files</title>
+
+      <indexterm><primary>interface files, finding them</primary></indexterm>
+      <indexterm><primary>finding interface files</primary></indexterm>
+
+      <para>In your program, you import a module
+      <literal>Foo</literal> by saying <literal>import Foo</literal>.
+      GHC goes looking for an interface file,
+      <filename>Foo.hi</filename>.  It has a builtin list of
+      directories (notably including <filename>.</filename>) where it
+      looks.</para>
+
+      <variablelist>
+
+       <varlistentry>
+         <term><option>-i&lt;dirs&gt;</option></term>
+         <listitem>
+           <para><indexterm><primary><option>-i&lt;dirs&gt;</option>
+            </primary></indexterm>This flag prepends a colon-separated
+            list of <filename>dirs</filename> to the &ldquo;import
+            directories&rdquo; list.  See also <XRef LinkEnd="recomp">
+            for the significance of using relative and absolute
+            pathnames in the <option>-i</option> list.</para>
+         </listitem>
+       </varlistentry>
+
+       <varlistentry>
+         <term><option>-i</option></term>
+         <listitem>
+           <para>resets the &ldquo;import directories&rdquo; list
+           back to nothing.</para>
+         </listitem>
+       </varlistentry>
+
+      </variablelist>
+
+      <para>See also the section on packages (<xref
+      linkend="packages">), which describes how to use installed
+      libraries.</para>
+
+    </sect2>
+
+    <Sect2 id="hi-options">
+      <title>Other options related to interface files</title>
+      <indexterm><primary>interface files, options</primary></indexterm>
+
+      <variablelist>
+       <varlistentry>
+         <term><option>-ohi</option>  <replaceable>file</replaceable></term>
+         <indexterm><primary><option>-ohi</option></primary>
+         </indexterm>
+         <listitem>
+           <para>The interface output may be directed to another file
+            <filename>bar2/Wurble.iface</filename> with the option
+            <option>-ohi bar2/Wurble.iface</option> (not recommended).
+            To avoid generating an interface at all, you can say
+            <literal>-ohi /dev/null</literal>, for example.</para>
+         </listitem>
+       </varlistentry>
+
+       <varlistentry>
+         <term><option>-ddump-hi</option></term>
+         <indexterm><primary><option>-ddump-hi</option></primary>
+         </indexterm>
+         <listitem>
+           <para>Dumps the new interface to standard output.</para>
+         </listitem>
+       </varlistentry>
+
+       <varlistentry>
+         <term><option>-ddump-hi-diffs</option></term>
+         <indexterm><primary><option>-ddump-hi-diffs</option></primary>
+         </indexterm>
+         <listitem>
+           <para>The compiler does not overwrite an existing
+            <filename>.hi</filename> interface file if the new one is
+            the same as the old one; this is friendly to
+            <command>make</command>.  When an interface does change,
+            it is often enlightening to be informed.  The
+            <option>-ddump-hi-diffs</option> option will make GHC run
+            <command>diff</command> on the old and new
+            <filename>.hi</filename> files.</para>
+         </listitem>
+       </varlistentry>
+
+       <varlistentry>
+         <term><option>-ddump-minimal-imports</option></term>
+         <indexterm><primary><option>-ddump-minimal-imports</option></primary>
+         </indexterm>
+         <listitem>
+           <para>Dump to the file "M.imports" (where M is the module
+            being compiled) a "minimal" set of import declarations.
+            You can safely replace all the import declarations in
+            "M.hs" with those found in "M.imports".  Why would you
+            want to do that?  Because the "minimal" imports (a) import
+            everything explicitly, by name, and (b) import nothing
+            that is not required.  It can be quite painful to maintain
+            this property by hand, so this flag is intended to reduce
+            the labour.</para>
+         </listitem>
+       </varlistentry>
+      </variablelist>
+       
+    </sect2>
+
+    <sect2 id="recomp">
+      <title>The recompilation checker</title>
+
+      <indexterm><primary>recompilation checker</primary></indexterm>
+
+      <variablelist>
+       <varlistentry>
+         <term><option>-no-recomp</option></term>
+         <indexterm><primary><option>-recomp</option></primary></indexterm>
+         <indexterm><primary><option>-no-recomp</option></primary></indexterm>
+         <listitem>
+           <para>Turn off recompilation checking (which is on by
+            default).  Recompilation checking normally stops
+            compilation early, leaving an existing
+            <filename>.o</filename> file in place, if it can be
+            determined that the module does not need to be
+            recompiled.</para>
+         </listitem>
+       </varlistentry>
+      </variablelist>
+      
+      <para>In the olden days, GHC compared the newly-generated
+      <filename>.hi</filename> file with the previous version; if they
+      were identical, it left the old one alone and didn't change its
+      modification date.  In consequence, importers of a module with
+      an unchanged output <filename>.hi</filename> file were not
+      recompiled.</para>
+
+      <para>This doesn't work any more.  Suppose module
+      <literal>C</literal> imports module <literal>B</literal>, and
+      <literal>B</literal> imports module <literal>A</literal>.  So
+      changes to <filename>A.hi</filename> should force a
+      recompilation of <literal>C</literal>.  And some changes to
+      <literal>A</literal> (changing the definition of a function that
+      appears in an inlining of a function exported by
+      <literal>B</literal>, say) may conceivably not change
+      <filename>B.hi</filename> one jot.  So now&hellip;</para>
+
+      <para>GHC keeps a version number on each interface file, and on
+      each type signature within the interface file.  It also keeps in
+      every interface file a list of the version numbers of everything
+      it used when it last compiled the file.  If the source file's
+      modification date is earlier than the <filename>.o</filename>
+      file's date (i.e. the source hasn't changed since the file was
+      last compiled), and the reompilation checking is on, GHC will be
+      clever.  It compares the version numbers on the things it needs
+      this time with the version numbers on the things it needed last
+      time (gleaned from the interface file of the module being
+      compiled); if they are all the same it stops compiling rather
+      early in the process saying &ldquo;Compilation IS NOT
+      required&rdquo;.  What a beautiful sight!</para>
+
+      <para>Patrick Sansom had a workshop paper about how all this is
+      done (though the details have changed quite a bit). <ULink
+      URL="mailto:sansom@dcs.gla.ac.uk">Ask him</ULink> if you want a
+      copy.</para>
+
+    </sect2>
+
+    <sect2 id="using-make">
+      <title>Using <command>make</command></title>
+
+      <indexterm><primary><literal>make</literal></primary></indexterm>
+
+      <para>It is reasonably straightforward to set up a
+      <filename>Makefile</filename> to use with GHC, assuming you name
+      your source files the same as your modules.  Thus:</para>
+
+<ProgramListing>
+HC      = ghc
+HC_OPTS = -cpp $(EXTRA_HC_OPTS)
+
+SRCS = Main.lhs Foo.lhs Bar.lhs
+OBJS = Main.o   Foo.o   Bar.o
+
+.SUFFIXES : .o .hs .hi .lhs .hc .s
+
+cool_pgm : $(OBJS)
+        rm $@
+        $(HC) -o $@ $(HC_OPTS) $(OBJS)
+
+# Standard suffix rules
+.o.hi:
+        @:
+
+.lhs.o:
+        $(HC) -c $&#60; $(HC_OPTS)
+
+.hs.o:
+        $(HC) -c $&#60; $(HC_OPTS)
+
+# Inter-module dependencies
+Foo.o Foo.hc Foo.s    : Baz.hi          # Foo imports Baz
+Main.o Main.hc Main.s : Foo.hi Baz.hi   # Main imports Foo and Baz
+</ProgramListing>
+
+      <para>(Sophisticated <command>make</command> variants may
+      achieve some of the above more elegantly.  Notably,
+      <command>gmake</command>'s pattern rules let you write the more
+      comprehensible:</para>
+
+<ProgramListing>
+%.o : %.lhs
+        $(HC) -c $&#60; $(HC_OPTS)
+</ProgramListing>
+
+      <para>What we've shown should work with any
+      <command>make</command>.)</para>
+
+      <para>Note the cheesy <literal>.o.hi</literal> rule: It records
+      the dependency of the interface (<filename>.hi</filename>) file
+      on the source.  The rule says a <filename>.hi</filename> file
+      can be made from a <filename>.o</filename> file by
+      doing&hellip;nothing.  Which is true.</para>
+
+      <para>Note the inter-module dependencies at the end of the
+      Makefile, which take the form</para>
+
+<ProgramListing>
+Foo.o Foo.hc Foo.s    : Baz.hi          # Foo imports Baz
+</ProgramListing>
+
+      <para>They tell <command>make</command> that if any of
+      <literal>Foo.o</literal>, <literal>Foo.hc</literal> or
+      <literal>Foo.s</literal> have an earlier modification date than
+      <literal>Baz.hi</literal>, then the out-of-date file must be
+      brought up to date.  To bring it up to date,
+      <literal>make</literal> looks for a rule to do so; one of the
+      preceding suffix rules does the job nicely.</para>
+
+      <sect3 id="sec-makefile-dependencies">
+       <title>Dependency generation</title>
+       <indexterm><primary>dependencies in Makefiles</primary></indexterm>
+       <indexterm><primary>Makefile dependencies</primary></indexterm>
+
+       <para>Putting inter-dependencies of the form <literal>Foo.o :
+        Bar.hi</literal> into your <filename>Makefile</filename> by
+        hand is rather error-prone.  Don't worry, GHC has support for
+        automatically generating the required dependencies.  Add the
+        following to your <filename>Makefile</filename>:</para>
+
+<ProgramListing>
+depend :
+        ghc -M $(HC_OPTS) $(SRCS)
+</ProgramListing>
+
+       <para>Now, before you start compiling, and any time you change
+        the <literal>imports</literal> in your program, do
+        <command>make depend</command> before you do <command>make
+        cool&lowbar;pgm</command>.  <command>ghc -M</command> will
+        append the needed dependencies to your
+        <filename>Makefile</filename>.</para>
+
+       <para>In general, if module <literal>A</literal> contains the
+        line
+
+<programlisting>
+import B ...blah...
+</programlisting>
+
+       then <command>ghc -M</command> will generate a dependency line
+        of the form:
+
+<programlisting>
+A.o : B.hi
+</programlisting>
+
+       If module <literal>A</literal> contains the line
+
+<programlisting>
+import {-# SOURCE #-} B ...blah...
+</programlisting>
+
+       then <command>ghc -M</command> will generate a dependency
+       line of the form:
+
+<programlisting>
+A.o : B.hi-boot
+</programlisting>
+
+       (See <xref linkend="mutual-recursion"> for details of
+       <literal>hi-boot</literal> style interface files.)  If
+       <literal>A</literal> imports multiple modules, then there will
+       be multiple lines with <filename>A.o</filename> as the
+       target.</para>
+
+        <para>By default, <command>ghc -M</command> generates all the
+        dependencies, and then concatenates them onto the end of
+        <filename>makefile</filename> (or
+        <filename>Makefile</filename> if <filename>makefile</filename>
+        doesn't exist) bracketed by the lines "<literal>&num; DO NOT
+        DELETE: Beginning of Haskell dependencies</literal>" and
+        "<literal>&num; DO NOT DELETE: End of Haskell
+        dependencies</literal>".  If these lines already exist in the
+        <filename>makefile</filename>, then the old dependencies are
+        deleted first.</para>
+
+       <para>The dependency generation phase of GHC can take some
+        additional options, which you may find useful.  For historical
+        reasons, each option passed to the dependency generator from
+        the GHC command line must be preceded by
+        <literal>-optdep</literal>.  For example, to pass <literal>-f
+        .depend</literal> to the dependency generator, you say
+
+<screen>
+ghc -M -optdep-f -optdep.depend ...
+</screen>
+      
+       The options which affect dependency generation are:</para>
+       
+       <variablelist>
+         <varlistentry>
+           <term><option>-w</option></term>
+           <listitem>
+             <para>Turn off warnings about interface file shadowing.</para>
+           </listitem>
+         </varlistentry>
+         
+         <varlistentry>
+           <term><option>-f</option> <replaceable>file</replaceable></term>
+           <listitem>
+             <para>Use <replaceable>file</replaceable> as the makefile,
+              rather than <filename>makefile</filename> or
+              <filename>Makefile</filename>.  If
+              <replaceable>file</replaceable> doesn't exist,
+              <command>mkdependHS</command> creates it.  We often use
+              <option>-f .depend</option> to put the dependencies in
+              <filename>.depend</filename> and then
+              <command>include</command> the file
+              <filename>.depend</filename> into
+              <filename>Makefile</filename>.</para>
+           </listitem>
+         </varlistentry>
+
+         <varlistentry>
+           <term><option>-o &lt;osuf&gt;</option></term>
+           <listitem>
+             <para>Use <filename>.&lt;osuf&gt;</filename> as the
+              "target file" suffix ( default: <literal>o</literal>).
+              Multiple <option>-o</option> flags are permitted
+              (GHC2.05 onwards).  Thus "<option>-o hc -o o</option>"
+              will generate dependencies for <filename>.hc</filename>
+              and <filename>.o</filename> files.</para>
+           </listitem>
+         </varlistentry>
+
+         <varlistentry>
+           <term><option>-s &lt;suf&gt;</option></term>
+           <listitem>
+             <para>Make extra dependencies that declare that files
+              with suffix
+              <filename>.&lt;suf&gt;&lowbar;&lt;osuf&gt;</filename>
+              depend on interface files with suffix
+              <filename>.&lt;suf&gt;&lowbar;hi</filename>, or (for
+              <literal>&lcub;-&num; SOURCE &num;-&rcub;</literal>
+              imports) on <filename>.hi-boot</filename>.  Multiple
+              <option>-s</option> flags are permitted.  For example,
+              <option>-o hc -s a -s b</option> will make dependencies
+              for <filename>.hc</filename> on
+              <filename>.hi</filename>,
+              <filename>.a&lowbar;hc</filename> on
+              <filename>.a&lowbar;hi</filename>, and
+              <filename>.b&lowbar;hc</filename> on
+              <filename>.b&lowbar;hi</filename>.  (Useful in
+              conjunction with NoFib "ways".)</para>
+           </listitem>
+         </varlistentry>
+
+         <varlistentry>
+           <term><option>--exclude-module=&lt;file&gt;</option></term>
+           <listitem>
+             <para>Regard <filename>&lt;file&gt;</filename> as
+              "stable"; i.e., exclude it from having dependencies on
+              it.</para>
+           </listitem>
+         </varlistentry>
+
+         <varlistentry>
+           <term><option>-x</option></term>
+           <listitem>
+             <para>same as <option>--exclude-module</option></para>
+           </listitem>
+         </varlistentry>
+
+         <varlistentry>
+           <term><option>--exclude-directory=&lt;dirs&gt;</option></term>
+           <listitem>
+             <para>Regard the colon-separated list of directories
+              <filename>&lt;dirs&gt;</filename> as containing stable,
+              don't generate any dependencies on modules
+              therein.</para>
+           </listitem>
+         </varlistentry>
+
+         <varlistentry>
+           <term><option>--include-module=&lt;file&gt;</option></term>
+           <listitem>
+             <para>Regard <filename>&lt;file&gt;</filename> as not
+              "stable"; i.e., generate dependencies on it (if
+              any). This option is normally used in conjunction with
+              the <option>--exclude-directory</option> option.</para>
+           </listitem>
+         </varlistentry>
+
+         <varlistentry>
+           <term><option>--include-prelude</option></term>
+           <listitem>
+             <para>Regard prelude libraries as unstable, i.e.,
+              generate dependencies on the prelude modules used
+              (including <literal>Prelude</literal>).  This option is
+              normally only used by the various system libraries. If a
+              <option>-package</option> option is used, dependencies
+              will also be generated on the library's
+              interfaces.</para>
+           </listitem>
+         </varlistentry>
+       </variablelist>
+
+      </sect3>
+    </sect2>
+
+    <sect2 id="mutual-recursion">
+      <title>How to compile mutually recursive modules</title>
+
+      <indexterm><primary>module system, recursion</primary></indexterm>
+      <indexterm><primary>recursion, between modules</primary></indexterm>
+
+      <para>Currently, the compiler does not have proper support for
+      dealing with mutually recursive modules:</para>
+
+<ProgramListing>
+module A where
+
+import B
+
+newtype TA = MkTA Int
+
+f :: TB -&#62; TA
+f (MkTB x) = MkTA x
+--------
+module B where
+
+import A
+
+data TB = MkTB !Int
+
+g :: TA -&#62; TB
+g (MkTA x) = MkTB x
+</ProgramListing>
+
+      <para>When compiling either module A and B, the compiler will
+      try (in vain) to look for the interface file of the other. So,
+      to get mutually recursive modules off the ground, you need to
+      hand write an interface file for A or B, so as to break the
+      loop.  These hand-written interface files are called
+      <literal>hi-boot</literal> files, and are placed in a file
+      called <filename>&lt;module&gt;.hi-boot</filename>.  To import
+      from an <literal>hi-boot</literal> file instead of the standard
+      <filename>.hi</filename> file, use the following syntax in the
+      importing module: <indexterm><primary><literal>hi-boot</literal>
+      files</primary></indexterm> <indexterm><primary>importing,
+      <literal>hi-boot</literal> files</primary></indexterm></para>
+
+<ProgramListing>
+import {-# SOURCE #-} A
+</ProgramListing>
+
+      <para>The hand-written interface need only contain the bare
+      minimum of information needed to get the bootstrapping process
+      started.  For example, it doesn't need to contain declarations
+      for <emphasis>everything</emphasis> that module
+      <literal>A</literal> exports, only the things required by the
+      module that imports <literal>A</literal> recursively.</para>
+
+      <para>For the example at hand, the boot interface file for A
+      would look like the following:</para>
+
+<ProgramListing>
+__interface A 1 0 where
+__export A TA{MkTA} ;
+1 newtype TA = MkTA PrelBase.Int ;
+</ProgramListing>
+
+      <para>The syntax is essentially the same as a normal
+      <filename>.hi</filename> file (unfortunately), so you can
+      usually tailor an existing <filename>.hi</filename> file to make
+      a <filename>.hi-boot</filename> file.</para>
+
+      <para>Notice that we only put the declaration for the newtype
+      <literal>TA</literal> in the <literal>hi-boot</literal> file,
+      not the signature for <Function>f</Function>, since
+      <Function>f</Function> isn't used by <literal>B</literal>.</para>
+
+      <para>The number &ldquo;1&rdquo; after
+      &ldquo;&lowbar;&lowbar;interface A&rdquo; gives the version
+      number of module A; it is incremented whenever anything in A's
+      interface file changes.  In a normal interface file, the
+      &ldquo;0&rdquo; is the version number of the compiler which
+      generated the interface file; it is used to ensure that we don't
+      mix-and-match interface files between compiler versions.
+      Leaving it as zero in an <literal>hi-boot</literal> file turns
+      off this check.</para>
+
+      <para>The number &ldquo;1&rdquo; at the beginning of a
+      declaration is the <emphasis>version number</emphasis> of that
+      declaration: for the purposes of <filename>.hi-boot</filename>
+      files these can all be set to 1.  All names must be fully
+      qualified with the <emphasis>original</emphasis> module that an
+      object comes from: for example, the reference to
+      <literal>Int</literal> in the interface for <literal>A</literal>
+      comes from <literal>PrelBase</literal>, which is a module
+      internal to GHC's prelude.  It's a pain, but that's the way it
+      is.</para>
+
+      <para>If you want an <literal>hi-boot</literal> file to export a
+      data type, but you don't want to give its constructors (because
+      the constructors aren't used by the SOURCE-importing module),
+      you can write simply:</para>
+
+<ProgramListing>
+__interface A 1 0 where
+__export A TA;
+1 data TA
+</ProgramListing>
+
+      <para>(You must write all the type parameters, but leave out the
+      '=' and everything that follows it.)</para>
+
+      <para><emphasis>Note:</emphasis> This is all a temporary
+      solution, a version of the compiler that handles mutually
+      recursive modules properly without the manual construction of
+      interface files, is (allegedly) in the works.</para>
+    </sect2>
+  </sect1>
+
+<!-- Emacs stuff:
+     ;;; Local Variables: ***
+     ;;; mode: sgml ***
+     ;;; sgml-parent-document: ("using.sgml" "book" "chapter") ***
+     ;;; End: ***
+ -->
index 8958c90..22b24ac 100644 (file)
@@ -1,3 +1,4 @@
+<!ENTITY flags          SYSTEM "flags.sgml">
 <!ENTITY license        SYSTEM "license.sgml">
 <!ENTITY intro          SYSTEM "intro.sgml" >
 <!ENTITY relnotes       SYSTEM "4-08-notes.sgml" >
@@ -9,7 +10,10 @@
 <!ENTITY sooner         SYSTEM "sooner.sgml" >
 <!ENTITY lang-features  SYSTEM "lang.sgml" >
 <!ENTITY glasgowexts    SYSTEM "glasgow_exts.sgml" >
+<!ENTITY packages       SYSTEM "packages.sgml" >
 <!ENTITY parallel       SYSTEM "parallel.sgml" >
+<!ENTITY phases         SYSTEM "phases.sgml" >
+<!ENTITY separate       SYSTEM "separate_compilation.sgml" >
 <!ENTITY vs-hs          SYSTEM "vs_haskell.sgml" >
 <!ENTITY wrong          SYSTEM "gone_wrong.sgml" >
 <!ENTITY utils          SYSTEM "utils.sgml" >
index 9957c9b..1b20b0d 100644 (file)
@@ -1,6 +1,6 @@
 <Chapter id="using-GHC">
-<Title>Using GHC
-</Title>
+<title>Using GHC
+</title>
 
 <para>
 <IndexTerm><Primary>GHC, using</Primary></IndexTerm>
@@ -8,14 +8,14 @@
 GHC is a command-line compiler: in order to compile a Haskell program,
 GHC must be invoked on the source file(s) by typing a command to the
 shell.  The steps involved in compiling a program can be automated
-using the <Command>make</Command> tool (this is especially useful if the program
+using the <command>make</command> tool (this is especially useful if the program
 consists of multiple source files which depend on each other).  This
 section describes how to use GHC from the command-line.
 </para>
 
 <Sect1 id="command-line-structure">
-<Title>Overall command-line structure
-</Title>
+<title>Overall command-line structure
+</title>
 
 <para>
 <IndexTerm><Primary>structure, command-line</Primary></IndexTerm>
@@ -39,12 +39,12 @@ Command-line arguments are either options or file names.
 </para>
 
 <para>
-Command-line options begin with <literal>-</literal>.  They may <Emphasis>not</Emphasis> be
+Command-line options begin with <literal>-</literal>.  They may <emphasis>not</emphasis> be
 grouped: <option>-vO</option> is different from <option>-v -O</option>.  Options need not
-precede filenames: e.g., <Command>ghc *.o -o foo</Command>.  All options are
+precede filenames: e.g., <command>ghc *.o -o foo</command>.  All options are
 processed and then applied to all files; you cannot, for example, invoke
-<Command>ghc -c -O1 Foo.hs -O2 Bar.hs</Command> to apply different optimisation
-levels to the files <Filename>Foo.hs</Filename> and <Filename>Bar.hs</Filename>.  For conflicting
+<command>ghc -c -O1 Foo.hs -O2 Bar.hs</command> to apply different optimisation
+levels to the files <filename>Foo.hs</filename> and <filename>Bar.hs</filename>.  For conflicting
 options, e.g., <option>-c -S</option>, we reserve the right to do anything we
 want.  (Usually, the last one applies.)
 </para>
@@ -52,8 +52,8 @@ want.  (Usually, the last one applies.)
 </Sect1>
 
 <Sect1 id="file-suffixes">
-<Title>Meaningful file suffixes
-</Title>
+<title>Meaningful file suffixes
+</title>
 
 <para>
 <IndexTerm><Primary>suffixes, file</Primary></IndexTerm>
@@ -61,7 +61,7 @@ want.  (Usually, the last one applies.)
 </para>
 
 <para>
-File names with &ldquo;meaningful&rdquo; suffixes (e.g., <Filename>.lhs</Filename> or <Filename>.o</Filename>)
+File names with &ldquo;meaningful&rdquo; suffixes (e.g., <filename>.lhs</filename> or <filename>.o</filename>)
 cause the &ldquo;right thing&rdquo; to happen to those files.
 </para>
 
@@ -69,7 +69,7 @@ cause the &ldquo;right thing&rdquo; to happen to those files.
 <VariableList>
 
 <VarListEntry>
-<Term><Filename>.lhs</Filename>:</Term>
+<Term><filename>.lhs</filename>:</Term>
 <ListItem>
 <para>
 <IndexTerm><Primary>lhs suffix</Primary></IndexTerm>
@@ -78,7 +78,7 @@ A &ldquo;literate Haskell&rdquo; module.
 </ListItem>
 </VarListEntry>
 <VarListEntry>
-<Term><Filename>.hs</Filename>:</Term>
+<Term><filename>.hs</filename>:</Term>
 <ListItem>
 <para>
 A not-so-literate Haskell module.
@@ -86,7 +86,7 @@ A not-so-literate Haskell module.
 </ListItem>
 </VarListEntry>
 <VarListEntry>
-<Term><Filename>.hi</Filename>:</Term>
+<Term><filename>.hi</filename>:</Term>
 <ListItem>
 <para>
 A Haskell interface file, probably compiler-generated.
@@ -94,7 +94,7 @@ A Haskell interface file, probably compiler-generated.
 </ListItem>
 </VarListEntry>
 <VarListEntry>
-<Term><Filename>.hc</Filename>:</Term>
+<Term><filename>.hc</filename>:</Term>
 <ListItem>
 <para>
 Intermediate C file produced by the Haskell compiler.
@@ -102,7 +102,7 @@ Intermediate C file produced by the Haskell compiler.
 </ListItem>
 </VarListEntry>
 <VarListEntry>
-<Term><Filename>.c</Filename>:</Term>
+<Term><filename>.c</filename>:</Term>
 <ListItem>
 <para>
 A C&nbsp;file not produced by the Haskell compiler.
@@ -110,7 +110,7 @@ A C&nbsp;file not produced by the Haskell compiler.
 </ListItem>
 </VarListEntry>
 <VarListEntry>
-<Term><Filename>.s</Filename>:</Term>
+<Term><filename>.s</filename>:</Term>
 <ListItem>
 <para>
 An assembly-language source file, usually
@@ -119,7 +119,7 @@ produced by the compiler.
 </ListItem>
 </VarListEntry>
 <VarListEntry>
-<Term><Filename>.o</Filename>:</Term>
+<Term><filename>.o</filename>:</Term>
 <ListItem>
 <para>
 An object file, produced by an assembler.
@@ -136,66 +136,11 @@ to the linker.
 
 </Sect1>
 
-<Sect1 id="options-help">
-<Title>Help and verbosity options
-</Title>
-
-<para>
-<IndexTerm><Primary>help options (GHC)</Primary></IndexTerm>
-<IndexTerm><Primary>verbose option (GHC)</Primary></IndexTerm>
-</para>
-
-    <informaltable>
-      <tgroup cols=3 align=left colsep=1 rowsep=1>
-       <thead>
-         <row>
-           <entry>Flag</entry>
-           <entry>Description</entry>
-           <entry>Static/Dynamic</entry>
-           <entry>Reverse</entry>
-         </row>
-       </thead>
-       <tbody>
-       <row>
-         <entry><literal>-?</literal></entry>
-         <entry>help</entry>
-         <entry>static</entry>
-         <entry>-</entry>
-       </row>
-       <row>
-         <entry><literal>-help</literal></entry>
-         <entry>help</entry>
-         <entry>static</entry>
-         <entry>-</entry>
-       </row>
-       <row>
-         <entry><literal>-v</literal></entry>
-         <entry>verbose mode (equivalent to <literal>-v3</literal>)</entry>
-         <entry>dynamic</entry>
-         <entry>-</entry>
-       </row>
-       <row>
-         <entry><literal>-v</literal><emphasis>n</emphasis></entry>
-         <entry>set verbosity level</entry>
-         <entry>dynamic</entry>
-         <entry>-</entry>
-       </row>
-       <row>
-         <entry><literal>--version</literal></entry>
-         <entry>display GHC version</entry>
-         <entry>static</entry>
-         <entry>-</entry>
-       </row>
-       <row>
-         <entry><literal>--numeric-version</literal></entry>
-         <entry>display GHC version (numeric only)</entry>
-         <entry>static</entry>
-         <entry>-</entry>
-       </row>
-       </tbody>
-      </tgroup>
-    </informaltable>
+  <sect1 id="options-help">
+    <title>Help and verbosity options</title>
 
+    <IndexTerm><Primary>help options</Primary></IndexTerm>
+    <IndexTerm><Primary>verbosity options</Primary></IndexTerm>
 
     <variablelist>
       <varlistentry>
@@ -214,7 +159,7 @@ to the linker.
        <indexterm><primary><literal>-v</literal></primary></indexterm>
        <listitem>
          <para>The <option>-v</option> option makes GHC
-          <Emphasis>verbose</Emphasis>: it reports its version number
+          <emphasis>verbose</emphasis>: it reports its version number
           and shows (on stderr) exactly how it invokes each phase of
           the compilation system.  Moreover, it passes the
           <option>-v</option> flag to most phases; each reports its
@@ -228,8 +173,8 @@ to the linker.
       </varlistentry>
        
       <varlistentry>
-       <term><literal>-v</literal><emphasis>n</emphasis></term>
-       <indexterm><primary><literal>-v</literal><emphasis>n</emphasis></primary></indexterm>
+       <term><literal>-v</literal><replaceable>n</replaceable></term>
+       <indexterm><primary><option>-v</option></primary></indexterm>
        <listitem>
          <para>To provide more control over the compiler's verbosity,
          the <option>-v</option> flag takes an optional numeric
@@ -311,52 +256,8 @@ to the linker.
     <indexterm><primary>order of passes in GHC</primary></indexterm>
     <indexterm><primary>pass ordering in GHC</primary></indexterm>
 
-    <informaltable>
-      <tgroup cols=3 align=left colsep=1 rowsep=1>
-       <thead>
-         <row>
-           <entry>Flag</entry>
-           <entry>Description</entry>
-           <entry>Static/Dynamic</entry>
-           <entry>Reverse</entry>
-         </row>
-       </thead>
-       <tbody>
-         <row>
-           <entry><literal>-cpp</literal></entry>
-           <entry>Run the C pre-processor on the Haskell source</entry>
-           <entry>dynamic</entry>
-           <entry>-</entry>
-         </row>
-         <row>
-           <entry><literal>-E</literal></entry>
-           <entry>Stop after preprocessing (<literal>.hspp</literal> file)</entry>
-           <entry>static</entry>
-           <entry>-</entry>
-         </row>
-         <row>
-           <entry><literal>-C</literal></entry>
-           <entry>Stop after generating C (<literal>.hc</literal> file)</entry>
-           <entry>static</entry>
-           <entry>-</entry>
-         </row>
-         <row>
-           <entry><literal>-S</literal></entry>
-           <entry>Stop after generating assembly (<literal>.s</literal> file)</entry>
-           <entry>static</entry>
-           <entry>-</entry>
-         </row>
-         <row>
-           <entry><literal>-c</literal></entry>
-           <entry>Stop after compiling to object code (<literal>.o</literal> file)</entry>
-           <entry>static</entry>
-           <entry>-</entry>
-         </row>
-       </tbody>
-      </tgroup>
-    </informaltable>
-
-    <para>The basic task of the <Command>ghc</Command> driver is to
+
+    <para>The basic task of the <command>ghc</command> driver is to
     run each input file through the right phases (compiling, linking,
     etc.).</para>
 
@@ -431,7 +332,7 @@ linker </Entry>
 <IndexTerm><Primary>-c option</Primary></IndexTerm>
 
 <para>
-Thus, a common invocation would be: <Command>ghc -c Foo.hs</Command>
+Thus, a common invocation would be: <command>ghc -c Foo.hs</command>
 </para>
 
 <para>
@@ -450,6 +351,43 @@ native-code generator is used (producing assembly language) or not
     pre-processor. Sans <option>-cpp</option>, the output is the
     de-litted version of the original source.</para>
 
+    <para>The following options also affect which phases get run:</para>
+
+    <variablelist>
+      <varlistentry>
+       <term><option>-cpp</option></term>
+       <indexterm><primary><option>-cpp</option></primary></indexterm>
+       <listitem>
+         <para>Run the C pre-processor on the Haskell source before
+         compiling it.  See <xref linkend="c-pre-processor"> for more
+         details.</para>
+       </listitem>
+      </varlistentry>
+
+      <varlistentry>
+       <term><option>-fasm</option></term>
+       <indexterm><primary><option>-fasm</option></primary></indexterm>
+       <listitem>
+         <para>Use GHC's native code generator rather than compiling
+         via C.  This will compile faster (up to twice as fast), but
+         may produce code that is slightly slower than compiling via
+         C.  <option>-fasm</option> is the default when optimisation
+         is off (see <xref linkend="options-optimise">).</para>
+       </listitem>
+      </varlistentry>
+
+      <varlistentry>
+       <term><option>-fvia-C</option></term>
+       <indexterm><primary><option>-fvia-C</option></primary>
+       </indexterm>
+       <listitem>
+         <para>Compile via C instead of using the native code
+         generator.  This is default for optimised compilations, and
+         on architectures for which GHC doesn't have a native code
+         generator.</para>
+       </listitem>
+      </varlistentry>
+    </variablelist>
   </sect1>
 
   <sect1 id="options-output">
@@ -458,50 +396,6 @@ native-code generator is used (producing assembly language) or not
     <indexterm><primary>output-directing options</primary></indexterm>
     <indexterm><primary>redirecting compilation output</primary></indexterm>
 
-    <informaltable>
-      <tgroup cols=3 align=left colsep=1 rowsep=1>
-       <thead>
-         <row>
-           <entry>Flag</entry>
-           <entry>Description</entry>
-           <entry>Static/Dynamic</entry>
-           <entry>Reverse</entry>
-         </row>
-       </thead>
-       <tbody>
-       <row>
-         <entry><literal>-hisuf</literal></entry>
-         <entry>set the suffix to use for interface files</entry>
-         <entry>static</entry>
-         <entry>-</entry>
-       </row>
-       <row>
-         <entry><literal>-o</literal></entry>
-         <entry>set output filename</entry>
-         <entry>static</entry>
-         <entry>-</entry>
-       </row>
-       <row>
-         <entry><literal>-odir</literal></entry>
-         <entry>set output directory</entry>
-         <entry>static</entry>
-         <entry>-</entry>
-       </row>
-       <row>
-         <entry><literal>-ohi</literal></entry>
-         <entry>set the filename in which to put the interface</entry>
-         <entry>static</entry>
-         <entry></entry>
-       </row>
-       <row>
-         <entry><literal>-osuf</literal></entry>
-         <entry>set the output file suffix</entry>
-         <entry>static</entry>
-         <entry>-</entry>
-       </row>
-       </tbody>
-      </tgroup>
-    </informaltable>
 
     <variablelist>
       <varlistentry>
@@ -509,16 +403,16 @@ native-code generator is used (producing assembly language) or not
        <indexterm><primary><literal>-o</literal></primary></indexterm>
        <listitem>
          <para>GHC's compiled output normally goes into a
-          <Filename>.hc</Filename>, <Filename>.o</Filename>, etc.,
+          <filename>.hc</filename>, <filename>.o</filename>, etc.,
           file, depending on the last-run compilation phase.  The
           option <option>-o foo</option><IndexTerm><Primary>-o
           option</Primary></IndexTerm> re-directs the output of that
-          last-run phase to file <Filename>foo</Filename>.</para>
+          last-run phase to file <filename>foo</filename>.</para>
 
          <para>Note: this &ldquo;feature&rdquo; can be
-          counterintuitive: <Command>ghc -C -o foo.o foo.hs</Command>
+          counterintuitive: <command>ghc -C -o foo.o foo.hs</command>
           will put the intermediate C code in the file
-          <Filename>foo.o</Filename>, name notwithstanding!</para>
+          <filename>foo.o</filename>, name notwithstanding!</para>
        </listitem>
       </varlistentry>
 
@@ -527,7 +421,7 @@ native-code generator is used (producing assembly language) or not
        <indexterm><primary><literal>-odir</literal></primary></indexterm>
        <listitem>
          <para>The <option>-o</option> option isn't of much use if
-          you have <Emphasis>several</Emphasis> input files&hellip;
+          you have <emphasis>several</emphasis> input files&hellip;
           Non-interface output files are normally put in the same
           directory as their corresponding input file came from.  You
           may specify that they be put in another directory using the
@@ -539,20 +433,20 @@ native-code generator is used (producing assembly language) or not
 % ghc -c parse/Foo.hs parse/Bar.hs gurgle/Bumble.hs -odir `arch`
 </Screen>
 
-          <para>The output files, <Filename>Foo.o</Filename>,
-          <Filename>Bar.o</Filename>, and
-          <Filename>Bumble.o</Filename> would be put into a
+          <para>The output files, <filename>Foo.o</filename>,
+          <filename>Bar.o</filename>, and
+          <filename>Bumble.o</filename> would be put into a
           subdirectory named after the architecture of the executing
-          machine (<Filename>sun4</Filename>,
-          <Filename>mips</Filename>, etc).  The directory must already
+          machine (<filename>sun4</filename>,
+          <filename>mips</filename>, etc).  The directory must already
           exist; it won't be created.</para>
 
           <para>Note that the <option>-odir</option> option does
-          <Emphasis>not</Emphasis> affect where the interface files
+          <emphasis>not</emphasis> affect where the interface files
           are put.  In the above example, they would still be put in
-          <Filename>parse/Foo.hi</Filename>,
-          <Filename>parse/Bar.hi</Filename>, and
-          <Filename>gurgle/Bumble.hi</Filename>.</para>
+          <filename>parse/Foo.hi</filename>,
+          <filename>parse/Bar.hi</filename>, and
+          <filename>gurgle/Bumble.hi</filename>.</para>
        </listitem>
       </varlistentry>
 
@@ -573,22 +467,22 @@ native-code generator is used (producing assembly language) or not
          <para>EXOTICA: The <option>-osuf
           &lt;suffix&gt;</option><IndexTerm><Primary>-osuf
           &lt;suffix&gt; option</Primary></IndexTerm> will change the
-          <Filename>.o</Filename> file suffix for object files to
+          <filename>.o</filename> file suffix for object files to
           whatever you specify.  (We use this in compiling the
           prelude.).</para>
 
          <para>Similarly, the <option>-hisuf
           &lt;suffix&gt;</option><IndexTerm><Primary>-hisuf
           &lt;suffix&gt; option</Primary></IndexTerm> will change the
-          <Filename>.hi</Filename> file suffix for non-system
+          <filename>.hi</filename> file suffix for non-system
           interface files (see <XRef LinkEnd="hi-options">).</para>
 
          <para>The <option>-hisuf</option>/<option>-osuf</option>
           game is useful if you want to compile a program with both
           GHC and HBC (say) in the same directory.  Let HBC use the
-          standard <Filename>.hi</Filename>/<Filename>.o</Filename>
+          standard <filename>.hi</filename>/<filename>.o</filename>
           suffixes; add <option>-hisuf g&lowbar;hi -osuf
-          g&lowbar;o</option> to your <Command>make</Command> rule for
+          g&lowbar;o</option> to your <command>make</command> rule for
           GHC compiling&hellip;</para>
        </listitem>
       </varlistentry>
@@ -603,44 +497,6 @@ native-code generator is used (producing assembly language) or not
       <indexterm><primary><literal>.s</literal> files, saving</primary>
       </indexterm>
 
-      <informaltable>
-       <tgroup cols=3 align=left colsep=1 rowsep=1>
-         <thead>
-           <row>
-             <entry>Flag</entry>
-             <entry>Description</entry>
-             <entry>Static/Dynamic</entry>
-             <entry>Reverse</entry>
-           </row>
-         </thead>
-         <tbody>
-           <row>
-             <entry><literal>-keep-hc-file</literal></entry>
-             <entry>retain intermediate <literal>.hc</literal> files</entry>
-             <entry>static</entry>
-             <entry>-</entry>
-           </row>
-           <row>
-             <entry><literal>-keep-s-file</literal></entry>
-             <entry>retain intermediate <literal>.s</literal> files</entry>
-             <entry>static</entry>
-             <entry>-</entry>
-           </row>
-           <row>
-             <entry><literal>-keep-raw-s-file</literal></entry>
-             <entry>retain intermediate <literal>.raw_s</literal> files</entry>
-             <entry>static</entry>
-             <entry>-</entry>
-           </row>
-           <row>
-             <entry><literal>-keep-tmp-files</literal></entry>
-             <entry>retain all intermediate temporary files</entry>
-             <entry>static</entry>
-             <entry>-</entry>
-           </row>
-         </tbody>
-       </tgroup>
-      </informaltable>
 
       <para>The following options are useful for keeping certain
       intermediate files around, when normally GHC would throw these
@@ -715,34 +571,13 @@ native-code generator is used (producing assembly language) or not
        <secondary>redirecting</secondary>
       </indexterm>
 
-      <informaltable>
-       <tgroup cols=3 align=left colsep=1 rowsep=1>
-         <thead>
-           <row>
-             <entry>Flag</entry>
-             <entry>Description</entry>
-             <entry>Static/Dynamic</entry>
-             <entry>Reverse</entry>
-           </row>
-         </thead>
-         <tbody>
-           <row>
-             <entry><literal>-tmpdir</literal></entry>
-             <entry>set the directory for temporary files</entry>
-             <entry>static</entry>
-             <entry>-</entry>
-           </row>
-         </tbody>
-       </tgroup>
-      </informaltable>
-
       <variablelist>
        <varlistentry>
          <term><literal>-tmpdir</literal></term>
          <indexterm><primary><literal>-tmpdir</literal></primary></indexterm>
          <listitem>
            <para>If you have trouble because of running out of space
-            in <Filename>/tmp</Filename> (or wherever your
+            in <filename>/tmp</filename> (or wherever your
             installation thinks temporary files should go), you may
             use the <option>-tmpdir
             &lt;dir&gt;</option><IndexTerm><Primary>-tmpdir
@@ -776,138 +611,6 @@ native-code generator is used (producing assembly language) or not
     <indexterm><primary>sanity-checking options</primary></indexterm>
     <indexterm><primary>warnings</primary></indexterm>
 
-    <informaltable>
-      <tgroup cols=3 align=left colsep=1 rowsep=1>
-       <thead>
-         <row>
-           <entry>Flag</entry>
-           <entry>Description</entry>
-           <entry>Static/Dynamic</entry>
-           <entry>Reverse</entry>
-         </row>
-       </thead>
-       <tbody>
-         <row>
-           <entry><literal>-W</literal></entry>
-           <entry>enable normal warnings</entry>
-           <entry>static</entry>
-           <entry><literal>-w</literal></entry>
-         </row>
-         <row>
-           <entry><literal>-w</literal></entry>
-           <entry>disable all warnings</entry>
-           <entry>static</entry>
-           <entry>-</entry>
-         </row>
-         <row>
-           <entry><literal>-Wall</literal></entry>
-           <entry>enable all warnings</entry>
-           <entry>static</entry>
-           <entry><literal>-w</literal></entry>
-         </row>
-
-         <row>
-           <entry><literal>-fwarn-deprecations</literal></entry>
-           <entry>warn about uses of functions & types that are deprecated</entry>
-           <entry>dynamic</entry>
-           <entry><literal>-fno-warn-deprecations</literal></entry>
-         </row>
-
-         <row>
-           <entry><literal>-fwarn-duplicate-exports</literal></entry>
-           <entry>warn when an entity is exported multiple times</entry>
-           <entry>dynamic</entry>
-           <entry><literal>-fno-warn-duplicate-exports</literal></entry>
-         </row>
-
-         <row>
-           <entry><literal>-fwarn-hi-shadowing</literal></entry>
-           <entry>warn when a <literal>.hi</literal> file in the
-           current directory shadows a library</entry>
-           <entry>dynamic</entry>
-           <entry><literal>-fno-warn-hi-shadowing</literal></entry>
-         </row>
-
-         <row>
-           <entry><literal>-fwarn-incomplete-patterns</literal></entry>
-           <entry>warn when a pattern match could fail</entry>
-           <entry>dynamic</entry>
-           <entry><literal>-fno-warn-incomplete-patterns</literal></entry>
-         </row>
-
-         <row>
-           <entry><literal>-fwarn-missing-fields</literal></entry>
-           <entry>warn when fields of a record are uninitialised</entry>
-           <entry>dynamic</entry>
-           <entry><literal>-fno-warn-missing-fields</literal></entry>
-         </row>
-
-         <row>
-           <entry><literal>-fwarn-missing-methods</literal></entry>
-           <entry>warn when class methods are undefined</entry>
-           <entry>dynamic</entry>
-           <entry><literal>-fno-warn-missing-methods</literal></entry>
-         </row>
-
-         <row>
-           <entry><literal>-fwarn-missing-signatures</literal></entry>
-           <entry>warn about top-level functions without signatures</entry>
-           <entry>dynamic</entry>
-           <entry><literal>-fno-warn-missing-signatures</literal></entry>
-         </row>
-
-         <row>
-           <entry><literal>-fwarn-name-shadowing</literal></entry>
-           <entry>warn when names are shadowed</entry>
-           <entry>dynamic</entry>
-           <entry><literal>-fno-warn-name-shadowing</literal></entry>
-         </row>
-
-         <row>
-           <entry><literal>-fwarn-overlapping-patterns</literal></entry>
-           <entry>warn about overlapping patterns</entry>
-           <entry>dynamic</entry>
-           <entry><literal>-fno-warn-overlapping-patterns</literal></entry>
-         </row>
-
-         <row>
-           <entry><literal>-fwarn-simple-patterns</literal></entry>
-           <entry>warn about lambda-patterns that can fail</entry>
-           <entry>dynamic</entry>
-           <entry><literal>-fno-warn-simple-patterns</literal></entry>
-         </row>
-
-         <row>
-           <entry><literal>-fwarn-type-defaults</literal></entry>
-           <entry>warn when defaulting happens</entry>
-           <entry>dynamic</entry>
-           <entry><literal>-fno-warn-type-defaults</literal></entry>
-         </row>
-
-         <row>
-           <entry><literal>-fwarn-unused-binds</literal></entry>
-           <entry>warn about bindings that are unused</entry>
-           <entry>dynamic</entry>
-           <entry><literal>-fno-warn-unused-binds</literal></entry>
-         </row>
-
-         <row>
-           <entry><literal>-fwarn-unused-imports</literal></entry>
-           <entry>warn about unnecessary imports</entry>
-           <entry>dynamic</entry>
-           <entry><literal>-fno-warn-unused-imports</literal></entry>
-         </row>
-
-         <row>
-           <entry><literal>-fwarn-unused-matches</literal></entry>
-           <entry>warn about variables in patterns that aren't used</entry>
-           <entry>dynamic</entry>
-           <entry><literal>-fno-warn-unused-matches</literal></entry>
-         </row>
-
-       </tbody>
-      </tgroup>
-    </informaltable>
 
     <para>GHC has a number of options that select which types of
     non-fatal error messages, otherwise known as warnings, can be
@@ -1194,2099 +897,404 @@ f "2"    = 2
 
   </sect1>
 
-<Sect1 id="separate-compilation">
-<Title>Separate compilation
-</Title>
+  &separate;
+  &packages;
+
+  <sect1 id="options-optimise">
+    <title>Optimisation (code improvement)</title>
+
+    <indexterm><primary>optimisation</primary></indexterm>
+    <indexterm><primary>improvement, code</primary></indexterm>
+
+    <para>The <option>-O*</option> options specify convenient
+    &ldquo;packages&rdquo; of optimisation flags; the
+    <option>-f*</option> options described later on specify
+    <emphasis>individual</emphasis> optimisations to be turned on/off;
+    the <option>-m*</option> options specify
+    <emphasis>machine-specific</emphasis> optimisations to be turned
+    on/off.</para>
+
+    <sect2 id="optimise-pkgs">
+      <title><option>-O*</option>: convenient &ldquo;packages&rdquo; of optimisation flags.</title>
+
+      <para>There are <emphasis>many</emphasis> options that affect
+      the quality of code produced by GHC.  Most people only have a
+      general goal, something like &ldquo;Compile quickly&rdquo; or
+      &ldquo;Make my program run like greased lightning.&rdquo; The
+      following &ldquo;packages&rdquo; of optimisations (or lack
+      thereof) should suffice.</para>
+
+      <para>Once you choose a <option>-O*</option>
+      &ldquo;package,&rdquo; stick with it&mdash;don't chop and
+      change.  Modules' interfaces <emphasis>will</emphasis> change
+      with a shift to a new <option>-O*</option> option, and you may
+      have to recompile a large chunk of all importing modules before
+      your program can again be run safely (see <XRef
+      LinkEnd="recomp">).</para>
 
-<para>
-<indexterm><primary>separate compilation</primary></indexterm>
-<indexterm><primary>recompilation checker</primary></indexterm>
-<indexterm><primary>make and recompilation</primary></indexterm>
-This section describes how GHC supports separate compilation.
-</para>
+      <variablelist>
 
-<Sect2 id="hi-files">
-<Title>Interface files
-</Title>
+       <varlistentry>
+         <term>No <option>-O*</option>-type option specified:</term>
+         <indexterm><primary>-O* not specified</primary></indexterm>
+         <listitem>
+           <para>This is taken to mean: &ldquo;Please compile
+            quickly; I'm not over-bothered about compiled-code
+            quality.&rdquo; So, for example: <command>ghc -c
+            Foo.hs</command></para>
+         </listitem>
+       </varlistentry>
 
-<para>
-<indexterm><primary>interface files</primary></indexterm>
-<indexterm><primary>.hi files</primary></indexterm>
-</para>
+       <varlistentry>
+         <term><option>-O0</option>:</term>
+         <indexterm><primary><option>-O0</option></primary></indexterm>
+         <listitem>
+           <para>Means &ldquo;turn off all optimisation&rdquo;,
+           reverting to the same settings as if no
+           <option>-O</option> options had been specified.  Saying
+           <option>-O0</option> can be useful if
+           eg. <command>make</command> has inserted a
+           <option>-O</option> on the command line already.</para>
+         </listitem>
+       </varlistentry>
 
-<para>
-When GHC compiles a source file <Filename>F</Filename> which contains a module <literal>A</literal>, say,
-it generates an object <Filename>F.o</Filename>, <Emphasis>and</Emphasis> a companion <Emphasis>interface
-file</Emphasis> <Filename>A.hi</Filename>.  The interface file is not intended for human
-consumption, as you'll see if you take a look at one.  It's merely
-there to help the compiler compile other modules in the same program.
-</para>
+       <varlistentry>
+         <term><option>-O</option> or <option>-O1</option>:</term>
+         <indexterm><primary>-O option</primary></indexterm>
+         <indexterm><primary>-O1 option</primary></indexterm>
+         <indexterm><primary>optimise</primary><secondary>normally</secondary></indexterm>
+         <listitem>
+           <para>Means: &ldquo;Generate good-quality code without
+            taking too long about it.&rdquo; Thus, for example:
+            <command>ghc -c -O Main.lhs</command></para>
+         </listitem>
+       </varlistentry>
 
-<para>
-NOTE: Having the name of the interface file follow the module name and
-not the file name, means that working with tools such as <Command>make</Command>
-become harder. <Command>make</Command> implicitly assumes that any output files
-produced by processing a translation unit will have file names that
-can be derived from the file name of the translation unit.  For
-instance, pattern rules becomes unusable.  For this reason, we
-recommend you stick to using the same file name as the module name.
-</para>
+       <varlistentry>
+         <term><option>-O2</option>:</term>
+         <indexterm><primary>-O2 option</primary></indexterm>
+         <indexterm><primary>optimise</primary><secondary>aggressively</secondary></indexterm>
+         <listitem>
+           <para>Means: &ldquo;Apply every non-dangerous
+            optimisation, even if it means significantly longer
+            compile times.&rdquo;</para>
+
+           <para>The avoided &ldquo;dangerous&rdquo; optimisations
+            are those that can make runtime or space
+            <emphasis>worse</emphasis> if you're unlucky.  They are
+            normally turned on or off individually.</para>
+
+           <para>At the moment, <option>-O2</option> is
+            <emphasis>unlikely</emphasis> to produce better code than
+            <option>-O</option>.</para>
+         </listitem>
+       </varlistentry>
 
-<para>
-The interface file for <literal>A</literal> contains information needed by the compiler
-when it compiles any module <literal>B</literal> that imports <literal>A</literal>, whether directly or
-indirectly.  When compiling <literal>B</literal>, GHC will read <Filename>A.hi</Filename> to find the
-details that it needs to know about things defined in <literal>A</literal>.
-</para>
+       <varlistentry>
+         <term><option>-O2-for-C</option>:</term>
+         <indexterm><primary>-O2-for-C option</primary></indexterm>
+         <indexterm><primary>gcc, invoking with -O2</primary></indexterm>
+         <listitem>
+           <para>Says to run GCC with <option>-O2</option>, which may
+            be worth a few percent in execution speed.  Don't forget
+            <option>-fvia-C</option>, lest you use the native-code
+            generator and bypass GCC altogether!</para>
+         </listitem>
+       </varlistentry>
 
-<para>
-Furthermore, when compiling module <literal>C</literal> which imports <literal>B</literal>, GHC may
-decide that it needs to know something about <literal>A</literal>&mdash;for example, <literal>B</literal>
-might export a function that involves a type defined in <literal>A</literal>.  In this
-case, GHC will go and read <Command>A.hi</Command> even though <literal>C</literal> does not explicitly
-import <literal>A</literal> at all.
-</para>
+       <varlistentry>
+         <term><option>-Ofile &lt;file&gt;</option>:</term>
+         <indexterm><primary>-Ofile &lt;file&gt; option</primary></indexterm>
+         <indexterm><primary>optimising, customised</primary></indexterm>
+         <listitem>
+           <para>(NOTE: not supported yet in GHC 5.x.  Please ask if
+           you're interested in this.)</para>
+           
+           <para>For those who need <emphasis>absolute</emphasis>
+            control over <emphasis>exactly</emphasis> what options are
+            used (e.g., compiler writers, sometimes :-), a list of
+            options can be put in a file and then slurped in with
+            <option>-Ofile</option>.</para>
+
+           <para>In that file, comments are of the
+            <literal>&num;</literal>-to-end-of-line variety; blank
+            lines and most whitespace is ignored.</para>
+
+           <para>Please ask if you are baffled and would like an
+           example of <option>-Ofile</option>!</para>
+         </listitem>
+       </varlistentry>
+      </variablelist>
 
-<para>
-The interface file may contain all sorts of things that aren't
-explicitly exported from <literal>A</literal> by the programmer.  For example, even
-though a data type is exported abstractly, <Filename>A.hi</Filename> will contain the
-full data type definition.  For small function definitions, <Filename>A.hi</Filename>
-will contain the complete definition of the function.  For bigger
-functions, <Filename>A.hi</Filename> will contain strictness information about the
-function.  And so on.  GHC puts much more information into <Filename>.hi</Filename> files
-when optimisation is turned on with the <option>-O</option> flag.  Without <option>-O</option> it
-puts in just the minimum; with <option>-O</option> it lobs in a whole pile of stuff.
-<indexterm><primary>optimsation, effect on .hi files</primary></indexterm>
-</para>
+      <para>We don't use a <option>-O*</option> flag for day-to-day
+      work.  We use <option>-O</option> to get respectable speed;
+      e.g., when we want to measure something.  When we want to go for
+      broke, we tend to use <option>-O -fvia-C -O2-for-C</option> (and
+      we go for lots of coffee breaks).</para>
 
-<para>
-<Filename>A.hi</Filename> should really be thought of as a compiler-readable version of
-<Filename>A.o</Filename>.  If you use a <Filename>.hi</Filename> file that wasn't generated by the same
-compilation run that generates the <Filename>.o</Filename> file the compiler may assume
-all sorts of incorrect things about <literal>A</literal>, resulting in core dumps and
-other unpleasant happenings.
-</para>
+      <para>The easiest way to see what <option>-O</option> (etc.)
+      &ldquo;really mean&rdquo; is to run with <option>-v</option>,
+      then stand back in amazement.</para>
+    </sect2>
 
-</sect2>
+    <sect2 id="options-f">
+      <title><option>-f*</option>: platform-independent flags</title>
 
-<Sect2 id="options-finding-imports">
-<Title>Finding interface files
-</Title>
+      <indexterm><primary>-f* options (GHC)</primary></indexterm>
+      <indexterm><primary>-fno-* options (GHC)</primary></indexterm>
 
-<para>
-<indexterm><primary>interface files, finding them</primary></indexterm>
-<indexterm><primary>finding interface files</primary></indexterm>
-</para>
+      <para>These flags turn on and off individual optimisations.
+      They are normally set via the <option>-O</option> options
+      described above, and as such, you shouldn't need to set any of
+      them explicitly (indeed, doing so could lead to unexpected
+      results).  However, there are one or two that may be of
+      interest:</para>
 
-<para>
-In your program, you import a module <literal>Foo</literal> by saying
-<literal>import Foo</literal>.  GHC goes looking for an interface file, <Filename>Foo.hi</Filename>.
-It has a builtin list of directories (notably including <Filename>.</Filename>) where
-it looks.
-</para>
+      <variablelist>
+       <varlistentry>
+         <term><option>-fexcess-precision</option>:</term>
+         <listitem>
+           <indexterm><primary><option>-fexcess-precision</option></primary></indexterm>
+           <para>When this option is given, intermediate floating
+           point values can have a <emphasis>greater</emphasis>
+           precision/range than the final type.  Generally this is a
+           good thing, but some programs may rely on the exact
+           precision/range of
+           <literal>Float</literal>/<literal>Double</literal> values
+           and should not use this option for their compilation.</para>
+         </listitem>
+       </varlistentry>
 
-<para>
-<VariableList>
+       <varlistentry>
+         <term><option>-fno-strictness</option></term>
+         <indexterm><primary><option>-fno-strictness</option></primary>
+         </indexterm>
+         <listitem>
+           <para>Turns off the strictness analyser; sometimes it eats
+           too many cycles.</para>
+         </listitem>
+       </varlistentry>
 
-<varlistentry>
-<term><option>-i&lt;dirs&gt;</option></term>
-<listitem>
-<para>
-<indexterm><primary>-i&lt;dirs&gt; option</primary></indexterm>This flag
-prepends a colon-separated list of <Filename>dirs</Filename> to the &ldquo;import
-directories&rdquo; list.
-See also <XRef LinkEnd="recomp"> for the significance of using
-relative and absolute pathnames in the <option>-i</option> list.
-</para>
-</listitem>
-</varlistentry>
+       <varlistentry>
+         <term><option>-fno-cpr-analyse</option></term>
+         <indexterm><primary><option>-fno-cpr-analyse</option></primary>
+         </indexterm>
+         <listitem>
+           <para>Turns off the CPR (constructed product result)
+           analysis; it is somewhat experimental.</para>
+         </listitem>
+       </varlistentry>
 
-<varlistentry>
-<term><option>-i</option></term>
-<listitem>
-<para>
-resets the &ldquo;import directories&rdquo; list back to nothing.
-</para>
-</listitem>
-</varlistentry>
+       <varlistentry>
+         <term><option>-funbox-strict-fields</option>:</term>
+         <listitem>
+           <indexterm><primary><option>-funbox-strict-fields</option></primary></indexterm>
+           <indexterm><primary>strict constructor fields</primary></indexterm>
+           <indexterm><primary>constructor fields, strict</primary></indexterm>
 
-<varlistentry>
-<term><option>-fno-implicit-prelude</option></term>
-<listitem>
-<para>
-<indexterm><primary>-fno-implicit-prelude option</primary></indexterm>
-GHC normally imports <Filename>Prelude.hi</Filename> files for you.  If you'd rather it
-didn't, then give it a <option>-fno-implicit-prelude</option> option.  
-The idea is that you can then import a Prelude of your own.  (But don't call it <literal>Prelude</literal>;
-the Haskell module namespace is flat, and you must not conflict with any Prelude module.)
-</para>
-<para>
-Even though you have not imported the Prelude, all the built-in syntax still refers to 
-the built-in Haskell Prelude types and values, as specified by the Haskell Report.  
-For example, the type <literal>[Int]</literal>
-still means <literal>Prelude.[] Int</literal>; tuples continue to refer to the standard Prelude
-tuples; the translation for list comprehensions continues to use <literal>Prelude.map</literal> etc.
-</para>
-<para> With one group of exceptions!  You may want to define your own numeric class hierarchy.
-It completely defeats that purpose if the literal "1" means "<literal>Prelude.fromInteger 1</literal>",
-which is what the Haskell Report specifies.  So the <option>-fno-implicit-prelude</option> flag causes
-the following pieces of built-in syntax to refer to whatever is in scope, not the Prelude versions:
-<ItemizedList>
-<listitem>
-<para>
-Integer and fractional literals mean "<literal>fromInteger 1</literal>" and "<literal>fromRational 3.2</literal>",
-not the Prelude-qualified versions; both in expressions and in patterns.
-</para>
-</listitem>
-<listitem>
-<para>
-Negation (e.g. "<literal>- (f x)</literal>") means "<literal>negate (f x)</literal>" (not <literal>Prelude.negate</literal>).
-</para>
-</listitem>
-<listitem>
-<para>
-In an n+k pattern, the standard Prelude <literal>Ord</literal> class is used for comparison, but the 
-necessary subtraction uses 
-whatever "<literal>(-)</literal>" is in scope (not "<literal>Prelude.(-)</literal>").
-</para>
-</listitem>
-</ItemizedList>
-</para>
-</listitem>
-</varlistentry>
+           <para>This option causes all constructor fields which are
+            marked strict (i.e. &ldquo;!&rdquo;) to be unboxed or
+            unpacked if possible.  For example:</para>
 
-<varlistentry>
-<term><option>-I&lt;dir&gt;</option></term>
-<listitem>
-<para>
-<indexterm><primary>-I&lt;dir&gt; option</primary></indexterm>
-Once a Haskell module has been compiled to C (<Filename>.hc</Filename> file), you may
-wish to specify where GHC tells the C compiler to look for <Filename>.h</Filename> files.
-(Or, if you are using the <option>-cpp</option> option<indexterm><primary>-cpp option</primary></indexterm>, where
-it tells the C pre-processor to look&hellip;)  For this purpose, use a <option>-I</option>
-option in the usual C-ish way.
-</para>
-</listitem>
-</varlistentry>
+<ProgramListing>
+data T = T !Float !Float
+</ProgramListing>
 
-</VariableList>
-</para>
+           <para>will create a constructor <literal>T</literal>
+            containing two unboxed floats if the
+            <option>-funbox-strict-fields</option> flag is given.
+            This may not always be an optimisation: if the
+            <Function>T</Function> constructor is scrutinised and the
+            floats passed to a non-strict function for example, they
+            will have to be reboxed (this is done automatically by the
+            compiler).</para>
 
-</sect2>
+           <para>This option should only be used in conjunction with
+            <option>-O</option>, in order to expose unfoldings to the
+            compiler so the reboxing can be removed as often as
+            possible.  For example:</para>
 
-<Sect2 id="hi-options">
-<Title>Other options related to interface files
-</Title>
+<ProgramListing>
+f :: T -&#62; Float
+f (T f1 f2) = f1 + f2
+</ProgramListing>
 
-<para>
-<indexterm><primary>interface files, options</primary></indexterm>
-The interface output may be directed to another file
-<Filename>bar2/Wurble.iface</Filename> with the option <option>-ohi bar2/Wurble.iface</option><indexterm><primary>-ohi
-&lt;file&gt; option</primary></indexterm> (not recommended).
-</para>
+           <para>The compiler will avoid reboxing
+            <Function>f1</Function> and <Function>f2</Function> by
+            inlining <Function>+</Function> on floats, but only when
+            <option>-O</option> is on.</para>
 
-<para>
-To avoid generating an interface file at all, use a <option>-nohi</option>
-option.<indexterm><primary>-nohi option</primary></indexterm>
-</para>
+           <para>Any single-constructor data is eligible for
+           unpacking; for example</para>
 
-<para>
-The compiler does not overwrite an existing <Filename>.hi</Filename> interface file if
-the new one is byte-for-byte the same as the old one; this is friendly
-to <Command>make</Command>.  When an interface does change, it is often enlightening to
-be informed.  The <option>-hi-diffs</option><indexterm><primary>-hi-diffs option</primary></indexterm> option will
-make GHC run <Command>diff</Command> on the old and new <Filename>.hi</Filename> files. You can also
-record the difference in the interface file itself, the
-<option>-keep-hi-diffs</option><indexterm><primary>-keep-hi-diffs</primary></indexterm> option takes care of that.
-</para>
+<ProgramListing>
+data T = T !(Int,Int)
+</ProgramListing>
 
-<para>
-The <Filename>.hi</Filename> files from GHC contain &ldquo;usage&rdquo; information which changes
-often and uninterestingly.  If you really want to see these changes
-reported, you need to use the
-<option>-hi-diffs-with-usages</option><indexterm><primary>-hi-diffs-with-usages option</primary></indexterm>
-option.
-</para>
+           <para>will store the two <literal>Int</literal>s directly
+            in the <Function>T</Function> constructor, by flattening
+            the pair.  Multi-level unpacking is also supported:</para>
 
-<para>
-Interface files are normally jammed full of compiler-produced
-<Emphasis>pragmas</Emphasis>, which record arities, strictness info, etc.  If you
-think these pragmas are messing you up (or you are doing some kind of
-weird experiment), you can tell GHC to ignore them with the
-<option>-fignore-interface-pragmas</option><indexterm><primary>-fignore-interface-pragmas
-option</primary></indexterm> option.
-</para>
+<ProgramListing>
+data T = T !S
+data S = S !Int !Int
+</ProgramListing>
 
-<para>
-When compiling without optimisations on, the compiler is extra-careful
-about not slurping in data constructors and instance declarations that
-it will not need. If you believe it is getting it wrong and not
-importing stuff which you think it should, this optimisation can be
-turned off with <option>-fno-prune-tydecls</option> and <option>-fno-prune-instdecls</option>.
-<indexterm><primary>-fno-prune-tydecls option</primary></indexterm><indexterm><primary>-fno-prune-instdecls
-option</primary></indexterm>
-</para>
+           <para>will store two unboxed <literal>Int&num;</literal>s
+           directly in the <Function>T</Function> constructor.</para>
+         </listitem>
+       </varlistentry>
 
-<para>
-See also <XRef LinkEnd="options-linker">, which describes how the linker finds standard
-Haskell libraries.
-</para>
+       <varlistentry>
+         <term><option>-funfolding-update-in-place&lt;n&gt;</option></term>
+         <indexterm><primary><option>-funfolding-update-in-place</option></primary></indexterm>
+         <listitem>
+           <para>Switches on an experimental "optimisation".
+            Switching it on makes the compiler a little keener to
+            inline a function that returns a constructor, if the
+            context is that of a thunk.
+<ProgramListing>
+   x = plusInt a b
+</ProgramListing>
+            If we inlined plusInt we might get an opportunity to use
+            update-in-place for the thunk 'x'.</para>
+         </listitem>
+       </varlistentry>
 
-</sect2>
+       <varlistentry>
+         <term><option>-funfolding-interface-threshold&lt;n&gt;</option>:</term>
+         <listitem>
+           <indexterm><primary><option>-funfolding-interface-threshold</option></primary></indexterm>
+           <indexterm><primary>inlining, controlling</primary></indexterm>
+           <indexterm><primary>unfolding, controlling</primary></indexterm>
+
+           <para>(Default: 30) By raising or lowering this number,
+            you can raise or lower the amount of pragmatic junk that
+            gets spewed into interface files.  (An unfolding has a
+            &ldquo;size&rdquo; that reflects the cost in terms of
+            &ldquo;code bloat&rdquo; of expanding that unfolding in
+            another module.  A bigger function would be assigned a
+            bigger cost.)</para>
+         </listitem>
+       </varlistentry>
 
-<Sect2 id="recomp">
-<Title>The recompilation checker
-</Title>
+       <varlistentry>
+         <term><option>-funfolding-creation-threshold&lt;n&gt;</option>:</term>
+         <listitem>
+           <indexterm><primary><option>-funfolding-creation-threshold</option></primary></indexterm>
+           <indexterm><primary>inlining, controlling</primary></indexterm>
+           <indexterm><primary>unfolding, controlling</primary></indexterm>
+           
+           <para>(Default: 30) This option is similar to
+            <option>-funfolding-interface-threshold</option>, except
+            that it governs unfoldings within a single module.
+            Increasing this figure is more likely to result in longer
+            compile times than faster code.  The next option is more
+            useful:</para>
+         </listitem>
+       </varlistentry>
 
-<indexterm><primary>recompilation checker</primary></indexterm>
+       <varlistentry>
+         <term><option>-funfolding-use-threshold&lt;n&gt;</option>:</term>
+         <listitem>
+           <indexterm><primary><option>-funfolding-use-threshold</option></primary></indexterm>
+           <indexterm><primary>inlining, controlling</primary></indexterm>
+           <indexterm><primary>unfolding, controlling</primary></indexterm>
+
+           <para>(Default: 8) This is the magic cut-off figure for
+            unfolding: below this size, a function definition will be
+            unfolded at the call-site, any bigger and it won't.  The
+            size computed for a function depends on two things: the
+            actual size of the expression minus any discounts that
+            apply (see <option>-funfolding-con-discount</option>).</para>
+         </listitem>
+       </varlistentry>
+      </variablelist>
 
-<para>
-<variablelist>
-<varlistentry>
-<term><option>-recomp</option></term>
-<indexterm><primary><option>-recomp</option> option</primary></indexterm>
-<listitem>
-<para>
-(On by default) Turn on recompilation checking.  This will stop
-compilation early, leaving an existing <filename>.o</filename> file in
-place, if it can be determined that the module does not need to be
-recompiled.
-</para>
-</listitem>
-</varlistentry>
-<varlistentry>
-<term><option>-no-recomp</option></term>
-<indexterm><primary><option>-recomp</option> option</primary></indexterm>
-<listitem>
-<para>
-Turn off recompilation checking.
-</para>
-</listitem>
-</varlistentry>
-</VariableList>
-</para>
+    </sect2>
+
+  </sect1>
+
+&phases;  
+
+<Sect1 id="sec-using-concurrent">
+<title>Using Concurrent Haskell</title>
 
 <para>
-In the olden days, GHC compared the newly-generated
-<Filename>.hi</Filename> file with the previous version; if they were
-identical, it left the old one alone and didn't change its
-modification date.  In consequence, importers of a module with an
-unchanged output <Filename>.hi</Filename> file were not recompiled.
+<indexterm><primary>Concurrent Haskell&mdash;use</primary></indexterm>
 </para>
 
 <para>
-This doesn't work any more.  In our earlier example, module
-<literal>C</literal> does not import module <literal>A</literal>
-directly, yet changes to <Filename>A.hi</Filename> should force a
-recompilation of <literal>C</literal>.  And some changes to
-<literal>A</literal> (changing the definition of a function that
-appears in an inlining of a function exported by <literal>B</literal>,
-say) may conceivably not change <Filename>B.hi</Filename> one jot.  So
-now&hellip;
+GHC (as of version 4.00) supports Concurrent Haskell by default,
+without requiring a special option or libraries compiled in a certain
+way.  To get access to the support libraries for Concurrent Haskell
+(i.e. <literal>Concurrent</literal> and friends), use the
+<option>-package concurrent</option> option.
 </para>
 
 <para>
-GHC keeps a version number on each interface file, and on each type
-signature within the interface file.  It also keeps in every interface
-file a list of the version numbers of everything it used when it last
-compiled the file.  If the source file's modification date is earlier
-than the <Filename>.o</Filename> file's date (i.e. the source hasn't
-changed since the file was last compiled), and the
-<option>-recomp</option> is given on the command line, GHC will be
-clever.  It compares the version numbers on the things it needs this
-time with the version numbers on the things it needed last time
-(gleaned from the interface file of the module being compiled); if
-they are all the same it stops compiling rather early in the process
-saying &ldquo;Compilation IS NOT required&rdquo;.  What a beautiful
-sight!
+Three RTS options are provided for modifying the behaviour of the
+threaded runtime system.  See the descriptions of
+<option>-C[&lt;us&gt;]</option>, <option>-q</option>, and
+<option>-t&lt;num&gt;</option> in <XRef LinkEnd="parallel-rts-opts">.
 </para>
 
 <para>
-Patrick Sansom had a workshop paper about how all this is done (though
-the details have changed quite a bit). <ULink URL="mailto:sansom@dcs.gla.ac.uk">Ask him</ULink> if you want a copy.
+Concurrent Haskell is described in more detail in <XRef
+LinkEnd="sec-Concurrent">.
 </para>
 
-</sect2>
-
+</Sect1>
 
-<Sect2 id="using-make">
-<Title>Using <Command>make</Command>
-</Title>
+<Sect1 id="sec-using-parallel">
+<title>Using Parallel Haskell</title>
 
 <para>
-<indexterm><primary><literal>make</literal></primary></indexterm>
+<indexterm><primary>Parallel Haskell&mdash;use</primary></indexterm>
 </para>
 
 <para>
-It is reasonably straightforward to set up a <Filename>Makefile</Filename> to use with GHC, assuming you name your source files the same as your modules.
-Thus:
+&lsqb;You won't be able to execute parallel Haskell programs unless PVM3
+(Parallel Virtual Machine, version 3) is installed at your site.]
 </para>
 
 <para>
+To compile a Haskell program for parallel execution under PVM, use the
+<option>-parallel</option> option,<indexterm><primary>-parallel
+option</primary></indexterm> both when compiling <emphasis>and
+linking</emphasis>.  You will probably want to <literal>import
+Parallel</literal> into your Haskell modules.
+</para>
 
-<ProgramListing>
-HC      = ghc
-HC_OPTS = -cpp $(EXTRA_HC_OPTS)
-
-SRCS = Main.lhs Foo.lhs Bar.lhs
-OBJS = Main.o   Foo.o   Bar.o
-
-.SUFFIXES : .o .hs .hi .lhs .hc .s
-
-cool_pgm : $(OBJS)
-        rm $@
-        $(HC) -o $@ $(HC_OPTS) $(OBJS)
-
-# Standard suffix rules
-.o.hi:
-        @:
-
-.lhs.o:
-        $(HC) -c $&#60; $(HC_OPTS)
-
-.hs.o:
-        $(HC) -c $&#60; $(HC_OPTS)
-
-# Inter-module dependencies
-Foo.o Foo.hc Foo.s    : Baz.hi          # Foo imports Baz
-Main.o Main.hc Main.s : Foo.hi Baz.hi   # Main imports Foo and Baz
-</ProgramListing>
-
+<para>
+To run your parallel program, once PVM is going, just invoke it
+&ldquo;as normal&rdquo;.  The main extra RTS option is
+<option>-N&lt;n&gt;</option>, to say how many PVM
+&ldquo;processors&rdquo; your program to run on.  (For more details of
+all relevant RTS options, please see <XRef
+LinkEnd="parallel-rts-opts">.)
 </para>
 
 <para>
-(Sophisticated <Command>make</Command> variants may achieve some of the above more
-elegantly.  Notably, <Command>gmake</Command>'s pattern rules let you write the more
-comprehensible:
+In truth, running Parallel Haskell programs and getting information
+out of them (e.g., parallelism profiles) is a battle with the vagaries of
+PVM, detailed in the following sections.
 </para>
 
+<sect2>
+<title>Dummy's guide to using PVM</title>
+
 <para>
+<indexterm><primary>PVM, how to use</primary></indexterm>
+<indexterm><primary>Parallel Haskell&mdash;PVM use</primary></indexterm>
+Before you can run a parallel program under PVM, you must set the
+required environment variables (PVM's idea, not ours); something like,
+probably in your <filename>.cshrc</filename> or equivalent:
 
 <ProgramListing>
-%.o : %.lhs
-        $(HC) -c $&#60; $(HC_OPTS)
-</ProgramListing>
-
-</para>
-
-<para>
-What we've shown should work with any <Command>make</Command>.)
-</para>
-
-<para>
-Note the cheesy <literal>.o.hi</literal> rule: It records the dependency of the
-interface (<Filename>.hi</Filename>) file on the source.  The rule says a <Filename>.hi</Filename> file can
-be made from a <Filename>.o</Filename> file by doing&hellip;nothing.  Which is true.
-</para>
-
-<para>
-Note the inter-module dependencies at the end of the Makefile, which
-take the form
-</para>
-
-<para>
-
-<ProgramListing>
-Foo.o Foo.hc Foo.s    : Baz.hi          # Foo imports Baz
-</ProgramListing>
-
-</para>
-
-<para>
-They tell <Command>make</Command> that if any of <literal>Foo.o</literal>, <literal>Foo.hc</literal> or <literal>Foo.s</literal> have an
-earlier modification date than <literal>Baz.hi</literal>, then the out-of-date file
-must be brought up to date.  To bring it up to date, <literal>make</literal> looks for
-a rule to do so; one of the preceding suffix rules does the job
-nicely.
-</para>
-
-    </sect2>
-
-    <sect2 id="sec-makefile-dependencies">
-      <title>Dependency generation</title>
-      <indexterm><primary>dependencies in Makefiles</primary></indexterm>
-      <indexterm><primary>Makefile dependencies</primary></indexterm>
-
-      <para>Putting inter-dependencies of the form <literal>Foo.o :
-      Bar.hi</literal> into your <Filename>Makefile</Filename> by hand
-      is rather error-prone.  Don't worry, GHC has support for
-      automatically generating the required dependencies.  Add the
-      following to your <Filename>Makefile</Filename>:</para>
-
-<ProgramListing>
-depend :
-        ghc -M $(HC_OPTS) $(SRCS)
-</ProgramListing>
-
-      <para>Now, before you start compiling, and any time you change
-      the <literal>imports</literal> in your program, do <Command>make
-      depend</Command> before you do <Command>make
-      cool&lowbar;pgm</Command>.  <Command>ghc -M</Command> will append
-      the needed dependencies to your
-      <Filename>Makefile</Filename>.</para>
-
-      <para>In general, if module <literal>A</literal> contains the
-      line
-
-<programlisting>
-import B ...blah...
-</programlisting>
-
-       then <command>ghc -M</command> will generate a dependency
-       line of the form:
-
-<programlisting>
-A.o : B.hi
-</programlisting>
-
-       If module <literal>A</literal> contains the line 
-
-<programlisting>
-import {-# SOURCE #-} B ...blah...
-</programlisting>
-
-       then <command>ghc -M</command> will generate a dependency
-       line of the form:
-
-<programlisting>
-A.o : B.hi-boot
-</programlisting>
-
-       (See <xref linkend="hi-files"> for details of interface files.)
-       If <literal>A</literal> imports multiple modules, then there
-       will be multiple lines with <filename>A.o</filename> as the
-       target.</para>
-
-      <para>By default, <Command>ghc -M</Command> generates all the
-      dependencies, and then concatenates them onto the end of
-      <Filename>makefile</Filename> (or <Filename>Makefile</Filename>
-      if <Filename>makefile</Filename> doesn't exist) bracketed by the
-      lines "<literal>&num; DO NOT DELETE: Beginning of Haskell
-      dependencies</literal>" and "<literal>&num; DO NOT DELETE: End
-      of Haskell dependencies</literal>".  If these lines already
-      exist in the <Filename>makefile</Filename>, then the old
-      dependencies are deleted first.</para>
-
-      <para>Internally, GHC uses a script to generate the
-      dependencies, called <command>mkdependHS</command>.  This script
-      has some options of its own, which you might find useful.
-      Options can be passed directly to <command>mkdependHS</command>
-      with GHC's <literal>-optdep</literal> option.  For example, to
-      generate the dependencies into a file called
-      <literal>.depend</literal> instead of
-      <literal>Makefile</literal>:</para>
-
-<screen>
-ghc -M -optdep-f optdep.depend ...
-</screen>
-      
-      <para>The full list of options accepted by
-      <command>mkdependHS</command> is:</para>
-
-      <variablelist>
-
-       <varlistentry>
-         <term><option>-w</option></term>
-         <listitem>
-           <para>Turn off warnings about interface file shadowing.</para>
-         </listitem>
-       </varlistentry>
-
-       <varlistentry>
-         <term><option>-f blah</option></term>
-         <listitem>
-           <para>Use <Filename>blah</Filename> as the makefile,
-            rather than <Filename>makefile</Filename> or
-            <Filename>Makefile</Filename>.  If
-            <Filename>blah</Filename> doesn't exist,
-            <Command>mkdependHS</Command> creates it.  We often use
-            <option>-f .depend</option> to put the dependencies in
-            <Filename>.depend</Filename> and then
-            <Command>include</Command> the file
-            <Filename>.depend</Filename> into
-            <Filename>Makefile</Filename>.</para>
-         </listitem>
-       </varlistentry>
-
-       <varlistentry>
-         <term><option>-o &lt;osuf&gt;</option></term>
-         <listitem>
-           <para>Use <Filename>.&lt;osuf&gt;</Filename> as the
-            "target file" suffix ( default: <literal>o</literal>).
-            Multiple <option>-o</option> flags are permitted (GHC2.05
-            onwards).  Thus "<option>-o hc -o o</option>" will
-            generate dependencies for <Filename>.hc</Filename> and
-            <Filename>.o</Filename> files.</para>
-         </listitem>
-       </varlistentry>
-
-       <varlistentry>
-         <term><option>-s &lt;suf&gt;</option></term>
-         <listitem>
-           <para>Make extra dependencies that declare that files with
-            suffix
-            <Filename>.&lt;suf&gt;&lowbar;&lt;osuf&gt;</Filename>
-            depend on interface files with suffix
-            <Filename>.&lt;suf&gt;&lowbar;hi</Filename>, or (for
-            <literal>&lcub;-&num; SOURCE &num;-&rcub;</literal>
-            imports) on <Filename>.hi-boot</Filename>.  Multiple
-            <option>-s</option> flags are permitted.  For example,
-            <option>-o hc -s a -s b</option> will make dependencies
-            for <Filename>.hc</Filename> on <Filename>.hi</Filename>,
-            <Filename>.a&lowbar;hc</Filename> on
-            <Filename>.a&lowbar;hi</Filename>, and
-            <Filename>.b&lowbar;hc</Filename> on
-            <Filename>.b&lowbar;hi</Filename>.  (Useful in conjunction
-            with NoFib "ways".)</para>
-         </listitem>
-       </varlistentry>
-
-       <varlistentry>
-         <term><option>--exclude-module=&lt;file&gt;</option></term>
-         <listitem>
-           <para>Regard <Filename>&lt;file&gt;</Filename> as
-            "stable"; i.e., exclude it from having dependencies on
-            it.</para>
-         </listitem>
-       </varlistentry>
-
-       <varlistentry>
-         <term><option>-x</option></term>
-         <listitem>
-           <para>same as <option>--exclude-module</option></para>
-         </listitem>
-       </varlistentry>
-
-       <varlistentry>
-         <term><option>--exclude-directory=&lt;dirs&gt;</option></term>
-         <listitem>
-           <para>Regard the colon-separated list of directories
-            <Filename>&lt;dirs&gt;</Filename> as containing stable,
-            don't generate any dependencies on modules therein.</para>
-         </listitem>
-       </varlistentry>
-
-       <varlistentry>
-         <term><option>-xdirs</option></term>
-         <listitem>
-           <para>same as <option>--exclude-directory</option>.</para>
-         </listitem>
-       </varlistentry>
-
-       <varlistentry>
-         <term><option>--include-module=&lt;file&gt;</option></term>
-         <listitem>
-           <para>Regard <Filename>&lt;file&gt;</Filename> as not
-            "stable"; i.e., generate dependencies on it (if any). This
-            option is normally used in conjunction with the
-            <option>--exclude-directory</option> option.</para>
-         </listitem>
-       </varlistentry>
-
-       <varlistentry>
-         <term><option>--include-prelude</option></term>
-         <listitem>
-           <para>Regard prelude libraries as unstable, i.e., generate
-            dependencies on the prelude modules used (including
-            <literal>Prelude</literal>).  This option is normally only
-            used by the various system libraries. If a
-            <option>-package</option> option is used, dependencies will
-            also be generated on the library's interfaces.</para>
-         </listitem>
-       </varlistentry>
-      </variablelist>
-
-</sect2>
-
-<Sect2 id="mutual-recursion">
-<Title>How to compile mutually recursive modules
-</Title>
-
-<para>
-<indexterm><primary>module system, recursion</primary></indexterm>
-<indexterm><primary>recursion, between modules</primary></indexterm>
-</para>
-
-<para>
-Currently, the compiler does not have proper support for dealing with
-mutually recursive modules:
-</para>
-
-<para>
-
-<ProgramListing>
-module A where
-
-import B
-
-newtype TA = MkTA Int
-
-f :: TB -&#62; TA
-f (MkTB x) = MkTA x
---------
-module B where
-
-import A
-
-data TB = MkTB !Int
-
-g :: TA -&#62; TB
-g (MkTA x) = MkTB x
-</ProgramListing>
-
-</para>
-
-<para>
-When compiling either module A and B, the compiler will try (in vain)
-to look for the interface file of the other. So, to get mutually
-recursive modules off the ground, you need to hand write an interface
-file for A or B, so as to break the loop.  These hand-written
-interface files are called <literal>hi-boot</literal> files, and are placed in a file
-called <Filename>&lt;module&gt;.hi-boot</Filename>.  To import from an <literal>hi-boot</literal> file instead
-of the standard <Filename>.hi</Filename> file, use the following syntax in the importing module:
-<indexterm><primary>hi-boot files</primary></indexterm>
-<indexterm><primary>importing, hi-boot files</primary></indexterm>
-</para>
-
-<para>
-
-<ProgramListing>
-import {-# SOURCE #-} A
-</ProgramListing>
-
-</para>
-
-<para>
-The hand-written interface need only contain the bare minimum of
-information needed to get the bootstrapping process started.  For
-example, it doesn't need to contain declarations for <Emphasis>everything</Emphasis>
-that module <literal>A</literal> exports, only the things required by the module that
-imports <literal>A</literal> recursively.
-</para>
-
-<para>
-For the example at hand, the boot interface file for A would look like
-the following:
-</para>
-
-<para>
-
-<ProgramListing>
-__interface A 1 404 where
-__export A TA{MkTA} ;
-1 newtype TA = MkTA PrelBase.Int ;
-</ProgramListing>
-
-</para>
-
-<para>
-The syntax is essentially the same as a normal <Filename>.hi</Filename> file
-(unfortunately), but you can usually tailor an existing <Filename>.hi</Filename> file to
-make a <Filename>.hi-boot</Filename> file.
-</para>
-
-<para>
-Notice that we only put the declaration for the newtype <literal>TA</literal> in the
-<literal>hi-boot</literal> file, not the signature for <Function>f</Function>, since <Function>f</Function> isn't used by
-<literal>B</literal>.
-</para>
-
-<para>
-The number &ldquo;1&rdquo; after &ldquo;&lowbar;&lowbar;interface A&rdquo; gives the version number of module A;
-it is incremented whenever anything in A's interface file changes.  The &ldquo;404&rdquo; is
-the version number of the interface file <Emphasis>syntax</Emphasis>; we change it when
-we change the syntax of interface files so that you get a better error message when
-you try to read an old-format file with a new-format compiler.
-</para>
-
-<para>
-The number &ldquo;1&rdquo; at the beginning of a declaration is the <Emphasis>version
-number</Emphasis> of that declaration: for the purposes of <Filename>.hi-boot</Filename> files
-these can all be set to 1.  All names must be fully qualified with the
-<Emphasis>original</Emphasis> module that an object comes from: for example, the
-reference to <literal>Int</literal> in the interface for <literal>A</literal> comes from <literal>PrelBase</literal>,
-which is a module internal to GHC's prelude.  It's a pain, but that's
-the way it is.
-</para>
-
-<para>
-If you want an hi-boot file to export a data type, but you don't want to give its constructors
-(because the constructors aren't used by the SOURCE-importing module), you can write simply:
-</para>
-
-<para>
-
-<ProgramListing>
-__interface A 1 404 where
-__export A TA;
-1 data TA
-</ProgramListing>
-
-</para>
-
-<para>
-(You must write all the type parameters, but leave out the '=' and everything that follows it.)
-</para>
-
-<para>
-<Emphasis>Note:</Emphasis> This is all a temporary solution, a version of the
-compiler that handles mutually recursive modules properly without the manual
-construction of interface files, is (allegedly) in the works.
-</para>
-
-</sect2>
-
-</Sect1>
-
-  <sect1 id="packages">
-    <title>Packages</title>
-    <indexterm><primary>packages</primary></indexterm>
-
-    <para>Packages are collections of libraries, conveniently grouped
-    together as a single entity.  The package system is flexible: a
-    package may consist of Haskell code, foreign language code (eg. C
-    libraries), or a mixture of the two.  A package is a good way to
-    group together related Haskell modules, and is essential if you
-    intend to make the modules into a Windows DLL (see below).</para>
-
-    <para>Because packages can contain both Haskell and C libraries, they
-    are also a good way to provide convenient access to a Haskell
-    layer over a C library.</para>
-
-    <para>GHC comes with several packages (see <xref
-    linkend="book-hslibs">), and packages can be added/removed from an
-    existing GHC installation.</para>
-
-    <sect2 id="listing-packages">
-      <title>Listing the available packages</title>
-      <indexterm><primary>packages</primary>
-       <secondary>listing</secondary></indexterm>
-
-      <para>To see what packages are currently installed, use the
-      <literal>--list-packages</literal> option:</para>
-      <indexterm><primary><literal>--list-packages</literal></primary>
-      </indexterm>
-
-<screen>
-  $ ghc --list-packages
-  gmp, rts, std, lang, concurrent, data, net, posix, text, util
-</screen>
-
-      <para>Note that your GHC installation might have a slightly
-      different set of packages installed.</para>
-
-      <para>The <literal>gmp</literal> and <literal>rts</literal>
-      packages are always present, and represent the multi-precision
-      integer and runtime system libraries respectively.  The
-      <literal>std</literal> package contains the Haskell prelude.
-      The rest of the packages are optional libraries.</para>
-
-    </sect2>
-
-    <sect2 id="using-packages">
-      <title>Using a package</title>
-      <indexterm><primary>packages</primary>
-       <secondary>using</secondary></indexterm>
-      
-      <para>To use a package, add the <literal>-package</literal> flag
-      to the command line:</para>
-
-      <variablelist>
-       <varlistentry>
-         <term><option>-package &lt;lib&gt;</option></term>
-         <indexterm><primary>-package &lt;lib&gt; option</primary></indexterm>
-         <listitem>
-           <para>This option brings into scope all the modules from
-           package <literal>&lt;lib&gt;</literal> (they still have to
-           be imported in your Haskell source, however).  It also
-           causes the relevant libraries to be linked when linking is
-           being done.</para>
-         </listitem>
-       </varlistentry>
-      </variablelist>
-
-      <para>Some packages depend on other packages, for example the
-      <literal>text</literal> package makes use of some of the modules
-      in the <literal>lang</literal> package.  The package system
-      takes care of all these dependencies, so that when you say
-      <literal>-package text</literal> on the command line, you
-      automatically get <literal>-package lang</literal> too.</para>
-    </sect2>
-
-    <sect2 id="building-packages">
-      <title>Building a package from Haskell source</title>
-      <indexterm><primary>packages</primary>
-       <secondary>building</secondary></indexterm>
-
-      <para>It takes some special considerations to build a new
-      package:</para>
-
-      <itemizedlist>
-       <listitem>
-         <para>A package may contain several Haskell modules. A
-          package may span many directories, or many packages may
-          exist in a single directory. Packages may not be mutually
-          recursive.</para>
-       </listitem>
-
-       <listitem>
-         <para>A package has a name
-         (e.g. <filename>std</filename>)</para>
-       </listitem>
-
-       <listitem>
-         <para>The Haskell code in a package may be built into one or
-         more Unix libraries (e.g. <Filename>libHSfoo.a</Filename>),
-         or a single DLL on Windows
-         (e.g. <Filename>HSfoo.dll</Filename>).  The restriction to a
-         single DLL on Windows is that the package system is used to
-         tell the compiler when it should make an inter-DLL call
-         rather than an intra-DLL call (inter-DLL calls require an
-         extra indirection).</para>
-       </listitem>
-
-       <listitem>
-         <para>GHC does not maintain detailed cross-package
-          dependency information.  It does remember which modules in
-          other packages the current module depends on, but not which
-          things within those imported things.</para>
-       </listitem>
-      </itemizedlist>
-
-      <para>To compile a module which is to be part of a new package,
-      use the <literal>-package-name</literal> option:</para>
-
-      <variablelist>
-       <varlistentry>
-         <term><option>-package-name &lt;foo&gt;</option></term>
-         <indexterm><primary><literal>-package-name</literal></primary>
-           <secondary>option</secondary></indexterm>
-         <listitem>
-           <para>This option is added to the command line when
-           compiling a module that is destined to be part of package
-           <literal>foo</literal>.  If this flag is omitted then the
-           default package <literal>Main</literal> is assumed.</para>
-         </listitem>
-       </varlistentry>
-      </variablelist>
-
-      <para>Failure to use the <literal>-package-name</literal> option
-      when compiling a package will result in disaster on Windows, but
-      is relatively harmless on Unix at the moment (it will just cause
-      a few extra dependencies in some interface files).  However,
-      bear in mind that we might add support for Unix shared libraries
-      at some point in the future.</para>
-
-      <para>It is worth noting that on Windows, because each package
-      is built as a DLL, and a reference to a DLL costs an extra
-      indirection, intra-package references are cheaper than
-      inter-package references. Of course, this applies to the
-      <Filename>Main</Filename> package as well.</para>
-
-    </sect2>
-    <sect2 id="package-management">
-      <title>Package management</title>
-      <indexterm><primary>packages</primary>
-       <secondary>management</secondary></indexterm>
-      
-      <para>GHC uses a package configuration file, called
-      <literal>packages.conf</literal>, which can be found in your GHC
-      install directory.  This file isn't intended to be edited
-      directly, instead GHC provides options for adding & removing
-      packages:</para>
-
-      <variablelist>
-       <varlistentry>
-         <term><option>--add-package</option></term>
-         <indexterm><primary><literal>--add-package</literal></primary>
-             <secondary>option</secondary></indexterm>
-         <listitem>
-           <para>Reads a package specification (see below) on stdin,
-           and adds it to the database of installed packages.  The
-           package specification must be a package that isn't already
-           installed.</para>
-         </listitem>
-       </varlistentry>
-
-       <varlistentry>
-         <term><option>--delete-package &lt;foo&gt;</option></term>
-         <indexterm><primary><literal>--delete-package</literal></primary>
-             <secondary>option</secondary></indexterm>
-         <listitem>
-           <para>Removes the specified package from the installed
-           configuration.</para>
-         </listitem>
-       </varlistentry>
-      </variablelist>
-
-      <para>In both cases, the old package configuration file is saved
-      in <literal>packages.conf.old</literal> in your GHC install
-      directory, so in an emergency you can always copy this file into
-      <literal>package.conf</literal> to restore the old
-      settings.</para>
-
-      <para>A package specification looks like this:</para>
-
-<screen>
-  Package {
-     name            = "mypkg",
-     import_dirs     = ["/usr/local/lib/imports/mypkg"],
-     library_dirs    = ["/usr/local/lib"],
-     hs_libraries    = ["HSmypkg" ],
-     extra_libraries = ["HSmypkg_cbits"],
-     include_dirs    = [],
-     c_includes      = ["HsMyPkg.h"],
-     package_deps    = ["text", "data"],
-     extra_ghc_opts  = [],
-     extra_cc_opts   = [],
-     extra_ld_opts   = ["-lmy_clib"]
-  }
-</screen>
-
-      <para>Components of a package specification may be specified in
-      any order, and are:</para>
-
-      <variablelist>
-       <varlistentry>
-         <term><literal>name</literal></term>
-         <indexterm><primary><literal>name</literal></primary>
-           <secondary>package specification</secondary></indexterm>
-         <listitem>
-            <para>The package's name, for use with
-            the <literal>-package</literal> flag and as listed in the
-            <literal>--list-packages</literal> list. 
-            </para>
-         </listitem>
-       </varlistentry>
-
-       <varlistentry>
-         <term><literal>import_dirs</literal></term>
-         <indexterm><primary><literal>import_dirs</literal></primary>
-           <secondary>package specification</secondary></indexterm>
-         <listitem>
-           <para>A list of directories containing interface files
-           (<literal>.hi</literal> files) for this package.</para>
-         </listitem>
-       </varlistentry>
-
-       <varlistentry>
-         <term><literal>library_dirs</literal></term>
-         <indexterm><primary><literal>library_dirs</literal></primary>
-           <secondary>package specification</secondary></indexterm>
-         <listitem>
-           <para>A list of directories containing libraries for this
-           package.</para>
-         </listitem>
-       </varlistentry>
-
-       <varlistentry>
-         <term><literal>hs_libraries</literal></term>
-         <indexterm><primary><literal>hs_libraries</literal></primary>
-           <secondary>package specification</secondary></indexterm>
-         <listitem>
-           <para>A list of libraries containing Haskell code for this
-           package, with the <literal>.a</literal> or
-           <literal>.dll</literal> suffix omitted.  On Unix, the
-           <literal>lib</literal> prefix is also omitted.</para>
-         </listitem>
-       </varlistentry>
-
-       <varlistentry>
-         <term><literal>extra_libraries</literal></term>
-         <indexterm><primary><literal>extra_libraries</literal></primary>
-           <secondary>package specification</secondary></indexterm>
-         <listitem>
-           <para>A list of extra libraries for this package.  The
-           difference between <literal>hs_libraries</literal> and
-           <literal>extra_libraries</literal> is that
-           <literal>hs_libraries</literal> normally have several
-           versions, to support profiling, parallel and other build
-           options.  The various versions are given different
-           suffixes to distinguish them, for example the profiling
-           version of the standard prelude library is named
-           <filename>libHSstd_p.a</filename>, with the
-           <literal>_p</literal> indicating that this is a profiling
-           version.  The suffix is added automatically by GHC for
-           <literal>hs_libraries</literal> only, no suffix is added
-           for libraries in
-           <literal>extra_libraries</literal>.</para>
-
-           <para>Also, <literal>extra_libraries</literal> are placed
-           on the linker command line before the
-           <literal>hs_libraries</literal> for the same package.  If
-           your package has dependencies in the other direction, you
-           might need to make two separate packages.</para>
-         </listitem>
-       </varlistentry>
-
-       <varlistentry>
-         <term><literal>include_dirs</literal></term>
-         <indexterm><primary><literal>include_dirs</literal></primary>
-           <secondary>package specification</secondary></indexterm>
-         <listitem>
-           <para>A list of directories containing C includes for this
-           package (maybe the empty list).</para>
-         </listitem>
-       </varlistentry>
-
-       <varlistentry>
-         <term><literal>c_includes</literal></term>
-         <indexterm><primary><literal>c_includes</literal></primary>
-           <secondary>package specification</secondary></indexterm>
-         <listitem>
-           <para>A list of files to include for via-C compilations
-           using this package.  Typically this include file will
-           contain function prototypes for any C functions used in
-           the package, in case they end up being called as a result
-           of Haskell functions from the package being
-           inlined.</para>
-         </listitem>
-       </varlistentry>
-
-       <varlistentry>
-         <term><literal>package_deps</literal></term>
-         <indexterm><primary><literal>package_deps</literal></primary>
-           <secondary>package specification</secondary></indexterm>
-         <listitem>
-           <para>A list of packages which this package depends
-           on.</para>
-         </listitem>
-       </varlistentry>
-
-       <varlistentry>
-         <term><literal>extra_ghc_opts</literal></term>
-         <indexterm><primary><literal>extra_ghc_opts</literal></primary>
-           <secondary>package specification</secondary></indexterm>
-         <listitem>
-           <para>Extra arguments to be added to the GHC command line
-           when this package is being used.</para>
-         </listitem>
-       </varlistentry>
-
-       <varlistentry>
-         <term><literal>extra_cc_opts</literal></term>
-         <indexterm><primary><literal>extra_cc_opts</literal></primary>
-           <secondary>package specification</secondary></indexterm>
-         <listitem>
-           <para>Extra arguments to be added to the gcc command line
-           when this package is being used (only for via-C
-           compilations).</para>
-         </listitem>
-       </varlistentry>
-
-       <varlistentry>
-         <term><literal>extra_ld_opts</literal></term>
-         <indexterm><primary><literal>extra_ld_opts</literal></primary>
-           <secondary>package specification</secondary></indexterm>
-         <listitem>
-           <para>Extra arguments to be added to the gcc command line
-           (for linking) when this package is being used.</para>
-         </listitem>
-       </varlistentry>
-      </variablelist>
-
-      <para>For examples of more package specifications, take a look
-      at the <literal>package.conf</literal> in your GHC
-      installation.</para>
-    </sect2>
-  </sect1>
-
-
-<Sect1 id="options-optimise">
-<Title>Optimisation (code improvement)
-</Title>
-
-<para>
-<indexterm><primary>optimisation (GHC)</primary></indexterm>
-<indexterm><primary>improvement, code (GHC)</primary></indexterm>
-</para>
-
-<para>
-The <option>-O*</option> options specify convenient &ldquo;packages&rdquo; of optimisation
-flags; the <option>-f*</option> options described later on specify
-<Emphasis>individual</Emphasis> optimisations to be turned on/off; the <option>-m*</option>
-options specify <Emphasis>machine-specific</Emphasis> optimisations to be turned
-on/off.
-</para>
-
-<Sect2 id="optimise-pkgs">
-<Title><option>-O*</option>: convenient &ldquo;packages&rdquo; of optimisation flags.
-</Title>
-
-<para>
-<indexterm><primary>-O options</primary></indexterm>
-</para>
-
-<para>
-There are <Emphasis>many</Emphasis> options that affect the quality of code
-produced by GHC.  Most people only have a general goal, something like
-&ldquo;Compile quickly&rdquo; or &ldquo;Make my program run like greased lightning.&rdquo;
-The following &ldquo;packages&rdquo; of optimisations (or lack thereof) should
-suffice.
-</para>
-
-<para>
-Once you choose a <option>-O*</option> &ldquo;package,&rdquo; stick with it&mdash;don't chop and
-change.  Modules' interfaces <Emphasis>will</Emphasis> change with a shift to a new
-<option>-O*</option> option, and you may have to recompile a large chunk of all
-importing modules before your program can again be run
-safely (see <XRef LinkEnd="recomp">).
-</para>
-
-<para>
-<VariableList>
-
-<varlistentry>
-<term>No <option>-O*</option>-type option specified:</term>
-<indexterm><primary>-O* not specified</primary></indexterm>
-<listitem>
-<para>
-This is taken to mean: &ldquo;Please compile quickly; I'm not over-bothered
-about compiled-code quality.&rdquo;  So, for example: <Command>ghc -c Foo.hs</Command>
-</para>
-</listitem>
-</varlistentry>
-<varlistentry>
-<term><option>-O</option> or <option>-O1</option>:</term>
-<indexterm><primary>-O option</primary></indexterm>
-<indexterm><primary>-O1 option</primary></indexterm>
-<indexterm><primary>optimise</primary><secondary>normally</secondary></indexterm>
-<listitem>
-<para>
-Means: &ldquo;Generate good-quality code without taking too long about
-it.&rdquo; Thus, for example: <Command>ghc -c -O Main.lhs</Command>
-</para>
-</listitem>
-</varlistentry>
-<varlistentry>
-<term><option>-O2</option>:</term>
-<indexterm><primary>-O2 option</primary></indexterm>
-<indexterm><primary>optimise</primary><secondary>aggressively</secondary></indexterm>
-<listitem>
-<para>
-Means: &ldquo;Apply every non-dangerous optimisation, even if it means
-significantly longer compile times.&rdquo;
-</para>
-
-<para>
-The avoided &ldquo;dangerous&rdquo; optimisations are those that can make
-runtime or space <Emphasis>worse</Emphasis> if you're unlucky.  They are
-normally turned on or off individually.
-</para>
-
-<para>
-At the moment, <option>-O2</option> is <Emphasis>unlikely</Emphasis> to produce
-better code than <option>-O</option>.
-</para>
-</listitem>
-</varlistentry>
-<varlistentry>
-<term><option>-O2-for-C</option>:</term>
-<indexterm><primary>-O2-for-C option</primary></indexterm>
-<indexterm><primary>gcc, invoking with -O2</primary></indexterm>
-<listitem>
-<para>
-Says to run GCC with <option>-O2</option>, which may be worth a few percent in
-execution speed.  Don't forget <option>-fvia-C</option>, lest you use the native-code
-generator and bypass GCC altogether!
-</para>
-</listitem>
-</varlistentry>
-<varlistentry>
-<term><option>-Onot</option>:</term>
-<indexterm><primary>-Onot option</primary></indexterm>
-<indexterm><primary>optimising, reset</primary></indexterm>
-<listitem>
-<para>
-This option will make GHC &ldquo;forget&rdquo; any
-<option>-O</option>ish options it has seen so far.  Sometimes useful;
-for example: <Command>make all
-EXTRA&lowbar;HC&lowbar;OPTS=-Onot</Command>.
-</para>
-</listitem>
-</varlistentry>
-<varlistentry>
-<term><option>-Ofile &lt;file&gt;</option>:</term>
-<indexterm><primary>-Ofile &lt;file&gt; option</primary></indexterm>
-<indexterm><primary>optimising, customised</primary></indexterm>
-<listitem>
-<para>
-For those who need <Emphasis>absolute</Emphasis> control over
-<Emphasis>exactly</Emphasis> what options are used (e.g., compiler
-writers, sometimes :-), a list of options can be put in a file and
-then slurped in with <option>-Ofile</option>.
-</para>
-
-<para>
-In that file, comments are of the
-<literal>&num;</literal>-to-end-of-line variety; blank lines and most
-whitespace is ignored.
-</para>
-
-<para>
-Please ask if you are baffled and would like an example of <option>-Ofile</option>!
-</para>
-</listitem>
-</varlistentry>
-</VariableList>
-</para>
-
-<para>
-At Glasgow, we don't use a <option>-O*</option> flag for day-to-day work.  We use
-<option>-O</option> to get respectable speed; e.g., when we want to measure
-something.  When we want to go for broke, we tend to use <option>-O -fvia-C
--O2-for-C</option> (and we go for lots of coffee breaks).
-</para>
-
-<para>
-The easiest way to see what <option>-O</option> (etc.) &ldquo;really mean&rdquo; is to run with
-<option>-v</option>, then stand back in amazement.  Alternatively, just look at the
-<literal>HsC&lowbar;minus&lt;blah&gt;</literal> lists in the GHC driver script.
-</para>
-
-</sect2>
-
-<sect2>
-<Title><option>-f*</option>: platform-independent flags</Title>
-
-<para>
-<indexterm><primary>-f* options (GHC)</primary></indexterm>
-<indexterm><primary>-fno-* options (GHC)</primary></indexterm>
-</para>
-
-<para>
-Flags can be turned <Emphasis>off</Emphasis> individually.  (NB: I hope you have a
-good reason for doing this&hellip;) To turn off the <option>-ffoo</option> flag, just use
-the <option>-fno-foo</option> flag.<indexterm><primary>-fno-&lt;opt&gt; anti-option</primary></indexterm> So, for
-example, you can say <option>-O2 -fno-strictness</option>, which will then drop out
-any running of the strictness analyser.
-</para>
-
-<para>
-The options you are most likely to want to turn off are:
-
-<ItemizedList>
-<listitem>
-
-<para>
-<option>-fno-strictness</option><indexterm><primary>-fno-strictness option</primary></indexterm> (strictness
-analyser, because it is sometimes slow),
-</para>
-</listitem>
-<listitem>
-
-<para>
-<option>-fno-specialise</option><indexterm><primary>-fno-specialise option</primary></indexterm> (automatic
-specialisation of overloaded functions, because it can make your code
-bigger) (US spelling also accepted), and
-</para>
-</listitem>
-<listitem>
-
-<para>
-<option>-fno-cpr-analyse</option><indexterm><primary>-fno-cpr-analyse option</primary></indexterm> switches off the CPR (constructed product
-result) analyser.
-</para>
-</listitem>
-
-</ItemizedList>
-
-</para>
-
-<para>
-Should you wish to turn individual flags <Emphasis>on</Emphasis>, you are advised
-to use the <option>-Ofile</option> option, described above.  Because the order in
-which optimisation passes are run is sometimes crucial, it's quite
-hard to do with command-line options.
-</para>
-
-<para>
-Here are some &ldquo;dangerous&rdquo; optimisations you <Emphasis>might</Emphasis> want to try:
-<VariableList>
-
-<varlistentry>
-<term><option>-fvia-C</option>:</term>
-<listitem>
-<para>
-<indexterm><primary>-fvia-C option</primary></indexterm>
-<indexterm><primary>native code generator, turning off</primary></indexterm>
-</para>
-
-<para>
-Compile via C, and don't use the native-code generator.  (There are many
-cases when GHC does this on its own.) You might pick up a little bit of
-speed by compiling via C (e.g. for floating-point intensive code on Intel).
-If you use <Function>&lowbar;casm&lowbar;</Function>s (which are utterly
-deprecated), you probably <Emphasis>have</Emphasis> to use
-<option>-fvia-C</option>.
-</para>
-
-<para>
-The lower-case incantation, <option>-fvia-c</option>, is synonymous.
-</para>
-
-<para>
-Compiling via C will probably be slower (in compilation time) than
-using GHC's native code generator.
-</para>
-</listitem>
-</varlistentry>
-<varlistentry>
-<term><option>-funfolding-interface-threshold&lt;n&gt;</option>:</term>
-<listitem>
-<para>
-<indexterm><primary>-funfolding-interface-threshold option</primary></indexterm>
-<indexterm><primary>inlining, controlling</primary></indexterm>
-<indexterm><primary>unfolding, controlling</primary></indexterm>
-(Default: 30) By raising or lowering this number, you can raise or
-lower the amount of pragmatic junk that gets spewed into interface
-files.  (An unfolding has a &ldquo;size&rdquo; that reflects the cost in terms
-of &ldquo;code bloat&rdquo; of expanding that unfolding in another module.  A
-bigger function would be assigned a bigger cost.)
-</para>
-</listitem>
-</varlistentry>
-<varlistentry>
-<term><option>-funfolding-creation-threshold&lt;n&gt;</option>:</term>
-<listitem>
-<para>
-<indexterm><primary>-funfolding-creation-threshold option</primary></indexterm>
-<indexterm><primary>inlining, controlling</primary></indexterm>
-<indexterm><primary>unfolding, controlling</primary></indexterm>
-(Default: 30) This option is similar to
-<option>-funfolding-interface-threshold</option>, except that it governs unfoldings
-within a single module.  Increasing this figure is more likely to
-result in longer compile times than faster code.  The next option is
-more useful:
-</para>
-</listitem>
-</varlistentry>
-<varlistentry>
-<term><option>-funfolding-use-threshold&lt;n&gt;</option>:</term>
-<listitem>
-<para>
-<indexterm><primary>-funfolding-use-threshold option</primary></indexterm>
-<indexterm><primary>inlining, controlling</primary></indexterm>
-<indexterm><primary>unfolding, controlling</primary></indexterm>
-(Default: 8) This is the magic cut-off figure for unfolding: below
-this size, a function definition will be unfolded at the call-site,
-any bigger and it won't.  The size computed for a function depends on
-two things: the actual size of the expression minus any discounts that
-apply (see <option>-funfolding-con-discount</option>).
-</para>
-</listitem>
-</varlistentry>
-
-<varlistentry>
-<term><option>-funfolding-update-in-place&lt;n&gt;</option>:</term>
-<listitem>
-<para>
-Switches on an experimental "optimisation".  Switching it on makes the compiler
-a little keener to inline a function that returns a constructor, if the context is
-that of a thunk.
-<ProgramListing>
-   x = plusInt a b
-</ProgramListing>
-If we inlined plusInt we might get an opportunity to use update-in-place for
-the thunk 'x'.
-</para>
-</listitem>
-</varlistentry>
-
-<varlistentry>
-<term><option>-funbox-strict-fields</option>:</term>
-<listitem>
-<para>
-<indexterm><primary>-funbox-strict-fields option</primary></indexterm>
-<indexterm><primary>strict constructor fields</primary></indexterm>
-<indexterm><primary>constructor fields, strict</primary></indexterm>
-</para>
-
-<para>
-This option causes all constructor fields which are marked strict
-(i.e. &ldquo;!&rdquo;) to be unboxed or unpacked if possible.  For example:
-</para>
-
-<para>
-
-<ProgramListing>
-data T = T !Float !Float
-</ProgramListing>
-
-</para>
-
-<para>
-will create a constructor <literal>T</literal> containing two unboxed floats if the
-<option>-funbox-strict-fields</option> flag is given.  This may not always be an
-optimisation: if the <Function>T</Function> constructor is scrutinised and the floats
-passed to a non-strict function for example, they will have to be
-reboxed (this is done automatically by the compiler).
-</para>
-
-<para>
-This option should only be used in conjunction with <option>-O</option>, in order to
-expose unfoldings to the compiler so the reboxing can be removed as
-often as possible.  For example:
-</para>
-
-<para>
-
-<ProgramListing>
-f :: T -&#62; Float
-f (T f1 f2) = f1 + f2
-</ProgramListing>
-
-</para>
-
-<para>
-The compiler will avoid reboxing <Function>f1</Function> and <Function>f2</Function> by inlining <Function>+</Function> on
-floats, but only when <option>-O</option> is on.
-</para>
-
-<para>
-Any single-constructor data is eligible for unpacking; for example
-</para>
-
-<para>
-
-<ProgramListing>
-data T = T !(Int,Int)
-</ProgramListing>
-
-</para>
-
-<para>
-will store the two <literal>Int</literal>s directly in the <Function>T</Function> constructor, by flattening
-the pair.  Multi-level unpacking is also supported:
-</para>
-
-<para>
-
-<ProgramListing>
-data T = T !S
-data S = S !Int !Int
-</ProgramListing>
-
-</para>
-
-<para>
-will store two unboxed <literal>Int&num;</literal>s directly in the <Function>T</Function> constructor.
-</para>
-</listitem>
-</varlistentry>
-<varlistentry>
-<term><option>-fsemi-tagging</option>:</term>
-<listitem>
-<para>
-This option (which <Emphasis>does not work</Emphasis> with the native-code generator)
-tells the compiler to add extra code to test for already-evaluated
-values.  You win if you have lots of such values during a run of your
-program, you lose otherwise.  (And you pay in extra code space.)
-</para>
-
-<para>
-We have not played with <option>-fsemi-tagging</option> enough to recommend it.
-(For all we know, it doesn't even work anymore&hellip; Sigh.)
-</para>
-</listitem>
-</varlistentry>
-<varlistentry>
-<term><option>-fexcess-precision</option>:</term>
-<listitem>
-<para>
-When this option is given, intermediate floating point values can have
-a <Emphasis>greater</Emphasis> precision/range than the final type.
-Generally this is a good thing, but some programs may rely on the
-exact precision/range of <literal>Float</literal>/<literal>Double</literal>
-values and should not use this option for their compilation.
-</para>
-</listitem>
-</varlistentry>
-</VariableList>
-</para>
-
-</sect2>
-
-<sect2>
-<Title><option>-m*</option>: platform-specific flags</Title>
-
-<para>
-<indexterm><primary>-m* options (GHC)</primary></indexterm>
-<indexterm><primary>platform-specific options</primary></indexterm>
-<indexterm><primary>machine-specific options</primary></indexterm>
-</para>
-
-<para>
-Some flags only make sense for particular target platforms.
-</para>
-
-<para>
-<VariableList>
-
-<varlistentry>
-<term><option>-mv8</option>:</term>
-<listitem>
-<para>
-(SPARC machines)<indexterm><primary>-mv8 option (SPARC only)</primary></indexterm>
-Means to pass the like-named option to GCC; it says to use the
-Version 8 SPARC instructions, notably integer multiply and divide.
-The similiar <option>-m*</option> GCC options for SPARC also work, actually.
-</para>
-</listitem>
-</varlistentry>
-<varlistentry>
-<term><option>-mlong-calls</option>:</term>
-<listitem>
-<para>
-(HPPA machines)<indexterm><primary>-mlong-calls option (HPPA only)</primary></indexterm>
-Means to pass the like-named option to GCC.  Required for Very Big
-modules, maybe.  (Probably means you're in trouble&hellip;)
-</para>
-</listitem>
-</varlistentry>
-<varlistentry>
-<term><option>-monly-[32]-regs</option>:</term>
-<listitem>
-<para>
-(iX86 machines)<indexterm><primary>-monly-N-regs option (iX86 only)</primary></indexterm>
-GHC tries to &ldquo;steal&rdquo; four registers from GCC, for performance
-reasons; it almost always works.  However, when GCC is compiling some
-modules with four stolen registers, it will crash, probably saying:
-
-<Screen>
-Foo.hc:533: fixed or forbidden register was spilled.
-This may be due to a compiler bug or to impossible asm
-statements or clauses.
-</Screen>
-
-Just give some registers back with <option>-monly-N-regs</option>.  Try `3' first,
-then `2'.  If `2' doesn't work, please report the bug to us.
-</para>
-</listitem>
-</varlistentry>
-</VariableList>
-</para>
-
-</sect2>
-
-<Sect2 id="optimise-C-compiler">
-<Title>Code improvement by the C compiler.
-</Title>
-
-<para>
-<indexterm><primary>optimisation by GCC</primary></indexterm>
-<indexterm><primary>GCC optimisation</primary></indexterm>
-</para>
-
-<para>
-The C&nbsp;compiler (GCC) is run with <option>-O</option> turned on.  (It has
-to be, actually).
-</para>
-
-<para>
-If you want to run GCC with <option>-O2</option>&mdash;which may be worth a few
-percent in execution speed&mdash;you can give a
-<option>-O2-for-C</option><indexterm><primary>-O2-for-C option</primary></indexterm> option.
-</para>
-
-</sect2>
-
-</Sect1>
-
-<Sect1 id="options-phases">
-<Title>Options related to a particular phase
-</Title>
-
-<Sect2 id="c-pre-processor">
-<Title>The C pre-processor
-</Title>
-
-<para>
-<indexterm><primary>pre-processing: cpp</primary></indexterm>
-<indexterm><primary>C pre-processor options</primary></indexterm>
-<indexterm><primary>cpp, pre-processing with</primary></indexterm>
-</para>
-
-<para>
-The C pre-processor <Command>cpp</Command> is run over your Haskell code only if the
-<option>-cpp</option> option <indexterm><primary>-cpp option</primary></indexterm> is given.  Unless you are
-building a large system with significant doses of conditional
-compilation, you really shouldn't need it.
-<VariableList>
-
-<varlistentry>
-<term><option>-D&lt;foo&gt;</option>:</term>
-<listitem>
-<para>
-<indexterm><primary>-D&lt;name&gt; option</primary></indexterm>
-Define macro <Constant>&lt;foo&gt;</Constant> in the usual way.  NB: does <Emphasis>not</Emphasis> affect
-<option>-D</option> macros passed to the C&nbsp;compiler when compiling via C!  For those,
-use the <option>-optc-Dfoo</option> hack&hellip; (see <XRef LinkEnd="forcing-options-through">).
-</para>
-</listitem>
-</varlistentry>
-<varlistentry>
-<term><option>-U&lt;foo&gt;</option>:</term>
-<listitem>
-<para>
-<indexterm><primary>-U&lt;name&gt; option</primary></indexterm>
-Undefine macro <Command>&lt;foo&gt;</Command> in the usual way.
-</para>
-</listitem>
-</varlistentry>
-<varlistentry>
-<term><option>-I&lt;dir&gt;</option>:</term>
-<listitem>
-<para>
-<indexterm><primary>-I&lt;dir&gt; option</primary></indexterm>
-Specify a directory in which to look for <literal>&num;include</literal> files, in
-the usual C way.
-</para>
-</listitem>
-</varlistentry>
-</VariableList>
-</para>
-
-<para>
-The GHC driver pre-defines several macros when processing Haskell
-source code (<Filename>.hs</Filename> or <Filename>.lhs</Filename> files):
-</para>
-
-<para>
-<VariableList>
-
-<varlistentry>
-<term><Constant>&lowbar;&lowbar;HASKELL98&lowbar;&lowbar;</Constant>:</term>
-<listitem>
-<para>
-<indexterm><primary>&lowbar;&lowbar;HASKELL98&lowbar;&lowbar;</primary></indexterm>
-If defined, this means that GHC supports the language defined by the
-Haskell 98 report.
-</para>
-</listitem>
-</varlistentry>
-<varlistentry>
-<term><Constant>&lowbar;&lowbar;HASKELL&lowbar;&lowbar;=98</Constant>:</term>
-<listitem>
-<para>
-<indexterm><primary>&lowbar;&lowbar;HASKELL&lowbar;&lowbar;</primary></indexterm>
-In GHC 4.04 and later, the <Constant>&lowbar;&lowbar;HASKELL&lowbar;&lowbar;</Constant> macro is defined as having
-the value <Constant>98</Constant>.
-</para>
-</listitem>
-</varlistentry>
-<varlistentry>
-<term><Constant>&lowbar;&lowbar;HASKELL1&lowbar;&lowbar;</Constant>:</term>
-<listitem>
-<para>
-<indexterm><primary>&lowbar;&lowbar;HASKELL1&lowbar;&lowbar; macro</primary></indexterm>
-If defined to <Emphasis>n</Emphasis>, that means GHC supports the Haskell language
-defined in the Haskell report version <Emphasis>1.n</Emphasis>.  Currently 5.  This
-macro is deprecated, and will probably disappear in future versions.
-</para>
-</listitem>
-</varlistentry>
-<varlistentry>
-<term><Constant>&lowbar;&lowbar;GLASGOW&lowbar;HASKELL&lowbar;&lowbar;</Constant>:</term>
-<listitem>
-<para>
-<indexterm><primary>&lowbar;&lowbar;GLASGOW&lowbar;HASKELL&lowbar;&lowbar; macro</primary></indexterm>
-For version <Emphasis>n</Emphasis> of the GHC system, this will be <literal>&num;define</literal>d to
-<Emphasis>100n</Emphasis>.  So, for version 4.00, it is 400.
-</para>
-
-<para>
-With any luck, <Constant>&lowbar;&lowbar;GLASGOW&lowbar;HASKELL&lowbar;&lowbar;</Constant> will be undefined in all other
-implementations that support C-style pre-processing.
-</para>
-
-<para>
-(For reference: the comparable symbols for other systems are:
-<Constant>&lowbar;&lowbar;HUGS&lowbar;&lowbar;</Constant> for Hugs and <Constant>&lowbar;&lowbar;HBC&lowbar;&lowbar;</Constant> for Chalmers.)
-</para>
-
-<para>
-NB. This macro is set when pre-processing both Haskell source and C
-source, including the C source generated from a Haskell module
-(i.e. <Filename>.hs</Filename>, <Filename>.lhs</Filename>, <Filename>.c</Filename> and <Filename>.hc</Filename> files).
-</para>
-</listitem>
-</varlistentry>
-<varlistentry>
-<term><Constant>&lowbar;&lowbar;CONCURRENT&lowbar;HASKELL&lowbar;&lowbar;</Constant>:</term>
-<listitem>
-<para>
-<indexterm><primary>&lowbar;&lowbar;CONCURRENT&lowbar;HASKELL&lowbar;&lowbar; macro</primary></indexterm>
-This symbol is defined when pre-processing Haskell (input) and
-pre-processing C (GHC output).  Since GHC from verion 4.00 now
-supports concurrent haskell by default, this symbol is always defined.
-</para>
-</listitem>
-</varlistentry>
-<varlistentry>
-<term><Constant>&lowbar;&lowbar;PARALLEL&lowbar;HASKELL&lowbar;&lowbar;</Constant>:</term>
-<listitem>
-<para>
-<indexterm><primary>&lowbar;&lowbar;PARALLEL&lowbar;HASKELL&lowbar;&lowbar; macro</primary></indexterm>
-Only defined when <option>-parallel</option> is in use!  This symbol is defined when
-pre-processing Haskell (input) and pre-processing C (GHC output).
-</para>
-</listitem>
-</varlistentry>
-</VariableList>
-</para>
-
-<para>
-Options other than the above can be forced through to the C
-pre-processor with the <option>-opt</option> flags (see
-<XRef LinkEnd="forcing-options-through">).
-</para>
-
-<para>
-A small word of warning: <option>-cpp</option> is not friendly to &ldquo;string
-gaps&rdquo;.<indexterm><primary>-cpp vs string gaps</primary></indexterm><indexterm><primary>string gaps vs
--cpp</primary></indexterm>.  In other words, strings such as the following:
-</para>
-
-<para>
-
-<ProgramListing>
-strmod = "\
-\ p \
-\ "
-</ProgramListing>
-
-</para>
-
-<para>
-don't work with <option>-cpp</option>; <Filename>/usr/bin/cpp</Filename> elides the
-backslash-newline pairs.
-</para>
-
-<para>
-However, it appears that if you add a space at the end of the line,
-then <Command>cpp</Command> (at least GNU <Command>cpp</Command> and possibly other <Command>cpp</Command>s)
-leaves the backslash-space pairs alone and the string gap works as
-expected.
-</para>
-
-</sect2>
-
-<Sect2 id="options-C-compiler">
-<Title>Options affecting the C compiler (if applicable)
-</Title>
-
-<para>
-<indexterm><primary>include-file options</primary></indexterm>
-<indexterm><primary>C compiler options</primary></indexterm>
-<indexterm><primary>GCC options</primary></indexterm>
-</para>
-
-<para>
-At the moment, quite a few common C-compiler options are passed on
-quietly to the C compilation of Haskell-compiler-generated C files.
-THIS MAY CHANGE.  Meanwhile, options so sent are:
-</para>
-
-<para>
-
-<InformalTable>
-<TGroup Cols="2">
-<ColSpec Align="Left" Colsep="0">
-<ColSpec Align="Left" Colsep="0">
-<TBody>
-<Row>
-<Entry><option>-ansi</option> </Entry>
-<Entry> do ANSI C (not K&amp;R) </Entry>
-</Row>
-<Row>
-<Entry>
-<option>-pedantic</option> </Entry>
-<Entry> be so</Entry>
-</Row>
-<Row>
-<Entry>
-<option>-dgcc-lint</option> </Entry>
-<Entry> (hack) short for &ldquo;make GCC very paranoid&rdquo;</Entry>
-</Row>
-
-</TBody>
-
-</TGroup>
-</InformalTable>
-
-<indexterm><primary>-ansi option (for GCC)</primary></indexterm>
-<indexterm><primary>-pedantic option (for GCC)</primary></indexterm>
-<indexterm><primary>-dgcc-lint option (GCC paranoia)</primary></indexterm>
-</para>
-
-<para>
-If you are compiling with lots of foreign calls, you may need to
-tell the C&nbsp;compiler about some <literal>&num;include</literal> files.  There is no real
-pretty way to do this, but you can use this hack from the
-command-line:
-</para>
-
-<para>
-
-<Screen>
-% ghc -c '-#include &#60;X/Xlib.h&#62;' Xstuff.lhs
-</Screen>
-
-</para>
-
-</sect2>
-
-<Sect2 id="options-linker">
-<Title>Linking and consistency-checking
-</Title>
-
-<para>
-<indexterm><primary>linker options</primary></indexterm>
-<indexterm><primary>ld options</primary></indexterm>
-</para>
-
-<para>
-GHC has to link your code with various libraries, possibly including:
-user-supplied, GHC-supplied, and system-supplied (<option>-lm</option> math
-library, for example).
-</para>
-
-<para>
-<VariableList>
-
-<varlistentry>
-<term><option>-l&lt;FOO&gt;</option>:</term>
-<listitem>
-<para>
-<indexterm><primary>-l&lt;lib&gt; option</primary></indexterm>
-Link in a library named <Filename>lib&lt;FOO&gt;.a</Filename> which resides somewhere on the
-library directories path.
-</para>
-
-<para>
-Because of the sad state of most UNIX linkers, the order of such
-options does matter.  Thus: <Command>ghc -lbar *.o</Command> is almost certainly
-wrong, because it will search <Filename>libbar.a</Filename> <Emphasis>before</Emphasis> it has
-collected unresolved symbols from the <Filename>*.o</Filename> files.
-<Command>ghc *.o -lbar</Command> is probably better.
-</para>
-
-<para>
-The linker will of course be informed about some GHC-supplied
-libraries automatically; these are:
-</para>
-
-<para>
-
-<InformalTable>
-<TGroup Cols="2">
-<ColSpec Align="Left" Colsep="0">
-<ColSpec Align="Left" Colsep="0">
-<TBody>
-<Row>
-<Entry><Emphasis>-l equivalent</Emphasis> </Entry>
-<Entry> <Emphasis>description</Emphasis> </Entry>
-</Row>
-
-<Row>
-<Entry>
-<option>-lHSrts,-lHSclib</option> </Entry>
-<Entry> basic runtime libraries </Entry>
-</Row>
-<Row>
-<Entry>
-<option>-lHS</option> </Entry>
-<Entry> standard Prelude library </Entry>
-</Row>
-<Row>
-<Entry>
-<option>-lHS&lowbar;cbits</option> </Entry>
-<Entry> C support code for standard Prelude library </Entry>
-</Row>
-<Row>
-<Entry>
-<option>-lgmp</option> </Entry>
-<Entry> GNU multi-precision library (for Integers)</Entry>
-</Row>
-
-</TBody>
-
-</TGroup>
-</InformalTable>
-
-</para>
-
-<para>
-<indexterm><primary>-lHS library</primary></indexterm>
-<indexterm><primary>-lHS&lowbar;cbits library</primary></indexterm>
-<indexterm><primary>-lHSrts library</primary></indexterm>
-<indexterm><primary>-lgmp library</primary></indexterm>
-</para>
-</listitem>
-</varlistentry>
-<varlistentry>
-<term><option>-package &lt;name&gt;</option>:</term>
-<listitem>
-<para>
-<indexterm><primary>-package &lt;name&gt; option</primary></indexterm>
-</para>
-
-<para>
-If you are using a Haskell &ldquo;package&rdquo; (e.g., the POSIX
-library), just use the <option>-package posix</option> option, and the
-correct code should be linked in.  See <xref linkend="packages"> for
-more details.
-</para>
-</listitem>
-</varlistentry>
-<varlistentry>
-<term><option>-L&lt;dir&gt;</option>:</term>
-<listitem>
-<para>
-<indexterm><primary>-L&lt;dir&gt; option</primary></indexterm>
-Where to find user-supplied libraries&hellip;  Prepend the directory
-<Filename>&lt;dir&gt;</Filename> to the library directories path.
-</para>
-</listitem>
-</varlistentry>
-<varlistentry>
-<term><option>-static</option>:</term>
-<listitem>
-<para>
-<indexterm><primary>-static option</primary></indexterm>
-Tell the linker to avoid shared libraries.
-</para>
-</listitem>
-</varlistentry>
-<varlistentry>
-<term><option>-no-link-chk</option> and <option>-link-chk</option>:</term>
-<listitem>
-<para>
-<indexterm><primary>-no-link-chk option</primary></indexterm>
-<indexterm><primary>-link-chk option</primary></indexterm>
-<indexterm><primary>consistency checking of executables</primary></indexterm>
-By default, immediately after linking an executable, GHC verifies that
-the pieces that went into it were compiled with compatible flags; a
-&ldquo;consistency check&rdquo;.
-(This is to avoid mysterious failures caused by non-meshing of
-incompatibly-compiled programs; e.g., if one <Filename>.o</Filename> file was compiled
-for a parallel machine and the others weren't.)  You may turn off this
-check with <option>-no-link-chk</option>.  You can turn it (back) on with
-<option>-link-chk</option> (the default).
-</para>
-</listitem>
-</varlistentry>
-<varlistentry>
-<term><option>-no-hs-main</option>:</term>
-<listitem>
-<para>
-<indexterm><primary>-no-hs-main option</primary></indexterm>
-<indexterm><primary>linking Haskell libraries with foreign code</primary></indexterm>
-</para>
-
-<para>
-In the event you want to include ghc-compiled code as part of another
-(non-Haskell) program, the RTS will not be supplying its definition of
-<Function>main()</Function> at link-time, you will have to. To signal that to the
-driver script when linking, use <option>-no-hs-main</option>.
-</para>
-
-<para>
-Notice that since the command-line passed to the linker is rather
-involved, you probably want to use the ghc driver script to do the
-final link of your `mixed-language' application. This is not a
-requirement though, just try linking once with <option>-v</option> on to see what
-options the driver passes through to the linker.
-</para>
-</listitem>
-</varlistentry>
-</VariableList>
-</para>
-
-</sect2>
-
-</Sect1>
-
-<Sect1 id="sec-using-concurrent">
-<Title>Using Concurrent Haskell</Title>
-
-<para>
-<indexterm><primary>Concurrent Haskell&mdash;use</primary></indexterm>
-</para>
-
-<para>
-GHC (as of version 4.00) supports Concurrent Haskell by default,
-without requiring a special option or libraries compiled in a certain
-way.  To get access to the support libraries for Concurrent Haskell
-(i.e. <literal>Concurrent</literal> and friends), use the
-<option>-package concurrent</option> option.
-</para>
-
-<para>
-Three RTS options are provided for modifying the behaviour of the
-threaded runtime system.  See the descriptions of
-<option>-C[&lt;us&gt;]</option>, <option>-q</option>, and
-<option>-t&lt;num&gt;</option> in <XRef LinkEnd="parallel-rts-opts">.
-</para>
-
-<para>
-Concurrent Haskell is described in more detail in <XRef
-LinkEnd="sec-Concurrent">.
-</para>
-
-</Sect1>
-
-<Sect1 id="sec-using-parallel">
-<Title>Using Parallel Haskell</Title>
-
-<para>
-<indexterm><primary>Parallel Haskell&mdash;use</primary></indexterm>
-</para>
-
-<para>
-&lsqb;You won't be able to execute parallel Haskell programs unless PVM3
-(Parallel Virtual Machine, version 3) is installed at your site.]
-</para>
-
-<para>
-To compile a Haskell program for parallel execution under PVM, use the
-<option>-parallel</option> option,<indexterm><primary>-parallel
-option</primary></indexterm> both when compiling <Emphasis>and
-linking</Emphasis>.  You will probably want to <literal>import
-Parallel</literal> into your Haskell modules.
-</para>
-
-<para>
-To run your parallel program, once PVM is going, just invoke it
-&ldquo;as normal&rdquo;.  The main extra RTS option is
-<option>-N&lt;n&gt;</option>, to say how many PVM
-&ldquo;processors&rdquo; your program to run on.  (For more details of
-all relevant RTS options, please see <XRef
-LinkEnd="parallel-rts-opts">.)
-</para>
-
-<para>
-In truth, running Parallel Haskell programs and getting information
-out of them (e.g., parallelism profiles) is a battle with the vagaries of
-PVM, detailed in the following sections.
-</para>
-
-<sect2>
-<Title>Dummy's guide to using PVM</Title>
-
-<para>
-<indexterm><primary>PVM, how to use</primary></indexterm>
-<indexterm><primary>Parallel Haskell&mdash;PVM use</primary></indexterm>
-Before you can run a parallel program under PVM, you must set the
-required environment variables (PVM's idea, not ours); something like,
-probably in your <Filename>.cshrc</Filename> or equivalent:
-
-<ProgramListing>
-setenv PVM_ROOT /wherever/you/put/it
-setenv PVM_ARCH `$PVM_ROOT/lib/pvmgetarch`
-setenv PVM_DPATH $PVM_ROOT/lib/pvmd
+setenv PVM_ROOT /wherever/you/put/it
+setenv PVM_ARCH `$PVM_ROOT/lib/pvmgetarch`
+setenv PVM_DPATH $PVM_ROOT/lib/pvmd
 </ProgramListing>
 
 </para>
@@ -3297,7 +1305,7 @@ business; nothing specific to Parallel Haskell.
 </para>
 
 <para>
-You use the <Command>pvm</Command><indexterm><primary>pvm command</primary></indexterm> command to start PVM on your
+You use the <command>pvm</command><indexterm><primary>pvm command</primary></indexterm> command to start PVM on your
 machine.  You can then do various things to control/monitor your
 &ldquo;parallel machine;&rdquo; the most useful being:
 </para>
@@ -3310,41 +1318,41 @@ machine.  You can then do various things to control/monitor your
 
 <Row>
 <Entry><KeyCombo><KeyCap>Control</KeyCap><KeyCap>D</KeyCap></KeyCombo></Entry>
-<Entry>exit <Command>pvm</Command>, leaving it running</Entry>
+<Entry>exit <command>pvm</command>, leaving it running</Entry>
 </Row>
 
 <Row>
-<Entry><Command>halt</Command></Entry>
+<Entry><command>halt</command></Entry>
 <Entry>kill off this &ldquo;parallel machine&rdquo; &amp; exit</Entry>
 </Row>
 
 <Row>
-<Entry><Command>add &lt;host&gt;</Command></Entry>
-<Entry>add <Command>&lt;host&gt;</Command> as a processor</Entry>
+<Entry><command>add &lt;host&gt;</command></Entry>
+<Entry>add <command>&lt;host&gt;</command> as a processor</Entry>
 </Row>
 
 <Row>
-<Entry><Command>delete &lt;host&gt;</Command></Entry>
-<Entry>delete <Command>&lt;host&gt;</Command></Entry>
+<Entry><command>delete &lt;host&gt;</command></Entry>
+<Entry>delete <command>&lt;host&gt;</command></Entry>
 </Row>
 
 <Row>
-<Entry><Command>reset</Command></Entry>
+<Entry><command>reset</command></Entry>
 <Entry>kill what's going, but leave PVM up</Entry>
 </Row>
 
 <Row>
-<Entry><Command>conf</Command></Entry>
+<Entry><command>conf</command></Entry>
 <Entry>list the current configuration</Entry>
 </Row>
 
 <Row>
-<Entry><Command>ps</Command></Entry>
+<Entry><command>ps</command></Entry>
 <Entry>report processes' status</Entry>
 </Row>
 
 <Row>
-<Entry><Command>pstat &lt;pid&gt;</Command></Entry>
+<Entry><command>pstat &lt;pid&gt;</command></Entry>
 <Entry>status of a particular process</Entry>
 </Row>
 
@@ -3354,13 +1362,13 @@ machine.  You can then do various things to control/monitor your
 </para>
 
 <para>
-The PVM documentation can tell you much, much more about <Command>pvm</Command>!
+The PVM documentation can tell you much, much more about <command>pvm</command>!
 </para>
 
 </sect2>
 
 <sect2>
-<Title>Parallelism profiles</Title>
+<title>Parallelism profiles</title>
 
 <para>
 <indexterm><primary>parallelism profiles</primary></indexterm>
@@ -3374,12 +1382,12 @@ results&mdash;only with &ldquo;how parallel&rdquo; it was!  We want pretty pictu
 </para>
 
 <para>
-Parallelism profiles (&agrave; la <Command>hbcpp</Command>) can be generated with the
+Parallelism profiles (&agrave; la <command>hbcpp</command>) can be generated with the
 <option>-q</option><indexterm><primary>-q RTS option (concurrent, parallel)</primary></indexterm> RTS option.  The
 per-processor profiling info is dumped into files named
-<Filename>&lt;full-path&gt;&lt;program&gt;.gr</Filename>.  These are then munged into a PostScript picture,
+<filename>&lt;full-path&gt;&lt;program&gt;.gr</filename>.  These are then munged into a PostScript picture,
 which you can then display.  For example, to run your program
-<Filename>a.out</Filename> on 8 processors, then view the parallelism profile, do:
+<filename>a.out</filename> on 8 processors, then view the parallelism profile, do:
 </para>
 
 <para>
@@ -3395,13 +1403,13 @@ which you can then display.  For example, to run your program
 
 <para>
 The scripts for processing the parallelism profiles are distributed
-in <Filename>ghc/utils/parallel/</Filename>.
+in <filename>ghc/utils/parallel/</filename>.
 </para>
 
 </sect2>
 
 <sect2>
-<Title>Other useful info about running parallel programs</Title>
+<title>Other useful info about running parallel programs</title>
 
 <para>
 The &ldquo;garbage-collection statistics&rdquo; RTS options can be useful for
@@ -3409,19 +1417,19 @@ seeing what parallel programs are doing.  If you do either
 <option>+RTS -Sstderr</option><indexterm><primary>-Sstderr RTS option</primary></indexterm> or <option>+RTS -sstderr</option>, then
 you'll get mutator, garbage-collection, etc., times on standard
 error. The standard error of all PE's other than the `main thread'
-appears in <Filename>/tmp/pvml.nnn</Filename>, courtesy of PVM.
+appears in <filename>/tmp/pvml.nnn</filename>, courtesy of PVM.
 </para>
 
 <para>
 Whether doing <option>+RTS -Sstderr</option> or not, a handy way to watch
-what's happening overall is: <Command>tail -f /tmp/pvml.nnn</Command>.
+what's happening overall is: <command>tail -f /tmp/pvml.nnn</command>.
 </para>
 
 </sect2>
 
 <Sect2 id="parallel-rts-opts">
-<Title>RTS options for Concurrent/Parallel Haskell
-</Title>
+<title>RTS options for Concurrent/Parallel Haskell
+</title>
 
 <para>
 <indexterm><primary>RTS options, concurrent</primary></indexterm>
@@ -3472,13 +1480,13 @@ is the maximum granularity available for timed context switches.
 <para>
 <indexterm><primary>-q RTS option</primary></indexterm>
 (PARALLEL ONLY) Produce a quasi-parallel profile of thread activity,
-in the file <FIlename>&lt;program&gt;.qp</FIlename>.  In the style of <Command>hbcpp</Command>, this profile
+in the file <FIlename>&lt;program&gt;.qp</FIlename>.  In the style of <command>hbcpp</command>, this profile
 records the movement of threads between the green (runnable) and red
 (blocked) queues.  If you specify the verbose suboption (<option>-qv</option>), the
 green queue is split into green (for the currently running thread
 only) and amber (for other runnable threads).  We do not recommend
 that you use the verbose suboption if you are planning to use the
-<Command>hbcpp</Command> profiling tools or if you are context switching at every heap
+<command>hbcpp</command> profiling tools or if you are context switching at every heap
 check (with <option>-C</option>).
 </para>
 </listitem>
@@ -3490,7 +1498,7 @@ check (with <option>-C</option>).
 <indexterm><primary>-t&lt;num&gt; RTS option</primary></indexterm>
 (PARALLEL ONLY) Limit the number of concurrent threads per processor
 to <literal>&lt;num&gt;</literal>.  The default is 32.  Each thread requires slightly over 1K
-<Emphasis>words</Emphasis> in the heap for thread state and stack objects.  (For
+<emphasis>words</emphasis> in the heap for thread state and stack objects.  (For
 32-bit machines, this translates to 4K bytes, and for 64-bit machines,
 8K bytes.)
 </para>
@@ -3502,10 +1510,10 @@ to <literal>&lt;num&gt;</literal>.  The default is 32.  Each thread requires sli
 <para>
 <indexterm><primary>-d RTS option (parallel)</primary></indexterm>
 (PARALLEL ONLY) Turn on debugging.  It pops up one xterm (or GDB, or
-something&hellip;) per PVM processor.  We use the standard <Command>debugger</Command>
+something&hellip;) per PVM processor.  We use the standard <command>debugger</command>
 script that comes with PVM3, but we sometimes meddle with the
-<Command>debugger2</Command> script.  We include ours in the GHC distribution,
-in <Filename>ghc/utils/pvm/</Filename>.
+<command>debugger2</command> script.  We include ours in the GHC distribution,
+in <filename>ghc/utils/pvm/</filename>.
 </para>
 </listitem>
 </varlistentry>
@@ -3539,8 +1547,68 @@ computation speed.
 
 </Sect1>
 
+  <sect1 id="options-platform">
+    <title>Platform-specific Flags</title>
+
+    <indexterm><primary>-m* options</primary></indexterm>
+    <indexterm><primary>platform-specific options</primary></indexterm>
+    <indexterm><primary>machine-specific options</primary></indexterm>
+
+    <para>Some flags only make sense for particular target
+    platforms.</para>
+
+    <variablelist>
+
+      <varlistentry>
+       <term><option>-mv8</option>:</term>
+       <listitem>
+         <para>(SPARC machines)<indexterm><primary>-mv8 option (SPARC
+          only)</primary></indexterm> Means to pass the like-named
+          option to GCC; it says to use the Version 8 SPARC
+          instructions, notably integer multiply and divide.  The
+          similiar <option>-m*</option> GCC options for SPARC also
+          work, actually.</para>
+       </listitem>
+      </varlistentry>
+
+      <varlistentry>
+       <term><option>-mlong-calls</option>:</term>
+       <listitem>
+         <para>(HPPA machines)<indexterm><primary>-mlong-calls option
+          (HPPA only)</primary></indexterm> Means to pass the
+          like-named option to GCC.  Required for Very Big modules,
+          maybe.  (Probably means you're in trouble&hellip;)</para>
+       </listitem>
+      </varlistentry>
+
+      <varlistentry>
+       <term><option>-monly-[32]-regs</option>:</term>
+       <listitem>
+         <para>(iX86 machines)<indexterm><primary>-monly-N-regs
+          option (iX86 only)</primary></indexterm> GHC tries to
+          &ldquo;steal&rdquo; four registers from GCC, for performance
+          reasons; it almost always works.  However, when GCC is
+          compiling some modules with four stolen registers, it will
+          crash, probably saying:
+
+<Screen>
+Foo.hc:533: fixed or forbidden register was spilled.
+This may be due to a compiler bug or to impossible asm
+statements or clauses.
+</Screen>
+
+          Just give some registers back with
+          <option>-monly-N-regs</option>.  Try `3' first, then `2'.
+          If `2' doesn't work, please report the bug to us.</para>
+       </listitem>
+      </varlistentry>
+    </variablelist>
+
+  </sect1>
+
 &runtime
 &debug
+&flags
 
 </Chapter>