pkgs/build-support/cabal: add 'enableSplitObjs' field to enable/disable object splitting

This patch configures all Cabal builds with '--enable-split-objs' unless the
Nix expression explicitly sets "enableSplitObjs = false". The Cabal manual [1]
describes this option as follows:

 | The GHC -split-objs reduces the final size of the executables that use the
 | library by allowing them to link with only the bits that they use rather
 | than the entire library. The downside is that building the library takes
 | longer and uses considerably more memory.

One immediate benefit of this change is that the 'darcs' closure defined in the
top-level no longer refers to GHC. The same is probably true with other
executable packages.

[1] http://www.haskell.org/cabal/users-guide/installing-packages.html#setup-configure
This commit is contained in:
Peter Simons 2013-02-18 12:32:15 +01:00
parent 4994518501
commit dd13aa9c94

View File

@ -80,15 +80,25 @@
isLibrary = ! self.isExecutable;
isExecutable = false;
# ignore version restrictions on the build inputs that the cabal file might specify
jailbreak = false;
# pass the '--enable-split-objs' flag to cabal in the configure stage
enableSplitObjs = true;
# configure flag to pass to enable/disable library profiling
libraryProfiling =
if enableLibraryProfiling then ["--enable-library-profiling"]
else ["--disable-library-profiling"];
# configure flag to pass to enable/disable object splitting
splitObjects = if self.enableSplitObjs then "--enable-split-objs" else "--disable-split-objs";
# compiles Setup and configures
configurePhase = ''
eval "$preConfigure"
${lib.optionalString (lib.attrByPath ["jailbreak"] false self) "${jailbreakCabal}/bin/jailbreak-cabal ${self.pname}.cabal"}
${lib.optionalString self.jailbreak "${jailbreakCabal}/bin/jailbreak-cabal ${self.pname}.cabal"}
for i in Setup.hs Setup.lhs; do
test -f $i && ghc --make $i
done
@ -104,7 +114,7 @@
done
done
./Setup configure --verbose --prefix="$out" $libraryProfiling $extraLibDirs $configureFlags
./Setup configure --verbose --prefix="$out" $libraryProfiling $splitObjects $extraLibDirs $configureFlags
eval "$postConfigure"
'';