Building on Windows

Neil Mitchell ndmitchell at gmail.com
Tue Sep 16 12:54:12 UTC 2014


Hi,

I just successfully built GHC on Windows. Last time I tried (5 years
ago) it took days. This time, it took hours, plus a bit of waiting for
a Windows specific breakage to be fixed. I made a log of what
happened, what confused me, what wasn't clear etc - hopefully these
provide suggestions for improving the wiki (if my thoughts are
actually correct). The worst aspect is that the Windows wiki page has
6 sets of instructions, with no obvious way to pick the right one -
everything else was pretty minor.

Thanks, Neil

My first step was to Google "build ghc on windows", which took me to
https://ghc.haskell.org/trac/ghc/wiki/Building/Preparation/Windows

"The instructions are current for GHC 7.6" - so they are not current.

"Other documentation for Windows includes:" - here are 5 alternate
links, any of which may be better/worse than this one. I have no way
to tell. As a piece of documentation, giving the uninformed user 6
options with no sensible way to make a decision is awful.

Simon PJ had said "MSYS2" works well, so I clicked that one. Even
though it appears to be the "wrong" one according to the wiki. Is it
the correct one? If so, replace the Windows page with it. If not,
perhaps indicate which one is.

"It should get you running in ~5 minutes, modulo download speeds." -
nice! It's a long way from being true, since you also need to include
extraction times and build times (which on my machine far outweight
download times). There were also enough hiccups that it took me about
an hour of clicking/typing, excluding the Windows specific bug I ran
into.

If I have 64bit OS, should I pick 64bit Windows? Or only if I want to
develop 64bit Windows, which isn't the default? Fortunately my machine
is old enough to be 32 bits so I didn't have the difficult question.

It's far easier to edit the PATH file manually with $ cygpath -w ~,
which returns C:\msys32\home\Neil, than to echo stuff to it. In
particular, if you echo anything wrong, you need to edit it anyway.

"Do not install python, python2 or gcc!" - it's not entirely clear how
to achieve that. It installed gcc-libs, is that a problem?

I'd have liked a better "check" step, e.g. run "gcc --version", "ghc
--version" and exactly what I should expect, what indicates a problem
etc. e.g what should i be on the lookout for to say Python doesn't
build.

I followed the step to upgrade my system, but it failed:

:: Starting full system upgrade...
:: Replace msys2-base with msys/filesystem? [Y/n]

(55/55) checking for file conflicts                [######################] 100%
error: failed to commit transaction (conflicting files)
bash-completion: /etc/profile.d/bash_completion.sh exists in filesystem
coreutils: /etc/DIR_COLORS exists in filesystem
ca-certificates: /etc/pki/ca-trust/extracted/java/cacerts exists in filesystem
ca-certificates:
/etc/pki/ca-trust/extracted/openssl/ca-bundle.trust.crt exists in
filesystem
ca-certificates: /etc/pki/ca-trust/extracted/pem/email-ca-bundle.pem
exists in filesystem
ca-certificates: /etc/pki/ca-trust/extracted/pem/objsign-ca-bundle.pem
exists in filesystem
ca-certificates: /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem
exists in filesystem
filesystem: /etc/profile.d/lang.sh exists in filesystem
filesystem: /etc/profile.d/tzset.sh exists in filesystem
filesystem: /etc/skel/.inputrc exists in filesystem
filesystem: /mingw32_shell.bat exists in filesystem
filesystem: /mingw64_shell.bat exists in filesystem
filesystem: /msys2_shell.bat exists in filesystem
grep: /usr/bin/egrep exists in filesystem
grep: /usr/bin/fgrep exists in filesystem
rebase: /autorebase.bat exists in filesystem
Errors occurred, no packages were upgraded.

I just ignored that, and continued, and that seemed to go OK...

/ghc-7.6.3/ didn't work, I needed to go /c/ghc/ghc-7.6.3/ for the
paths. Perhaps make it clear which are absolute paths, and which you
have to edit. Perhaps you were hoping I'd symlink the GHC path?

Any reason for the && commands in the final list of commands? isn't
one per line cleaner? It also lets you retry the right bit when
something fails.

checking for version of happy... 1.18.4
configure: error: Happy version 1.19.4 or later is required to compile GHC.

Nice - this was a useful check that made it easy to fix and continue.

$ make -j3
+ test -f mk/config.mk.old
+ cp -p mk/config.mk mk/config.mk.old
touch -r mk/config.mk.old mk/config.mk
+ test -f mk/project.mk.old
+ cp -p mk/project.mk mk/project.mk.old
touch -r mk/project.mk.old mk/project.mk
      2 [main] make 6024 child_info_fork::abort:
C:\msys32\bin\msys-unistring-2.dll: Loaded to different address:
parent(0x250000) != child(0x7C0000)
make: fork: Resource temporarily unavailable

This error repeated. On a hunch I ran "autorebase.bat" from msys32,
and restarted my shell, then it worked - I have no idea which fixed
it.

"inplace/bin/ghc-stage1.exe" -hisuf hi -osuf  o -hcsuf hc -static
-H32m -O    -this-package-key haske_9y30zKcKDr9BxdhpktYrNk
-hide-all-packages -i -ilibraries/haskeline/.
-ilibraries/haskeline/dist-install/build
-ilibraries/haskeline/dist-install/build/autogen
-Ilibraries/haskeline/dist-install/build
-Ilibraries/haskeline/dist-install/build/autogen
-Ilibraries/haskeline/includes   -optP-DUSE_GHC_ENCODINGS -optP-DMINGW
-optP-include -optPlibraries/haskeline/dist-install/build/autogen/cabal_macros.h
-package-key Win32_43THQMouBnk2wpnouztX1X -package-key
base_ESD4aQEEWwsHtYJVc1BwtJ -package-key bytes_Kc0PyaputnzDnBdZW0y2Gv
-package-key conta_ChF4XLXB9JmByIycPzerow -package-key
direc_6qC0tVrFkqbBNeWAGS0s7g -package-key filep_34DFDFT9FVD9pRLLgh8IdQ
-package-key trans_5jw4w9yTgmZ89ByuixDAKP -Wall -XHaskell98
-XForeignFunctionInterface -XRank2Types -XFlexibleInstances
-XTypeSynonymInstances -XFlexibleContexts -XExistentialQuantification
-XScopedTypeVariables -XGeneralizedNewtypeDeriving
-XMultiParamTypeClasses -XOverlappingInstances -XUndecidableInstances
-XCPP -XDeriveDataTypeable -XPatternGuards -O2  -no-user-package-db
-rtsopts      -odir libraries/haskeline/dist-install/build -hidir
libraries/haskeline/dist-install/build -stubdir
libraries/haskeline/dist-install/build -split-objs  -c
libraries/haskeline/dist-install/build/System/Console/Haskeline/Backend/Win32.hs
-o libraries/haskeline/dist-install/build/System/Console/Haskeline/Backend/Win32.o

librarieshaskelineSystemConsoleHaskelineBackendWin32.hsc:263:15:
    No instance for (Applicative (Draw m))
      arising from the 'deriving' clause of a data type declaration
    Possible fix:
      use a standalone 'deriving instance' declaration,
        so you can specify the instance context yourself
    When deriving the instance for (Monad (Draw m))

I fixed that by applying the patch from
https://ghc.haskell.org/trac/ghc/ticket/9598. With that, I could build
to completion. An empty build (nothing to do) takes 1m50s which is a
bit sad, but it does work.

After all this there are exactly two things I want to know (both of
which would be useful links from the bottom of the building on Windows
page):

* How do I update to the next day, resync and rebuild. In particular,
should i sync-all or not (a link to another page is fine)

* How do I run the tests.


More information about the ghc-devs mailing list