summaryrefslogtreecommitdiff
path: root/docs/users_guide/phases.rst
diff options
context:
space:
mode:
authorPatrick Dougherty <patrick.doc@ameritech.net>2017-08-18 09:20:07 -0400
committerBen Gamari <ben@smart-cactus.org>2017-08-18 23:28:16 -0400
commitcf8ab1ced6f15dad03dd7bcc454ef759cf4d3b3d (patch)
treeeeb48abdaa020f02a3787d6225f2138b5c82b0ed /docs/users_guide/phases.rst
parent6267d8c9e54663a23f0ac13556522a53580d0910 (diff)
downloadhaskell-cf8ab1ced6f15dad03dd7bcc454ef759cf4d3b3d.tar.gz
users_guide: Convert mkUserGuidePart generation to a Sphinx extension
This removes all dependencies the users guide had on `mkUserGuidePart`. The generation of the flag reference table and the various pieces of the man page is now entirely contained within the Spinx extension `flags.py`. You can see the man page generation on the orphan page https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/ghc.html The extension works by collecting all of the meta-data attached to the `ghc-flag` directives and then formatting and displaying it at `flag-print` directives. There is a single printing directive that can be customized with two options, what format to display (table, list, or block of flags) and an optional category to limit the output to (verbosity, warnings, codegen, etc.). New display formats can be added by creating a function `generate_flag_xxx` (where `xxx` is a description of the format) which takes a list of flags and a category and returns a new `xxx`. Then just add a reference in the dispatch table `handlers`. That display can now be run by passing `:type: xxx` to the `flag-print` directive. `flags.py` contains two maps of settings that can be adjusted. The first is a canonical list of flag categories, and the second sets default categories for files. The only functionality that Sphinx could not replace was the `what_glasgow_exts_does.gen.rst` file. `mkUserGuidePart` actually just reads the list of flags from `compiler/main/DynFlags.hs` which Sphinx cannot do. As the flag is deprecated, I added the list as a static file which can be updated manually. Additionally, this patch updates every single documented flag with the data from `mkUserGuidePart` to generate the reference table. Fixes #11654 and, incidentally, #12155. Reviewers: austin, bgamari Subscribers: rwbarton, thomie GHC Trac Issues: #11654, #12155 Differential Revision: https://phabricator.haskell.org/D3839
Diffstat (limited to 'docs/users_guide/phases.rst')
-rw-r--r--docs/users_guide/phases.rst229
1 files changed, 229 insertions, 0 deletions
diff --git a/docs/users_guide/phases.rst b/docs/users_guide/phases.rst
index 074b9499f5..92e308db15 100644
--- a/docs/users_guide/phases.rst
+++ b/docs/users_guide/phases.rst
@@ -18,46 +18,79 @@ following options allow you to change the external program used for a
given compilation phase:
.. ghc-flag:: -pgmL ⟨cmd⟩
+ :shortdesc: Use ⟨cmd⟩ as the literate pre-processor
+ :type: dynamic
+ :category: phase-programs
Use ⟨cmd⟩ as the literate pre-processor.
.. ghc-flag:: -pgmP ⟨cmd⟩
+ :shortdesc: Use ⟨cmd⟩ as the C pre-processor (with ``-cpp`` only)
+ :type: dynamic
+ :category: phase-programs
Use ⟨cmd⟩ as the C pre-processor (with ``-cpp`` only).
.. ghc-flag:: -pgmc ⟨cmd⟩
+ :shortdesc: Use ⟨cmd⟩ as the C compiler
+ :type: dynamic
+ :category: phase-programs
Use ⟨cmd⟩ as the C compiler.
.. ghc-flag:: -pgmlo ⟨cmd⟩
+ :shortdesc: Use ⟨cmd⟩ as the LLVM optimiser
+ :type: dynamic
+ :category: phase-programs
Use ⟨cmd⟩ as the LLVM optimiser.
.. ghc-flag:: -pgmlc ⟨cmd⟩
+ :shortdesc: Use ⟨cmd⟩ as the LLVM compiler
+ :type: dynamic
+ :category: phase-programs
Use ⟨cmd⟩ as the LLVM compiler.
.. ghc-flag:: -pgms ⟨cmd⟩
+ :shortdesc: Use ⟨cmd⟩ as the splitter
+ :type: dynamic
+ :category: phase-programs
Use ⟨cmd⟩ as the splitter.
.. ghc-flag:: -pgma ⟨cmd⟩
+ :shortdesc: Use ⟨cmd⟩ as the assembler
+ :type: dynamic
+ :category: phase-programs
Use ⟨cmd⟩ as the assembler.
.. ghc-flag:: -pgml ⟨cmd⟩
+ :shortdesc: Use ⟨cmd⟩ as the linker
+ :type: dynamic
+ :category: phase-programs
Use ⟨cmd⟩ as the linker.
.. ghc-flag:: -pgmdll ⟨cmd⟩
+ :shortdesc: Use ⟨cmd⟩ as the DLL generator
+ :type: dynamic
+ :category: phase-programs
Use ⟨cmd⟩ as the DLL generator.
.. ghc-flag:: -pgmF ⟨cmd⟩
+ :shortdesc: Use ⟨cmd⟩ as the pre-processor (with ``-F`` only)
+ :type: dynamic
+ :category: phase-programs
Use ⟨cmd⟩ as the pre-processor (with ``-F`` only).
.. ghc-flag:: -pgmwindres ⟨cmd⟩
+ :shortdesc: Use ⟨cmd⟩ as the program for embedding manifests on Windows.
+ :type: dynamic
+ :category: phase-programs
Use ⟨cmd⟩ as the program to use for embedding manifests on Windows.
Normally this is the program ``windres``, which is supplied with a
@@ -65,10 +98,16 @@ given compilation phase:
:ref:`options-linker`.
.. ghc-flag:: -pgmlibtool ⟨cmd⟩
+ :shortdesc: Use ⟨cmd⟩ as the command for libtool (with ``-staticlib`` only).
+ :type: dynamic
+ :category: phase-programs
Use ⟨cmd⟩ as the libtool command (when using ``-staticlib`` only).
.. ghc-flag:: -pgmi ⟨cmd⟩
+ :shortdesc: Use ⟨cmd⟩ as the external interpreter command.
+ :type: dynamic
+ :category: phase-programs
Use ⟨cmd⟩ as the external interpreter command (see:
:ref:`external-interpreter`). Default: ``ghc-iserv-prof`` if
@@ -87,48 +126,81 @@ Options can be forced through to a particular compilation phase, using
the following flags:
.. ghc-flag:: -optL ⟨option⟩
+ :shortdesc: pass ⟨option⟩ to the literate pre-processor
+ :type: dynamic
+ :category: phase-options
Pass ⟨option⟩ to the literate pre-processor
.. ghc-flag:: -optP ⟨option⟩
+ :shortdesc: pass ⟨option⟩ to cpp (with ``-cpp`` only)
+ :type: dynamic
+ :category: phase-options
Pass ⟨option⟩ to CPP (makes sense only if ``-cpp`` is also on).
.. ghc-flag:: -optF ⟨option⟩
+ :shortdesc: pass ⟨option⟩ to the custom pre-processor
+ :type: dynamic
+ :category: phase-options
Pass ⟨option⟩ to the custom pre-processor (see
:ref:`pre-processor`).
.. ghc-flag:: -optc ⟨option⟩
+ :shortdesc: pass ⟨option⟩ to the C compiler
+ :type: dynamic
+ :category: phase-options
Pass ⟨option⟩ to the C compiler.
.. ghc-flag:: -optlo ⟨option⟩
+ :shortdesc: pass ⟨option⟩ to the LLVM optimiser
+ :type: dynamic
+ :category: phase-options
Pass ⟨option⟩ to the LLVM optimiser.
.. ghc-flag:: -optlc ⟨option⟩
+ :shortdesc: pass ⟨option⟩ to the LLVM compiler
+ :type: dynamic
+ :category: phase-options
Pass ⟨option⟩ to the LLVM compiler.
.. ghc-flag:: -opta ⟨option⟩
+ :shortdesc: pass ⟨option⟩ to the assembler
+ :type: dynamic
+ :category: phase-options
Pass ⟨option⟩ to the assembler.
.. ghc-flag:: -optl ⟨option⟩
+ :shortdesc: pass ⟨option⟩ to the linker
+ :type: dynamic
+ :category: phase-options
Pass ⟨option⟩ to the linker.
.. ghc-flag:: -optdll ⟨option⟩
+ :shortdesc: pass ⟨option⟩ to the DLL generator
+ :type: dynamic
+ :category: phase-options
Pass ⟨option⟩ to the DLL generator.
.. ghc-flag:: -optwindres ⟨option⟩
+ :shortdesc: pass ⟨option⟩ to ``windres``.
+ :type: dynamic
+ :category: phase-options
Pass ⟨option⟩ to ``windres`` when embedding manifests on Windows.
See ``-fno-embed-manifest`` in :ref:`options-linker`.
.. ghc-flag:: -opti ⟨option⟩
+ :shortdesc: pass ⟨option⟩ to the interpreter sub-process.
+ :type: dynamic
+ :category: phase-options
Pass ⟨option⟩ to the interpreter sub-process (see
:ref:`external-interpreter`). A common use for this is to pass
@@ -149,12 +221,23 @@ to GHC's runtime system you can enclose them in ``+RTS ... -RTS`` (see
Options affecting the C pre-processor
-------------------------------------
+.. ghc-flag:: -XCPP
+ :shortdesc: Enable the :ref:`C preprocessor <c-pre-processor>`.
+ :type: dynamic
+ :reverse: -XNoCPP
+ :category: language
+
+ :since: 6.8.1
+
.. index::
single: pre-processing: cpp
single: C pre-processor options
single: cpp, pre-processing with
.. ghc-flag:: -cpp
+ :shortdesc: Run the C pre-processor on Haskell source files
+ :type: dynamic
+ :category: cpp
The C pre-processor :command:`cpp` is run over your Haskell code only if
the ``-cpp`` option -cpp option is given. Unless you are building a
@@ -162,6 +245,10 @@ Options affecting the C pre-processor
really shouldn't need it.
.. ghc-flag:: -D⟨symbol⟩[=⟨value⟩]
+ :shortdesc: Define a symbol in the C pre-processor
+ :type: dynamic
+ :reverse: -U⟨symbol⟩
+ :category: cpp
Define macro ⟨symbol⟩ in the usual way. When no value is given, the value is
taken to be ``1``. For instance, ``-DUSE_MYLIB`` is equivalent to
@@ -174,10 +261,16 @@ Options affecting the C pre-processor
this case use the ``-optc-Dfoo`` hack… (see :ref:`forcing-options-through`).
.. ghc-flag:: -U⟨symbol⟩
+ :shortdesc: Undefine a symbol in the C pre-processor
+ :type: dynamic
+ :category: cpp
Undefine macro ⟨symbol⟩ in the usual way.
.. ghc-flag:: -I⟨dir⟩
+ :shortdesc: Add ⟨dir⟩ to the directory search list for ``#include`` files
+ :type: dynamic
+ :category: cpp
Specify a directory in which to look for ``#include`` files, in the
usual C way.
@@ -363,6 +456,10 @@ Options affecting a Haskell pre-processor
single: pre-processor options
.. ghc-flag:: -F
+ :shortdesc: Enable the use of a :ref:`pre-processor <pre-processor>`
+ (set with :ghc-flag:`-pgmF ⟨cmd⟩`)
+ :type: dynamic
+ :category: phases
A custom pre-processor is run over your Haskell source file only if
the ``-F`` option is given.
@@ -412,11 +509,19 @@ Options affecting code generation
---------------------------------
.. ghc-flag:: -fasm
+ :shortdesc: Use the :ref:`native code generator <native-code-gen>`
+ :type: dynamic
+ :reverse: -fllvm
+ :category: codegen
Use GHC's :ref:`native code generator <native-code-gen>` rather than
compiling via LLVM. ``-fasm`` is the default.
.. ghc-flag:: -fllvm
+ :shortdesc: Compile using the :ref:`LLVM code generator <llvm-code-gen>`
+ :type: dynamic
+ :reverse: -fasm
+ :category: codegen
Compile via :ref:`LLVM <llvm-code-gen>` instead of using the native
code generator. This will generally take slightly longer than the
@@ -426,11 +531,17 @@ Options affecting code generation
in :envvar:`PATH`.
.. ghc-flag:: -fno-code
+ :shortdesc: Omit code generation
+ :type: dynamic
+ :category: codegen
Omit code generation (and all later phases) altogether. This is
useful if you're only interested in type checking code.
.. ghc-flag:: -fwrite-interface
+ :shortdesc: Always write interface files
+ :type: dynamic
+ :category: codegen
Always write interface files. GHC will normally write interface
files automatically, but this flag is useful with :ghc-flag:`-fno-code`,
@@ -439,12 +550,18 @@ Options affecting code generation
compiling dependencies.
.. ghc-flag:: -fobject-code
+ :shortdesc: Generate object code
+ :type: dynamic
+ :category: codegen
Generate object code. This is the default outside of GHCi, and can
be used with GHCi to cause object code to be generated in preference
to bytecode.
.. ghc-flag:: -fbyte-code
+ :shortdesc: Generate byte-code
+ :type: dynamic
+ :category: codegen
Generate byte-code instead of object-code. This is the default in
GHCi. Byte-code can currently only be used in the interactive
@@ -452,6 +569,9 @@ Options affecting code generation
reversing the effect of :ghc-flag:`-fobject-code`.
.. ghc-flag:: -fPIC
+ :shortdesc: Generate position-independent code (where available)
+ :type: dynamic
+ :category: codegen
Generate position-independent code (code that can be put into shared
libraries). This currently works on Linux x86 and x86-64. On
@@ -459,6 +579,9 @@ Options affecting code generation
no-op on that platform.
.. ghc-flag:: -dynamic
+ :shortdesc: Build dynamically-linked object files and executables
+ :type: dynamic
+ :category: codegen
:noindex:
When generating code, assume that entities imported from a different
@@ -472,6 +595,10 @@ Options affecting code generation
shared libraries.
.. ghc-flag:: -dynamic-too
+ :shortdesc: Build dynamic object files *as well as* static object files
+ during compilation
+ :type: dynamic
+ :category: codegen
Generates both dynamic and static object files in a single run of
GHC. This option is functionally equivalent to running GHC twice,
@@ -499,6 +626,9 @@ user-supplied, GHC-supplied, and system-supplied (``-lm`` math library,
for example).
.. ghc-flag:: -l ⟨lib⟩
+ :shortdesc: Link in library ⟨lib⟩
+ :type: dynamic
+ :category: linking
Link in the ⟨lib⟩ library. On Unix systems, this will be in a file
called :file:`lib{lib}.a` or :file:`lib{lib}.so` which resides somewhere on the
@@ -518,12 +648,18 @@ for example).
and pass ``-no-hs-main``. See also :ref:`using-own-main`.
.. ghc-flag:: -c
+ :shortdesc: Stop after generating object (``.o``) file
+ :type: mode
+ :category: linking
Omits the link step. This option can be used with :ghc-flag:`--make` to
avoid the automatic linking that takes place if the program contains
a ``Main`` module.
.. ghc-flag:: -package ⟨name⟩
+ :shortdesc: Expose package ⟨pkg⟩
+ :type: dynamic/ ``:set``
+ :category: linking
If you are using a Haskell "package" (see :ref:`packages`), don't
forget to add the relevant ``-package`` option when linking the
@@ -532,6 +668,10 @@ for example).
result in several pages of link errors.
.. ghc-flag:: -framework ⟨name⟩
+ :shortdesc: On Darwin/OS X/iOS only, link in the framework ⟨name⟩. This
+ option corresponds to the ``-framework`` option for Apple's Linker.
+ :type: dynamic
+ :category: linking
On Darwin/OS X/iOS only, link in the framework ⟨name⟩. This option
corresponds to the ``-framework`` option for Apple's Linker. Please
@@ -541,17 +681,31 @@ for example).
for example, you'd use ``-framework Carbon``.
.. ghc-flag:: -staticlib
+ :shortdesc: Generate a standalone static library (as opposed to an
+ executable). This is useful when cross compiling. The
+ library together with all its dependencies ends up in in a
+ single static library that can be linked against.
+ :type: dynamic
+ :category: linking
Link all passed files into a static library suitable for linking.
To control the name, use the :ghc-flag:`-o ⟨file⟩` option
as usual. The default name is ``liba.a``.
.. ghc-flag:: -L ⟨dir⟩
+ :shortdesc: Add ⟨dir⟩ to the list of directories searched for libraries
+ :type: dynamic
+ :category: linking
Where to find user-supplied libraries… Prepend the directory ⟨dir⟩
to the library directories path.
.. ghc-flag:: -framework-path ⟨dir⟩
+ :shortdesc: On Darwin/OS X/iOS only, add ⟨dir⟩ to the list of directories
+ searched for frameworks. This option corresponds to the ``-F``
+ option for Apple's Linker.
+ :type: dynamic
+ :category: linking
On Darwin/OS X/iOS only, prepend the directory ⟨dir⟩ to the
framework directories path. This option corresponds to the ``-F``
@@ -559,6 +713,9 @@ for example).
GHC).
.. ghc-flag:: -split-objs
+ :shortdesc: Split objects (for libraries)
+ :type: dynamic
+ :category: linking
Tell the linker to split the single object file that would normally
be generated into multiple object files, one per top-level Haskell
@@ -571,6 +728,9 @@ for example).
larger. We use this feature for building GHC's libraries.
.. ghc-flag:: -split-sections
+ :shortdesc: Split sections for link-time dead-code stripping
+ :type: dynamic
+ :category: linking
Place each generated function or data item into its own section in the
output file if the target supports arbitrary sections. The name of the
@@ -583,11 +743,17 @@ for example).
files are about 30% smaller than with :ghc-flag:`-split-objs`.
.. ghc-flag:: -static
+ :shortdesc: Use static Haskell libraries
+ :type: dynamic
+ :category: linking
Tell the linker to avoid shared Haskell libraries, if possible. This
is the default.
.. ghc-flag:: -dynamic
+ :shortdesc: Build dynamically-linked object files and executables
+ :type: dynamic
+ :category: linking
This flag tells GHC to link against shared Haskell libraries. This
flag only affects the selection of dependent libraries, not the form
@@ -598,6 +764,9 @@ for example).
above).
.. ghc-flag:: -shared
+ :shortdesc: Generate a shared library (as opposed to an executable)
+ :type: dynamic
+ :category: linking
Instead of creating an executable, GHC produces a shared object with
this linker flag. Depending on the operating system target, this
@@ -618,12 +787,18 @@ for example).
when linked against this package. See shared object name mangling.
.. ghc-flag:: -dynload
+ :shortdesc: Selects one of a number of modes for finding shared libraries at runtime.
+ :type: dynamic
+ :category: linking
This flag selects one of a number of modes for finding shared
libraries at runtime. See :ref:`finding-shared-libs` for a
description of each mode.
.. ghc-flag:: -main-is ⟨thing⟩
+ :shortdesc: Set main module and function
+ :type: dynamic
+ :category: linking
.. index::
single: specifying your own main function
@@ -655,6 +830,9 @@ for example).
:ghc-flag:`-fforce-recomp` flag.
.. ghc-flag:: -no-hs-main
+ :shortdesc: Don't assume this program contains ``main``
+ :type: dynamic
+ :category: linking
.. index::
single: linking Haskell libraries with foreign code
@@ -684,6 +862,9 @@ for example).
:ghc-flag:`-with-rtsopts=⟨opts⟩` when using your own ``main``.
.. ghc-flag:: -debug
+ :shortdesc: Use the debugging runtime
+ :type: dynamic
+ :category: linking
Link the program with a debugging version of the runtime system. The
debugging runtime turns on numerous assertions and sanity checks,
@@ -691,6 +872,9 @@ for example).
(run the program with ``+RTS -?`` to see a list).
.. ghc-flag:: -threaded
+ :shortdesc: Use the threaded runtime
+ :type: dynamic
+ :category: linking
Link the program with the "threaded" version of the runtime system.
The threaded runtime system is so-called because it manages multiple
@@ -716,6 +900,9 @@ for example).
:ref:`ffi-threads`.
.. ghc-flag:: -eventlog
+ :shortdesc: Enable runtime event tracing
+ :type: dynamic
+ :category: linking
Link the program with the "eventlog" version of the runtime system.
A program linked in this way can generate a runtime trace of events
@@ -727,6 +914,13 @@ for example).
:ghc-flag:`-debug`.
.. ghc-flag:: -rtsopts[=⟨none|some|all⟩]
+ :shortdesc: Control whether the RTS behaviour can be tweaked via command-line
+ flags and the ``GHCRTS`` environment variable. Using ``none``
+ means no RTS flags can be given; ``some`` means only a minimum
+ of safe options can be given (the default), and ``all`` (or no
+ argument at all) means that all RTS flags are permitted.
+ :type: dynamic
+ :category: linking
:default: all
@@ -770,6 +964,9 @@ for example).
see :ref:`using-own-main` for details.
.. ghc-flag:: -with-rtsopts=⟨opts⟩
+ :shortdesc: Set the default RTS options to ⟨opts⟩.
+ :type: dynamic
+ :category: linking
This option allows you to set the default RTS options at link-time.
For example, ``-with-rtsopts="-H128m"`` sets the default heap size
@@ -783,6 +980,10 @@ for example).
``-no-hs-main``; see :ref:`using-own-main` for details.
.. ghc-flag:: -no-rtsopts-suggestions
+ :shortdesc: Don't print RTS suggestions about linking with
+ :ghc-flag:`-rtsopts[=⟨none|some|all⟩]`.
+ :type: dynamic
+ :category: linking
This option disables RTS suggestions about linking with
:ghc-flag:`-rtsopts[=⟨none|some|all⟩]` when they are not available. These
@@ -792,6 +993,9 @@ for example).
build with either ``-rtsopts`` or ``-no-rtsopts-suggestions``.
.. ghc-flag:: -fno-gen-manifest
+ :shortdesc: Do not generate a manifest file (Windows only)
+ :type: dynamic
+ :category: linking
On Windows, GHC normally generates a manifestmanifest file when
linking a binary. The manifest is placed in the file
@@ -823,6 +1027,9 @@ for example).
below.
.. ghc-flag:: -fno-embed-manifest
+ :shortdesc: Do not embed the manifest in the executable (Windows only)
+ :type: dynamic
+ :category: linking
.. index::
single: windres
@@ -838,6 +1045,9 @@ for example).
:ghc-flag:`-optwindres ⟨option⟩` (:ref:`forcing-options-through`).
.. ghc-flag:: -fno-shared-implib
+ :shortdesc: Don't generate an import library for a DLL (Windows only)
+ :type: dynamic
+ :category: linking
DLLs on Windows are typically linked to by linking to a
corresponding ``.lib`` or ``.dll.a`` — the so-called import library.
@@ -853,6 +1063,13 @@ for example).
library entirely.
.. ghc-flag:: -dylib-install-name ⟨path⟩
+ :shortdesc: Set the install name (via ``-install_name`` passed to Apple's
+ linker), specifying the full install path of the library file.
+ Any libraries or executables that link with it later will pick
+ up that path as their runtime search location for it.
+ (Darwin/OS X only)
+ :type: dynamic
+ :category: linking
On Darwin/OS X, dynamic libraries are stamped at build time with an
"install name", which is the ultimate install path of the library
@@ -864,6 +1081,13 @@ for example).
on other platforms.
.. ghc-flag:: -rdynamic
+ :shortdesc: This instructs the linker to add all symbols, not only used
+ ones, to the dynamic symbol table. Currently Linux and
+ Windows/MinGW32 only. This is equivalent to using
+ ``-optl -rdynamic`` on Linux, and ``-optl -export-all-symbols``
+ on Windows.
+ :type: dynamic
+ :category: linking
This instructs the linker to add all symbols, not only used ones, to
the dynamic symbol table. Currently Linux and Windows/MinGW32 only.
@@ -871,6 +1095,11 @@ for example).
``-optl -export-all-symbols`` on Windows.
.. ghc-flag:: -fwhole-archive-hs-libs
+ :shortdesc: When linking a binary executable, this inserts the flag
+ ``-Wl,--whole-archive`` before any ``-l`` flags for Haskell
+ libraries, and ``-Wl,--no-whole-archive`` afterwards
+ :type: dynamic
+ :category: linking
When linking a binary executable, this inserts the flag
``-Wl,--whole-archive`` before any ``-l`` flags for Haskell