Building on Windows with msys

Simon Peyton-Jones simonpj at
Wed Aug 28 10:08:02 CEST 2013

My Windows build (new laptop) got stuck again, but this time I managed to work out what is going on.  This email is just to record the issue; I'll add something to the wiki.
tl;dr: a MSYS build will fail in a deeply strange way if your MSYS bin directory doesn't take priority over the windows/system32 director.
Symptom: "sh libtool" hangs indefinitely.  The process manager shows an extant "cmd" and "sed", but nothing else.  libtool is a shell script that comes from a tarball, and is unpacked into libraries/integer-gmp/gmp/gmpbuild/libtool
Cause: libtool invokes the following command line (in the function func_convert_coer_msys_to_w32:
     cmd /c "echo blah"
and pipes the result to sed.  But MSYS mangles the command line to turn slashes into backslashes.  So the actual command line is more like
     cmd \c "echo blah"
which does something entirely different, and indeed hangs waiting for input on stdin.
Solution: So how did this ever work on any MSYS installation?  Because

*         msys/1.0/bin has a little script "cmd" which hands off to the real c:/windows/system32/cmd

*         MSYS does not mangle the command-line for programs in msys/1.0/bin

*         On my old laptop, msys/1.0/bin was in my path before c:/windows/system32.  So plain "cmd" gets the script, and MSYS does not mangle the command line. The script passes arguments on unchanged to the real cmd.

*         NB: c:/windows/system32 is in the "system" path, which precedes the "user" path.  So no amount of fiddling with the "user" path will fix this.  There are two solutions:

o   Modify the system path

o   Use a .bashrc file to prepend the stuff you need
This is pretty subtle stuff.
Microsoft Research Limited (company number 03369488) is registered in England and Wales
Registered office is at 21 Station Road, Cambridge, CB1 2FB

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the ghc-devs mailing list