windows.md 2.31 KB
Newer Older
1
# Building GHC on Windows
2

3
[![Windows status](https://img.shields.io/appveyor/ci/snowleopard/hadrian/master.svg?label=Windows)](https://ci.appveyor.com/project/snowleopard/hadrian)
4

Andrey Mokhov's avatar
Andrey Mokhov committed
5
6
Here is how you can build GHC, from source, on Windows. We assume that `git` and `stack` are
installed (see [prerequisites](https://github.com/snowleopard/hadrian/blob/master/doc/windows.md#prerequisites)).
7

8
9
10
11
12
```sh
# Get GHC and Hadrian sources
git clone --recursive git://git.haskell.org/ghc.git
cd ghc
git clone git://github.com/snowleopard/hadrian
13

14
# Download and install the bootstrapping GHC and MSYS2
Andrey Mokhov's avatar
Andrey Mokhov committed
15
cd hadrian
16
stack setup
17

18
19
# Install utilities required during the GHC build process
stack exec -- pacman -S autoconf automake-wrapper make patch tar --noconfirm
20

21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# Build Hadrian and dependencies (including GHC dependencies Alex and Happy)
stack build

# Build GHC
stack exec hadrian -- --directory ".." -j --flavour=quickest

# Test GHC
cd ..
inplace\bin\ghc-stage2 -e 1+2
```	

The entire process should take about 20 minutes. Note, this will build GHC without
optimisations. If you need an optimised GHC, drop the `--flavour=quickest` flag from
the build command line (this will slow down the build to about an hour).

These are currently not the
[official GHC building instructions](https://ghc.haskell.org/trac/ghc/wiki/Building/Preparation/Windows),
but are much simpler and may also be more robust.

The `stack build` and `stack exec hadrian` commands can be replaced by an invocation
of Hadrian's Stack-based build script: `build.stack.bat -j --flavour=quickest`. Use this
script if you plan to work on Hadrian and/or rebuild GHC often.

## Prerequisites

The above works on a clean machine with `git` and `stack` installed (tested with default
installation settings), which you can get from https://git-scm.com/download/win and
https://www.stackage.org/stack/windows-x86_64-installer. 

## Testing

These instructions have been tested on a clean Windows 10 machine using the
[free VirtualBox image](https://dev.windows.com/en-us/microsoft-edge/tools/vms/windows/),
and are also routinely tested on
[Hadrian's AppVeyor CI instance](https://ci.appveyor.com/project/snowleopard/hadrian/history). 

## Notes

Beware of the [current limitations of Hadrian](https://github.com/snowleopard/hadrian#current-limitations).
60