Using GHCGHC, usingusing GHCGHC can work in one of three “modes”:ghc––interactiveinteractive modeghciInteractive mode, which is also available as
ghci. Interactive mode is described in
more detail in .ghc––makemake modeIn this mode, GHC will build a multi-module Haskell
program automatically, figuring out dependencies for itself.
If you have a straightforward Haskell program, this is likely
to be much easier, and faster, than using
make.ghc-E-C-S-cThis is the traditional batch-compiler mode, in which
GHC can compile source files one at a time, or link objects
together into an executable.Options overviewGHC's behaviour is controlled by
options, which for historical reasons are
also sometimes referred to as command-line flags or arguments.
Options can be specified in three ways:Command-line argumentsstructure, command-linecommand-lineargumentsargumentscommand-lineAn invocation of GHC takes the following form:
ghc [argument...]
Command-line arguments are either options or file names.Command-line options begin with -.
They may not be grouped:
is different from .
Options need not precede filenames: e.g., ghc *.o -o
foo. All options are processed and then applied to
all files; you cannot, for example, invoke ghc -c -O1
Foo.hs -O2 Bar.hs to apply different optimisation
levels to the files Foo.hs and
Bar.hs.Command line options in source filessource-file optionsSometimes it is useful to make the connection between a
source file and the command-line options it requires quite
tight. For instance, if a Haskell source file uses GHC
extensions, it will always need to be compiled with the
option. Rather than maintaining
the list of per-file options in a Makefile,
it is possible to do this directly in the source file using the
OPTIONS pragma OPTIONS
pragma:
{-# OPTIONS -fglasgow-exts #-}
module X where
...
OPTIONS pragmas are only looked for at
the top of your source files, upto the first
(non-literate,non-empty) line not containing
OPTIONS. Multiple OPTIONS
pragmas are recognised. Note that your command shell does not
get to the source file options, they are just included literally
in the array of command-line arguments the compiler driver
maintains internally, so you'll be desperately disappointed if
you try to glob etc. inside OPTIONS.NOTE: the contents of OPTIONS are prepended to the
command-line options, so you do have the
ability to override OPTIONS settings via the command
line.It is not recommended to move all the contents of your
Makefiles into your source files, but in some circumstances, the
OPTIONS pragma is the Right Thing. (If you
use and have OPTION flags in
your module, the OPTIONS will get put into the generated .hc
file).Setting options in GHCiOptions may also be modified from within GHCi, using the
:set command. See
for more details.Static vs. Dynamic optionsstaticoptionsdynamicoptionsEach of GHC's command line options is classified as either
static or dynamic.
A static flag may only be specified on the command line, whereas a
dynamic flag may also be given in an OPTIONS
pragma in a source file or set from the GHCi command-line with
:set.As a rule of thumb, all the language options are dynamic, as
are the warning options and the debugging options. The rest are
static, with the notable exceptions of ,
, ,
, and .
The flag reference tables () lists
the status of each flag.Meaningful file suffixessuffixes, filefile suffixes for GHCFile names with “meaningful” suffixes (e.g.,
.lhs or .o) cause the
“right thing” to happen to those files..lhslhs suffixA “literate Haskell” module..hsA not-so-literate Haskell module..hiA Haskell interface file, probably
compiler-generated..hcIntermediate C file produced by the Haskell
compiler..cA C file not produced by the Haskell
compiler..sAn assembly-language source file, usually produced by
the compiler..oAn object file, produced by an assembler.Files with other suffixes (or without suffixes) are passed
straight to the linker.Help and verbosity optionshelp optionsverbosity optionsCause GHC to spew a long usage message to standard
output and then exit.The option makes GHC
verbose: it reports its version number
and shows (on stderr) exactly how it invokes each phase of
the compilation system. Moreover, it passes the
flag to most phases; each reports its
version number (and possibly some other information).Please, oh please, use the option
when reporting bugs! Knowing that you ran the right bits in
the right order is always the first thing we want to
verify.nTo provide more control over the compiler's verbosity,
the flag takes an optional numeric
argument. Specifying on its own is
equivalent to , and the other levels
have the following meanings:Disable all non-essential messages (this is the
default).Minimal verbosity: print one line per
compilation (this is the default when
or
is on).Print the name of each compilation phase as it
is executed. (equivalent to
).The same as , except that in
addition the full command line (if appropriate) for
each compilation phase is also printed.The same as except that the
intermediate program representation after each
compilation phase is also printed (excluding
preprocessed and C/assembly files).Print a one-line string including GHC's version number.Print GHC's numeric version number only.Print the path to GHC's library directory. This is
the top of the directory tree containing GHC's libraries,
interfaces, and include files (usually something like
/usr/local/lib/ghc-5.04 on Unix). This
is the value of
$libdirlibdirin the package configuration file (see ).Using ghcseparate compilationWhen given the option, GHC will
build a multi-module Haskell program by following dependencies
from a single root module (usually Main). For
example, if your Main module is in a file
called Main.hs, you could compile and link
the program like this:
ghc ––make Main.hs
The command line may contain any number of source file names
or module names; GHC will figure out all the modules in the
program by following the imports from these initial modules. It
will then attempt to compile each module which is out of date, and
finally if there is a Main module, the program
will also be linked into an executable.The main advantages to using ghc ––make
over traditional Makefiles are:GHC doesn't have to be restarted for each compilation,
which means it can cache information between compilations.
Compiling a muli-module program with ghc
––make can be up to twice as fast as running
ghc individually on each source
file.You don't have to write a
Makefile.MakefilesavoidingGHC re-calculates the dependencies each time it is
invoked, so the dependencies never get out of sync with the
source.Any of the command-line options described in the rest of
this chapter can be used with , but note
that any options you give on the command line will apply to all
the source files compiled, so if you want any options to apply to
a single source file only, you'll need to use an
OPTIONS pragma (see ).If the program needs to be linked with additional objects
(say, some auxilliary C code), then the object files can be
given on the command line and GHC will include them when linking
the executable.Note that GHC can only follow dependencies if it has the
source file available, so if your program includes a module for
which there is no source file, even if you have an object and an
interface file for the module, then GHC will complain. The
exception to this rule is for package modules, which may or may
not have source files.The source files for the program don't all need to be in the
same directory; the option can be used to add
directories to the search path (see ).GHC without Without , GHC will compile one or
more source files given on the command line.The first phase to run is determined by each input-file
suffix, and the last phase is determined by a flag. If no
relevant flag is present, then go all the way through linking.
This table summarises:Phase of the compilation systemSuffix saying “start here”Flag saying “stop after”(suffix of) output fileliterate pre-processor.lhs-.hsC pre-processor (opt.)
.hs (with
).hsppHaskell compiler.hs, .hc, .sC compiler (opt.).hc or .c.sassembler.s.olinkerother-a.outThus, a common invocation would be: ghc -c
Foo.hsNote: What the Haskell compiler proper produces depends on
whether a native-code generatornative-code
generator is used (producing assembly
language) or not (producing C). See for more details.Note: C pre-processing is optional, the
flag turns it on. See for more details.Note: The option -E
option runs just the pre-processing passes
of the compiler, dumping the result in a file. Note that this
differs from the previous behaviour of dumping the file to
standard output.Re-directing the compilation output(s)output-directing optionsredirecting compilation outputGHC's compiled output normally goes into a
.hc, .o, etc.,
file, depending on the last-run compilation phase. The
option -o
option re-directs the output of that
last-run phase to file foo.Note: this “feature” can be
counterintuitive: ghc -C -o foo.o foo.hs
will put the intermediate C code in the file
foo.o, name notwithstanding!Note: on Windows, if the result is an executable file, the
extension ".exe" is added if the specified filename
does not already have an extension. Thus
ghc -o foo Main.hs
will compile and link the module Main.hs, and put the
resulting executable in foo.exe (not foo).
The option isn't of much use if
you have several input files…
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
-odir
<dir> option (the “Oh,
dear” option). For example:
% ghc -c parse/Foo.hs parse/Bar.hs gurgle/Bumble.hs -odir `arch`
The output files, Foo.o,
Bar.o, and
Bumble.o would be put into a
subdirectory named after the architecture of the executing
machine (sun4,
mips, etc). The directory must already
exist; it won't be created.Note that the option does
not affect where the interface files
are put. In the above example, they would still be put in
parse/Foo.hi,
parse/Bar.hi, and
gurgle/Bumble.hi.fileThe interface output may be directed to another file
bar2/Wurble.iface with the option
(not
recommended).WARNING: if you redirect the interface file somewhere
that GHC can't find it, then the recompilation checker may
get confused (at the least, you won't get any recompilation
avoidance). We recommend using a combination of
and options
instead, if possible.To avoid generating an interface at all, you could use
this option to redirect the interface into the bit bucket:
-ohi /dev/null, for example.directoryRedirects all generated interface files into
directory, instead of the default
which is to place the interface file in the same directory
as the source file.suffixsuffixsuffixEXOTICA: The
suffix will change the
.o file suffix for object files to
whatever you specify. We use this when compiling libraries,
so that objects for the profiling versions of the libraries
don't clobber the normal ones.Similarly, the
suffix will change the
.hi file suffix for non-system interface
files (see ).Finally, the option
suffix will change the
.hc file suffix for compiler-generated
intermediate C files.The /
game is particularly useful if you want to compile a program both with and without
profiling, in the same directory. You can say:
ghc ...
to get the ordinary version, and
ghc ... -osuf prof.o -hisuf prof.hi -prof -auto-all
to get the profiled version.Keeping Intermediate Filesintermediate files, saving.hc files, saving.s files, savingThe following options are useful for keeping certain
intermediate files around, when normally GHC would throw these
away after compilation:Keep intermediate .hc files when
doing .hs-to-.o
compilations via C (NOTE: .hc files
aren't generated when using the native code generator, you
may need to use to force them
to be produced).Keep intermediate .s files.Keep intermediate .raw-s files.
These are the direct output from the C compiler, before
GHC does “assembly mangling” to produce the
.s file. Again, these are not produced
when using the native code generator.temporary fileskeepingInstructs the GHC driver not to delete any of its
temporary files, which it normally keeps in
/tmp (or possibly elsewhere; see ). Running GHC with
will show you what temporary files
were generated along the way.Redirecting temporary filestemporary filesredirectingIf you have trouble because of running out of space
in /tmp (or wherever your
installation thinks temporary files should go), you may
use the -tmpdir
<dir> option option to specify
an alternate directory. For example, says to put temporary files in the current
working directory.Alternatively, use your TMPDIR
environment variable.TMPDIR
environment variable Set it to the
name of the directory where temporary files should be put.
GCC and other programs will honour the
TMPDIR variable as well.Even better idea: Set the
DEFAULT_TMPDIR make variable when
building GHC, and never worry about
TMPDIR again. (see the build
documentation).Warnings and sanity-checkingsanity-checking optionswarningsGHC has a number of options that select which types of
non-fatal error messages, otherwise known as warnings, can be
generated during compilation. By default, you get a standard set
of warnings which are generally likely to indicate bugs in your
program. These are:
,
,
,
, and
. The following flags are
simple ways to select standard “packages” of warnings:
:-W optionProvides the standard warnings plus
,
,
,
, and
.:Turns off all warnings, including the standard ones.:Turns on all warning options.:Makes any warning into a fatal error. Useful so that you don't
miss warnings when doing batch compilation. The full set of warning options is described below. To turn
off any warning, simply give the corresponding
option on the command line.:deprecationsCauses a warning to be emitted when a deprecated
function or type is used. Entities can be marked as
deprecated using a pragma, see .:duplicate exports, warningexport lists, duplicatesHave the compiler warn about duplicate entries in
export lists. This is useful information if you maintain
large export lists, and want to avoid the continued export
of a definition after you've deleted (one) mention of it in
the export list.This option is on by default.:shadowinginterface filesCauses the compiler to emit a warning when a module or
interface file in the current directory is shadowing one
with the same module name in a library or other
directory.:incomplete patterns, warningpatterns, incompleteSimilarly for incomplete patterns, the function
g below will fail when applied to
non-empty lists, so the compiler will emit a warning about
this when is
enabled.
g [] = 2
This option isn't enabled be default because it can be
a bit noisy, and it doesn't always indicate a bug in the
program. However, it's generally considered good practice
to cover all the cases in your functions.:Turns on warnings for various harmless but untidy
things. This currently includes: importing a type with
(..) when the export is abstract, and
listing duplicate class assertions in a qualified type.:missing fields, warningfields, missingThis option is on by default, and warns you whenever
the construction of a labelled field constructor isn't
complete, missing initializers for one or more fields. While
not an error (the missing fields are initialised with
bottoms), it is often an indication of a programmer error.:missing methods, warningmethods, missingThis option is on by default, and warns you whenever
an instance declaration is missing one or more methods, and
the corresponding class declaration has no default
declaration for them.The warning is suppressed if the method name
begins with an underscore. Here's an example where this is useful:
class C a where
_simpleFn :: a -> String
complexFn :: a -> a -> String
complexFn x y = ... _simpleFn ...
The idea is that: (a) users of the class will only call complexFn;
never _simpleFn; and (b)
instance declarations can define either complexFn or _simpleFn.
:type signatures, missingIf you would like GHC to check that every top-level
function/value has a type signature, use the
option. This
option is off by default.:shadowing, warningThis option causes a warning to be emitted whenever an
inner-scope value has the same name as an outer-scope value,
i.e. the inner value shadows the outer one. This can catch
typographical errors that turn into hard-to-find bugs, e.g.,
in the inadvertent cyclic definition let x = ... x
... in.Consequently, this option does
will complain about cyclic recursive
definitions.:overlapping patterns, warningpatterns, overlappingBy default, the compiler will warn you if a set of
patterns are overlapping, i.e.,
f :: String -> Int
f [] = 0
f (_:xs) = 1
f "2" = 2
where the last pattern match in f
won't ever be reached, as the second pattern overlaps
it. More often than not, redundant patterns is a programmer
mistake/error, so this option is enabled by default.:Causes the compiler to warn about lambda-bound
patterns that can fail, eg. \(x:xs)->....
Normally, these aren't treated as incomplete patterns by
.``Lambda-bound patterns'' includes all places where there is a single pattern,
including list comprehensions and do-notation. In these cases, a pattern-match
failure is quite legitimate, and triggers filtering (list comprehensions) or
the monad fail operation (monads). For example:
f :: [Maybe a] -> [a]
f xs = [y | Just y <- xs]
Switching on will elicit warnings about
these probably-innocent cases, which is why the flag is off by default. The deriving( Read ) mechanism produces monadic code with
pattern matches, so you will also get misleading warnings about the compiler-generated
code. (This is arguably a Bad Thing, but it's awkward to fix.):defaulting mechanism, warningHave the compiler warn/inform you where in your source
the Haskell defaulting mechanism for numeric types kicks
in. This is useful information when converting code from a
context that assumed one default into one with another,
e.g., the `default default' for Haskell 1.4 caused the
otherwise unconstrained value 1 to be
given the type Int, whereas Haskell 98
defaults it to Integer. This may lead to
differences in performance and behaviour, hence the
usefulness of being non-silent about this.This warning is off by default.:unused binds, warningbinds, unusedReport any function definitions (and local bindings)
which are unused. For top-level functions, the warning is
only given if the binding is not exported.:unused imports, warningimports, unusedReport any objects that are explicitly imported but
never used.:unused matches, warningmatches, unusedReport all unused variables which arise from pattern
matches, including patterns consisting of a single variable.
For instance f x y = [] would report
x and y as unused. The
warning is suppressed if the variable name begins with an underscore, thus:
f _x = True
If you're feeling really paranoid, the
option
is a good choice. It turns on heavyweight intra-pass
sanity-checking within GHC. (It checks GHC's sanity, not
yours.)
&separate;
&packages;
Optimisation (code improvement)optimisationimprovement, codeThe options specify convenient
“packages” of optimisation flags; the
options described later on specify
individual optimisations to be turned on/off;
the options specify
machine-specific optimisations to be turned
on/off.: convenient “packages” of optimisation flags.There are many options that affect
the quality of code produced by GHC. Most people only have a
general goal, something like “Compile quickly” or
“Make my program run like greased lightning.” The
following “packages” of optimisations (or lack
thereof) should suffice.Once you choose a
“package,” stick with it—don't chop and
change. Modules' interfaces will change
with a shift to a new option, and you may
have to recompile a large chunk of all importing modules before
your program can again be run safely (see ).No -type option specified:-O* not specifiedThis is taken to mean: “Please compile
quickly; I'm not over-bothered about compiled-code
quality.” So, for example: ghc -c
Foo.hs:Means “turn off all optimisation”,
reverting to the same settings as if no
options had been specified. Saying
can be useful if
eg. make has inserted a
on the command line already. or :-O option-O1 optionoptimisenormallyMeans: “Generate good-quality code without
taking too long about it.” Thus, for example:
ghc -c -O Main.lhs:-O2 optionoptimiseaggressivelyMeans: “Apply every non-dangerous
optimisation, even if it means significantly longer
compile times.”The avoided “dangerous” optimisations
are those that can make runtime or space
worse if you're unlucky. They are
normally turned on or off individually.At the moment, is
unlikely to produce better code than
.:-Ofile <file> optionoptimising, customised(NOTE: not supported yet in GHC 5.x. Please ask if
you're interested in this.)For those who need absolute
control over exactly what options are
used (e.g., compiler writers, sometimes :-), a list of
options can be put in a file and then slurped in with
.In that file, comments are of the
#-to-end-of-line variety; blank
lines and most whitespace is ignored.Please ask if you are baffled and would like an
example of !We don't use a flag for day-to-day
work. We use to get respectable speed;
e.g., when we want to measure something. When we want to go for
broke, we tend to use (and we go for
lots of coffee breaks).The easiest way to see what (etc.)
“really mean” is to run with ,
then stand back in amazement.: platform-independent flags-f* options (GHC)-fno-* options (GHC)These flags turn on and off individual optimisations.
They are normally set via the 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::When this option is given, intermediate floating
point values can have a greater
precision/range than the final type. Generally this is a
good thing, but some programs may rely on the exact
precision/range of
Float/Double values
and should not use this option for their compilation.:Causes GHC to ignore uses of the function
Exception.assert in source code (in
other words, rewriting Exception.assert p
e to e (see ). This flag is turned on by
.
Turns off the strictness analyser; sometimes it eats
too many cycles.Turns off the CPR (constructed product result)
analysis; it is somewhat experimental.:strict constructor fieldsconstructor fields, strictThis option causes all constructor fields which are
marked strict (i.e. “!”) to be unboxed or
unpacked if possible. For example:
data T = T !Float !Float
will create a constructor T
containing two unboxed floats if the
flag is given.
This may not always be an optimisation: if the
T 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).This option should only be used in conjunction with
, in order to expose unfoldings to the
compiler so the reboxing can be removed as often as
possible. For example:
f :: T -> Float
f (T f1 f2) = f1 + f2
The compiler will avoid reboxing
f1 and f2 by
inlining + on floats, but only when
is on.Any single-constructor data is eligible for
unpacking; for example
data T = T !(Int,Int)
will store the two Ints directly
in the T constructor, by flattening
the pair. Multi-level unpacking is also supported:
data T = T !S
data S = S !Int !Int
will store two unboxed Int#s
directly in the T constructor.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.
x = plusInt a b
If we inlined plusInt we might get an opportunity to use
update-in-place for the thunk 'x'.:inlining, controllingunfolding, controlling(Default: 45) Governs the maximum size that GHC will
allow a function unfolding to be. (An unfolding has a
“size” that reflects the cost in terms of
“code bloat” of expanding that unfolding at
at a call site. A bigger function would be assigned a
bigger cost.) Consequences: (a) nothing larger than this will be
inlined (unless it has an INLINE pragma); (b) nothing
larger than this will be spewed into an interface
file. Increasing this figure is more likely to result in longer
compile times than faster code. The next option is more
useful::inlining, controllingunfolding, controlling(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 ).
&phases;
Using Concurrent HaskellConcurrent Haskell—use
GHC 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, just import
Control.Concurrent (details are in the accompanying
library documentation).
RTS options are provided for modifying the behaviour of the threaded
runtime system. See .
Concurrent Haskell is described in more detail in the documentation
for the Control.Concurrent module.
Using Parallel HaskellParallel Haskell—use
[You won't be able to execute parallel Haskell programs unless PVM3
(Parallel Virtual Machine, version 3) is installed at your site.]
To compile a Haskell program for parallel execution under PVM, use the
option,-parallel
option both when compiling and
linking. You will probably want to import
Parallel into your Haskell modules.
To run your parallel program, once PVM is going, just invoke it
“as normal”. The main extra RTS option is
, to say how many PVM
“processors” your program to run on. (For more details of
all relevant RTS options, please see .)
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.
Dummy's guide to using PVMPVM, how to useParallel Haskell—PVM use
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 .cshrc or equivalent:
setenv PVM_ROOT /wherever/you/put/it
setenv PVM_ARCH `$PVM_ROOT/lib/pvmgetarch`
setenv PVM_DPATH $PVM_ROOT/lib/pvmd
Creating and/or controlling your “parallel machine” is a purely-PVM
business; nothing specific to Parallel Haskell. The following paragraphs
describe how to configure your parallel machine interactively.
If you use parallel Haskell regularly on the same machine configuration it
is a good idea to maintain a file with all machine names and to make the
environment variable PVM_HOST_FILE point to this file. Then you can avoid
the interactive operations described below by just saying
pvm $PVM_HOST_FILE
You use the pvmpvm command command to start PVM on your
machine. You can then do various things to control/monitor your
“parallel machine;” the most useful being:
ControlDexit pvm, leaving it runninghaltkill off this “parallel machine” & exitadd <host>add <host> as a processordelete <host>delete <host>resetkill what's going, but leave PVM upconflist the current configurationpsreport processes' statuspstat <pid>status of a particular process
The PVM documentation can tell you much, much more about pvm!
Parallelism profilesparallelism profilesprofiles, parallelismvisualisation tools
With Parallel Haskell programs, we usually don't care about the
results—only with “how parallel” it was! We want pretty pictures.
Parallelism profiles (à la hbcpp) can be generated with the
-qP RTS option (concurrent, parallel) RTS option. The
per-processor profiling info is dumped into files named
<full-path><program>.gr. These are then munged into a PostScript picture,
which you can then display. For example, to run your program
a.out on 8 processors, then view the parallelism profile, do:
$ ./a.out +RTS -qP -qp8
$ grs2gr *.???.gr > temp.gr # combine the 8 .gr files into one
$ gr2ps -O temp.gr # cvt to .ps; output in temp.ps
$ ghostview -seascape temp.ps # look at it!
The scripts for processing the parallelism profiles are distributed
in ghc/utils/parallel/.
Other useful info about running parallel programs
The “garbage-collection statistics” RTS options can be useful for
seeing what parallel programs are doing. If you do either
-Sstderr RTS option or , 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 /tmp/pvml.nnn, courtesy of PVM.
Whether doing or not, a handy way to watch
what's happening overall is: tail -f /tmp/pvml.nnn.
RTS options for Concurrent/Parallel Haskell
RTS options, concurrentRTS options, parallelConcurrent Haskell—RTS optionsParallel Haskell—RTS options
Besides the usual runtime system (RTS) options
(), there are a few options particularly
for concurrent/parallel execution.
:-qp<N> RTS option
(PARALLEL ONLY) Use <N> PVM processors to run this program;
the default is 2.
:-C<us> RTS option Sets
the context switch interval to <s> seconds.
A context switch will occur at the next heap block allocation after
the timer expires (a heap block allocation occurs every 4k of
allocation). With or ,
context switches will occur as often as possible (at every heap block
allocation). By default, context switches occur every 20ms
milliseconds. Note that GHC's internal timer ticks every 20ms, and
the context switch timer is always a multiple of this timer, so 20ms
is the maximum granularity available for timed context switches.
:-q RTS option
(PARALLEL ONLY) Produce a quasi-parallel profile of thread activity,
in the file <program>.qp. In the style of hbcpp, this profile
records the movement of threads between the green (runnable) and red
(blocked) queues. If you specify the verbose suboption (), 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
hbcpp profiling tools or if you are context switching at every heap
check (with ).
-->
:-qt<num> RTS option
(PARALLEL ONLY) Limit the thread pool size, i.e. the number of concurrent
threads per processor to <num>. The default is
32. Each thread requires slightly over 1K words 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.)
:-qe<num> RTS option
(parallel) (PARALLEL ONLY) Limit the spark pool size
i.e. the number of pending sparks per processor to
<num>. The default is 100. A larger number may be
appropriate if your program generates large amounts of parallelism
initially.
:-qQ<num> RTS option (parallel)
(PARALLEL ONLY) Set the size of packets transmitted between processors
to <num>. The default is 1024 words. A larger number may be
appropriate if your machine has a high communication cost relative to
computation speed.
:-qh<num> RTS option (parallel)
(PARALLEL ONLY) Select a packing scheme. Set the number of non-root thunks to pack in one packet to
<num>-1 (0 means infinity). By default GUM uses full-subgraph
packing, i.e. the entire subgraph with the requested closure as root is
transmitted (provided it fits into one packet). Choosing a smaller value
reduces the amount of pre-fetching of work done in GUM. This can be
advantageous for improving data locality but it can also worsen the balance
of the load in the system.
:-qg<num> RTS option
(parallel) (PARALLEL ONLY) Select a globalisation
scheme. This option affects the
generation of global addresses when transferring data. Global addresses are
globally unique identifiers required to maintain sharing in the distributed
graph structure. Currently this is a binary option. With <num>=0 full globalisation is used
(default). This means a global address is generated for every closure that
is transmitted. With <num>=1 a thunk-only globalisation scheme is
used, which generated global address only for thunks. The latter case may
lose sharing of data but has a reduced overhead in packing graph structures
and maintaining internal tables of global addresses.
Platform-specific Flags-m* optionsplatform-specific optionsmachine-specific optionsSome flags only make sense for particular target
platforms.:(SPARC machines)-mv8 option (SPARC
only) 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 GCC options for SPARC also
work, actually.:(iX86 machines)-monly-N-regs
option (iX86 only) GHC tries to
“steal” 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:
Foo.hc:533: fixed or forbidden register was spilled.
This may be due to a compiler bug or to impossible asm
statements or clauses.
Just give some registers back with
. Try `3' first, then `2'.
If `2' doesn't work, please report the bug to us.
&runtime;
Generating and compiling External Core Filesintermediate code generationGHC can dump its optimized intermediate code (said to be in “Core” format)
to a file as a side-effect of compilation. Core files, which are given the suffix
.hcr, can be read and processed by non-GHC back-end
tools. The Core format is formally described in An External Representation for the GHC Core Language,
and sample tools (in Haskell)
for manipulating Core files are available in the GHC source distribution
directory /fptools/ghc/utils/ext-core.
Note that the format of .hcr
files is different (though similar) to the Core output format generated
for debugging purposes ().The Core format natively supports notes which you can add to
your source code using the CORE pragma (see ).Generate .hcr files.GHC can also read in External Core files as source; just give the .hcr file on
the command line, instead of the .hs or .lhs Haskell source.
A current infelicity is that you need to give teh -fglasgow-exts flag too, because
ordinary Haskell 98, when translated to External Core, uses things like rank-2 types.
&debug;
&flags;