lol

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.

+42 -19
+32 -16
pkgs/build-support/cabal/default.nix
··· 4 4 , enableLibraryProfiling ? false 5 5 , enableSharedLibraries ? false 6 6 , enableSharedExecutables ? false 7 - , enableCheckPhase ? true 7 + , enableCheckPhase ? stdenv.lib.versionOlder "7.4" ghc.version 8 8 }: 9 9 10 - # The Cabal library shipped with GHC versions older than 7.x doesn't accept the --enable-tests configure flag. 11 - assert enableCheckPhase -> stdenv.lib.versionOlder "7" ghc.ghcVersion; 10 + let 11 + enableFeature = stdenv.lib.enableFeature; 12 + versionOlder = stdenv.lib.versionOlder; 13 + optional = stdenv.lib.optional; 14 + optionals = stdenv.lib.optionals; 15 + optionalString = stdenv.lib.optionalString; 16 + filter = stdenv.lib.filter; 17 + in 18 + 19 + # Cabal shipped with GHC 6.12.4 or earlier doesn't know the "--enable-tests configure" flag. 20 + assert enableCheckPhase -> versionOlder "7" ghc.version; 21 + 22 + # GHC prior to 7.4.x doesn't know the "--enable-executable-dynamic" flag. 23 + assert enableSharedExecutables -> versionOlder "7.4" ghc.version; 24 + 25 + # Our GHC 6.10.x builds do not provide sharable versions of their core libraries. 26 + assert enableSharedLibraries -> versionOlder "6.12" ghc.version; 12 27 13 28 { 14 29 mkDerivation = ··· 25 40 # in the interest of keeping hashes stable. 26 41 postprocess = 27 42 x : (removeAttrs x internalAttrs) // { 28 - buildInputs = stdenv.lib.filter (y : ! (y == null)) x.buildInputs; 29 - propagatedBuildInputs = stdenv.lib.filter (y : ! (y == null)) x.propagatedBuildInputs; 43 + buildInputs = filter (y : ! (y == null)) x.buildInputs; 44 + propagatedBuildInputs = filter (y : ! (y == null)) x.propagatedBuildInputs; 30 45 doCheck = enableCheckPhase && x.doCheck; 31 46 }; 32 47 ··· 69 84 # but often propagatedBuildInputs is preferable anyway 70 85 buildInputs = [ghc Cabal] ++ self.extraBuildInputs; 71 86 extraBuildInputs = self.buildTools ++ 72 - (stdenv.lib.optionals self.doCheck self.testDepends) ++ 87 + (optionals self.doCheck self.testDepends) ++ 73 88 (if self.pkgconfigDepends == [] then [] else [pkgconfig]) ++ 74 89 (if self.isLibrary then [] else self.buildDepends ++ self.extraLibraries ++ self.pkgconfigDepends); 75 90 ··· 105 120 jailbreak = false; 106 121 107 122 # pass the '--enable-split-objs' flag to cabal in the configure stage 108 - enableSplitObjs = !( stdenv.isDarwin # http://hackage.haskell.org/trac/ghc/ticket/4013 109 - || stdenv.lib.versionOlder "7.6.99" ghc.ghcVersion # -fsplit-ojbs is broken in 7.7 snapshot 123 + enableSplitObjs = !( stdenv.isDarwin # http://hackage.haskell.org/trac/ghc/ticket/4013 124 + || versionOlder "7.6.99" ghc.version # -fsplit-ojbs is broken in 7.7 snapshot 110 125 ); 111 126 112 127 # pass the '--enable-tests' flag to cabal in the configure stage ··· 122 137 inherit enableSharedExecutables; 123 138 124 139 extraConfigureFlags = [ 125 - (stdenv.lib.enableFeature enableLibraryProfiling "library-profiling") 126 - (stdenv.lib.enableFeature self.enableSharedLibraries "shared") 127 - (stdenv.lib.enableFeature self.enableSharedExecutables "executable-dynamic") 128 - (stdenv.lib.enableFeature self.enableSplitObjs "split-objs") 129 - ] ++ stdenv.lib.optional (stdenv.lib.versionOlder "7" ghc.ghcVersion) (stdenv.lib.enableFeature self.doCheck "tests"); 140 + (enableFeature self.enableSplitObjs "split-objs") 141 + (enableFeature enableLibraryProfiling "library-profiling") 142 + (enableFeature self.enableSharedLibraries "shared") 143 + (optional (versionOlder "7.4" ghc.version) (enableFeature self.enableSharedExecutables "executable-dynamic")) 144 + (optional (versionOlder "7" ghc.version) (enableFeature self.doCheck "tests")) 145 + ]; 130 146 131 147 # GHC needs the locale configured during the Haddock phase. 132 148 LANG = "en_US.UTF-8"; 133 - LOCALE_ARCHIVE = lib.optionalString stdenv.isLinux "${glibcLocales}/lib/locale/locale-archive"; 149 + LOCALE_ARCHIVE = optionalString stdenv.isLinux "${glibcLocales}/lib/locale/locale-archive"; 134 150 135 151 # compiles Setup and configures 136 152 configurePhase = '' 137 153 eval "$preConfigure" 138 154 139 - ${lib.optionalString self.jailbreak "${jailbreakCabal}/bin/jailbreak-cabal ${self.pname}.cabal"} 155 + ${optionalString self.jailbreak "${jailbreakCabal}/bin/jailbreak-cabal ${self.pname}.cabal"} 140 156 141 157 for i in Setup.hs Setup.lhs; do 142 158 test -f $i && ghc --make $i ··· 175 191 eval "$postBuild" 176 192 ''; 177 193 178 - checkPhase = stdenv.lib.optional self.doCheck '' 194 + checkPhase = optional self.doCheck '' 179 195 eval "$preCheck" 180 196 181 197 ./Setup test ${self.testTarget}
+10 -3
pkgs/top-level/haskell-packages.nix
··· 58 58 # 59 59 # For most packages, however, we keep only one version, and use default.nix. 60 60 61 - {pkgs, newScope, ghc, prefFun, enableLibraryProfiling ? false, modifyPrio ? (x : x)}: 61 + { pkgs, newScope, ghc, prefFun, modifyPrio ? (x : x) 62 + , enableLibraryProfiling ? false 63 + , enableSharedLibraries ? true 64 + , enableSharedExecutables ? false 65 + , enableCheckPhase ? pkgs.stdenv.lib.versionOlder "7.4" ghc.version 66 + }: 62 67 63 68 # We redefine callPackage to take into account the new scope. The optional 64 69 # modifyPrio argument can be set to lowPrio to make all Haskell packages have ··· 105 110 # packages. It isn't the Cabal library, which is spelled "Cabal". 106 111 107 112 cabal = callPackage ../build-support/cabal { 108 - enableLibraryProfiling = enableLibraryProfiling; 109 - enableCheckPhase = pkgs.stdenv.lib.versionOlder "7.4" self.ghc.ghcVersion; 113 + inherit enableLibraryProfiling; 114 + inherit enableSharedLibraries; 115 + inherit enableSharedExecutables; 116 + inherit enableCheckPhase; 110 117 glibcLocales = if pkgs.stdenv.isLinux then pkgs.glibcLocales else null; 111 118 }; 112 119