source/build separation

Simon Marlow marlowsd at
Tue Nov 15 17:47:18 CET 2011

On 15/11/2011 10:21, Rustom Mody wrote:
> I am building ghc from source.
> The building page
> mentions lndir for separating source trees from build trees.
> Given how much detail is generally given for individual commands eg
> maybe it would be nice to have a (typical?) lndir command also given?

Sure.  It's just

   $ mkdir <build>
   $ cd <build>
   $ lndir <source>

but lndir is not a standard tool (any more), so you might have to build 
it yourself.  There are sources in the GHC source tree in utils/lndir.

Note the GHC build works perfectly well without a separate build tree, 
and I think that's the way most people do it.

> Also there is a mention about using a local git clone here
> Arent these two alternative ways with similar intent - viz. keeping
> source pristine and separating build 'messiness'?
> Or do people use both git (local) clone + lndir?  If so why?

Right - arguably you can just clone a new source tree for each build 
that you want.  I use separate build trees for two reasons:

  - my source trees are on a backed-up network file system, but the
    build trees are on fast local disk.

  - I can have several builds on different machines all using the same
    source tree.

On my laptop the situation is similar, but my source trees are in my 
home dir which is an ecryptfs and the build trees are outside on the 
unencrypted partition.  Not only is ecryptfs too slow for building on, 
it also doesn't work properly (there's some bug related to time stamps 
that I never managed to narrow down, it results in unnecessary rebuilding).

You could do all this with git clones, but it would mean extra shuffling 
of patches around.  If you're happy with that, then that's fine - use 
whatever scheme you're more comfortable with.


More information about the Glasgow-haskell-users mailing list