[project @ 2003-06-02 08:52:28 by simonmar]
[ghc-hetmet.git] / docs / building / building.sgml
index c08ac39..30353c5 100644 (file)
             from the access control list.  Don't leave them there but
             deny them access, because 'they' may be a list that
             includes you!</para>
+           <para>[March 2003] In fact <command>ssh</command> 3.6.1 now seems to <emphasis>require</emphasis>
+             you to have Unix permissions 600 (read/write for owner only) 
+             on the <literal>.ssh/identity</literal> file, else it 
+             bombs out.  For your local C drive, it seems that <literal>chmod 600 identity</literal> works,
+             but on Windows NT/XP, it doesn't work on a network drive (exact dteails obscure).  
+             The solution seems to be to set the CYGWIN environment
+             variable to "<literal>ntsec neta</literal>".  The CYGWIN environment variable is discussed
+             in <ulink url="http://cygwin.com/cygwin-ug-net/using-cygwinenv.html">the Cygwin User's Guide</ulink>,
+             and there are more details in <ulink url="http://cygwin.com/faq/faq_4.html#SEC44">the Cygwin FAQ</ulink>.
+             </para>
          </listitem>
 
          <listitem>
@@ -446,6 +456,10 @@ setsockopt IPTOS_THROUGHPUT: Invalid argument
           <literal>hslibs</literal> and <literal>libraries</literal>
           modules (for a full list of the projects available, see
           <xref linkend="projects">).</para>
+
+         <para>Remember that if you do not have
+          <literal>happy</literal> installed, you need to check it out
+          as well.</para>
        </listitem>
       </itemizedlist>
     </sect2>
@@ -481,7 +495,14 @@ $ cvs diff
           you the results.</para>
        </listitem>
 
-      <listitem>
+       <listitem>
+         <para>If you changed something in the 
+          <literal>fptools/libraries</literal> subdirectories, also run
+          <literal>make html</literal> to check if the documentation can
+          be generated successfully, too.</para>
+       </listitem>
+
+       <listitem>
          <para>Before checking in a change, you need to update your
           source tree:</para>
 
@@ -564,17 +585,25 @@ $ cvs commit -F <replaceable>commit-message</replaceable> <replaceable>directory
       major cause of headaches. </para>
 
       <para>So, to avoid a lot of hassle, follow this recipe for
-      updating your tree: </para>
+      updating your tree:</para>
 
 <screen>
 $ cd fptools
-$ cvs update -Pd 2&gt;&amp;1 | tee log</screen>
+$ cvs update -P 2&gt;&amp;1 | tee log</screen>
 
       <para>Look at the log file, and fix any conflicts (denoted by a
-      <quote>C</quote> in the first column). If you're using multiple
-      build trees, then for every build tree you have pointing at this
-      source tree, you need to update the links in case any new files
-      have appeared: </para>
+      <quote>C</quote> in the first column).  New directories may have
+      appeared in the repository; CVS doesn't check these out by
+      default, so to get new directories you have to explicitly do
+<screen>
+$ cvs update -d</screen>
+      in each project subdirectory.  Don't do this at the top level,
+      because then <emphasis>all</emphasis> the projects will be
+      checked out.</para>
+
+      <para>If you're using multiple build trees, then for every build
+      tree you have pointing at this source tree, you need to update
+      the links in case any new files have appeared: </para>
 
 <screen>
 $ cd <replaceable>build-tree</replaceable>
@@ -1195,6 +1224,12 @@ $ cvs checkout nofib/spectral
           <command>egcs</command>) have varying degrees of stability
           depending on the platform.</para>
 
+         <para>GCC 3.2 is currently known to have problems building
+         GHC on Sparc, but is stable on x86.</para>
+         
+         <para>GCC 3.3 currently cannot be used to build GHC, due to
+         some problems with the new C preprocessor.</para>
+
          <para>If your GCC dies with &ldquo;internal error&rdquo; on
           some GHC source file, please let us know, so we can report
           it and get things improved.  (Exception: on iX86
@@ -1226,7 +1261,7 @@ $ cvs checkout nofib/spectral
           (<literal>fptools/happy</literal>).  It can be built from
           source, but bear in mind that you'll need GHC installed in
           order to build it.  To avoid the chicken/egg problem,
-          install a binary distribtion of either Happy or GHC to get
+          install a binary distribution of either Happy or GHC to get
           started.  Happy distributions are available from <ulink
           url="http://www.haskell.org/happy/">Happy's Web
           Page</ulink>.</para>
@@ -1242,6 +1277,10 @@ $ cvs checkout nofib/spectral
           CVS sources, it is <emphasis>not</emphasis> needed if you
           just intend to build a standard source distribution.</para>
 
+         <para>Version 2.52 or later of autoconf is required.
+         NB. vesrion 2.13 will no longer work, as of GHC version
+         6.1.</para>
+
          <para>Autoconf builds the <command>configure</command>
           script from <filename>configure.in</filename> and
           <filename>aclocal.m4</filename>.  If you modify either of
@@ -1283,7 +1322,7 @@ $ cvs checkout nofib/spectral
          <listitem>
            <para>PVM is the Parallel Virtual Machine on which
             Parallel Haskell programs run.  (You only need this if you
-            plan to run Parallel Haskell.  Concurent Haskell, which
+            plan to run Parallel Haskell.  Concurrent Haskell, which
             runs concurrent threads on a uniprocessor doesn't need
             it.)  Underneath PVM, you can have (for example) a network
             of workstations (slow) or a multiprocessor box
@@ -1711,6 +1750,9 @@ $ make install
       includes <filename>build.mk</filename> after
       <filename>config.mk</filename>.)</para>
 
+     <para>For your convenience, there's a file called <filename>build.mk.sample</filename>
+     that can serve as a starting point for your <filename>build.mk</filename>.</para>
+
       <para>For example, <filename>config.mk.in</filename> contains
       the definition:</para>
 
@@ -2197,7 +2239,7 @@ Foo.o : Baz.hi
 
       <para> Do <emphasis>NOT</emphasis> use
       <filename>ghc/compiler/ghc</filename>, or
-      <filename>ghc/compiler/ghc-5.xx</filename>, as these are the
+      <filename>ghc/compiler/ghc-6.xx</filename>, as these are the
       scripts intended for installation, and contain hard-wired paths
       to the installed libraries, rather than the libraries in the
       build tree.</para>
@@ -3583,10 +3625,10 @@ $ make install-docs
       target machine, and compiling them using gcc to get a working
       GHC.</para>
 
-      <para><emphasis>NOTE: GHC version 5.xx is significantly harder
-      to bootstrap from C than previous versions.  We recommend
-      starting from version 4.08.2 if you need to bootstrap in this
-      way.</emphasis></para>
+      <para><emphasis>NOTE: GHC versions 5.xx and later are
+      significantly harder to bootstrap from C than earlier versions.
+      We recommend starting from version 4.08.2 if you need to
+      bootstrap in this way.</emphasis></para>
 
       <para>HC files are architecture-dependent (but not
       OS-dependent), so you have to get a set that were generated on
@@ -3708,11 +3750,11 @@ GhcWithRegisterised=NO
 </programlisting>
 
 <programlisting>
-# build.mk for GHC 5.xx
+# build.mk for GHC 5.xx and 6.x
 GhcUnregisterised=YES
 </programlisting>
 
-       <para>Version 5.xx only: use the option
+       <para>Versions 5.xx and 6.x only: use the option
        <option>--enable-hc-boot-unregisterised</option> instead of
        <option>--enable-hc-boot</option> when running
        <filename>./configure</filename>.</para>
@@ -4074,7 +4116,7 @@ guide) before continuing to read these notes.
 </para>
 
 
-<sect2><Title>Cygwin and MinGW</Title>
+<sect2 id="cygwin-and-mingw"><Title>Cygwin and MinGW</Title>
 
 <para> The Windows situation for building GHC is rather confusing.  This section
 tries to clarify, and to establish terminology.</para>
@@ -4129,6 +4171,37 @@ that Haskell programs compiled by GHC-cygwin can import the (Haskell) Posix libr
 </para>
 </sect3>
 
+<sect3><title>HOST_OS vs TARGET_OS</title>
+
+<para>
+In the source code you'll find various ifdefs looking like:
+<programlisting>
+  #ifdef mingw32_HOST_OS
+    ...blah blah...
+  #endif
+</programlisting>
+and 
+<programlisting>
+  #ifdef mingw32_TARGET_OS
+    ...blah blah...
+  #endif
+</programlisting>
+These macros are set by the configure script (via the file config.h).
+Which is which?  The criterion is this.  In the ifdefs in GHC's source code:
+<itemizedlist>
+  <listitem> <para>
+  The "host" system is the one on which GHC itself will be run.
+  </para> </listitem>
+  <listitem> <para>
+  The "target" system is the one for which the program compiled by GHC will be run.
+  </para> </listitem>
+</itemizedlist>
+For a stage-2 compiler, in which GHCi is available, the "host" and "target" systems must be the same.
+So then it doesn't really matter whether you use the HOST_OS or TARGET_OS cpp macros.
+
+</para>
+</sect3>
+
 <sect3><title>Summary</title>
 
 <para>Notice that "GHC-mingw" means "GHC that <emphasis>targets</emphasis> MinGW".  It says nothing about 
@@ -4166,9 +4239,13 @@ but you do need it to <emphasis>build</emphasis> GHC.</para>
 
 <para> Install Cygwin from <ulink url="http://www.cygwin.com/">http://www.cygwin.com/</ulink>.
 The installation process is straightforward; we install it in <Filename>c:/cygwin</Filename>.
-Both <command>cvs</command> and <command>ssh</command>
-come with Cygwin, but you'll need them, so make sure you select them when running
-the Cygwin installer.
+During the installation dialogue, make sure that you select:
+<command>cvs</command>, <command>openssh</command>,
+<command>autoconf</command>,
+<command>binutils</command> (includes ld and (I think) ar),
+<command>gcc</command>,
+<command>flex</command>,
+<command>make</command>.
 
 </para>
 <para> Now set the following user environment variables:
@@ -4206,8 +4283,24 @@ There are a few other things to do:
 <itemizedlist>
 <listitem>
 <para>
+By default, cygwin provides the command shell <filename>ash</filename>
+as <filename>sh.exe</filename>. We have often seen build-system problems that 
+turn out to be due to bugs in <filename>ash</filename>
+(to do with quoting
+and length of command lines).  On the other hand <filename>bash</filename> seems
+to be rock solid.
+So, in <filename>cygwin/bin</filename>
+remove the supplied <filename>sh.exe</filename> (or rename it as <filename>ash.exe</filename>),
+and copy <filename>bash.exe</filename> to  <filename>sh.exe</filename>.
+You'll need to do this in Windows Explorer or the Windows <command>cmd</command> shell, because
+you can't rename a running program!
+</para>
+</listitem>
+
+<listitem>
+<para>
 Some script files used in the make system start with "<Command>#!/bin/perl</Command>",
-(and similarly for <Command>bash</Command>).  Notice the hardwired path!
+(and similarly for <Command>sh</Command>).  Notice the hardwired path!
 So you need to ensure that your <Filename>/bin</Filename> directory has the following
 binaries in it:
 <itemizedlist>
@@ -4219,21 +4312,10 @@ All these come in Cygwin's <Filename>bin</Filename> directory, which you probabl
 installed as <Filename>c:/cygwin/bin</Filename>.  By default Cygwin mounts "<Filename>/</Filename>" as
 <Filename>c:/cygwin</Filename>, so if you just take the defaults it'll all work ok.
 (You can discover where your Cygwin
-root directory <Filename>/</Filename> is by typing <Command>mount</Command>).
+root directory <Filename>/</Filename> is by typing <Command>mount</Command>.)
 Provided <Filename>/bin</Filename> points to the Cygwin <Filename>bin</Filename>
-directory, there's no need to copy anything.
-</para>
-</listitem>
-
-<listitem>
-<para>
-By default, cygwin provides the command shell <filename>ash</filename>
-as <filename>sh.exe</filename>. It has a couple of 'issues' (to do with quoting
-and length of command lines), so
-in your <filename>/bin</filename> directory, make sure that <filename>
-bash.exe</filename> is also provided as <filename>sh.exe</filename>
-(i.e. overwrite the old <filename>sh.exe</filename> with a copy of
-<filename>bash.exe</filename>).
+directory, there's no need to copy anything.  If not, copy these binaries from the <filename>cygwin/bin</filename>
+directory (after fixing the <filename>sh.exe</filename> stuff mentioned in the previous bullet).
 </para>
 </listitem>
 </itemizedlist>
@@ -4290,7 +4372,8 @@ Happy is a parser generator used to compile the Haskell grammar.  Add it in your
 
 <listitem>
 <para>GHC uses the <emphasis>mingw</emphasis> C compiler to
-generate code, so you have to install that. Just pick up a mingw bundle at
+generate code, so you have to install that (see <xref linkend="cygwin-and-mingw">). 
+Just pick up a mingw bundle at
 <ulink url="http://www.mingw.org/">http://www.mingw.org/</ulink>.
 We install it in <filename>c:/mingw</filename>.
 </para>
@@ -4303,6 +4386,18 @@ you are likely to get into a mess because their names overlap with Cygwin binari
 
 
 <listitem>
+<para>We use <command>emacs</command> a lot, so we install that too.
+When you are in <filename>fptools/ghc/compiler</filename>, you can use
+"<literal>make tags</literal>" to make a TAGS file for emacs.  That uses the utility
+<filename>fptools/ghc/utils/hasktags/hasktags</filename>, so you need to make that first.
+The most convenient way to do this is by going <literal>make boot</literal> in <filename>fptools/ghc</filename>.
+The <literal>make tags</literal> command also uses <command>etags</command>, which comes with <command>emacs</command>,
+so you will need to add <filename>emacs/bin</filename> to your <literal>PATH</literal>.
+</para>
+</listitem>
+
+
+<listitem>
 <para> Finally, check out a copy of GHC sources from
 the CVS repository, following the instructions above (<xref linkend="cvs-access">).
 </para>
@@ -4366,13 +4461,39 @@ can be really confusing.
     <filename>fptools/</filename> thus:
 
 <Screen>
-  ./configure --host=i386-unknown-mingw32 --with-gcc=/mingw/bin/gcc
+  ./configure --host=i386-unknown-mingw32 --with-gcc=c:/mingw/bin/gcc
 </Screen>
 This is the point at which you specify that you are building GHC-mingw
-(see <xref linkend="ghc-mingw">).  
+(see <xref linkend="ghc-mingw">). </para>
 
-Both these options are important! It's possible to get into
+<para> Both these options are important! It's possible to get into
 trouble using the wrong C compiler!</para>
+<para>
+Furthermore, it's <emphasis>very important</emphasis> that you specify a 
+full MinGW path for <command>gcc</command>, not a Cygwin path, because GHC (which
+uses this path to invoke <command>gcc</command>) is a MinGW program and won't
+understand a Cygwin path.  For example, if you 
+say <literal>--with-gcc=/mingw/bin/gcc</literal>, it'll be interpreted as
+<filename>/cygdrive/c/mingw/bin/gcc</filename>, and GHC will fail the first
+time it tries to invoke it.   Worse, the failure comes with
+no error message whatsoever.  GHC simply fails silently when first invoked, 
+typically leaving you with this:
+<programlisting>
+make[4]: Leaving directory `/cygdrive/e/fptools-stage1/ghc/rts/gmp'
+../../ghc/compiler/ghc-inplace -optc-mno-cygwin -optc-O 
+  -optc-Wall -optc-W  -optc-Wstrict-prototypes -optc-Wmissing-prototypes 
+  -optc-Wmissing-declarations -optc-Winline -optc-Waggregate-return 
+  -optc-Wbad-function-cast -optc-Wcast-align -optc-I../includes 
+  -optc-I. -optc-Iparallel -optc-DCOMPILING_RTS 
+  -optc-fomit-frame-pointer -O2 -static 
+  -package-name rts -O -dcore-lint -c Adjustor.c -o Adjustor.o
+make[2]: *** [Adjustor.o] Error 1
+make[1]: *** [all] Error 1
+make[1]: Leaving directory `/cygdrive/e/fptools-stage1/ghc'
+make: *** [all] Error 1
+</programlisting>
+Be warned!
+</para>
 
 <para>
 If you want to build GHC-cygwin (<xref linkend="ghc-cygwin">)
@@ -4383,6 +4504,17 @@ you'll have to do something more like:
 </para>
 </listitem>
 
+<listitem><para> You almost certainly want to set
+<programlisting>
+  SplitObjs = NO
+</programlisting>
+in your <filename>build.mk</filename> configuration file (see <xref linkend="sec-build-config">).
+This tells the build system not to split each library into a myriad of little object files, one
+for each function.  Doing so reduces binary sizes for statically-linked binaries, but on Windows
+it dramatically increases the time taken to build the libraries in the first place.
+</para>
+</listitem>
+
 <listitem><para> Do not attempt to build the documentation.
 It needs all kinds of wierd Jade stuff that we haven't worked out for
 Win32.</para></listitem>