95a8a9e6c85f508ea1b2ef2fbccb87851addc878
[ghc-hetmet.git] / ghc / driver / ghc-usage.txt
1 Use of the Glasgow Haskell Compiler driver:
2
3     $$ [command-line-options-and-input-files]
4
5 ------------------------------------------------------------------------
6 This driver ($$) guides each input file through (some of the)
7 possible phases of a compilation:
8
9     - unlit:    extract code from a "literate program"
10     - hscpp:    run code through the C pre-processor (if -cpp flag given)
11     - hsc:      run the Haskell compiler proper
12     - gcc:      run the C compiler (if compiling via C)
13     - as:       run the assembler
14     - ld:       run the linker
15
16 For each input file, the phase to START with is determined by the
17 file's suffix:
18     - .lhs      literate Haskell: unlit
19     - .hs       illiterate Haskell: hsc
20     - .hc       C from the Haskell compiler: gcc
21     - .c        C not from the Haskell compiler: gcc
22     - .s        assembly language: as
23     - other     passed directly to the linker: ld
24
25 If no files are given on the command line, input is taken from
26 standard input, and processing is as for an .hs file.  (All output is
27 to stdout or stderr, however).
28
29 The phase at which to STOP processing is determined by a command-line
30 option:
31     -E          stop after generating preprocessed, de-litted Haskell
32                      (used in conjunction with -cpp)
33     -C          stop after generating C (.hc output)
34     -S          stop after generating assembler (.s output)
35     -c          stop after generating object files (.o output)
36
37 Other commonly-used options are:
38
39     -O          An `optimising' package of compiler flags, for faster code
40
41     -prof       Compile for cost-centre profiling
42                  (add -auto for automagic cost-centres on top-level functions)
43
44     -fglasgow-exts  Allow Glasgow extensions (unboxed types, etc.)
45
46     -H14m       Increase compiler's heap size
47
48     -M          Output the Makefile rules recording the
49                  dependencies of a list of Haskell files.
50                  (ghc driver script calls upon the help of a
51                   compatible mkdependHS script to do the actual
52                   processing)
53
54 The User's Guide has more information about GHC's *many* options.
55
56 Given the above, here are some TYPICAL invocations of $$:
57
58     # compile a Haskell module to a .o file, optimising:
59     % $$ -c -O Foo.hs
60     # link three .o files into an executable called "test":
61     % $$ -o test Foo.o Bar.o Baz.o
62     # compile a Haskell module to C (a .hc file), using a bigger heap:
63     % $$ -C -H16m Foo.hs
64     # compile Haskell-produced C (.hc) to assembly language:
65     % $$ -S Foo.hc
66 ------------------------------------------------------------------------