Changes between Version 25 and Version 26 of Building/Windows

May 16, 2008 11:32:02 AM (9 years ago)



  • Building/Windows

    v25 v26  
    1212You don't need Cygwin or MSYS to ''use'' GHC,
    1313but you do need one or the other to ''build'' GHC.
     15== Summary ==
     17 1. Install ''either'' [wiki:Building/WindowsTools#InstallingandconfiguringMSYS MSYS] (including the MSYS Devlopment ToolKit) ''or'' [wiki:Building/WindowsTools#InstallingandconfiguringCygwin Cygwin].  This is the interactive shell plus development tools (make etc) in which you're going to build GHC.
     19 2. [wiki:Building/WindowsTools#ConfigureSSH Configure SSH].
     21 3. [wiki:Building/WindowsTools#Otherthingsyouneedtoinstall Get other tools you need for development]:
     22    * Darcs
     23    * GHC itself (used for bootstrapping)
     24    * Happy
     25    * Alex
     26    * Python (already in Cygwin)
     27    * An editor
     29 4. Get MinGW. This is used solely for the C compiler and linker that are bundled into the GHC distribution.  Do not add any of the MinGW stuff to your path; the C compiler is only explicitly (via the `--with-gcc` flag you give to `configure` later)
     31 5. Get the [wiki:Building/GettingTheSources GHC sources]
     33 6. Do the build
    1535== Vista users ==
    3757with MingW's gcc first.
    39 == Installing and configuring MSYS ==
    41 MSYS is a lightweight alternative to Cygwin. 
    42 You don't need MSYS to ''use'' GHC,
    43 but you do need it or Cygwin to ''build'' GHC.
    44 Here's how to install MSYS.
    45  * Go to [] and
    46    download the following (of course, the version numbers will differ):
    47     * The main MSYS package (binary is sufficient): {{{MSYS-1.0.9.exe}}}
    48     * The MSYS developer's toolkit (binary is sufficient): {{{msysDTK-1.0.1.exe}}}.
    49       This provides {{{make}}}, {{{autoconf}}},
    50       {{{ssh}}} and probably more besides.
    51    Run both executables (in the order given above) to install them.  I put them in {{{c:/msys}}}
    52  * Set the following environment variables
    53     * {{{PATH}}}: add {{{c:/msys/1.0/bin}}} and
    54       {{{c:/msys/1.0/local/bin}}}
    55       to your path.  (Of course, the version number may differ.)
    56       MSYS mounts the former as both {{{/bin}}} and
    57       {{{/usr/bin}}} and the latter as {{{/usr/local/bin}}}. Make sure that the Windows paths (e.g. `C:/WINDOWS/System32`) are ''after'' the MSYS paths in your `PATH` variable.
    58     * {{{HOME}}}: set to your home directory (e.g. {{{c:/userid}}}). 
    59       This is where, among other things, {{{ssh}}} will look for your {{{.ssh}}} directory.
    60     * {{{SHELL}}}: set to {{{c:/msys/1.0/bin/sh.exe}}}
    61  * Check that the {{{CYGWIN}}} environment variable is ''not'' set.  It's a bad bug
    62    that MSYS is affected by this, but if you have CYGWIN set to "ntsec ntea", which is right for Cygwin, it
    63    causes the MSYS {{{ssh}}} to bogusly fail complaining that your {{{.ssh/identity}}}
    64    file has too-liberal permissinos.
    66 Here are some points to bear in mind when using MSYS:
    67  * MSYS does some kind of special magic to binaries stored in
    68    {{{/bin}}} and {{{/usr/bin}}}, which are by default both mapped
    69    to {{{c:/msys/1.0/bin}}} (assuming you installed MSYS in {{{c:/msys}}}).
    70    Do not put any other binaries (such as GHC or Alex) in this directory or its sub-directories:
    71    they fail in mysterious ways.  However, it's fine to put other binaries in {{{/usr/local/bin}}},
    72    which maps to {{{c:/msys/1.0/local/bin}}}.
    74 == Installing and configuring Cygwin ==
    76 Install Cygwin from [].
    77 The installation process is straightforward; we install it in
    78 {{{c:/cygwin}}}.
    80 You must install enough Cygwin ''packages'' to support
    81 building GHC.  If you miss out any of these, strange things will happen to you.   There are two ways to do this:
    82  * The direct, but laborious way is to
    83    select all of the following packages in the installation dialogue:
    84    {{{cvs}}},
    85    {{{openssh}}},
    86    {{{autoconf}}},
    87    {{{binutils}}} (includes ld and (I think) ar),
    88    {{{gcc}}},
    89    {{{flex}}},
    90    {{{make}}}.
    91    To see these packages,
    92    click on the "View" button in the "Select Packages"
    93    stage of Cygwin's installation dialogue, until the view says "Full".  The default view, which is
    94    "Category" isn't very helpful, and the "View" button is rather unobtrousive.
    95  * The clever way is to point the Cygwin installer at the
    96    {{{ghc-depends}}} package, which is kept at
    97    [].
    98    When the Cygwin installer asks you to "Choose a Download Site", choose one of
    99    the
    100    offered mirror sites; and then type "" into the
    101    "User URL" box and click "Add"; now two sites are selected. (The Cygwin
    102    installer remembers this for next time.)
    103    Click "Next".
    104    [[br]]
    105    In the "Select Packages" dialogue box that follows, click the "+" sign by
    106    "Devel", scroll down to the end of the "Devel" packages, and choose
    107    {{{ghc-depends}}}.
    108    The package {{{ghc-depends}}} will not actually install anything itself,
    109    but forces additional packages to be added by the Cygwin installer.
    111 Now set the following user environment variables:
    112  * Add {{{c:/cygwin/bin}}} and {{{c:/cygwin/usr/bin}}} to your
    113    {{{PATH}}}
    114  * Set {{{MAKE_MODE}}} to {{{UNIX}}}. If you
    115    don't do this you get very weird messages when you type
    116    {{{make}}}, such as:
    117    {{{
    118 /c: /c: No such file or directory
    119 }}}
    120  * Set {{{SHELL}}} to
    121    {{{c:/cygwin/bin/bash}}}. When you invoke a shell in Emacs, this
    122    {{{SHELL}}} is what you get.
    123  * Set {{{HOME}}} to point to your
    124    home directory.  This is where, for example,
    125    {{{bash}}} will look for your {{{.bashrc}}}
    126    file.  Ditto {{{emacs}}} looking for {{{.emacsrc}}}
    128 Here are some things to be aware of when using Cygwin:
    129  * Cygwin doesn't deal well with filenames that include
    130    spaces. "{{{Program Files}}}" and "{{{Local files}}}" are
    131    common gotchas.
    132  * Cygwin implements a symbolic link as a text file with some
    133    magical text in it.  So other programs that don't use Cygwin's
    134    I/O libraries won't recognise such files as symlinks. 
    135    In particular, programs compiled by GHC are meant to be runnable
    136    without having Cygwin, so they don't use the Cygwin library, so
    137    they don't recognise symlinks.
    138  * See the notes in [[ref(Installing and configuring MSYS)]] about {{{find}}} and {{{bzip}}},
    139    which apply to Cygwin too.
    140  * Some script files used in the make system start with "{{{#!/bin/perl}}}",
    141    (and similarly for {{{sh}}}).  Notice the hardwired path!
    142    So you need to ensure that your {{{/bin}}} directory has at least
    143    {{{sh}}}, {{{perl}}}, and {{{cat}}} in it.
    144    All these come in Cygwin's {{{bin}}} directory, which you probably have
    145    installed as {{{c:/cygwin/bin}}}.  By default Cygwin mounts "{{{/}}}" as
    146    {{{c:/cygwin}}}, so if you just take the defaults it'll all work ok.
    147    (You can discover where your Cygwin
    148    root directory {{{/}}} is by typing {{{mount}}}.)
    149    Provided {{{/bin}}} points to the Cygwin {{{bin}}}
    150    directory, there's no need to copy anything.  If not, copy these binaries from the {{{cygwin/bin}}}
    151    directory (after fixing the {{{sh.exe}}} stuff mentioned in the previous bullet).
    152  * By default, cygwin provides the command shell {{{ash}}}
    153    as {{{sh.exe}}}.   It seems to be fine now, but in the past we
    154    saw build-system problems that turned out to be due to bugs in {{{ash}}}
    155    (to do with quoting and length of command lines).  On the other hand {{{bash}}} seems
    156    to be rock solid.
    157    If this happens to you (which it shouldn't), in {{{cygwin/bin}}}
    158    remove the supplied {{{sh.exe}}} (or rename it as {{{ash.exe}}}),
    159    and copy {{{bash.exe}}} to  {{{sh.exe}}}.
    160    You'll need to do this in Windows Explorer or the Windows {{{cmd}}} shell, because
    161    you can't rename a running program!
    163 == Configuring SSH ==
    165 {{{ssh}}} comes with both Cygwin and MSYS.
    166 (Cygwin note: you need to ask for package {{{openssh}}} (not ssh)
    167 in the Cygwin list of packages; or use the {{{ghc-depends}}}
    168 package -- see [[ref(Installing and configuring Cygwin)]].)
    170 There are several strange things about {{{ssh}}} on Windows that you need to know.
    171  * The programs {{{ssh-keygen1}}}, {{{ssh1}}}, and {{{cvs}}},
    172    seem to lock up {{{bash}}} entirely if they try to get user input (e.g. if
    173    they ask for a password).  To solve this, start up {{{cmd.exe}}}
    174    and run it as follows:
    175    {{{
    176 c:\tmp> set CYGWIN32=tty
    177 c:\tmp> c:/user/local/bin/ssh-keygen1
    178 }}}
    179  * (Cygwin-only problem, I think.)
    180    {{{ssh}}} needs to access your directory {{{.ssh}}}, in your home directory. 
    181    To determine your home directory {{{ssh}}} first looks in
    182    {{{c:/cygwin/etc/passwd}}} (or wherever you have Cygwin installed).  If there's an entry
    183    there with your userid, it'll use that entry to determine your home directory, ''ignoring
    184    the setting of the environment variable $HOME''.  If the home directory is
    185    bogus, {{{ssh}}} fails horribly.   The best way to see what is going on is to say
    186    {{{
    187 ssh -v
    188 }}}
    189    which makes {{{ssh}}} print out information about its activity.
    190    [[br]]
    191    You can fix this problem, either by correcting the home-directory field in
    192    {{{c:/cygwin/etc/passwd}}}, or by simply deleting the entire entry for your userid. If
    193    you do that, {{{ssh}}} uses the $HOME environment variable instead.
    194  * To protect your
    195    {{{.ssh}}} from access by anyone else,
    196    right-click your {{{.ssh}}} directory, and
    197    select {{{Properties}}}.  If you are not on
    198    the access control list, add yourself, and give yourself
    199    full permissions (the second panel).  Remove everyone else
    200    from the access control list.  Don't leave them there but
    201    deny them access, because 'they' may be a list that
    202    includes you!
    203  * In fact {{{ssh}}} 3.6.1 now seems to ''require''
    204    you to have Unix permissions 600 (read/write for owner only)
    205    on the {{{.ssh/identity}}} file, else it
    206    bombs out.  For your local C drive, it seems that {{{chmod 600 identity}}} works,
    207    but on Windows NT/XP, it doesn't work on a network drive (exact dteails obscure). 
    208    The solution seems to be to set the {{{$CYGWIN}}} environment
    209    variable to "{{{ntsec neta}}}".  The {{{$CYGWIN}}} environment variable is discussed
    210    in [ the Cygwin User's Guide],
    211    and there are more details in [ the Cygwin FAQ].
    213 == Other things you need to install ==
    215 You have to install the following other things to build GHC, listed below.
    217 On Windows you often install executables in directories with spaces, such as
    218 "{{{Program Files}}}". However, the {{{make}}} system doesn't
    219 deal with this situation (it'd have to do more quoting of binaries), so you are strongly advised
    220 to put binaries for all tools in places with no spaces in their path.
    221 On both MSYS and Cygwin, it's perfectly OK to install such programs in the standard Unixy places,
    222 {{{/usr/local/bin}}} and {{{/usr/local/lib}}}.  But it doesn't matter,
    223 provided they are in your path.
    224  * Install an executable GHC, from [].
    225    This is what you will use to compile GHC.  Add it in your
    226    {{{PATH}}}: the installer tells you the path element
    227    you need to add upon completion.
    228  * Install an executable Happy, from [].
    229  * Install an executable Alex, froim [].
    230  * If you want to run the testsuite, you'll need Python (at least version 2.4).  This comes with Cygwin, but if you use MSYS you'll need to get Python separately, from ``.  I found I had to set the environment variable `PYTHONHOME` to the installation directory before it would work.
    231  * GHC uses the ''mingw'' C compiler to
    232    generate code, so you have to install that (see [wiki:Building/PlatformsScriptsFileNames#Windowsplatforms:CygwinMSYSandMinGW Windows platforms: Cygwin, MSYS, and MinGW]).
    233    Just pick up a mingw bundle at
    234    [].
    235    We install it in {{{c:/mingw}}}.
    236    [[br]]
    237    ''On MSYS'', add {{{c:/mingw/bin}}} to your PATH. MSYS does not provide {{{gcc}}},
    238    {{{ld}}}, {{{ar}}}, and so on, because it just uses the MinGW ones.  So you need them
    239    in your path.
    240    [[br]]
    241    ''On Cygwin, do not'' add any of the ''mingw'' binaries to your  path.
    242    They are only going to get used by explicit access (via the --with-gcc flag you
    243    give to {{{configure}}} later).  If you do add them to your path
    244    you are likely to get into a mess because their names overlap with Cygwin
    245    binaries.
    246    On the other hand, you ''do'' need {{{ld}}}, {{{ar}}}
    247    (and perhaps one or two other things) in your path.  The Cygwin ones are fine,
    248    but you must have them; hence needing the  Cygwin binutils package.
    249  * We use {{{emacs}}} a lot, so we install that too.
    250    When you are in {{{$(GHC_TOP)/compiler}}}, you can use
    251    "{{{make tags}}}" to make a TAGS file for emacs.  That uses the utility
    252    {{{$(GHC_TOP)/ghc/utils/hasktags/hasktags}}}, so you need to make that first.
    253    The most convenient way to do this is by going {{{make boot}}} in {{{$(GHC_TOP)/ghc}}}.
    254    The {{{make tags}}} command also uses {{{etags}}}, which comes with {{{emacs}}},
    255    so you will need to add {{{emacs/bin}}} to your {{{PATH}}}.
    256  * You might want to install GLUT in your MSYS/Cygwin
    257    installation, otherwise the GLUT package will not be built with
    258    GHC.
    259  * Finally, check out a copy of GHC sources from
    260    the darcs repository, following the instructions at [].
    26261== Building GHC ==