X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=docs%2Fbuilding%2Fbuilding.sgml;h=7196bf1c499e8a7e6d9387eb8a29b20de025b660;hb=38178e3b480cbe8487df8ad3083c0938db5be7ac;hp=bd5246c598cf56cd7461655577c95f2a0a60adcc;hpb=cab3c5cb1a0038412472172cb0b25bc81dfdde8f;p=ghc-hetmet.git diff --git a/docs/building/building.sgml b/docs/building/building.sgml index bd5246c..7196bf1 100644 --- a/docs/building/building.sgml +++ b/docs/building/building.sgml @@ -58,7 +58,7 @@ the parser specifications. If you don't want to alter the parser then this saves you having to find and install happy. You will still need a working - version of GHC (preferably version 4.08+) on your machine in + version of GHC (version 5.x or later) on your machine in order to compile (most of) the sources, however. @@ -137,6 +137,12 @@ Set your $CVSROOT environment variable to :pserver:anoncvs@glass.cse.ogi.edu:/cvs + If you set $CVSROOT in a shell script, be sure not to + have any trailing spaces on that line, otherwise CVS will respond with + a perplexing message like + + /cvs : no such repository + Run the command @@ -434,8 +440,8 @@ setsockopt IPTOS_THROUGHPUT: Invalid argument ). Remember that if you do not have - happy installed, you need to check it out - as well. + happy and/or Alex + installed, you need to check them out as well. @@ -720,6 +726,17 @@ $ cvs checkout nofib/spectral + alex + alex + project + + The Alex lexical + analyser generator for Haskell. + + + + ghc ghc project @@ -989,12 +1006,21 @@ $ cvs checkout nofib/spectral sparc-sun-solaris2 sparc-sun-solaris2 - Fully supported (at least for Solaris 2.7), + Fully supported (at least for Solaris 2.7 and 2.6), including native-code generator. + sparc-unknown-openbsd + sparc-unknown-openbsd + + Supported, including native-code generator. The + same should also be true of NetBSD + + + + hppa1.1-hp-hpux (HP-PA boxes running HPUX 9.x) hppa1.1-hp-hpux @@ -1069,6 +1095,15 @@ $ cvs checkout nofib/spectral ia64-unknown-linux ia64-unknown-linux + Supported, except there is no native code + generator. + + + + + x86_64-unknown-linux + x86_64-unknown-linux + GHC currently works unregisterised. A registerised port is in progress. @@ -1087,6 +1122,14 @@ $ cvs checkout nofib/spectral + mips64-sgi-irix6 + mips-sgi-irix6 + + GHC currently works unregisterised. + + + + powerpc-ibm-aix powerpc-ibm-aix @@ -1101,8 +1144,8 @@ $ cvs checkout nofib/spectral powerpc-apple-darwin powerpc-apple-darwin - Supported registerised. No native code - generator. + Supported registerised. Native code generator is + almost working. @@ -1203,12 +1246,9 @@ $ cvs checkout nofib/spectral GCC 3.2 is currently known to have problems building GHC on Sparc, but is stable on x86. - GCC 3.3 currently cannot be used to build GHC, due to - some problems with the new C preprocessor. - If your GCC dies with “internal error” on some GHC source file, please let us know, so we can report - it and get things improved. (Exception: on iX86 + it and get things improved. (Exception: on x86 boxes—you may need to fiddle with GHC's option; see the User's Guide) @@ -1245,22 +1285,35 @@ $ cvs checkout nofib/spectral - Autoconf - pre-supposed: Autoconf - Autoconf, pre-supposed + Alex + Alex - GNU Autoconf is needed if you intend to build from the + Alex is a lexical-analyser generator for Haskell, + which GHC uses to generate its lexer. Like Happy, Alex is + written in Haskell and is a project in the CVS repository. + Alex distributions are available from Alex's Web + Page. + + + + + Autoreconf + pre-supposed: Autoreconf + Autoreconf, pre-supposed + + GNU Autoreconf is needed if you intend to build from the CVS sources, it is not needed if you just intend to build a standard source distribution. - Version 2.52 or later of autoconf is required. + Version 2.52 or later of autoreconf is required. NB. vesrion 2.13 will no longer work, as of GHC version 6.1. - Autoconf builds the configure + Autoreconf builds the configure script from configure.ac and aclocal.m4. If you modify either of - these files, you'll need autoconf to + these files, you'll need autoreconf to rebuild configure. @@ -1381,7 +1434,8 @@ $ cvs checkout nofib/spectral want a completely standard build, then the following should work: -$ ./configure +$ autoreconf +$ ./configure $ make $ make install @@ -1553,20 +1607,27 @@ $ make install Change directory to $(FPTOOLS_TOP) and issue the command - autoconfautoconf + +autoreconf + + autoreconf (with no arguments). This GNU program converts $(FPTOOLS_TOP)/configure.ac to a shell script called $(FPTOOLS_TOP)/configure. + If autoreconf bleats that it can't write the file configure, + then delete the latter and try again. Note that you must use autoreconf, + and not the old autoconf! If you erroneously use the latter, you'll get + a message like "No rule to make target 'mk/config.h.in'". Some projects, including GHC, have their own configure script. If there's an $(FPTOOLS_TOP)/<project>/configure.ac, - then you need to run autoconf in that + then you need to run autoreconf in that directory too. - Both these steps are completely + These steps are completely platform-independent; they just mean that the human-written file (configure.ac) can be short, although the resulting shell script, @@ -1846,7 +1907,7 @@ $ cd /scratch/joe-bloggs/myfptools-sun4 Prepare for system configuration: -$ autoconf +$ autoreconf (You can skip this step if you are starting from a @@ -1855,11 +1916,11 @@ $ autoconf mk/config.h.in.) Some projects, including GHC itself, have their own - configure scripts, so it is necessary to run autoconf again + configure scripts, so it is necessary to run autoreconf again in the appropriate subdirectories. eg: -$ (cd ghc; autoconf) +$ (cd ghc; autoreconf) @@ -2221,7 +2282,8 @@ Foo.o : Baz.hi build tree. Happy can similarly be run from the build tree, using - happy/src/happy-inplace. + happy/src/happy-inplace, and similarly for + Alex and Haddock. @@ -3601,17 +3663,16 @@ $ make install-docs target machine, and compiling them using gcc to get a working GHC. - NOTE: GHC versions 5.xx and later are - significantly harder to bootstrap from C than earlier versions. - We recommend starting from version 4.08.2 if you need to - bootstrap in this way. + NOTE: GHC versions 5.xx were hard to bootstrap + from C. We recommend using GHC 6.0.1 or + later. - HC files are architecture-dependent (but not - OS-dependent), so you have to get a set that were generated on - similar hardware. There may be some supplied on the GHC - download page, otherwise you'll have to compile some up - yourself, or start from unregisterised HC - files - see . + HC files are platform-dependent, so you have to get a set + that were generated on similar hardware. There may be some + supplied on the GHC download page, otherwise you'll have to + compile some up yourself, or start from + unregisterised HC files - see . The following steps should result in a working GHC build with full libraries: @@ -3695,65 +3756,239 @@ foo% make install since unregisterised compilation is usually just a step on the way to a full registerised port, we don't mind too much. - - Building an unregisterised port + Notes on GHC portability in general: we've tried to stick + to writing portable code in most parts of the system, so it + should compile on any POSIXish system with gcc, but in our + experience most systems differ from the standards in one way or + another. Deal with any problems as they arise - if you get + stuck, ask the experts on + glasgow-haskell-users@haskell.org. - The first step is to get some unregisterised HC files. - Either (a) download them from the GHC site (if there are - some available for the right version of GHC), or - (b) build them yourself on any machine with a working - GHC. If at all possible this should be a machine with the - same word size as the target. - - There is a script available which should automate the - process of doing the 2-stage bootstrap necessary to get the - unregisterised HC files - it's available in fptools/distrib/cross-port - in CVS. - - Now take these unregisterised HC files to the target - platform and bootstrap a compiler from them as per the - instructions in . In - build.mk, you need to tell the build - system that the compiler you're building is - (a) unregisterised itself, and (b) builds - unregisterised binaries. This varies depending on the GHC - version you're bootstraping: + Lots of useful information about the innards of GHC is + available in the GHC + Commentary, which might be helpful if you run into some + code which needs tweaking for your system. - -# build.mk for GHC 4.08.x -GhcWithRegisterised=NO - + + Cross-compiling to produce an unregisterised GHC + + In this section, we explain how to bootstrap GHC on a + new platform, using unregisterised intermediate C files. We + haven't put a great deal of effort into automating this + process, for two reasons: it is done very rarely, and the + process usually requires human intervention to cope with minor + porting issues anyway. + + The following step-by-step instructions should result in + a fully working, albeit unregisterised, GHC. Firstly, you + need a machine that already has a working GHC (we'll call this + the host machine), in order to + cross-compile the intermediate C files that we will use to + bootstrap the compiler on the target + machine. + + + + On the target machine: + + + + Unpack a source tree (preferably a released + version). We will call the path to the root of this + tree T. + + + + +$ cd T +$ ./configure --enable-hc-boot --enable-hc-boot-unregisterised + + + You might need to update + configure.in to recognise the new + architecture, and re-generate + configure with + autoreconf. + + + + +$ cd T/ghc/includes +$ make config.h + + + + + + + On the host machine: + + + + Unpack a source tree (same released version). Call + this directory H. + + + + +$ cd H +$ ./configure + + + + + Create + H/mk/build.mk, + with the following contents: -# build.mk for GHC 5.xx and 6.x -GhcUnregisterised=YES +GhcUnregisterised = YES +GhcLibHcOpts = -O -H32m -keep-hc-files +GhcLibWays = +SplitObjs = NO +GhcWithNativeCodeGen = NO +GhcWithInterpreter = NO +GhcStage1HcOpts = -O -H32m -fasm +GhcStage2HcOpts = -O -fvia-C -keep-hc-files + - Versions 5.xx and 6.x only: use the option - instead of - when running - ./configure. - - The build may not go through cleanly. We've tried to - stick to writing portable code in most parts of the compiler, - so it should compile on any POSIXish system with gcc, but in - our experience most systems differ from the standards in one - way or another. Deal with any problems as they arise - if you - get stuck, ask the experts on - glasgow-haskell-users@haskell.org. - - Once you have the unregisterised compiler up and - running, you can use it to start a registerised port. The - following sections describe the various parts of the system - that will need architecture-specific tweaks in order to get a - registerised build going. - - Lots of useful information about the innards of GHC is - available in the GHC - Commentary, which might be helpful if you run into - some code which needs tweaking for your system. + + Edit + H/mk/config.mk: + + + change TARGETPLATFORM + appropriately, and set the variables involving + TARGET to the correct values for + the target platform. This step is necessary because + currently configure doesn't cope + with specifying different values for the + --host and + --target flags. + + + copy LeadingUnderscore + setting from target. + + + + + + Copy + T/ghc/includes/config.h + to + H/ghc/includes. + Note that we are building on the host machine, using the + target machine's config.h file. This + is so that the intermediate C files generated here will + be suitable for compiling on the target system. + + + + + Touch config.h, just to make + sure it doesn't get replaced during the build: + +$ touch H/ghc/includes/config.h + + + + Now build the compiler: + +$ cd H/glafp-utils && make boot && make +$ cd H/ghc && make boot && make + + Don't worry if the build falls over in the RTS, we + don't need the RTS yet. + + + + +$ cd H/libraries +$& make boot && make + + + + + +$ cd H/ghc +$ make boot stage=2 && make stage=2 + + + + + +$ cd H/ghc/utils +$ make clean +$ make -k HC=H/ghc/compiler/stage1/ghc-inplace \ + EXTRA_HC_OPTS='-O -fvia-C -keep-hc-files' + + + + + +$ cd H +$ make hc-file-bundle Project=Ghc + + + + + copy + H/*-hc.tar.gz + to T/... + + + + + + On the target machine: + + At this stage we simply need to bootstrap a compiler + from the intermediate C files we generated above. The + process of bootstrapping from C files is automated by the + script in distrib/hc-build, and is + described in . + + +$ ./distrib/hc-build --enable-hc-boot-unregisterised + + + However, since this is a bootstrap on a new machine, + the automated process might not run to completion the + first time. For that reason, you might want to treat the + hc-build script as a list of + instructions to follow, rather than as a fully automated + script. This way you'll be able to restart the process + part-way through if you need to fix anything on the + way. + + Don't bother with running + make install in the newly + bootstrapped tree; just use the compiler in that tree to + build a fresh compiler from scratch, this time without + booting from C files. Before doing this, you might want + to check that the bootstrapped compiler is generating + working binaries: + + +$ cat >hello.hs +main = putStrLn "Hello World!\n" +^D +$ T/ghc/compiler/ghc-inplace hello.hs -o hello +$ ./hello +Hello World! + + + Once you have the unregisterised compiler up and + running, you can use it to start a registerised port. The + following sections describe the various parts of the + system that will need architecture-specific tweaks in + order to get a registerised build going. + + + @@ -3880,10 +4115,13 @@ GhcUnregisterised=YES To support GHCi, you need to port the dynamic linker (fptools/ghc/rts/Linker.c). The linker currently supports the ELF and PEi386 object file formats - if - your platform uses one of these then you probably don't have - to do anything except fiddle with the - #ifdefs at the top of - Linker.c to tell it about your OS. + your platform uses one of these then things will be + significantly easier. The majority of Unix platforms use the + ELF format these days. Even so, there are some + machine-specific parts of the ELF linker: for example, the + code for resolving particular relocation types is + machine-specific, so some porting of this code to your + architecture will probaly be necessary. If your system uses a different object file format, then you have to write a linker — good luck! @@ -4215,14 +4453,37 @@ but you do need it to build GHC. Install Cygwin from http://www.cygwin.com/. The installation process is straightforward; we install it in c:/cygwin. -During the installation dialogue, make sure that you select: -cvs, openssh, -autoconf, -binutils (includes ld and (I think) ar), -gcc, -flex, -make. - +During the installation dialogue, make sure that you select all of the following: + + + cvs, + + + openssh, + + + autoreconf, + + + automake, + + + binutils (includes ld and (I think) ar), + + + gcc, + + + flex, + + + make. + + +If you miss out any of these, strange things will happen to you. To see thse packages, +click on the "View" button in the "Select Packages" +stage of Cygwin's installation dialogue, until the view says "Full". The default view, which is +"Category" isn't very helpful, and the "View" button is rather unobtrousive. Now set the following user environment variables: @@ -4242,7 +4503,7 @@ don't do this you get very weird messages when you type Set SHELL to -c:/cygwin/bin/sh. When you invoke a shell in Emacs, this +c:/cygwin/bin/bash. When you invoke a shell in Emacs, this SHELL is what you get. @@ -4412,6 +4673,12 @@ Happy is a parser generator used to compile the Haskell grammar. Add it in your + + Install Alex. This can be done by building from the + source distribution in the usual way. Sources are + available from http://www.haskell.org/alex. + GHC uses the mingw C compiler to @@ -4458,7 +4725,7 @@ you about Windows-specific wrinkles. -Run autoconf both in fptools +Run autoreconf both in fptools and in fptools/ghc. If you omit the latter step you'll get an error when you run ./configure: @@ -4473,11 +4740,11 @@ configure: error: ./configure failed for ghc - autoconf seems to create the file configure -read-only. So if you need to run autoconf again (which I sometimes do for safety's sake), + autoreconf seems to create the file configure +read-only. So if you need to run autoreconf again (which I sometimes do for safety's sake), you get -/usr/bin/autoconf: cannot create configure: permission denied +/usr/bin/autoreconf: cannot create configure: permission denied Solution: delete configure first. @@ -4500,7 +4767,7 @@ can be really confusing. - After autoconf run ./configure in + After autoreconf run ./configure in fptools/ thus: