Test Trac #9036
[ghc.git] / docs / comm / genesis / genesis.html
2 <html>
3 <head>
4 <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">
5 <title>The GHC Commentary - Outline of the Genesis</title>
6 </head>
9 <h1>The GHC Commentary - Outline of the Genesis</h1>
10 <p>
11 Building GHC happens in two stages: First you have to prepare the tree
12 with <code>make boot</code>; and second, you build the compiler and
13 associated libraries with <code>make all</code>. The <code>boot</code>
14 stage builds some tools used during the main build process, generates
15 parsers and other pre-computed source, and finally computes dependency
16 information. There is considerable detail on the build process in GHC's
17 <a
18 href="http://ghc.haskell.org/trac/ghc/wiki/Building">Building Guide.</a>
20 <h4>Debugging the Beast</h4>
21 <p>
22 If you are hacking the compiler or like to play with unstable
23 development versions, chances are that the compiler someday just crashes
24 on you. Then, it is a good idea to load the <code>core</code> into
25 <code>gdb</code> as usual, but unfortunately there is usually not too
26 much useful information.
27 <p>
28 The next step, then, is somewhat tedious. You should build a compiler
29 producing programs with a runtime system that has debugging turned on
30 and use that to build the crashing compiler. There are many sanity
31 checks in the RTS, which may detect inconsistency before they lead to a
32 crash and you may include more debugging information, which helps
33 <code>gdb.</code> For a RTS with debugging turned on, add the following
34 to <code>build.mk</code> (see also the comment in
35 <a
36 href="http://cvs.haskell.org/cgi-bin/cvsweb.cgi/fptools/mk/config.mk.in"><code>config.mk.in</code></a> that you find when searching for
37 <code>GhcRtsHcOpts</code>):
38 <blockquote><pre>
39 GhcRtsHcOpts+=-optc-DDEBUG
40 GhcRtsCcOpts+=-g
41 EXTRA_LD_OPTS=-lbfd -liberty</pre></blockquote>
42 <p>
43 Then go into <code>fptools/ghc/rts</code> and <code>make clean boot &&
44 make all</code>. With the resulting runtime system, you have to re-link
45 the compiler. Go into <code>fptools/ghc/compiler</code>, delete the
46 file <code>hsc</code> (up to version 4.08) or
47 <code>ghc-&lt;version&gt;</code>, and execute <code>make all</code>.
48 <p>
49 The <code>EXTRA_LD_OPTS</code> are necessary as some of the debugging
50 code uses the BFD library, which in turn requires <code>liberty</code>.
51 I would also recommend (in 4.11 and from 5.0 upwards) adding these linker
52 options to the files <code>package.conf</code> and
53 <code>package.conf.inplace</code> in the directory
54 <code>fptools/ghc/driver/</code> to the <code>extra_ld_opts</code> entry
55 of the package <code>RTS</code>. Otherwise, you have to supply them
56 whenever you compile and link a program with a compiler that uses the
57 debugging RTS for the programs it produces.
58 <p>
59 To run GHC up to version 4.08 in <code>gdb</code>, first invoke the
60 compiler as usual, but pass it the option <code>-v</code>. This will
61 show you the exact invocation of the compiler proper <code>hsc</code>.
62 Run <code>hsc</code> with these options in <code>gdb</code>. The
63 development version 4.11 and stable releases from 5.0 on do no longer
64 use the Perl driver; so, you can run them directly with gdb.
65 <p>
66 <strong>Debugging a compiler during building from HC files.</strong>
67 If you are boot strapping the compiler on new platform from HC files and
68 it crashes somewhere during the build (e.g., when compiling the
69 libraries), do as explained above, but you may have to re-configure the
70 build system with <code>--enable-hc-boot</code> before re-making the
71 code in <code>fptools/ghc/driver/</code>.
72 If you do this with a compiler up to version 4.08, run the build process
73 with <code>make EXTRA_HC_OPTS=-v</code> to get the exact arguments with
74 which you have to invoke <code>hsc</code> in <code>gdb</code>.
76 <p><small>
77 <!-- hhmts start -->
78 Last modified: Sun Apr 24 22:16:30 CEST 2005
79 <!-- hhmts end -->
80 </small>
81 </body>
82 </html>