Cabal recompiles library for executables
simonmar at microsoft.com
Mon Dec 4 10:26:49 EST 2006
Neil Mitchell wrote:
>> If a project consists of both a library and executables, the library
>> modules are re-compiled for each executable. (I use GHC.) That leads to
>> high space and time consumption. Is this a bug or a feature?
> I also note that if a cabal project contains two programs which share
> code, then this code is recompiled twice on each change.
Compiling twice is the safe thing to do. Sharing the object files is only
possible if the object code really would be the same if it was recompiled; there
are various things that could prevent that being true, for example if flags
change or modules lower down the dependency tree have changed. I'm sure it's
possible to do this, but AFAIK nobody has put any thought into figuring out when
it's safe to do it.
If you share code between executables, the right thing to do is to put it in a
library (I realise that when the amount of code shared is small it doesn't seem
worthwhile to create a whole package, though).
More information about the cabal-devel