X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=docs%2Fbuilding%2Fbuilding.xml;h=04cf05e35add036ef252dd14990f6f447b654a19;hb=09c814ec2c4fa854165f98aff4d29a69cafdc92a;hp=18d3ff4f7941786e3738ab398b685833556cc087;hpb=22501a5d518c093b1233af3e5c52503d5aa43281;p=ghc-hetmet.git diff --git a/docs/building/building.xml b/docs/building/building.xml index 18d3ff4..04cf05e 100644 --- a/docs/building/building.xml +++ b/docs/building/building.xml @@ -504,12 +504,12 @@ $ make install Like the source tree, the top level of your build tree must be (a linked copy of) the root directory of the GHC source tree.. Inside Makefiles, the root of your build tree is called - $(FPTOOLS_TOP)FPTOOLS_TOP. + $(GHC_TOP)GHC_TOP. In the rest of this document path names are relative to - $(FPTOOLS_TOP) unless + $(GHC_TOP) unless otherwise stated. For example, the file mk/target.mk is actually - $(FPTOOLS_TOP)/mk/target.mk. + $(GHC_TOP)/mk/target.mk. @@ -545,15 +545,15 @@ $ make install rather than darcs sources, you can skip this step. Change directory to - $(FPTOOLS_TOP) and + $(GHC_TOP) and issue the command $ autoreconf autoreconf (with no arguments). This GNU program (recursively) converts - $(FPTOOLS_TOP)/configure.ac and - $(FPTOOLS_TOP)/aclocal.m4 + $(GHC_TOP)/configure.ac and + $(GHC_TOP)/aclocal.m4 to a shell script called - $(FPTOOLS_TOP)/configure. + $(GHC_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 @@ -564,7 +564,7 @@ $ make install libraries, have their own configure script. autoreconf takes care of that, too, so all you have to do is calling autoreconf in the top-level directory - $(FPTOOLS_TOP). + $(GHC_TOP). These steps are completely platform-independent; they just mean that the human-written files (configure.ac and @@ -784,7 +784,7 @@ $ make install You can also use build.mk to override anything that configure got wrong. One place where this happens often is with the definition of - FPTOOLS_TOP_ABS: this + GHC_TOP_ABS: this variable is supposed to be the canonical path to the top of your source tree, but if your system uses an automounter then the correct directory is hard to find automatically. If you find @@ -875,9 +875,9 @@ $ mkshadowdir . /scratch/joe-bloggs/myghc-x86 The first thing you need to know is that you must use GNU make. On some - systems this is called gmake, whereas on - others it is the standard make command. In - this document we will always refer to it as + systems (eg. FreeBSD) this is called gmake, + whereas on others it is the standard make + command. In this document we will always refer to it as make; please substitute with gmake if your system requires it. If you use a the wrong make you will get all sorts of @@ -960,6 +960,23 @@ $ mkshadowdir . /scratch/joe-bloggs/myghc-x86 n is the stage to install. + + + binary-dist + + make a binary distribution. This is the target we + use to build the binary distributions of GHC. + + + + + dist + + make a source distribution. Note that this target + does “make distclean” as part of its work; + don't use it if you want to keep what you've built. + + The top-level Makefile also arranges @@ -997,12 +1014,11 @@ $ mkshadowdir . /scratch/joe-bloggs/myghc-x86 Invoking the boot target explicitly is not normally necessary. From the top-level - fptools directory, invoking - make causes make boot - all to be invoked in each of the project - subdirectories, in the order specified by - $(AllTargets) in - config.mk. + directory, invoking make causes + make boot to be invoked in various + subdirectories first, in the right order. Unless you + really know what you are doing, it is best to always say + make from the top level first. If you're working in a subdirectory somewhere and need to update the dependencies, make @@ -1049,7 +1065,7 @@ $ mkshadowdir . /scratch/joe-bloggs/myghc-x86 uninstall reverses the effect of - install. + install (WARNING: probably doesn't work). @@ -1105,13 +1121,10 @@ $ mkshadowdir . /scratch/joe-bloggs/myghc-x86 anything that needs to exist in order to run configure and then begin to build the program. - - - - check - - run the test suite. + After a maintainer-clean, a + configure will be necessary before + building again. @@ -1121,16 +1134,6 @@ $ mkshadowdir . /scratch/joe-bloggs/myghc-x86 - configure - - is only available in the root directory - $(FPTOOLS_TOP); it has - been discussed in . - - - - depend make a .depend file in each @@ -1151,49 +1154,29 @@ $ mkshadowdir . /scratch/joe-bloggs/myghc-x86 file is automatically included by every Makefile. - - - binary-dist - - make a binary distribution. This is the target we - use to build the binary distributions of GHC and - Happy. - - - - - dist - - make a source distribution. Note that this target - does “make distclean” as part of its work; - don't use it if you want to keep what you've built. - - - Most Makefiles have targets other + Some Makefiles have targets other than these. You can discover them by looking in the Makefile itself. - Using a project from the build tree + Using GHC from the build tree - If you want to build GHC (say) and just use it direct from - the build tree without doing make install - first, you can run the in-place driver script: - compiler/ghc-inplace. + If you want to build GHC and just use it direct from the + build tree without doing make install first, + you can run the in-place driver script. To run the stage 1 + compiler, use compiler/stage1/ghc-inplace, + stage 2 is compiler/stage2/ghc-inplace, and + so on. Do NOT use - compiler/ghc, or - compiler/ghc-6.xx, as these are the + compiler/stage1/ghc, or + compiler/stage1/ghc-6.xx, as these are the scripts intended for installation, and contain hard-wired paths to the installed libraries, rather than the libraries in the build tree. - - Happy can similarly be run from the build tree, using - happy/src/happy-inplace, and similarly for - Alex and Haddock. @@ -1263,27 +1246,23 @@ $ mkshadowdir . /scratch/joe-bloggs/myghc-x86 - A small project + A small example To get started, let us look at the - Makefile for an imaginary small - fptools project, small. - Each project in fptools has its own directory - in FPTOOLS_TOP, so the - small project will have its own directory - FPOOLS_TOP/small/. Inside the - small/ directory there will be a + Makefile for an imaginary small program, + small. Each program or library in the GHC + source tree typically has its own directory, in this case we'll + use $(GHC_TOP)/small. + Inside the small/ directory there will be a Makefile, looking something like this: Makefile, minimal -# Makefile for fptools project "small" - +# Makefile for program "small" TOP = .. include $(TOP)/mk/boilerplate.mk -SRCS = $(wildcard *.lhs) $(wildcard *.c) HS_PROG = small include $(TOP)/target.mk @@ -1303,9 +1282,8 @@ directive. - a file of “boilerplate” code from the level - above (which in this case will be - FPTOOLS_TOP/mk/boilerplate.mkboilerplate.mk). + a file of “boilerplate” code from the top level + boilerplate.mk). As its name suggests, boilerplate.mk consists of a large quantity of standard Makefile code. We discuss this @@ -1317,13 +1295,13 @@ directive. Before the include statement, you must define the make variable TOPTOP - to be the directory containing the mk + to be the top-level directory of the source tree, containing + the mk directory in which the boilerplate.mk file is. It is not OK to simply say include ../mk/boilerplate.mk # NO NO NO - Why? Because the boilerplate.mk file needs to know where it is, so that it can, in turn, include other files. (Unfortunately, @@ -1338,40 +1316,16 @@ directive. refers to itself. It is up to the Makefile doing the include to ensure this is the case. - - Files intended for inclusion in other - Makefiles are written to have the - following property: after - foo.mk is included, - it leaves TOP containing the same value - as it had just before the include - statement. In our example, this invariant - guarantees that the include for - target.mk will look in the same - directory as that for boilerplate.mk. - The second section defines the following standard - make variables: - SRCSSRCS - (the source files from which is to be built), and + The second section defines the standard + make variable HS_PROGHS_PROG (the executable binary to be built). We will discuss in more detail what the “standard variables” are, and how they affect what happens, in . - - The definition for SRCS uses the - useful GNU make construct - $(wildcard $pat$)wildcard, - which expands to a list of all the files matching the - pattern pat in the current directory. In - this example, SRCS is set to the list - of all the .lhs and - .c files in the directory. (Let's - suppose there is one of each, Foo.lhs - and Baz.c.) @@ -1405,14 +1359,22 @@ directive. - make figures out that the object - files are Foo.o and - Baz.o. + make looks in the current directory + to see what source files it can find + (eg. Foo.hs, + Baz.c), and from that it figures out + what object files need to be built + (eg. Foo.o, + Baz.o). Because source files are found + and used automatically, omitting them from a program or + library has to be done manually (see + EXCLUDED_SRCS in ). It uses a boilerplate pattern rule to compile - Foo.lhs to Foo.o + Foo.hs to Foo.o using a Haskell compiler. (Which one? That is set in the build configuration.) @@ -1440,90 +1402,6 @@ directive. three-section format. - - A larger project - - Larger projects are usually structured into a number of - sub-directories, each of which has its own - Makefile. (In very large projects, this - sub-structure might be iterated recursively, though that is - rare.) To give you the idea, here's part of the directory - structure for the (rather large) GHC project: - -$(FPTOOLS_TOP)/ghc/ - Makefile - mk/ - boilerplate.mk - rules.mk - docs/ - Makefile - ...source files for documentation... - driver/ - Makefile - ...source files for driver... - compiler/ - Makefile - parser/...source files for parser... - renamer/...source files for renamer... - ...etc... - - The sub-directories docs, - driver, compiler, and - so on, each contains a sub-component of GHC, and each has its - own Makefile. There must also be a - Makefile in - $(FPTOOLS_TOP)/ghc. - It does most of its work by recursively invoking - make on the Makefiles - in the sub-directories. We say that - ghc/Makefile is a non-leaf - Makefile, because it does little - except organise its children, while the - Makefiles in the sub-directories are all - leaf Makefiles. (In - principle the sub-directories might themselves contain a - non-leaf Makefile and several - sub-sub-directories, but that does not happen in GHC.) - - The Makefile in - ghc/compiler is considered a leaf - Makefile even though the - ghc/compiler has sub-directories, because - these sub-directories do not themselves have - Makefiles in them. They are just used to - structure the collection of modules that make up GHC, but all - are managed by the single Makefile in - ghc/compiler. - - You will notice that ghc/ also - contains a directory ghc/mk/. It contains - GHC-specific Makefile boilerplate code. - More precisely: - - - - ghc/mk/boilerplate.mk is included - at the top of ghc/Makefile, and of all - the leaf Makefiles in the - sub-directories. It in turn includes the - main boilerplate file - mk/boilerplate.mk. - - - - ghc/mk/target.mk is - included at the bottom of - ghc/Makefile, and of all the leaf - Makefiles in the sub-directories. It - in turn includes the file - mk/target.mk. - - - - So these two files are the place to look for GHC-wide - customisation of the standard boilerplate. - - Boilerplate architecture boilerplate architecture @@ -1642,11 +1520,11 @@ directive. - The main <filename>mk/boilerplate.mk</filename> file + The <filename>mk/boilerplate.mk</filename> file boilerplate.mk If you look at - $(FPTOOLS_TOP)/mk/boilerplate.mk + $(GHC_TOP)/mk/boilerplate.mk you will find that it consists of the following sections, each held in a separate file: @@ -2036,7 +1914,7 @@ directive. extra options to pass to all C compilations. This is intended for command line use, thus: -$ make libHS.a EXTRA_CC_OPTS="-v" +$ make libHS.a EXTRA_HC_OPTS="-v" @@ -2112,34 +1990,9 @@ directive. $(libdir). - - - LIB_DATALIB_DATA - - - - - - - LIB_EXECLIB_EXEC - - - - - - - HS_SRCSHS_SRCS, C_SRCSC_SRCS. - - If HS_SRCS is defined - and non-empty, a rule for the target - depend is included, which generates - dependency information for Haskell programs. Similarly - for C_SRCS. - - - All of these rules are “double-colon” rules, + Some rules are “double-colon” rules, thus install :: $(HS_PROG) @@ -2326,8 +2179,7 @@ directive. Tools for building the Documentation The following additional tools are required if you want to - format the documentation that comes with the - fptools projects: + format the documentation that comes with GHC: @@ -2360,11 +2212,9 @@ directive. Haddock is a Haskell documentation tool that we use for automatically generating documentation from the - library source code. It is an fptools - project in itself. To build documentation for the - libraries (fptools/libraries) you - should check out and build Haddock in - fptools/haddock. Haddock requires GHC + library source code. To build documentation for the + libraries ($(GHC_TOP)/libraries) you + should build and install Haddock. Haddock requires GHC to build. @@ -2501,24 +2351,25 @@ $ make install Porting GHC This section describes how to port GHC to a currenly - unsupported platform. There are two distinct - possibilities: + unsupported platform. To avoid confusion, when we say + “architecture” we are referring to the processor, and + we use the term “platform” to refer to the combination + of architecture and operating system. + + There are two distinct porting scenarios: - The hardware architecture for your system is already - supported by GHC, but you're running an OS that isn't - supported (or perhaps has been supported in the past, but - currently isn't). This is the easiest type of porting job, - but it still requires some careful bootstrapping. Proceed to - . + Your platform is already supported, but you want to + compile up GHC using just a C compiler. This is a + straightforward bootstrap from HC files, and is described in + . - Your system's hardware architecture isn't supported by - GHC. This will be a more difficult port (though by comparison - perhaps not as difficult as porting gcc). Proceed to . + Your platform isn't supported by GHC. You will need to + do an unregisterised bootstrap, proceed + to . @@ -2539,25 +2390,40 @@ $ make install later. HC files are platform-dependent, so you have to get a set - that were generated on the same platform. 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 . + that were generated on the same platform. + There may be some supplied on the GHC download page, otherwise + you'll have to compile some up yourself. The following steps should result in a working GHC build with full libraries: - Unpack the HC files on top of a fresh source tree - (make sure the source tree version matches the version of - the HC files exactly!). This will - place matching .hc files next to the - corresponding Haskell source (.hs or - .lhs) in the compiler subdirectory - ghc/compiler and in the libraries - (subdirectories of + Make a set of HC files. On an identical system with + GHC already installed, get a GHC source tree and put the + following in mk/build.mk: + + +SRC_HC_OPTS = -H32m -O -fasm -Rghc-timing -keep-hc-files +GhcLibHcOpts = -O +GhcLibWays = +SplitObjs = NO + + + Build GHC as normal, and then make + hc-file-bundle Project=ghc to creates the tar file + containing the hc files. + + + + On the target system, unpack the HC files on top of a + fresh source tree (make sure the source tree version matches + the version of the HC files exactly!). + This will place matching .hc files next + to the corresponding Haskell source + (.hs or .lhs) in + the compiler subdirectory ghc/compiler + and in the libraries (subdirectories of libraries). @@ -2589,10 +2455,10 @@ $ make install - Porting GHC to a new architecture + Porting GHC to a new platform - The first step in porting to a new architecture is to get - an unregisterised build working. An + The first step in porting to a new platform is to get an + unregisterised build working. An unregisterised build is one that compiles via vanilla C only. By contrast, a registerised build uses the following architecture-specific hacks for speed: @@ -2623,6 +2489,13 @@ $ make install since unregisterised compilation is usually just a step on the way to a full registerised port, we don't mind too much. + You should go through this process even if your + architecture is already has registerised support in GHC, but + your OS currently isn't supported. In this case you probably + won't need to port any of the architecture-specific parts of the + code, and you can proceed straight from the unregisterised build + to build a registerised compiler. + 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 @@ -2679,7 +2552,7 @@ $ ./configure --enable-hc-boot --enable-hc-boot-unregisterised You might need to update configure.in to recognise the new - architecture, and re-generate + platform, and re-generate configure with autoreconf. @@ -3001,15 +2874,15 @@ Hello World! GHCi 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 things will be - significantly easier. The majority of Unix platforms use the - ELF format these days. Even so, there are some + ($(GHC_TOP)/rts/Linker.c). The + linker currently supports the ELF and PEi386 object file + formats - if 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. + architecture and/or OS will probaly be necessary. If your system uses a different object file format, then you have to write a linker — good luck! @@ -3049,9 +2922,8 @@ The best way around it is to say export TMPDIR=<dir> -in your build.mk file. -Then GHC and the other fptools programs will use the appropriate directory -in all cases. +in your build.mk file. Then GHC and the other +tools will use the appropriate directory in all cases. @@ -3717,7 +3589,7 @@ you do that, ssh uses the $HOME environment variable instead. You have to install the following other things to build GHC, listed below. On Windows you often install executables in directories with spaces, such as -"Program Files". However, the make system for fptools doesn't +"Program Files". However, the make system doesn't deal with this situation (it'd have to do more quoting of binaries), so you are strongly advised to put binaries for all tools in places with no spaces in their path. On both MSYS and Cygwin, it's perfectly OK to install such programs in the standard Unixy places, @@ -3782,10 +3654,10 @@ but you must have them; hence needing the Cygwin binutils package. We use emacs a lot, so we install that too. -When you are in fptools/ghc/compiler, you can use +When you are in $(GHC_TOP)/compiler, you can use "make tags" to make a TAGS file for emacs. That uses the utility -fptools/ghc/utils/hasktags/hasktags, so you need to make that first. -The most convenient way to do this is by going make boot in fptools/ghc. +$(GHC_TOP)/ghc/utils/hasktags/hasktags, so you need to make that first. +The most convenient way to do this is by going make boot in $(GHC_TOP)/ghc. The make tags command also uses etags, which comes with emacs, so you will need to add emacs/bin to your PATH. @@ -3837,7 +3709,7 @@ Solution: delete configure first. After autoreconf run ./configure in - fptools/ thus: + $(GHC_TOP)/ thus: $ ./configure --host=i386-unknown-mingw32 --with-gcc=c:/mingw/bin/gcc This is the point at which you specify that you are building GHC-mingw @@ -3855,7 +3727,7 @@ say --with-gcc=/mingw/bin/gcc, it'll be interpreted as time it tries to invoke it. Worse, the failure comes with no error message whatsoever. GHC simply fails silently when first invoked, typically leaving you with this: -make[4]: Leaving directory `/cygdrive/e/fptools-stage1/ghc/rts/gmp' +make[4]: Leaving directory `/cygdrive/e/ghc-stage1/ghc/rts/gmp' ../../ghc/compiler/ghc-inplace -optc-mno-cygwin -optc-O -optc-Wall -optc-W -optc-Wstrict-prototypes -optc-Wmissing-prototypes -optc-Wmissing-declarations -optc-Winline -optc-Waggregate-return @@ -3865,7 +3737,7 @@ typically leaving you with this: -package-name rts -O -dcore-lint -c Adjustor.c -o Adjustor.o make[2]: *** [Adjustor.o] Error 1 make[1]: *** [all] Error 1 -make[1]: Leaving directory `/cygdrive/e/fptools-stage1/ghc' +make[1]: Leaving directory `/cygdrive/e/ghc-stage1/ghc' make: *** [all] Error 1 Be warned! @@ -3944,7 +3816,7 @@ choices, but it gives a single path that works. ; also, subscribe to cvs-all@haskell.org, or follow the mailing list ; archive, in case you checkout a version with problems ; http://www.haskell.org//pipermail/cvs-all/ - - mkdir c:/fptools; cd c:/fptools + - mkdir c:/ghc-build; cd c:/ghc-build ; (or whereever you want your darcs tree to be) - darcs get http://darcs.haskell.org/ghc - cd ghc @@ -3956,7 +3828,7 @@ choices, but it gives a single path that works. ; for haddock, alex, happy (*) - export PATH=/cygdrive/c/mingw/bin:$PATH ; without, we pick up some cygwin tools at best! - - cd c:/fptools/fptools + - cd c:/ghc-build ; (if you aren't there already) - autoreconf - ./configure --host=i386-unknown-mingw32 --with-gcc=C:/Mingw/bin/gcc.exe