add -fflatten and -funsafe-skolemize flags
[ghc-hetmet.git] / driver / ghc-usage.txt
1 Usage:
2
3     $$ [command-line-options-and-input-files]
4
5 To compile and link a complete Haskell program, run the compiler like
6 so:
7
8     $$ --make Main
9
10 where the module Main is in a file named Main.hs (or Main.lhs) in the
11 current directory.  The other modules in the program will be located
12 and compiled automatically, and the linked program will be placed in
13 the file `a.out' (or `Main.exe' on Windows).
14
15 Alternatively, $$ can be used to compile files individually.  Each
16 input file is guided through (some of the) possible phases of a
17 compilation:
18
19     - unlit:    extract code from a "literate program"
20     - hscpp:    run code through the C pre-processor (if -cpp flag given)
21     - hsc:      run the Haskell compiler proper
22     - gcc:      run the C compiler (if compiling via C)
23     - as:       run the assembler
24     - ld:       run the linker
25
26 For each input file, the phase to START with is determined by the
27 file's suffix:
28
29     - .lhs      literate Haskell                 unlit
30     - .hs       plain Haskell                    ghc
31     - .hc       C from the Haskell compiler      gcc
32     - .c        C not from the Haskell compiler  gcc
33     - .s        assembly language                as
34     - other     passed directly to the linker    ld
35
36 The phase at which to STOP processing is determined by a command-line
37 option:
38
39     -E          stop after generating preprocessed, de-litted Haskell
40                      (used in conjunction with -cpp)
41     -C          stop after generating C (.hc output)
42     -S          stop after generating assembler (.s output)
43     -c          stop after generating object files (.o output)
44
45 Other commonly-used options are:
46
47     -v[n]           Control verbosity (n is 0--5, normal verbosity level is 1,
48                       -v alone is equivalent to -v3)
49
50     -fglasgow-exts  Allow Glasgow extensions (unboxed types, etc.)
51
52     -O              An `optimising' package of compiler flags, for faster code
53
54     -prof           Compile for cost-centre profiling
55                      (add -auto-all for automagic cost-centres on all
56                       top-level functions)
57
58     -H14m           Increase compiler's heap size (might make compilation
59                     faster, especially on large source files).
60
61     -M              Output Makefile rules recording the
62                     dependencies of a list of Haskell files.
63
64 Given the above, here are some TYPICAL invocations of $$:
65
66     # compile a Haskell module to a .o file, optimising:
67     % $$ -c -O Foo.hs
68     # link three .o files into an executable called "test":
69     % $$ -o test Foo.o Bar.o Baz.o
70     # compile a Haskell module to C (a .hc file), using a bigger heap:
71     % $$ -C -H16m Foo.hs
72     # compile Haskell-produced C (.hc) to assembly language:
73     % $$ -S Foo.hc
74
75 The User's Guide has more information about GHC's *many* options.  An
76 online copy can be found here:
77
78    http://haskell.org/haskellwiki/GHC
79
80 ------------------------------------------------------------------------