|Version 48 (modified by simonmar, 6 years ago) (diff)|
Instructions for building under Windows
This section gives detailed instructions for how to build GHC from source on your Windows machine. Similar instructions for installing and running GHC may be found in the user guide. In general, Win95/Win98 behave the same, and WinNT/Win2k behave the same.
Make sure you read the preceding section on platforms before reading section. You don't need Cygwin or MSYS to use GHC, but you do need one or the other to build GHC.
- Get the tools you need for development
- Get the GHC sources
- Configure SSH (if you need it)
- Do the build
OK! Now go read the documentation above on building from source (Quick start: just building and installing GHC); the bullets below only tell you about Windows-specific wrinkles. Also look in the section that immediately follows this one for typical failure cases and what do to about them.
- After sh boot run ./configure in
$ ./configure --host=i386-unknown-mingw32 --with-gcc=c:/mingw/bin/gcc --with-ld=c:/mingw/bin/ld.exeThis is the point at which you specify that you are building GHC-mingw (see MinGW).
Both these options are important! It's possible to get into trouble using the wrong C compiler!
- You almost certainly want to set
SplitObjs = NOin your build.mk configuration file (see Getting the build you want). This tells the build system not to split each library into a myriad of little object files, one for each function. Doing so reduces binary sizes for statically-linked binaries, but on Windows it dramatically increases the time taken to build the libraries in the first place.
A Windows build log using Cygwin
Here is a complete, from-scratch, log of all you need to build GHC using Cygwin, kindly provided by Claus Reinke. It does not discuss alternative choices, but it gives a single path that works. Please help us to keep this up to date: if you are using newer versions, let us know whether you succeed or run into issues while following this log.
Note: starting with the August 2008 version of 'setup.exe', adding 'http://www.haskell.org/ghc/cygwin' will not work unless you disable verification (not recommended) - until that site has a signature, you can add the dependencies from Devel->ghc-depends manually.
- Install some editor (vim, emacs, whatever) - Install cygwin (http://www.cygwin.com) ; i used 1.5.16-1, installed in c:\cygwin - run 'setup.exe' Choose a Download Source: select 'download from internet'; Select Root Install Directory: root dir: c:\cygwin; install for: all users; default file type: unix Select Local Package Directory choose a spare temporary home Select Your Internet Connection Use IE5 settings Choose a Download Site Choose your preferred main mirror and Add 'http://www.haskell.org/ghc/cygwin' Select Packages In addition to 'Base' (default install), select 'Devel->ghc-depends' - Install mingw (http://www.mingw.org/) ; i used MinGW-3.1.0-1.exe ; installed in c:\mingw - you probably want to add GLUT ; (http://www.xmission.com/~nate/glut.html) ; i used glut-3.7.3-mingw32.tar - Get recent binary snapshot of ghc-6.4.1 for mingw ; (http://www.haskell.org/ghc/dist/stable/dist/) - unpack in c:/ghc - add C:\ghc\ghc-6.4.1\bin to %PATH% (Start->Control Panel->System->Advanced->Environment Variables) - Get and install binary release of darcs ; (http://zooko.com/darcs/darcsdir-cygwin-1.0.7.tar.bz2) - In the following, shell commands are entered in cygwin bash - Get darcs version of ghc ; also, subscribe to [email protected], and possibly ; to [email protected], or follow the mailing list ; archives, in case you checkout a version with problems ; http://www.haskell.org/mailman/listinfo/cvs-ghc/ ; http://www.haskell.org/mailman/listinfo/cvs-libraries/ - mkdir c:/ghc-build; cd c:/ghc-build ; (or whereever you want your darcs tree to be) - darcs get --partial http://darcs.haskell.org/ghc - cd ghc - chmod +x darcs-all - ./darcs-all get - Build ghc, using cygwin and mingw, targetting mingw - export PATH=/cygdrive/c/ghc/ghc-6.4.1:$PATH ; for haddock, alex, happy (*) - export PATH=/cygdrive/c/mingw/bin:$PATH ; without, we pick up some cygwin tools at best! - cd c:/ghc-build/ghc ; (if you aren't there already) - sh boot - ./configure --host=i386-unknown-mingw32 --with-gcc=C:/Mingw/bin/gcc.exe --with-ld=C:/Mingw/bin/ld.exe ; we use cygwin, but build for windows - cp mk/build.mk.sample mk/build.mk - in mk/build.mk: add line: SplitObjs = NO (MSYS seems slow when there are zillions of object files) uncomment line: BuildFlavour = perf (or BuildFlavour = devel, if you are doing development) add line: BIN_DIST=1 - make 2>&1 | tee make.log ; always useful to have a log around - Package up binary distribution - make binary-dist 2>&1 | tee make-bin-dist.log ; always useful to have a log around - unpack ghc-<version>-i386-unknown-mingw32.tar.bz2 somewhere in your filesystem...
Additional notes from Neil Mitchell: - cygwin installation doesn't quite work with the latest version because the ghc depends file doesn't have a .sig file with it - for mingw installation just select the minimal package (or at least i did...) - I got the following hiccup, which seemed transient: ---------- nmitche6@wlon1207009001 /cygdrive/c/ghc-build/ghc $ sh boot Booting . /usr/bin/m4:configure.ac:1281: cannot create temporary file for diversion: Permi ssion denied autom4te-2.61: /usr/bin/m4 failed with exit status: 1 Booting libraries/base Booting libraries/directory Booting libraries/editline Booting libraries/old-time Booting libraries/process Booting libraries/unix nmitche6@wlon1207009001 /cygdrive/c/ghc-build/ghc $ ./configure --host=i386-unknown-mingw32 --with-gcc=C:/Mingw/bin/gcc.exe --wit h-ld=C:/Mingw/bin/ld.exe configure: WARNING: If you wanted to set the --build type, don't use --host. If a cross compiler is detected then cross compile mode will be used. mk/config.h.in doesn't exist: perhaps you haven't run 'sh boot'? nmitche6@wlon1207009001 /cygdrive/c/ghc-build/ghc $ sh boot Booting . Booting libraries/base Booting libraries/directory Booting libraries/editline Booting libraries/old-time Booting libraries/process Booting libraries/unix --------- - I required happy, haddock and alex to be installed - Everything failed a few minutes in to the compile: http://www.haskell.org/pipermail/glasgow-haskell-users/2008-September/015429.html No solutions are yet known - http://www.nabble.com/cc1-not-found-td9742088.html - looks interesting, tried adding c:\mingw\libexec\gcc\mingw32\3.4.5 to the $PATH - Some hacks make the build get further: http://www.haskell.org/pipermail/glasgow-haskell-users/2008-September/015434.html - Plus some things that don't work with the latest mingw: http://www.haskell.org/pipermail/cvs-ghc/2008-September/044945.html