pkgs/build-support/cabal: stabilize shared linking support

We cannot pass the --{enable,disable}-executable-dynamic flags to GHC
versions prior to 7.4.x.

Building shared libraries via --{enable,disable}-shared is possible in theory
with GHC 6.12.x or later, but doesn't work in practice because our GHC 6.10.x
builds don't provide shared versions of their base libraries. This could
probably be fixed, but it's probably not worth the effort.
This commit is contained in:
Peter Simons 2013-10-20 14:58:05 +02:00
parent 312d081b6a
commit 911ca85240
2 changed files with 42 additions and 19 deletions

View File

@ -4,11 +4,26 @@
, enableLibraryProfiling ? false , enableLibraryProfiling ? false
, enableSharedLibraries ? false , enableSharedLibraries ? false
, enableSharedExecutables ? false , enableSharedExecutables ? false
, enableCheckPhase ? true , enableCheckPhase ? stdenv.lib.versionOlder "7.4" ghc.version
}: }:
# The Cabal library shipped with GHC versions older than 7.x doesn't accept the --enable-tests configure flag. let
assert enableCheckPhase -> stdenv.lib.versionOlder "7" ghc.ghcVersion; enableFeature = stdenv.lib.enableFeature;
versionOlder = stdenv.lib.versionOlder;
optional = stdenv.lib.optional;
optionals = stdenv.lib.optionals;
optionalString = stdenv.lib.optionalString;
filter = stdenv.lib.filter;
in
# Cabal shipped with GHC 6.12.4 or earlier doesn't know the "--enable-tests configure" flag.
assert enableCheckPhase -> versionOlder "7" ghc.version;
# GHC prior to 7.4.x doesn't know the "--enable-executable-dynamic" flag.
assert enableSharedExecutables -> versionOlder "7.4" ghc.version;
# Our GHC 6.10.x builds do not provide sharable versions of their core libraries.
assert enableSharedLibraries -> versionOlder "6.12" ghc.version;
{ {
mkDerivation = mkDerivation =
@ -25,8 +40,8 @@ assert enableCheckPhase -> stdenv.lib.versionOlder "7" ghc.ghcVersion;
# in the interest of keeping hashes stable. # in the interest of keeping hashes stable.
postprocess = postprocess =
x : (removeAttrs x internalAttrs) // { x : (removeAttrs x internalAttrs) // {
buildInputs = stdenv.lib.filter (y : ! (y == null)) x.buildInputs; buildInputs = filter (y : ! (y == null)) x.buildInputs;
propagatedBuildInputs = stdenv.lib.filter (y : ! (y == null)) x.propagatedBuildInputs; propagatedBuildInputs = filter (y : ! (y == null)) x.propagatedBuildInputs;
doCheck = enableCheckPhase && x.doCheck; doCheck = enableCheckPhase && x.doCheck;
}; };
@ -69,7 +84,7 @@ assert enableCheckPhase -> stdenv.lib.versionOlder "7" ghc.ghcVersion;
# but often propagatedBuildInputs is preferable anyway # but often propagatedBuildInputs is preferable anyway
buildInputs = [ghc Cabal] ++ self.extraBuildInputs; buildInputs = [ghc Cabal] ++ self.extraBuildInputs;
extraBuildInputs = self.buildTools ++ extraBuildInputs = self.buildTools ++
(stdenv.lib.optionals self.doCheck self.testDepends) ++ (optionals self.doCheck self.testDepends) ++
(if self.pkgconfigDepends == [] then [] else [pkgconfig]) ++ (if self.pkgconfigDepends == [] then [] else [pkgconfig]) ++
(if self.isLibrary then [] else self.buildDepends ++ self.extraLibraries ++ self.pkgconfigDepends); (if self.isLibrary then [] else self.buildDepends ++ self.extraLibraries ++ self.pkgconfigDepends);
@ -105,8 +120,8 @@ assert enableCheckPhase -> stdenv.lib.versionOlder "7" ghc.ghcVersion;
jailbreak = false; jailbreak = false;
# pass the '--enable-split-objs' flag to cabal in the configure stage # pass the '--enable-split-objs' flag to cabal in the configure stage
enableSplitObjs = !( stdenv.isDarwin # http://hackage.haskell.org/trac/ghc/ticket/4013 enableSplitObjs = !( stdenv.isDarwin # http://hackage.haskell.org/trac/ghc/ticket/4013
|| stdenv.lib.versionOlder "7.6.99" ghc.ghcVersion # -fsplit-ojbs is broken in 7.7 snapshot || versionOlder "7.6.99" ghc.version # -fsplit-ojbs is broken in 7.7 snapshot
); );
# pass the '--enable-tests' flag to cabal in the configure stage # pass the '--enable-tests' flag to cabal in the configure stage
@ -122,21 +137,22 @@ assert enableCheckPhase -> stdenv.lib.versionOlder "7" ghc.ghcVersion;
inherit enableSharedExecutables; inherit enableSharedExecutables;
extraConfigureFlags = [ extraConfigureFlags = [
(stdenv.lib.enableFeature enableLibraryProfiling "library-profiling") (enableFeature self.enableSplitObjs "split-objs")
(stdenv.lib.enableFeature self.enableSharedLibraries "shared") (enableFeature enableLibraryProfiling "library-profiling")
(stdenv.lib.enableFeature self.enableSharedExecutables "executable-dynamic") (enableFeature self.enableSharedLibraries "shared")
(stdenv.lib.enableFeature self.enableSplitObjs "split-objs") (optional (versionOlder "7.4" ghc.version) (enableFeature self.enableSharedExecutables "executable-dynamic"))
] ++ stdenv.lib.optional (stdenv.lib.versionOlder "7" ghc.ghcVersion) (stdenv.lib.enableFeature self.doCheck "tests"); (optional (versionOlder "7" ghc.version) (enableFeature self.doCheck "tests"))
];
# GHC needs the locale configured during the Haddock phase. # GHC needs the locale configured during the Haddock phase.
LANG = "en_US.UTF-8"; LANG = "en_US.UTF-8";
LOCALE_ARCHIVE = lib.optionalString stdenv.isLinux "${glibcLocales}/lib/locale/locale-archive"; LOCALE_ARCHIVE = optionalString stdenv.isLinux "${glibcLocales}/lib/locale/locale-archive";
# compiles Setup and configures # compiles Setup and configures
configurePhase = '' configurePhase = ''
eval "$preConfigure" eval "$preConfigure"
${lib.optionalString self.jailbreak "${jailbreakCabal}/bin/jailbreak-cabal ${self.pname}.cabal"} ${optionalString self.jailbreak "${jailbreakCabal}/bin/jailbreak-cabal ${self.pname}.cabal"}
for i in Setup.hs Setup.lhs; do for i in Setup.hs Setup.lhs; do
test -f $i && ghc --make $i test -f $i && ghc --make $i
@ -175,7 +191,7 @@ assert enableCheckPhase -> stdenv.lib.versionOlder "7" ghc.ghcVersion;
eval "$postBuild" eval "$postBuild"
''; '';
checkPhase = stdenv.lib.optional self.doCheck '' checkPhase = optional self.doCheck ''
eval "$preCheck" eval "$preCheck"
./Setup test ${self.testTarget} ./Setup test ${self.testTarget}

View File

@ -58,7 +58,12 @@
# #
# For most packages, however, we keep only one version, and use default.nix. # For most packages, however, we keep only one version, and use default.nix.
{pkgs, newScope, ghc, prefFun, enableLibraryProfiling ? false, modifyPrio ? (x : x)}: { pkgs, newScope, ghc, prefFun, modifyPrio ? (x : x)
, enableLibraryProfiling ? false
, enableSharedLibraries ? true
, enableSharedExecutables ? false
, enableCheckPhase ? pkgs.stdenv.lib.versionOlder "7.4" ghc.version
}:
# We redefine callPackage to take into account the new scope. The optional # We redefine callPackage to take into account the new scope. The optional
# modifyPrio argument can be set to lowPrio to make all Haskell packages have # modifyPrio argument can be set to lowPrio to make all Haskell packages have
@ -105,8 +110,10 @@ let result = let callPackage = x : y : modifyPrio (newScope result.finalReturn x
# packages. It isn't the Cabal library, which is spelled "Cabal". # packages. It isn't the Cabal library, which is spelled "Cabal".
cabal = callPackage ../build-support/cabal { cabal = callPackage ../build-support/cabal {
enableLibraryProfiling = enableLibraryProfiling; inherit enableLibraryProfiling;
enableCheckPhase = pkgs.stdenv.lib.versionOlder "7.4" self.ghc.ghcVersion; inherit enableSharedLibraries;
inherit enableSharedExecutables;
inherit enableCheckPhase;
glibcLocales = if pkgs.stdenv.isLinux then pkgs.glibcLocales else null; glibcLocales = if pkgs.stdenv.isLinux then pkgs.glibcLocales else null;
}; };