Newbie building GHC

Mike Thomas mthomas@gil.com.au
Tue, 24 Sep 2002 22:17:19 +1000


Hi Simon.

You're the victim of my first sentence which was obfuscated by simultaneous
attempts at humour and a "bad memory" disclaimer - sorry - my wife always
tells me not to make up my own jokes!  (Oops.)

"To build yesterday's CVS HEAD (previously autoconfed) using Windows 2000,
GHC 5.04.1, and Mingw32 gcc 2.95.3-7 in the southern hemisphere 10 hours
ahead of GMT, I did the following (by memory - the details of the configure
options may be shaky):"

>(a) I believe that it's important to run autoconf

I agree. Note the very well hidden "(previously autoconfed)".


>What you did may work, but I am not confident in it.  For example where
>are you saying where to find the (mingw) gcc that GHC should use?


Note the second line below which places the mingw bin directory (and
therefore the Mingw executables) directly in front of the Cygwin path:


>| - Run the following following commands:
>|
>|     export PATH=/cygdrive/c/lang/mingw32/bin::${PATH}
>|
>|     make clean; ./configure --build=mingw >& configure.log

Having said that, specifying the C compiler by your method is better as you
never know when a shell script or tool might temporarily modify the path.
(sh and /etc/profile being a known candidate for doing this behind your
back).


>Uh oh.  You aren't following the instructions in Section 12.4 of the GHC
>building guide!
>http://haskell.cs.yale.edu/ghc/docs/latest/html/building/winbuild.html

True - they didn't change for such a long time I gave up looking at them!


>(b) I've never seen this --build option for configure.  What I use (as
>the building guide says) is:

>    ./configure --host=i386-unknown-mingw32 --with-gcc=/mingw/bin/gcc

If you type "./configure --help" you will see:

=====================================================
System types:
  --build=BUILD     configure for building on BUILD [guessed]
  --host=HOST       cross-compile to build programs to run on HOST [BUILD]
  --target=TARGET   configure for building compilers for TARGET [HOST]

=====================================================

These are standard GNU configure options.  Note that the triple above
cascades down from the "--build" option.  You only need to specify
"--build".  "--host" seems to be meant for cross-compilation.

A common Mingw32 practice (not one that I recommend for casual users) is to
cross compile from Linux, and in fact I noticed recently someone was
cross-compiling from a spare four processor Sparc they had lying around
their office!

As it happens, the GHC configure is also set up to recognize the phrase
"mingw32" as an argument to "--build" (I mistakenly put mingw above) and
canonicalises that to "i386-unknown-mingw32".

In fact - I use the following script as follows for configure (after the
autoconf process):

=====================================================
$ cat ~/ghcc1
make clean;
./configure --build=mingw32 --enable-hopengl --enable-objectio --prefix=c:/l
ang/ghc --datadir=c:/lang/ghc/imports --libdir=c:/lang/ghc >&configure.log
=====================================================

The lesson I learnt today based on what you and Sigbjorn have to say is that
I should also add the following lines to that script:

=====================================================
find . -iname *.o -exec rm \{\} \;
find . -iname *.hi -exec rm \{\} \;
find . -iname *.p_o -exec rm \{\} \;
find . -iname *.p_hi -exec rm \{\} \;
=====================================================

At risk of stating the (now) obvious, apparently, "make clean" only deletes
files with those endings which correspond to already existing ".hs" and
".lhs" files, so that a CVS update which removes source files leaves
orphaned interfaces etc around.

Do you think we should change this behaviour?

Cheers

Mike Thomas