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 ........................................................................................... 9 1. Introduction to GHC ....................................................................................................................10 1.1. The (batch) compilation system components.....................................................................10 1.2. What really happens when I “compile” a Haskell program? .............................................11 1.3. Meta-information: Web sites, mailing lists, etc. ................................................................11 1.4. GHC version numbering policy .........................................................................................12 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 from binary distributions............................................................................................16 2.1. Installing on Unix-a-likes...................................................................................................16 2.1.1. Bundle structure.....................................................................................................16 2.1.1.1. Installing ...................................................................................................18 2.1.1.2. What bundles there are..............................................................................19 2.1.1.3. Testing that GHC seems to be working ....................................................20 2.2. Installing on Windows........................................................................................................20 2.2.1. System requirements .............................................................................................21 2.2.2. Software required ..................................................................................................21 2.2.2.1. The cygwin toolchain (beta20.1) ..............................................................21 2.2.2.2. Environment variables ..............................................................................22 2.2.2.3. Perl5 ..........................................................................................................22 2.2.3. Installing GHC.......................................................................................................23 2.2.4. Installing ghc-win32 FAQ .....................................................................................24 2.3. Building the documentation ...............................................................................................24 2.3.1. Installing the DocBook tools from RPMs .............................................................24 2.3.2. Installing from binaries on Windows ....................................................................25 2.3.3. Installing the DocBook tools from source.............................................................25 2.3.3.1. Jade ...........................................................................................................25 2.3.3.2. DocBook and the DocBook stylesheets....................................................25 2.3.4. Configuring the DocBook tools.............................................................................26 2.3.5. Remaining problems..............................................................................................26 3. Using GHC ....................................................................................................................................27 3.1. Overall command-line structure.........................................................................................27 3.2. Meaningful file suffixes......................................................................................................27 3.3. Help and verbosity options.................................................................................................28 3.4. Running the right phases in the right order........................................................................28 3.5. Re-directing the compilation output(s) ..............................................................................29 3.5.1. Keeping Intermediate Files....................................................................................30 3.5.2. Saving GHC’s standard error output .....................................................................30 3.5.3. Redirecting temporary files ...................................................................................30 3 3.6. Warnings and sanity-checking ...........................................................................................31 3.7. Separate compilation..........................................................................................................33 3.7.1. Interface files .........................................................................................................33 3.7.2. Finding interface files ............................................................................................34 3.7.3. Other options related to interface files...................................................................35 3.7.4. The recompilation checker ....................................................................................35 3.7.5. Using make ...........................................................................................................36 3.7.6. Dependency generation .........................................................................................37 3.7.7. How to compile mutually recursive modules ........................................................39 3.8. Packages.............................................................................................................................41 3.8.1. Listing the available packages...............................................................................41 3.8.2. Using a package.....................................................................................................41 3.8.3. Building a package from Haskell source...............................................................41 3.8.4. Package management ............................................................................................42 3.9. Optimisation (code improvement) .....................................................................................44 3.9.1. -O*: convenient “packages” of optimisation flags. ...............................................44 3.9.2. -f*: platform-independent flags ...........................................................................46 3.9.3. -m*: platform-specific flags...................................................................................48 3.9.4. Code improvement by the C compiler...................................................................49 3.10. Options related to a particular phase................................................................................49 3.10.1. The C pre-processor ............................................................................................49 3.10.2. Options affecting the C compiler (if applicable).................................................51 3.10.3. Linking and consistency-checking ......................................................................51 3.11. Using Concurrent Haskell................................................................................................52 3.12. Using Parallel Haskell......................................................................................................53 3.12.1. Dummy’s guide to using PVM............................................................................53 3.12.2. Parallelism profiles ..............................................................................................54 3.12.3. Other useful info about running parallel programs .............................................54 3.12.4. RTS options for Concurrent/Parallel Haskell ......................................................54 3.13. Running a compiled program...........................................................................................56 3.13.1. RTS options to control the garbage-collector......................................................56 3.13.2. RTS options for profiling and Concurrent/Parallel Haskell.................................59 3.13.3. RTS options for hackers, debuggers, and over-interested souls ..........................59 3.13.4. “Hooks” to change RTS behaviour......................................................................60 3.14. Debugging the compiler...................................................................................................62 3.14.1. Replacing the program for one or more phases...................................................62 3.14.2. Forcing options to a particular phase...................................................................62 3.14.3. Dumping out compiler intermediate structures