The Glasgow Haskell Compiler User's Guide, Version 4.08
Total Page:16
File Type:pdf, Size:1020Kb
The Glasgow Haskell Compiler User's Guide, Version 4.08 The GHC Team The Glasgow Haskell Compiler User's Guide, Version 4.08 by The GHC Team Table of Contents The Glasgow Haskell Compiler License ......................................................................................-999 1. Introduction to GHC .................................................................................................................-999 1.1. The (batch) compilation system components..................................................................-999 1.2. What really happens when I “compile” a Haskell program? ..........................................-999 1.3. Meta-information: Web sites, mailing lists, etc. .............................................................-999 1.4. GHC version numbering policy ......................................................................................-999 1.5. Release notes for version 4.08 (July 2000) ........................................................................13 1.5.1. User-visible compiler changes...............................................................................13 1.5.2. User-visible library changes ..................................................................................14 1.5.3. Internal changes.....................................................................................................14 2. Installing GHC..............................................................................................................................16 2.1. Installing on Unix-a-likes...................................................................................................16 2.1.1. When a platform-specific package is available .....................................................16 2.1.2. GHC binary distributions.......................................................................................16 2.1.2.1. Installing ...................................................................................................18 2.1.2.2. What bundles there are..............................................................................19 2.1.2.3. Testing that GHC seems to be working ....................................................20 2.2. Installing on Windows........................................................................................................20 2.2.1. Installing GHC.......................................................................................................21 2.2.2. Installing ghc-win32 FAQ .....................................................................................21 2.3. Building the documentation ...............................................................................................22 2.3.1. Installing the DocBook tools from RPMs .............................................................22 2.3.2. Installing DocBook on FreeBSD...........................................................................22 2.3.3. Installing from binaries on Windows ....................................................................22 2.3.4. Installing the DocBook tools from source.............................................................23 2.3.4.1. Jade ...........................................................................................................23 2.3.4.2. DocBook and the DocBook stylesheets....................................................23 2.3.5. Configuring the DocBook tools.............................................................................23 2.3.6. Remaining problems..............................................................................................23 3. Using GHC ....................................................................................................................................25 3.1. Overall command-line structure.........................................................................................25 3.2. Meaningful file suffixes......................................................................................................25 3.3. Help and verbosity options.................................................................................................26 3.4. Running the right phases in the right order........................................................................26 3.5. Re-directing the compilation output(s) ..............................................................................27 3.5.1. Saving GHC’s standard error output .....................................................................27 3.5.2. Redirecting temporary files ...................................................................................28 3.6. Warnings and sanity-checking ...........................................................................................28 3.7. Separate compilation..........................................................................................................30 3.7.1. Interface files .........................................................................................................30 3.7.2. Finding interface files ............................................................................................31 3 3.7.3. Other options related to interface files...................................................................32 3.7.4. The recompilation checker ....................................................................................32 3.7.4.1. Packages....................................................................................................33 3.7.5. Using make ...........................................................................................................34 3.7.6. Dependency generation .........................................................................................35 3.7.7. How to compile mutually recursive modules ........................................................37 3.8. Optimisation (code improvement) .....................................................................................38 3.8.1. -O*: convenient “packages” of optimisation flags. ...............................................38 3.8.2. -f*: platform-independent flags ...........................................................................39 3.8.3. -m*: platform-specific flags...................................................................................42 3.8.4. Code improvement by the C compiler...................................................................42 3.9. Options related to a particular phase..................................................................................42 3.9.1. The C pre-processor ..............................................................................................43 3.9.2. Options affecting the C compiler (if applicable)...................................................44 3.9.3. Linking and consistency-checking ........................................................................44 3.10. Using Concurrent Haskell................................................................................................46 3.11. Using Parallel Haskell......................................................................................................46 3.11.1. Dummy’s guide to using PVM............................................................................46 3.11.2. Parallelism profiles ..............................................................................................47 3.11.3. Other useful info about running parallel programs .............................................47 3.11.4. RTS options for Concurrent/Parallel Haskell ......................................................47 3.12. Running a compiled program...........................................................................................49 3.12.1. RTS options to control the garbage-collector......................................................49 3.12.2. RTS options for profiling and Concurrent/Parallel Haskell.................................51 3.12.3. RTS options for hackers, debuggers, and over-interested souls ..........................52 3.12.4. “Hooks” to change RTS behaviour......................................................................52 3.13. Debugging the compiler...................................................................................................55 3.13.1. Replacing the program for one or more phases...................................................55 3.13.2. Forcing options to a particular phase...................................................................55 3.13.3. Dumping out compiler intermediate structures ...................................................56 3.13.4. Checking for consistency.....................................................................................59 3.13.5. How to read Core syntax (from some -ddump-* flags) .....................................59 3.13.6. Command line options in source files .................................................................61 4. Profiling .........................................................................................................................................62 4.1. Cost centres and cost-centre stacks....................................................................................62 4.1.1. Inserting cost centres by hand ...............................................................................64 4.1.2. Rules for attributing costs......................................................................................65 4.2. Profiling memory usage .....................................................................................................65