From c6f742b770924dd1af775714c588f79110e68b30 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Sun, 13 May 2018 10:53:09 -0400 Subject: [PATCH 01/12] haskell-generic-builder: Add extra framework dirs Just like with the other `--extra-*` flags, cc/ld-wrapper already handles this, but we need to make Cabal aware so that the haskell builds have the correct metadata. --- pkgs/development/haskell-modules/generic-builder.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkgs/development/haskell-modules/generic-builder.nix b/pkgs/development/haskell-modules/generic-builder.nix index 3ab77c42cbba..53974ada8009 100644 --- a/pkgs/development/haskell-modules/generic-builder.nix +++ b/pkgs/development/haskell-modules/generic-builder.nix @@ -248,6 +248,9 @@ stdenv.mkDerivation ({ if [ -d "$p/lib" ]; then configureFlags+=" --extra-lib-dirs=$p/lib" fi + if [[ -d "$p/Library/Frameworks" ]]; then + configureFlags+=" --extra-framework-dirs=$p/Library/Frameworks" + fi done '' # only use the links hack if we're actually building dylibs. otherwise, the From 900862ea3bda4ef87dc8b4a8aa78a242d1ae7b04 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Mon, 21 May 2018 14:44:46 -0400 Subject: [PATCH 02/12] haskell generic builder: `setupHaskellDepends` should be `nativeBuildInputs This is because they are just for Setup.hs, so they are just used at build time and completely isolated from the normal components' dependencies. This was previous implemented in 8a8f0408cd9b7fdda1095718107c800057658c44, but reverted in e69c7f56419589c0d3296e81f47032fa813cca4b because it broken setup-depends non-cross in haskell shell environments (custom Setup.hs in cross shell environments has never worked). This version adds a special native exception to avoid that breakage. --- pkgs/development/haskell-modules/generic-builder.nix | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkgs/development/haskell-modules/generic-builder.nix b/pkgs/development/haskell-modules/generic-builder.nix index 53974ada8009..42f0facef419 100644 --- a/pkgs/development/haskell-modules/generic-builder.nix +++ b/pkgs/development/haskell-modules/generic-builder.nix @@ -169,18 +169,22 @@ let optionals doCheck testPkgconfigDepends ++ optionals doBenchmark benchmarkPkgconfigDepends; nativeBuildInputs = [ ghc nativeGhc removeReferencesTo ] ++ optional (allPkgconfigDepends != []) pkgconfig ++ + setupHaskellDepends ++ buildTools ++ libraryToolDepends ++ executableToolDepends; propagatedBuildInputs = buildDepends ++ libraryHaskellDepends ++ executableHaskellDepends; - otherBuildInputs = setupHaskellDepends ++ extraLibraries ++ librarySystemDepends ++ executableSystemDepends ++ + otherBuildInputs = extraLibraries ++ librarySystemDepends ++ executableSystemDepends ++ optionals (allPkgconfigDepends != []) allPkgconfigDepends ++ optionals doCheck (testDepends ++ testHaskellDepends ++ testSystemDepends ++ testToolDepends) ++ optionals doBenchmark (benchmarkDepends ++ benchmarkHaskellDepends ++ benchmarkSystemDepends ++ benchmarkToolDepends); + allBuildInputs = propagatedBuildInputs ++ otherBuildInputs; haskellBuildInputs = stdenv.lib.filter isHaskellPkg allBuildInputs; systemBuildInputs = stdenv.lib.filter isSystemPkg allBuildInputs; - ghcEnv = ghc.withPackages (p: haskellBuildInputs); + # When not cross compiling, also include Setup.hs dependencies. + ghcEnv = ghc.withPackages (p: + haskellBuildInputs ++ stdenv.lib.optional (!isCross) setupHaskellDepends); setupCommand = "./Setup"; From 15759df6607204d960f70420a092178cf65306b7 Mon Sep 17 00:00:00 2001 From: Moritz Angermann Date: Thu, 1 Mar 2018 13:35:48 +0800 Subject: [PATCH 03/12] haskell generic builder: Use setup package database for setup-depends Adapted from https://github.com/obsidiansystems/nixpkgs/commit/b69f420121120433220c568e4b35ade539ef60f2 by @Ericson2314 --- .../haskell-modules/generic-builder.nix | 54 +++++++++++++------ 1 file changed, 39 insertions(+), 15 deletions(-) diff --git a/pkgs/development/haskell-modules/generic-builder.nix b/pkgs/development/haskell-modules/generic-builder.nix index 42f0facef419..3e191cd23451 100644 --- a/pkgs/development/haskell-modules/generic-builder.nix +++ b/pkgs/development/haskell-modules/generic-builder.nix @@ -194,6 +194,22 @@ let nativeGhcCommand = "${nativeGhc.targetPrefix}ghc"; + buildPkgDb = ghcName: '' + if [ -d "$p/lib/${ghcName}/package.conf.d" ]; then + cp -f "$p/lib/${ghcName}/package.conf.d/"*.conf $packageConfDir/ + continue + fi + if [ -d "$p/include" ]; then + configureFlags+=" --extra-include-dirs=$p/include" + fi + if [ -d "$p/lib" ]; then + configureFlags+=" --extra-lib-dirs=$p/lib" + fi + if [[ -d "$p/Library/Frameworks" ]]; then + configureFlags+=" --extra-framework-dirs=$p/Library/Frameworks" + fi + ''; + in assert allPkgconfigDepends != [] -> pkgconfig != null; @@ -234,27 +250,31 @@ stdenv.mkDerivation ({ echo "Build with ${ghc}." ${optionalString (hasActiveLibrary && hyperlinkSource) "export PATH=${hscolour}/bin:$PATH"} + '' + (optionalString (setupHaskellDepends != []) '' + setupPackageConfDir="$TMPDIR/setup-package.conf.d" + mkdir -p $setupPackageConfDir + '') + '' packageConfDir="$TMPDIR/package.conf.d" mkdir -p $packageConfDir setupCompileFlags="${concatStringsSep " " setupCompileFlags}" configureFlags="${concatStringsSep " " defaultConfigureFlags} $configureFlags" + '' + # We build the Setup.hs on the *build* machine, and as such should only add + # dependencies for the build machine. + # + # pkgs* arrays defined in stdenv/setup.hs + + (optionalString (setupHaskellDepends != []) '' + for p in "''${pkgsBuildBuild[@]}" "''${pkgsBuildHost[@]}" "''${pkgsBuildTarget[@]}"; do + ${buildPkgDb nativeGhc.name} + done + ${nativeGhcCommand}-pkg --${nativePackageDbFlag}="$setupPackageConfDir" recache + '') - # host.*Pkgs defined in stdenv/setup.hs + # For normal components + + '' for p in "''${pkgsHostHost[@]}" "''${pkgsHostTarget[@]}"; do - if [ -d "$p/lib/${ghc.name}/package.conf.d" ]; then - cp -f "$p/lib/${ghc.name}/package.conf.d/"*.conf $packageConfDir/ - continue - fi - if [ -d "$p/include" ]; then - configureFlags+=" --extra-include-dirs=$p/include" - fi - if [ -d "$p/lib" ]; then - configureFlags+=" --extra-lib-dirs=$p/lib" - fi - if [[ -d "$p/Library/Frameworks" ]]; then - configureFlags+=" --extra-framework-dirs=$p/Library/Frameworks" - fi + ${buildPkgDb ghc.name} done '' # only use the links hack if we're actually building dylibs. otherwise, the @@ -289,7 +309,11 @@ stdenv.mkDerivation ({ done echo setupCompileFlags: $setupCompileFlags - ${nativeGhcCommand} $setupCompileFlags --make -o Setup -odir $TMPDIR -hidir $TMPDIR $i + ${optionalString (setupHaskellDepends != []) + '' + echo GHC_PACKAGE_PATH="$setupPackageConfDir:" + GHC_PACKAGE_PATH="$setupPackageConfDir:" '' + }${nativeGhcCommand} $setupCompileFlags --make -o Setup -odir $TMPDIR -hidir $TMPDIR $i runHook postCompileBuildDriver ''; From 4ea33def46709e90b9f41ccd6fb6a84342ecd926 Mon Sep 17 00:00:00 2001 From: Moritz Angermann Date: Sun, 11 Mar 2018 17:13:25 +0800 Subject: [PATCH 04/12] haskell generic builder: Disable static libs on Windows because no -staticlib The reason why this does not work is not that we can't built static objects, we can, but we can't use `-staticlib` on GHC on windows. `-staticlib` rolls all dependencies into a combined archive. While this would work on windows if we used gnu ar and MRI script, GHC can't rely on GNU ar, and as such has a quick archive concatenation module for GNU and BSD archives only. --- pkgs/development/haskell-modules/generic-builder.nix | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkgs/development/haskell-modules/generic-builder.nix b/pkgs/development/haskell-modules/generic-builder.nix index 3e191cd23451..1b9372c28df5 100644 --- a/pkgs/development/haskell-modules/generic-builder.nix +++ b/pkgs/development/haskell-modules/generic-builder.nix @@ -31,7 +31,7 @@ in , enableSharedExecutables ? false , enableSharedLibraries ? ((ghc.isGhcjs or false) || stdenv.lib.versionOlder "7.7" ghc.version) , enableDeadCodeElimination ? (!stdenv.isDarwin) # TODO: use -dead_strip for darwin -, enableStaticLibraries ? true +, enableStaticLibraries ? !hostPlatform.isWindows , enableHsc2hsViaAsm ? hostPlatform.isWindows && stdenv.lib.versionAtLeast ghc.version "8.4" , extraLibraries ? [], librarySystemDepends ? [], executableSystemDepends ? [] , homepage ? "http://hackage.haskell.org/package/${pname}" @@ -68,6 +68,10 @@ in assert editedCabalFile != null -> revision != null; +# --enable-static does not work on windows. This is a bug in GHC. +# --enable-static will pass -staticlib to ghc, which only works for mach-o and elf. +assert hostPlatform.isWindows -> enableStaticLibraries == false; + let inherit (stdenv.lib) optional optionals optionalString versionOlder versionAtLeast From 5e589a40497eaf15108f503f41dd62b925ad9e5f Mon Sep 17 00:00:00 2001 From: Moritz Angermann Date: Sat, 17 Mar 2018 14:42:28 +0800 Subject: [PATCH 05/12] haskell generic builder: Do the `links` dance only if shared is enabled. --- pkgs/development/haskell-modules/generic-builder.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/development/haskell-modules/generic-builder.nix b/pkgs/development/haskell-modules/generic-builder.nix index 1b9372c28df5..a94f20710041 100644 --- a/pkgs/development/haskell-modules/generic-builder.nix +++ b/pkgs/development/haskell-modules/generic-builder.nix @@ -284,7 +284,7 @@ stdenv.mkDerivation ({ # only use the links hack if we're actually building dylibs. otherwise, the # "dynamic-library-dirs" point to nonexistent paths, and the ln command becomes # "ln -s $out/lib/links", which tries to recreate the links dir and fails - + (optionalString (stdenv.isDarwin && enableSharedLibraries) '' + + (optionalString (stdenv.isDarwin && (enableSharedLibraries || enableSharedExecutables)) '' # Work around a limit in the macOS Sierra linker on the number of paths # referenced by any one dynamic library: # From 82a847a04b5ed2f041d8c94895011e13b0735f6e Mon Sep 17 00:00:00 2001 From: Moritz Angermann Date: Sat, 17 Mar 2018 16:55:39 +0800 Subject: [PATCH 06/12] haskell infra: Adds buildFlags logic --- pkgs/development/haskell-modules/generic-builder.nix | 5 ++++- pkgs/development/haskell-modules/lib.nix | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/pkgs/development/haskell-modules/generic-builder.nix b/pkgs/development/haskell-modules/generic-builder.nix index a94f20710041..99c85ac688a5 100644 --- a/pkgs/development/haskell-modules/generic-builder.nix +++ b/pkgs/development/haskell-modules/generic-builder.nix @@ -19,6 +19,7 @@ in , buildTarget ? "" , buildTools ? [], libraryToolDepends ? [], executableToolDepends ? [], testToolDepends ? [], benchmarkToolDepends ? [] , configureFlags ? [] +, buildFlags ? [] , description ? "" , doCheck ? !isCross && (stdenv.lib.versionOlder "7.4" ghc.version) , doBenchmark ? false @@ -130,6 +131,8 @@ let crossCabalFlagsString = stdenv.lib.optionalString isCross (" " + stdenv.lib.concatStringsSep " " crossCabalFlags); + buildFlagsString = optionalString (buildFlags != []) (" " + concatStringsSep " " buildFlags); + defaultConfigureFlags = [ "--verbose" "--prefix=$out" "--libdir=\\$prefix/lib/\\$compiler" "--libsubdir=\\$pkgid" (optionalString enableSeparateDataOutput "--datadir=$data/share/${ghc.name}") @@ -345,7 +348,7 @@ stdenv.mkDerivation ({ buildPhase = '' runHook preBuild - ${setupCommand} build ${buildTarget}${crossCabalFlagsString} + ${setupCommand} build ${buildTarget}${crossCabalFlagsString}${buildFlagsString} runHook postBuild ''; diff --git a/pkgs/development/haskell-modules/lib.nix b/pkgs/development/haskell-modules/lib.nix index ff86e06979c1..fedb0fa8de83 100644 --- a/pkgs/development/haskell-modules/lib.nix +++ b/pkgs/development/haskell-modules/lib.nix @@ -131,6 +131,8 @@ rec { */ appendConfigureFlag = drv: x: overrideCabal drv (drv: { configureFlags = (drv.configureFlags or []) ++ [x]; }); + appendBuildFlag = drv: x: overrideCabal drv (drv: { buildFlags = (drv.buildFlags or []) ++ [x]; }); + appendBuildFlags = drv: xs: overrideCabal drv (drv: { buildFlags = (drv.buildFlags or []) ++ xs; }); /* removeConfigureFlag drv x is a Haskell package like drv, but with all cabal configure arguments that are equal to x removed. From f914fdd960688e5afeddc7f50235000f1c9418d6 Mon Sep 17 00:00:00 2001 From: Moritz Angermann Date: Mon, 26 Mar 2018 14:57:56 +0800 Subject: [PATCH 07/12] used stdenv.targetPlatform.isDarwin and not stdenv.isDarwin. --- pkgs/development/haskell-modules/configuration-nix.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/development/haskell-modules/configuration-nix.nix b/pkgs/development/haskell-modules/configuration-nix.nix index 469b249010fa..2f1eb1ad97a8 100644 --- a/pkgs/development/haskell-modules/configuration-nix.nix +++ b/pkgs/development/haskell-modules/configuration-nix.nix @@ -128,7 +128,7 @@ self: super: builtins.intersectAttrs super { # Prevents needing to add security_tool as a build tool to all of x509-system's # dependencies. - x509-system = if pkgs.stdenv.isDarwin && !pkgs.stdenv.cc.nativeLibc + x509-system = if pkgs.stdenv.targetPlatform.isDarwin && !pkgs.stdenv.cc.nativeLibc then let inherit (pkgs.darwin) security_tool; in pkgs.lib.overrideDerivation (addBuildDepend super.x509-system security_tool) (drv: { postPatch = (drv.postPatch or "") + '' From 6f2f081b90a14f274274f6ce0bce5860057495d1 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Fri, 18 May 2018 19:33:05 -0400 Subject: [PATCH 08/12] ghc: Normalize derivations --- pkgs/development/compilers/ghc/7.10.3.nix | 7 +++++-- pkgs/development/compilers/ghc/8.0.2.nix | 8 +++++++- pkgs/development/compilers/ghc/8.2.2.nix | 11 ++++++----- pkgs/development/compilers/ghc/8.4.2.nix | 12 +++++++----- pkgs/development/compilers/ghc/head.nix | 7 +++++-- 5 files changed, 30 insertions(+), 15 deletions(-) diff --git a/pkgs/development/compilers/ghc/7.10.3.nix b/pkgs/development/compilers/ghc/7.10.3.nix index e4bf23c6e9e2..150d14e1db46 100644 --- a/pkgs/development/compilers/ghc/7.10.3.nix +++ b/pkgs/development/compilers/ghc/7.10.3.nix @@ -68,7 +68,6 @@ let targetCC = builtins.head toolsForTarget; in - stdenv.mkDerivation rec { version = "7.10.3"; name = "${targetPrefix}ghc-${version}"; @@ -87,6 +86,8 @@ stdenv.mkDerivation rec { ./relocation.patch ]; + postPatch = "patchShebangs ."; + # GHC is a bit confused on its cross terminology. preConfigure = '' for env in $(env | grep '^TARGET_' | sed -E 's|\+?=.*||'); do @@ -103,6 +104,7 @@ stdenv.mkDerivation rec { export RANLIB="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ranlib" export READELF="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}readelf" export STRIP="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}strip" + echo -n "${buildMK}" > mk/build.mk sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure '' + stdenv.lib.optionalString (!stdenv.isDarwin) '' @@ -135,7 +137,8 @@ stdenv.mkDerivation rec { crossConfig = true; nativeBuildInputs = [ - ghc perl libxml2 libxslt docbook_xsl docbook_xml_dtd_45 docbook_xml_dtd_42 hscolour + perl libxml2 libxslt docbook_xsl docbook_xml_dtd_45 docbook_xml_dtd_42 + ghc hscolour ]; # For building runtime libs diff --git a/pkgs/development/compilers/ghc/8.0.2.nix b/pkgs/development/compilers/ghc/8.0.2.nix index 7d11ffb66c60..60707c0288d6 100644 --- a/pkgs/development/compilers/ghc/8.0.2.nix +++ b/pkgs/development/compilers/ghc/8.0.2.nix @@ -86,6 +86,8 @@ stdenv.mkDerivation rec { ] ++ stdenv.lib.optional stdenv.isLinux ./ghc-no-madv-free.patch ++ stdenv.lib.optional stdenv.isDarwin ./ghc-8.0.2-no-cpp-warnings.patch; + postPatch = "patchShebangs ."; + # GHC is a bit confused on its cross terminology. preConfigure = '' for env in $(env | grep '^TARGET_' | sed -E 's|\+?=.*||'); do @@ -102,6 +104,7 @@ stdenv.mkDerivation rec { export RANLIB="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ranlib" export READELF="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}readelf" export STRIP="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}strip" + echo -n "${buildMK}" > mk/build.mk sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure '' + stdenv.lib.optionalString (!stdenv.isDarwin) '' @@ -133,7 +136,10 @@ stdenv.mkDerivation rec { # masss-rebuild. crossConfig = true; - nativeBuildInputs = [ ghc perl hscolour sphinx ]; + nativeBuildInputs = [ + perl sphinx + ghc hscolour + ]; # For building runtime libs depsBuildTarget = toolsForTarget; diff --git a/pkgs/development/compilers/ghc/8.2.2.nix b/pkgs/development/compilers/ghc/8.2.2.nix index 192ff1ba207d..c0fadbb61750 100644 --- a/pkgs/development/compilers/ghc/8.2.2.nix +++ b/pkgs/development/compilers/ghc/8.2.2.nix @@ -23,10 +23,8 @@ , # Whether to build dynamic libs for the standard library (on the target # platform). Static libs are always built. - enableShared ? - !(targetPlatform.isDarwin - # On iOS, dynamic linking is not supported - && (targetPlatform.isAarch64 || targetPlatform.isAarch32)) + enableShared ? true + , # Whether to backport https://phabricator.haskell.org/D4388 for # deterministic profiling symbol names, at the cost of a slightly # non-standard GHC API @@ -152,7 +150,10 @@ stdenv.mkDerivation rec { # masss-rebuild. crossConfig = true; - nativeBuildInputs = [ alex autoconf autoreconfHook automake ghc happy hscolour perl python3 sphinx ]; + nativeBuildInputs = [ + autoconf autoreconfHook automake perl python3 sphinx + ghc alex happy hscolour + ]; # For building runtime libs depsBuildTarget = toolsForTarget; diff --git a/pkgs/development/compilers/ghc/8.4.2.nix b/pkgs/development/compilers/ghc/8.4.2.nix index 94555482d28b..bebc386f2243 100644 --- a/pkgs/development/compilers/ghc/8.4.2.nix +++ b/pkgs/development/compilers/ghc/8.4.2.nix @@ -3,7 +3,7 @@ # build-tools , bootPkgs, alex, happy -, autoconf, automake, coreutils, fetchurl, fetchpatch, perl, python3 +, autoconf, automake, coreutils, fetchurl, fetchpatch, perl, python3, m4 , libffi, libiconv ? null, ncurses @@ -15,7 +15,7 @@ , # If enabled, GHC will be built with the GPL-free but slower integer-simple # library instead of the faster but GPLed integer-gmp library. - enableIntegerSimple ? false, gmp ? null, m4 + enableIntegerSimple ? false, gmp ? null , # If enabled, use -fPIC when compiling static libs. enableRelocatedStaticLibs ? targetPlatform != hostPlatform @@ -24,7 +24,6 @@ # platform). Static libs are always built. enableShared ? !targetPlatform.useAndroidPrebuilt -, version ? "8.4.2" }: assert !enableIntegerSimple -> gmp != null; @@ -69,7 +68,7 @@ let in stdenv.mkDerivation rec { - inherit version; + version = "8.4.2"; name = "${targetPrefix}ghc-${version}"; src = fetchurl { @@ -143,7 +142,10 @@ stdenv.mkDerivation rec { # masss-rebuild. crossConfig = true; - nativeBuildInputs = [ ghc perl autoconf automake m4 happy alex python3 ]; + nativeBuildInputs = [ + perl autoconf automake m4 python3 + ghc alex happy + ]; # For building runtime libs depsBuildTarget = toolsForTarget; diff --git a/pkgs/development/compilers/ghc/head.nix b/pkgs/development/compilers/ghc/head.nix index 7e1c73d166a2..e0de4e7e60e6 100644 --- a/pkgs/development/compilers/ghc/head.nix +++ b/pkgs/development/compilers/ghc/head.nix @@ -3,7 +3,7 @@ # build-tools , bootPkgs, alex, happy -, autoconf, automake, coreutils, fetchgit, perl, python3 +, autoconf, automake, coreutils, fetchgit, perl, python3, m4 , libffi, libiconv ? null, ncurses @@ -141,7 +141,10 @@ stdenv.mkDerivation rec { # masss-rebuild. crossConfig = true; - nativeBuildInputs = [ ghc perl autoconf automake happy alex python3 ]; + nativeBuildInputs = [ + perl autoconf automake m4 python3 + ghc alex happy + ]; # For building runtime libs depsBuildTarget = toolsForTarget; From 8d2ce113d571046382c9490b1e47e14454c6469f Mon Sep 17 00:00:00 2001 From: John Ericson Date: Sun, 20 May 2018 02:16:07 -0400 Subject: [PATCH 09/12] ghc: Handle flavors better --- pkgs/development/compilers/ghc/7.10.3.nix | 9 ++++++++- pkgs/development/compilers/ghc/8.0.2.nix | 9 ++++++++- pkgs/development/compilers/ghc/8.2.2.nix | 8 +++++++- pkgs/development/compilers/ghc/8.4.2.nix | 8 +++++++- pkgs/development/compilers/ghc/head.nix | 8 +++++++- 5 files changed, 37 insertions(+), 5 deletions(-) diff --git a/pkgs/development/compilers/ghc/7.10.3.nix b/pkgs/development/compilers/ghc/7.10.3.nix index 150d14e1db46..7d2f37916323 100644 --- a/pkgs/development/compilers/ghc/7.10.3.nix +++ b/pkgs/development/compilers/ghc/7.10.3.nix @@ -24,6 +24,10 @@ , # Whether to build dynamic libs for the standard library (on the target # platform). Static libs are always built. enableShared ? true + +, # What flavour to build. An empty string indicates no + # specific flavour and falls back to ghc default values. + ghcFlavour ? stdenv.lib.optionalString (targetPlatform != hostPlatform) "perf-cross" }: assert !enableIntegerSimple -> gmp != null; @@ -42,11 +46,14 @@ let }; buildMK = '' + BuildFlavour = ${ghcFlavour} + ifneq \"\$(BuildFlavour)\" \"\" + include mk/flavours/\$(BuildFlavour).mk + endif DYNAMIC_GHC_PROGRAMS = ${if enableShared then "YES" else "NO"} '' + stdenv.lib.optionalString enableIntegerSimple '' INTEGER_LIBRARY = integer-simple '' + stdenv.lib.optionalString (targetPlatform != hostPlatform) '' - BuildFlavour = perf-cross Stage1Only = YES HADDOCK_DOCS = NO '' + stdenv.lib.optionalString enableRelocatedStaticLibs '' diff --git a/pkgs/development/compilers/ghc/8.0.2.nix b/pkgs/development/compilers/ghc/8.0.2.nix index 60707c0288d6..b5cd111f1e51 100644 --- a/pkgs/development/compilers/ghc/8.0.2.nix +++ b/pkgs/development/compilers/ghc/8.0.2.nix @@ -23,6 +23,10 @@ , # Whether to build dynamic libs for the standard library (on the target # platform). Static libs are always built. enableShared ? true + +, # What flavour to build. An empty string indicates no + # specific flavour and falls back to ghc default values. + ghcFlavour ? stdenv.lib.optionalString (targetPlatform != hostPlatform) "perf-cross" }: assert !enableIntegerSimple -> gmp != null; @@ -36,11 +40,14 @@ let "${targetPlatform.config}-"; buildMK = '' + BuildFlavour = ${ghcFlavour} + ifneq \"\$(BuildFlavour)\" \"\" + include mk/flavours/\$(BuildFlavour).mk + endif DYNAMIC_GHC_PROGRAMS = ${if enableShared then "YES" else "NO"} '' + stdenv.lib.optionalString enableIntegerSimple '' INTEGER_LIBRARY = integer-simple '' + stdenv.lib.optionalString (targetPlatform != hostPlatform) '' - BuildFlavour = perf-cross Stage1Only = YES HADDOCK_DOCS = NO '' + stdenv.lib.optionalString enableRelocatedStaticLibs '' diff --git a/pkgs/development/compilers/ghc/8.2.2.nix b/pkgs/development/compilers/ghc/8.2.2.nix index c0fadbb61750..4bd6889d1df8 100644 --- a/pkgs/development/compilers/ghc/8.2.2.nix +++ b/pkgs/development/compilers/ghc/8.2.2.nix @@ -25,6 +25,9 @@ # platform). Static libs are always built. enableShared ? true +, # What flavour to build. An empty string indicates no + # specific flavour and falls back to ghc default values. + ghcFlavour ? stdenv.lib.optionalString (targetPlatform != hostPlatform) "perf-cross" , # Whether to backport https://phabricator.haskell.org/D4388 for # deterministic profiling symbol names, at the cost of a slightly # non-standard GHC API @@ -42,11 +45,14 @@ let "${targetPlatform.config}-"; buildMK = '' + BuildFlavour = ${ghcFlavour} + ifneq \"\$(BuildFlavour)\" \"\" + include mk/flavours/\$(BuildFlavour).mk + endif DYNAMIC_GHC_PROGRAMS = ${if enableShared then "YES" else "NO"} '' + stdenv.lib.optionalString enableIntegerSimple '' INTEGER_LIBRARY = integer-simple '' + stdenv.lib.optionalString (targetPlatform != hostPlatform) '' - BuildFlavour = perf-cross Stage1Only = YES HADDOCK_DOCS = NO BUILD_SPHINX_HTML = NO diff --git a/pkgs/development/compilers/ghc/8.4.2.nix b/pkgs/development/compilers/ghc/8.4.2.nix index bebc386f2243..b432682802e5 100644 --- a/pkgs/development/compilers/ghc/8.4.2.nix +++ b/pkgs/development/compilers/ghc/8.4.2.nix @@ -24,6 +24,9 @@ # platform). Static libs are always built. enableShared ? !targetPlatform.useAndroidPrebuilt +, # What flavour to build. An empty string indicates no + # specific flavour and falls back to ghc default values. + ghcFlavour ? stdenv.lib.optionalString (targetPlatform != hostPlatform) "perf-cross" }: assert !enableIntegerSimple -> gmp != null; @@ -37,11 +40,14 @@ let "${targetPlatform.config}-"; buildMK = '' + BuildFlavour = ${ghcFlavour} + ifneq \"\$(BuildFlavour)\" \"\" + include mk/flavours/\$(BuildFlavour).mk + endif DYNAMIC_GHC_PROGRAMS = ${if enableShared then "YES" else "NO"} '' + stdenv.lib.optionalString enableIntegerSimple '' INTEGER_LIBRARY = integer-simple '' + stdenv.lib.optionalString (targetPlatform != hostPlatform) '' - BuildFlavour = perf-cross Stage1Only = YES HADDOCK_DOCS = NO BUILD_SPHINX_HTML = NO diff --git a/pkgs/development/compilers/ghc/head.nix b/pkgs/development/compilers/ghc/head.nix index e0de4e7e60e6..f5a7be5156d7 100644 --- a/pkgs/development/compilers/ghc/head.nix +++ b/pkgs/development/compilers/ghc/head.nix @@ -25,6 +25,9 @@ enableShared ? !targetPlatform.useAndroidPrebuilt , version ? "8.5.20180118" +, # What flavour to build. An empty string indicates no + # specific flavour and falls back to ghc default values. + ghcFlavour ? stdenv.lib.optionalString (targetPlatform != hostPlatform) "perf-cross" }: assert !enableIntegerSimple -> gmp != null; @@ -38,11 +41,14 @@ let "${targetPlatform.config}-"; buildMK = '' + BuildFlavour = ${ghcFlavour} + ifneq \"\$(BuildFlavour)\" \"\" + include mk/flavours/\$(BuildFlavour).mk + endif DYNAMIC_GHC_PROGRAMS = ${if enableShared then "YES" else "NO"} '' + stdenv.lib.optionalString enableIntegerSimple '' INTEGER_LIBRARY = integer-simple '' + stdenv.lib.optionalString (targetPlatform != hostPlatform) '' - BuildFlavour = perf-cross Stage1Only = YES HADDOCK_DOCS = NO BUILD_SPHINX_HTML = NO From 6af0c192d15b3e87f1cf757250f7c8f8b84bd2d3 Mon Sep 17 00:00:00 2001 From: Moritz Angermann Date: Mon, 5 Mar 2018 21:34:31 +0800 Subject: [PATCH 10/12] ghc: paxmark all unwraped executables across the board Shell glob works even as the exact set of executable (filenames) varries beween configuations. --- pkgs/development/compilers/ghc/8.0.2.nix | 2 +- pkgs/development/compilers/ghc/8.2.2.nix | 2 +- pkgs/development/compilers/ghc/8.4.2.nix | 2 +- pkgs/development/compilers/ghc/head.nix | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkgs/development/compilers/ghc/8.0.2.nix b/pkgs/development/compilers/ghc/8.0.2.nix index b5cd111f1e51..02cf40e2c664 100644 --- a/pkgs/development/compilers/ghc/8.0.2.nix +++ b/pkgs/development/compilers/ghc/8.0.2.nix @@ -166,7 +166,7 @@ stdenv.mkDerivation rec { # zsh and other shells are smart about `{ghc}` but bash isn't, and doesn't # treat that as a unary `{x,y,z,..}` repetition. postInstall = '' - paxmark m $out/lib/${name}/bin/${if targetPlatform != hostPlatform then "ghc" else "{ghc,haddock}"} + paxmark m $out/lib/${name}/bin/* # Install the bash completion file. install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc diff --git a/pkgs/development/compilers/ghc/8.2.2.nix b/pkgs/development/compilers/ghc/8.2.2.nix index 4bd6889d1df8..f6608305fb0d 100644 --- a/pkgs/development/compilers/ghc/8.2.2.nix +++ b/pkgs/development/compilers/ghc/8.2.2.nix @@ -181,7 +181,7 @@ stdenv.mkDerivation rec { # zsh and other shells are smart about `{ghc}` but bash isn't, and doesn't # treat that as a unary `{x,y,z,..}` repetition. postInstall = '' - paxmark m $out/lib/${name}/bin/${if targetPlatform != hostPlatform then "ghc" else "{ghc,haddock}"} + paxmark m $out/lib/${name}/bin/* # Install the bash completion file. install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc diff --git a/pkgs/development/compilers/ghc/8.4.2.nix b/pkgs/development/compilers/ghc/8.4.2.nix index b432682802e5..e498a67976f2 100644 --- a/pkgs/development/compilers/ghc/8.4.2.nix +++ b/pkgs/development/compilers/ghc/8.4.2.nix @@ -173,7 +173,7 @@ stdenv.mkDerivation rec { # zsh and other shells are smart about `{ghc}` but bash isn't, and doesn't # treat that as a unary `{x,y,z,..}` repetition. postInstall = '' - paxmark m $out/lib/${name}/bin/${if targetPlatform != hostPlatform then "ghc" else "{ghc,haddock}"} + paxmark m $out/lib/${name}/bin/* # Install the bash completion file. install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc diff --git a/pkgs/development/compilers/ghc/head.nix b/pkgs/development/compilers/ghc/head.nix index f5a7be5156d7..a1ba5af4c792 100644 --- a/pkgs/development/compilers/ghc/head.nix +++ b/pkgs/development/compilers/ghc/head.nix @@ -172,7 +172,7 @@ stdenv.mkDerivation rec { # zsh and other shells are smart about `{ghc}` but bash isn't, and doesn't # treat that as a unary `{x,y,z,..}` repetition. postInstall = '' - paxmark m $out/lib/${name}/bin/${if targetPlatform != hostPlatform then "ghc" else "{ghc,haddock}"} + paxmark m $out/lib/${name}/bin/* # Install the bash completion file. install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc From 03602f8162d96a4c510b935134337070812e1bbf Mon Sep 17 00:00:00 2001 From: John Ericson Date: Sun, 20 May 2018 02:21:37 -0400 Subject: [PATCH 11/12] ghc 8.4.2, head: Adjust enableShared enableTerminfo for windows --- pkgs/development/compilers/ghc/8.4.2.nix | 7 +++++-- pkgs/development/compilers/ghc/head.nix | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/pkgs/development/compilers/ghc/8.4.2.nix b/pkgs/development/compilers/ghc/8.4.2.nix index e498a67976f2..70dfaa2dcc57 100644 --- a/pkgs/development/compilers/ghc/8.4.2.nix +++ b/pkgs/development/compilers/ghc/8.4.2.nix @@ -22,7 +22,10 @@ , # Whether to build dynamic libs for the standard library (on the target # platform). Static libs are always built. - enableShared ? !targetPlatform.useAndroidPrebuilt + enableShared ? !targetPlatform.isWindows && !targetPlatform.useAndroidPrebuilt + +, # Whetherto build terminfo. + enableTerminfo ? !targetPlatform.isWindows , # What flavour to build. An empty string indicates no # specific flavour and falls back to ghc default values. @@ -60,7 +63,7 @@ let ''; # Splicer will pull out correct variations - libDeps = platform: [ ncurses ] + libDeps = platform: stdenv.lib.optional enableTerminfo [ ncurses ] ++ stdenv.lib.optional (!enableIntegerSimple) gmp ++ stdenv.lib.optional (platform.libc != "glibc") libiconv; diff --git a/pkgs/development/compilers/ghc/head.nix b/pkgs/development/compilers/ghc/head.nix index a1ba5af4c792..29993e8096d5 100644 --- a/pkgs/development/compilers/ghc/head.nix +++ b/pkgs/development/compilers/ghc/head.nix @@ -22,7 +22,10 @@ , # Whether to build dynamic libs for the standard library (on the target # platform). Static libs are always built. - enableShared ? !targetPlatform.useAndroidPrebuilt + enableShared ? !targetPlatform.isWindows && !targetPlatform.useAndroidPrebuilt + +, # Whetherto build terminfo. + enableTerminfo ? !targetPlatform.isWindows , version ? "8.5.20180118" , # What flavour to build. An empty string indicates no @@ -61,7 +64,7 @@ let ''; # Splicer will pull out correct variations - libDeps = platform: [ ncurses ] + libDeps = platform: stdenv.lib.optional enableTerminfo [ ncurses ] ++ stdenv.lib.optional (!enableIntegerSimple) gmp ++ stdenv.lib.optional (platform.libc != "glibc") libiconv; From 4b480942851d72bc6f292539b1e9a0c100323fae Mon Sep 17 00:00:00 2001 From: Moritz Angermann Date: Thu, 3 May 2018 13:54:00 +0800 Subject: [PATCH 12/12] ghc 8.4.2, head: Drop `libiconv` on windows. nixpkgs#37012 and nixpkgs#37707 introduces the setup-hooks for libiconv, which inject `-liconv` into the `NIX_LDFLAGS`. This breaks horribly on windows where the linker end up having no idea how to linke `-liconv`. The configure.ac file specifically ignores libiconv on windows. --- pkgs/development/compilers/ghc/8.4.2.nix | 4 ++-- pkgs/development/compilers/ghc/head.nix | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkgs/development/compilers/ghc/8.4.2.nix b/pkgs/development/compilers/ghc/8.4.2.nix index 70dfaa2dcc57..6615c0282e65 100644 --- a/pkgs/development/compilers/ghc/8.4.2.nix +++ b/pkgs/development/compilers/ghc/8.4.2.nix @@ -65,7 +65,7 @@ let # Splicer will pull out correct variations libDeps = platform: stdenv.lib.optional enableTerminfo [ ncurses ] ++ stdenv.lib.optional (!enableIntegerSimple) gmp - ++ stdenv.lib.optional (platform.libc != "glibc") libiconv; + ++ stdenv.lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv; toolsForTarget = if hostPlatform == buildPlatform then @@ -133,7 +133,7 @@ stdenv.mkDerivation rec { "--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib" ] ++ stdenv.lib.optional (targetPlatform == hostPlatform && ! enableIntegerSimple) [ "--with-gmp-includes=${gmp.dev}/include" "--with-gmp-libraries=${gmp.out}/lib" - ] ++ stdenv.lib.optional (targetPlatform == hostPlatform && hostPlatform.libc != "glibc") [ + ] ++ stdenv.lib.optional (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [ "--with-iconv-includes=${libiconv}/include" "--with-iconv-libraries=${libiconv}/lib" ] ++ stdenv.lib.optionals (targetPlatform != hostPlatform) [ "--enable-bootstrap-with-devel-snapshot" diff --git a/pkgs/development/compilers/ghc/head.nix b/pkgs/development/compilers/ghc/head.nix index 29993e8096d5..ede25c7679a6 100644 --- a/pkgs/development/compilers/ghc/head.nix +++ b/pkgs/development/compilers/ghc/head.nix @@ -66,7 +66,7 @@ let # Splicer will pull out correct variations libDeps = platform: stdenv.lib.optional enableTerminfo [ ncurses ] ++ stdenv.lib.optional (!enableIntegerSimple) gmp - ++ stdenv.lib.optional (platform.libc != "glibc") libiconv; + ++ stdenv.lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv; toolsForTarget = if hostPlatform == buildPlatform then @@ -132,7 +132,7 @@ stdenv.mkDerivation rec { "--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib" ] ++ stdenv.lib.optional (targetPlatform == hostPlatform && ! enableIntegerSimple) [ "--with-gmp-includes=${gmp.dev}/include" "--with-gmp-libraries=${gmp.out}/lib" - ] ++ stdenv.lib.optional (targetPlatform == hostPlatform && hostPlatform.libc != "glibc") [ + ] ++ stdenv.lib.optional (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [ "--with-iconv-includes=${libiconv}/include" "--with-iconv-libraries=${libiconv}/lib" ] ++ stdenv.lib.optionals (targetPlatform != hostPlatform) [ "--enable-bootstrap-with-devel-snapshot"