Merge pull request #40996 from obsidiansystems/cross-ghc

ghc, haskell-infra: #40929 take 2

authored by

John Ericson and committed by
GitHub
ce0180df a0c480ab

+155 -58
+13 -3
pkgs/development/compilers/ghc/7.10.3.nix
··· 24 24 , # Whether to build dynamic libs for the standard library (on the target 25 25 # platform). Static libs are always built. 26 26 enableShared ? true 27 + 28 + , # What flavour to build. An empty string indicates no 29 + # specific flavour and falls back to ghc default values. 30 + ghcFlavour ? stdenv.lib.optionalString (targetPlatform != hostPlatform) "perf-cross" 27 31 }: 28 32 29 33 assert !enableIntegerSimple -> gmp != null; ··· 42 46 }; 43 47 44 48 buildMK = '' 49 + BuildFlavour = ${ghcFlavour} 50 + ifneq \"\$(BuildFlavour)\" \"\" 51 + include mk/flavours/\$(BuildFlavour).mk 52 + endif 45 53 DYNAMIC_GHC_PROGRAMS = ${if enableShared then "YES" else "NO"} 46 54 '' + stdenv.lib.optionalString enableIntegerSimple '' 47 55 INTEGER_LIBRARY = integer-simple 48 56 '' + stdenv.lib.optionalString (targetPlatform != hostPlatform) '' 49 - BuildFlavour = perf-cross 50 57 Stage1Only = YES 51 58 HADDOCK_DOCS = NO 52 59 '' + stdenv.lib.optionalString enableRelocatedStaticLibs '' ··· 68 75 targetCC = builtins.head toolsForTarget; 69 76 70 77 in 71 - 72 78 stdenv.mkDerivation rec { 73 79 version = "7.10.3"; 74 80 name = "${targetPrefix}ghc-${version}"; ··· 86 92 docFixes 87 93 ./relocation.patch 88 94 ]; 95 + 96 + postPatch = "patchShebangs ."; 89 97 90 98 # GHC is a bit confused on its cross terminology. 91 99 preConfigure = '' ··· 103 111 export RANLIB="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ranlib" 104 112 export READELF="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}readelf" 105 113 export STRIP="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}strip" 114 + 106 115 echo -n "${buildMK}" > mk/build.mk 107 116 sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure 108 117 '' + stdenv.lib.optionalString (!stdenv.isDarwin) '' ··· 135 144 crossConfig = true; 136 145 137 146 nativeBuildInputs = [ 138 - ghc perl libxml2 libxslt docbook_xsl docbook_xml_dtd_45 docbook_xml_dtd_42 hscolour 147 + perl libxml2 libxslt docbook_xsl docbook_xml_dtd_45 docbook_xml_dtd_42 148 + ghc hscolour 139 149 ]; 140 150 141 151 # For building runtime libs
+19 -5
pkgs/development/compilers/ghc/8.0.2.nix
··· 23 23 , # Whether to build dynamic libs for the standard library (on the target 24 24 # platform). Static libs are always built. 25 25 enableShared ? true 26 + 27 + , # What flavour to build. An empty string indicates no 28 + # specific flavour and falls back to ghc default values. 29 + ghcFlavour ? stdenv.lib.optionalString (targetPlatform != hostPlatform) "perf-cross" 26 30 }: 27 31 28 32 assert !enableIntegerSimple -> gmp != null; ··· 36 40 "${targetPlatform.config}-"; 37 41 38 42 buildMK = '' 43 + BuildFlavour = ${ghcFlavour} 44 + ifneq \"\$(BuildFlavour)\" \"\" 45 + include mk/flavours/\$(BuildFlavour).mk 46 + endif 39 47 DYNAMIC_GHC_PROGRAMS = ${if enableShared then "YES" else "NO"} 40 48 '' + stdenv.lib.optionalString enableIntegerSimple '' 41 49 INTEGER_LIBRARY = integer-simple 42 50 '' + stdenv.lib.optionalString (targetPlatform != hostPlatform) '' 43 - BuildFlavour = perf-cross 44 51 Stage1Only = YES 45 52 HADDOCK_DOCS = NO 46 53 '' + stdenv.lib.optionalString enableRelocatedStaticLibs '' ··· 87 94 ++ stdenv.lib.optional stdenv.isDarwin ./ghc-8.0.2-no-cpp-warnings.patch 88 95 ++ stdenv.lib.optional stdenv.isDarwin ./backport-dylib-command-size-limit.patch; 89 96 97 + postPatch = "patchShebangs ."; 98 + 90 99 # GHC is a bit confused on its cross terminology. 91 100 preConfigure = '' 92 101 for env in $(env | grep '^TARGET_' | sed -E 's|\+?=.*||'); do ··· 103 112 export RANLIB="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ranlib" 104 113 export READELF="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}readelf" 105 114 export STRIP="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}strip" 115 + 106 116 echo -n "${buildMK}" > mk/build.mk 107 117 sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure 108 118 '' + stdenv.lib.optionalString (!stdenv.isDarwin) '' ··· 134 144 # masss-rebuild. 135 145 crossConfig = true; 136 146 137 - nativeBuildInputs = [ ghc perl hscolour sphinx ]; 147 + nativeBuildInputs = [ 148 + perl sphinx 149 + ghc hscolour 150 + ]; 138 151 139 152 # For building runtime libs 140 153 depsBuildTarget = toolsForTarget; ··· 151 164 # that in turn causes GHCi to abort 152 165 stripDebugFlags = [ "-S" ] ++ stdenv.lib.optional (!targetPlatform.isDarwin) "--keep-file-symbols"; 153 166 154 - # zsh and other shells are smart about `{ghc}` but bash isn't, and doesn't 155 - # treat that as a unary `{x,y,z,..}` repetition. 156 167 postInstall = '' 157 - paxmark m $out/lib/${name}/bin/${if targetPlatform != hostPlatform then "ghc" else "{ghc,haddock}"} 168 + for bin in "$out"/lib/${name}/bin/*; do 169 + isELF "$bin" || continue 170 + paxmark m "$bin" 171 + done 158 172 159 173 # Install the bash completion file. 160 174 install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc
+17 -9
pkgs/development/compilers/ghc/8.2.2.nix
··· 23 23 24 24 , # Whether to build dynamic libs for the standard library (on the target 25 25 # platform). Static libs are always built. 26 - enableShared ? 27 - !(targetPlatform.isDarwin 28 - # On iOS, dynamic linking is not supported 29 - && (targetPlatform.isAarch64 || targetPlatform.isAarch32)) 26 + enableShared ? true 27 + 28 + , # What flavour to build. An empty string indicates no 29 + # specific flavour and falls back to ghc default values. 30 + ghcFlavour ? stdenv.lib.optionalString (targetPlatform != hostPlatform) "perf-cross" 30 31 , # Whether to backport https://phabricator.haskell.org/D4388 for 31 32 # deterministic profiling symbol names, at the cost of a slightly 32 33 # non-standard GHC API ··· 44 45 "${targetPlatform.config}-"; 45 46 46 47 buildMK = '' 48 + BuildFlavour = ${ghcFlavour} 49 + ifneq \"\$(BuildFlavour)\" \"\" 50 + include mk/flavours/\$(BuildFlavour).mk 51 + endif 47 52 DYNAMIC_GHC_PROGRAMS = ${if enableShared then "YES" else "NO"} 48 53 '' + stdenv.lib.optionalString enableIntegerSimple '' 49 54 INTEGER_LIBRARY = integer-simple 50 55 '' + stdenv.lib.optionalString (targetPlatform != hostPlatform) '' 51 - BuildFlavour = perf-cross 52 56 Stage1Only = YES 53 57 HADDOCK_DOCS = NO 54 58 BUILD_SPHINX_HTML = NO ··· 153 157 # masss-rebuild. 154 158 crossConfig = true; 155 159 156 - nativeBuildInputs = [ alex autoconf autoreconfHook automake ghc happy hscolour perl python3 sphinx ]; 160 + nativeBuildInputs = [ 161 + autoconf autoreconfHook automake perl python3 sphinx 162 + ghc alex happy hscolour 163 + ]; 157 164 158 165 # For building runtime libs 159 166 depsBuildTarget = toolsForTarget; ··· 172 179 173 180 checkTarget = "test"; 174 181 175 - # zsh and other shells are smart about `{ghc}` but bash isn't, and doesn't 176 - # treat that as a unary `{x,y,z,..}` repetition. 177 182 postInstall = '' 178 - paxmark m $out/lib/${name}/bin/${if targetPlatform != hostPlatform then "ghc" else "{ghc,haddock}"} 183 + for bin in "$out"/lib/${name}/bin/*; do 184 + isELF "$bin" || continue 185 + paxmark m "$bin" 186 + done 179 187 180 188 # Install the bash completion file. 181 189 install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc
+25 -13
pkgs/development/compilers/ghc/8.4.2.nix
··· 3 3 4 4 # build-tools 5 5 , bootPkgs, alex, happy 6 - , autoconf, automake, coreutils, fetchurl, fetchpatch, perl, python3 6 + , autoconf, automake, coreutils, fetchurl, fetchpatch, perl, python3, m4 7 7 8 8 , libffi, libiconv ? null, ncurses 9 9 ··· 15 15 16 16 , # If enabled, GHC will be built with the GPL-free but slower integer-simple 17 17 # library instead of the faster but GPLed integer-gmp library. 18 - enableIntegerSimple ? false, gmp ? null, m4 18 + enableIntegerSimple ? false, gmp ? null 19 19 20 20 , # If enabled, use -fPIC when compiling static libs. 21 21 enableRelocatedStaticLibs ? targetPlatform != hostPlatform 22 22 23 23 , # Whether to build dynamic libs for the standard library (on the target 24 24 # platform). Static libs are always built. 25 - enableShared ? !targetPlatform.useAndroidPrebuilt 25 + enableShared ? !targetPlatform.isWindows && !targetPlatform.useAndroidPrebuilt 26 26 27 - , version ? "8.4.2" 27 + , # Whetherto build terminfo. 28 + enableTerminfo ? !targetPlatform.isWindows 29 + 30 + , # What flavour to build. An empty string indicates no 31 + # specific flavour and falls back to ghc default values. 32 + ghcFlavour ? stdenv.lib.optionalString (targetPlatform != hostPlatform) "perf-cross" 28 33 }: 29 34 30 35 assert !enableIntegerSimple -> gmp != null; ··· 38 43 "${targetPlatform.config}-"; 39 44 40 45 buildMK = '' 46 + BuildFlavour = ${ghcFlavour} 47 + ifneq \"\$(BuildFlavour)\" \"\" 48 + include mk/flavours/\$(BuildFlavour).mk 49 + endif 41 50 DYNAMIC_GHC_PROGRAMS = ${if enableShared then "YES" else "NO"} 42 51 '' + stdenv.lib.optionalString enableIntegerSimple '' 43 52 INTEGER_LIBRARY = integer-simple 44 53 '' + stdenv.lib.optionalString (targetPlatform != hostPlatform) '' 45 - BuildFlavour = perf-cross 46 54 Stage1Only = YES 47 55 HADDOCK_DOCS = NO 48 56 BUILD_SPHINX_HTML = NO ··· 55 63 ''; 56 64 57 65 # Splicer will pull out correct variations 58 - libDeps = platform: [ ncurses ] 66 + libDeps = platform: stdenv.lib.optional enableTerminfo [ ncurses ] 59 67 ++ stdenv.lib.optional (!enableIntegerSimple) gmp 60 - ++ stdenv.lib.optional (platform.libc != "glibc") libiconv; 68 + ++ stdenv.lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv; 61 69 62 70 toolsForTarget = 63 71 if hostPlatform == buildPlatform then ··· 69 77 70 78 in 71 79 stdenv.mkDerivation rec { 72 - inherit version; 80 + version = "8.4.2"; 73 81 name = "${targetPrefix}ghc-${version}"; 74 82 75 83 src = fetchurl { ··· 126 134 "--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib" 127 135 ] ++ stdenv.lib.optional (targetPlatform == hostPlatform && ! enableIntegerSimple) [ 128 136 "--with-gmp-includes=${gmp.dev}/include" "--with-gmp-libraries=${gmp.out}/lib" 129 - ] ++ stdenv.lib.optional (targetPlatform == hostPlatform && hostPlatform.libc != "glibc") [ 137 + ] ++ stdenv.lib.optional (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [ 130 138 "--with-iconv-includes=${libiconv}/include" "--with-iconv-libraries=${libiconv}/lib" 131 139 ] ++ stdenv.lib.optionals (targetPlatform != hostPlatform) [ 132 140 "--enable-bootstrap-with-devel-snapshot" ··· 144 152 # masss-rebuild. 145 153 crossConfig = true; 146 154 147 - nativeBuildInputs = [ ghc perl autoconf automake m4 happy alex python3 ]; 155 + nativeBuildInputs = [ 156 + perl autoconf automake m4 python3 157 + ghc alex happy 158 + ]; 148 159 149 160 # For building runtime libs 150 161 depsBuildTarget = toolsForTarget; ··· 163 174 164 175 checkTarget = "test"; 165 176 166 - # zsh and other shells are smart about `{ghc}` but bash isn't, and doesn't 167 - # treat that as a unary `{x,y,z,..}` repetition. 168 177 postInstall = '' 169 - paxmark m $out/lib/${name}/bin/${if targetPlatform != hostPlatform then "ghc" else "{ghc,haddock}"} 178 + for bin in "$out"/lib/${name}/bin/*; do 179 + isELF "$bin" || continue 180 + paxmark m "$bin" 181 + done 170 182 171 183 # Install the bash completion file. 172 184 install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc
+23 -10
pkgs/development/compilers/ghc/head.nix
··· 3 3 4 4 # build-tools 5 5 , bootPkgs, alex, happy 6 - , autoconf, automake, coreutils, fetchgit, perl, python3 6 + , autoconf, automake, coreutils, fetchgit, perl, python3, m4 7 7 8 8 , libffi, libiconv ? null, ncurses 9 9 ··· 22 22 23 23 , # Whether to build dynamic libs for the standard library (on the target 24 24 # platform). Static libs are always built. 25 - enableShared ? !targetPlatform.useAndroidPrebuilt 25 + enableShared ? !targetPlatform.isWindows && !targetPlatform.useAndroidPrebuilt 26 + 27 + , # Whetherto build terminfo. 28 + enableTerminfo ? !targetPlatform.isWindows 26 29 27 30 , version ? "8.5.20180118" 31 + , # What flavour to build. An empty string indicates no 32 + # specific flavour and falls back to ghc default values. 33 + ghcFlavour ? stdenv.lib.optionalString (targetPlatform != hostPlatform) "perf-cross" 28 34 }: 29 35 30 36 assert !enableIntegerSimple -> gmp != null; ··· 38 44 "${targetPlatform.config}-"; 39 45 40 46 buildMK = '' 47 + BuildFlavour = ${ghcFlavour} 48 + ifneq \"\$(BuildFlavour)\" \"\" 49 + include mk/flavours/\$(BuildFlavour).mk 50 + endif 41 51 DYNAMIC_GHC_PROGRAMS = ${if enableShared then "YES" else "NO"} 42 52 '' + stdenv.lib.optionalString enableIntegerSimple '' 43 53 INTEGER_LIBRARY = integer-simple 44 54 '' + stdenv.lib.optionalString (targetPlatform != hostPlatform) '' 45 - BuildFlavour = perf-cross 46 55 Stage1Only = YES 47 56 HADDOCK_DOCS = NO 48 57 BUILD_SPHINX_HTML = NO ··· 55 64 ''; 56 65 57 66 # Splicer will pull out correct variations 58 - libDeps = platform: [ ncurses ] 67 + libDeps = platform: stdenv.lib.optional enableTerminfo [ ncurses ] 59 68 ++ stdenv.lib.optional (!enableIntegerSimple) gmp 60 - ++ stdenv.lib.optional (platform.libc != "glibc") libiconv; 69 + ++ stdenv.lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv; 61 70 62 71 toolsForTarget = 63 72 if hostPlatform == buildPlatform then ··· 123 132 "--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib" 124 133 ] ++ stdenv.lib.optional (targetPlatform == hostPlatform && ! enableIntegerSimple) [ 125 134 "--with-gmp-includes=${gmp.dev}/include" "--with-gmp-libraries=${gmp.out}/lib" 126 - ] ++ stdenv.lib.optional (targetPlatform == hostPlatform && hostPlatform.libc != "glibc") [ 135 + ] ++ stdenv.lib.optional (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [ 127 136 "--with-iconv-includes=${libiconv}/include" "--with-iconv-libraries=${libiconv}/lib" 128 137 ] ++ stdenv.lib.optionals (targetPlatform != hostPlatform) [ 129 138 "--enable-bootstrap-with-devel-snapshot" ··· 141 150 # masss-rebuild. 142 151 crossConfig = true; 143 152 144 - nativeBuildInputs = [ ghc perl autoconf automake happy alex python3 ]; 153 + nativeBuildInputs = [ 154 + perl autoconf automake m4 python3 155 + ghc alex happy 156 + ]; 145 157 146 158 # For building runtime libs 147 159 depsBuildTarget = toolsForTarget; ··· 160 172 161 173 checkTarget = "test"; 162 174 163 - # zsh and other shells are smart about `{ghc}` but bash isn't, and doesn't 164 - # treat that as a unary `{x,y,z,..}` repetition. 165 175 postInstall = '' 166 - paxmark m $out/lib/${name}/bin/${if targetPlatform != hostPlatform then "ghc" else "{ghc,haddock}"} 176 + for bin in "$out"/lib/${name}/bin/*; do 177 + isELF "$bin" || continue 178 + paxmark m "$bin" 179 + done 167 180 168 181 # Install the bash completion file. 169 182 install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc
+1 -1
pkgs/development/haskell-modules/configuration-nix.nix
··· 128 128 129 129 # Prevents needing to add security_tool as a build tool to all of x509-system's 130 130 # dependencies. 131 - x509-system = if pkgs.stdenv.isDarwin && !pkgs.stdenv.cc.nativeLibc 131 + x509-system = if pkgs.stdenv.targetPlatform.isDarwin && !pkgs.stdenv.cc.nativeLibc 132 132 then let inherit (pkgs.darwin) security_tool; 133 133 in pkgs.lib.overrideDerivation (addBuildDepend super.x509-system security_tool) (drv: { 134 134 postPatch = (drv.postPatch or "") + ''
+55 -17
pkgs/development/haskell-modules/generic-builder.nix
··· 19 19 , buildTarget ? "" 20 20 , buildTools ? [], libraryToolDepends ? [], executableToolDepends ? [], testToolDepends ? [], benchmarkToolDepends ? [] 21 21 , configureFlags ? [] 22 + , buildFlags ? [] 22 23 , description ? "" 23 24 , doCheck ? !isCross && stdenv.lib.versionOlder "7.4" ghc.version 24 25 , doBenchmark ? false ··· 31 32 , enableSharedExecutables ? false 32 33 , enableSharedLibraries ? ((ghc.isGhcjs or false) || stdenv.lib.versionOlder "7.7" ghc.version) 33 34 , enableDeadCodeElimination ? (!stdenv.isDarwin) # TODO: use -dead_strip for darwin 34 - , enableStaticLibraries ? true 35 + , enableStaticLibraries ? !hostPlatform.isWindows 35 36 , enableHsc2hsViaAsm ? hostPlatform.isWindows && stdenv.lib.versionAtLeast ghc.version "8.4" 36 37 , extraLibraries ? [], librarySystemDepends ? [], executableSystemDepends ? [] 37 38 , homepage ? "http://hackage.haskell.org/package/${pname}" ··· 67 68 } @ args: 68 69 69 70 assert editedCabalFile != null -> revision != null; 71 + 72 + # --enable-static does not work on windows. This is a bug in GHC. 73 + # --enable-static will pass -staticlib to ghc, which only works for mach-o and elf. 74 + assert hostPlatform.isWindows -> enableStaticLibraries == false; 70 75 71 76 let 72 77 ··· 125 130 126 131 crossCabalFlagsString = 127 132 stdenv.lib.optionalString isCross (" " + stdenv.lib.concatStringsSep " " crossCabalFlags); 133 + 134 + buildFlagsString = optionalString (buildFlags != []) (" " + concatStringsSep " " buildFlags); 128 135 129 136 defaultConfigureFlags = [ 130 137 "--verbose" "--prefix=$out" "--libdir=\\$prefix/lib/\\$compiler" "--libsubdir=\\$pkgid" ··· 169 176 optionals doCheck testPkgconfigDepends ++ optionals doBenchmark benchmarkPkgconfigDepends; 170 177 171 178 nativeBuildInputs = [ ghc nativeGhc removeReferencesTo ] ++ optional (allPkgconfigDepends != []) pkgconfig ++ 179 + setupHaskellDepends ++ 172 180 buildTools ++ libraryToolDepends ++ executableToolDepends; 173 181 propagatedBuildInputs = buildDepends ++ libraryHaskellDepends ++ executableHaskellDepends; 174 - otherBuildInputs = setupHaskellDepends ++ extraLibraries ++ librarySystemDepends ++ executableSystemDepends ++ 182 + otherBuildInputs = extraLibraries ++ librarySystemDepends ++ executableSystemDepends ++ 175 183 allPkgconfigDepends ++ 176 184 optionals doCheck (testDepends ++ testHaskellDepends ++ testSystemDepends ++ testToolDepends) ++ 177 185 optionals doBenchmark (benchmarkDepends ++ benchmarkHaskellDepends ++ benchmarkSystemDepends ++ benchmarkToolDepends); 186 + 178 187 allBuildInputs = propagatedBuildInputs ++ otherBuildInputs; 179 188 180 189 haskellBuildInputs = stdenv.lib.filter isHaskellPkg allBuildInputs; 181 190 systemBuildInputs = stdenv.lib.filter isSystemPkg allBuildInputs; 182 191 183 - ghcEnv = ghc.withPackages (p: haskellBuildInputs); 192 + # When not cross compiling, also include Setup.hs dependencies. 193 + ghcEnv = ghc.withPackages (p: 194 + haskellBuildInputs ++ stdenv.lib.optional (!isCross) setupHaskellDepends); 184 195 185 196 setupCommand = "./Setup"; 186 197 ··· 190 201 191 202 nativeGhcCommand = "${nativeGhc.targetPrefix}ghc"; 192 203 204 + buildPkgDb = ghcName: '' 205 + if [ -d "$p/lib/${ghcName}/package.conf.d" ]; then 206 + cp -f "$p/lib/${ghcName}/package.conf.d/"*.conf $packageConfDir/ 207 + continue 208 + fi 209 + if [ -d "$p/include" ]; then 210 + configureFlags+=" --extra-include-dirs=$p/include" 211 + fi 212 + if [ -d "$p/lib" ]; then 213 + configureFlags+=" --extra-lib-dirs=$p/lib" 214 + fi 215 + if [[ -d "$p/Library/Frameworks" ]]; then 216 + configureFlags+=" --extra-framework-dirs=$p/Library/Frameworks" 217 + fi 218 + ''; 219 + 193 220 in 194 221 195 222 assert allPkgconfigDepends != [] -> pkgconfig != null; ··· 230 257 echo "Build with ${ghc}." 231 258 ${optionalString (hasActiveLibrary && hyperlinkSource) "export PATH=${hscolour}/bin:$PATH"} 232 259 260 + '' + (optionalString (setupHaskellDepends != []) '' 261 + setupPackageConfDir="$TMPDIR/setup-package.conf.d" 262 + mkdir -p $setupPackageConfDir 263 + '') + '' 233 264 packageConfDir="$TMPDIR/package.conf.d" 234 265 mkdir -p $packageConfDir 235 266 236 267 setupCompileFlags="${concatStringsSep " " setupCompileFlags}" 237 268 configureFlags="${concatStringsSep " " defaultConfigureFlags} $configureFlags" 269 + '' 270 + # We build the Setup.hs on the *build* machine, and as such should only add 271 + # dependencies for the build machine. 272 + # 273 + # pkgs* arrays defined in stdenv/setup.hs 274 + + (optionalString (setupHaskellDepends != []) '' 275 + for p in "''${pkgsBuildBuild[@]}" "''${pkgsBuildHost[@]}" "''${pkgsBuildTarget[@]}"; do 276 + ${buildPkgDb nativeGhc.name} 277 + done 278 + ${nativeGhcCommand}-pkg --${nativePackageDbFlag}="$setupPackageConfDir" recache 279 + '') 238 280 239 - # host.*Pkgs defined in stdenv/setup.hs 281 + # For normal components 282 + + '' 240 283 for p in "''${pkgsHostHost[@]}" "''${pkgsHostTarget[@]}"; do 241 - if [ -d "$p/lib/${ghc.name}/package.conf.d" ]; then 242 - cp -f "$p/lib/${ghc.name}/package.conf.d/"*.conf $packageConfDir/ 243 - continue 244 - fi 245 - if [ -d "$p/include" ]; then 246 - configureFlags+=" --extra-include-dirs=$p/include" 247 - fi 248 - if [ -d "$p/lib" ]; then 249 - configureFlags+=" --extra-lib-dirs=$p/lib" 250 - fi 284 + ${buildPkgDb ghc.name} 251 285 done 252 286 '' 253 287 # only use the links hack if we're actually building dylibs. otherwise, the 254 288 # "dynamic-library-dirs" point to nonexistent paths, and the ln command becomes 255 289 # "ln -s $out/lib/links", which tries to recreate the links dir and fails 256 - + (optionalString (stdenv.isDarwin && enableSharedLibraries) '' 290 + + (optionalString (stdenv.isDarwin && (enableSharedLibraries || enableSharedExecutables)) '' 257 291 # Work around a limit in the macOS Sierra linker on the number of paths 258 292 # referenced by any one dynamic library: 259 293 # ··· 282 316 done 283 317 284 318 echo setupCompileFlags: $setupCompileFlags 285 - ${nativeGhcCommand} $setupCompileFlags --make -o Setup -odir $TMPDIR -hidir $TMPDIR $i 319 + ${optionalString (setupHaskellDepends != []) 320 + '' 321 + echo GHC_PACKAGE_PATH="$setupPackageConfDir:" 322 + GHC_PACKAGE_PATH="$setupPackageConfDir:" '' 323 + }${nativeGhcCommand} $setupCompileFlags --make -o Setup -odir $TMPDIR -hidir $TMPDIR $i 286 324 287 325 runHook postCompileBuildDriver 288 326 ''; ··· 310 348 311 349 buildPhase = '' 312 350 runHook preBuild 313 - ${setupCommand} build ${buildTarget}${crossCabalFlagsString} 351 + ${setupCommand} build ${buildTarget}${crossCabalFlagsString}${buildFlagsString} 314 352 runHook postBuild 315 353 ''; 316 354
+2
pkgs/development/haskell-modules/lib.nix
··· 131 131 */ 132 132 appendConfigureFlag = drv: x: overrideCabal drv (drv: { configureFlags = (drv.configureFlags or []) ++ [x]; }); 133 133 134 + appendBuildFlag = drv: x: overrideCabal drv (drv: { buildFlags = (drv.buildFlags or []) ++ [x]; }); 135 + appendBuildFlags = drv: xs: overrideCabal drv (drv: { buildFlags = (drv.buildFlags or []) ++ xs; }); 134 136 /* removeConfigureFlag drv x is a Haskell package like drv, but with 135 137 all cabal configure arguments that are equal to x removed. 136 138