From 513cd3de0e05fa25b08b4bf52e6389e406916190 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 f08130a3157..80d3bec38e7 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 e1b9419dec7fa09a4d08482ed8156b4bba90bd51 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 80d3bec38e7..0a668fd38ca 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 ++ 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 38fbdcc7267d84aa224a8711038caa2b8ef8a418 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 0a668fd38ca..b0cf228f8c7 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 a4d5dbd45dfe35ca93b32daedba1c25167701cb0 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 b0cf228f8c7..66c8c1fd375 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 affeb0cb805f82bcc51e192a4c3bfe00f5f63fc9 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 66c8c1fd375..ef4cccdd820 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 87afa66a63eff046b5da7605909bae956b26e585 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 ef4cccdd820..8d9b596276c 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 55e45bd6559..fb1302f60ea 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 63e5b3ce716c9d10f024cc4aafca82146d76258e 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 469b249010f..2f1eb1ad97a 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 9ce15ea60c8a93753d20a06d7f3dae6c867f7d10 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 e4bf23c6e9e..150d14e1db4 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 4017a01e702..c3c7690b09f 100644 --- a/pkgs/development/compilers/ghc/8.0.2.nix +++ b/pkgs/development/compilers/ghc/8.0.2.nix @@ -87,6 +87,8 @@ stdenv.mkDerivation rec { ++ stdenv.lib.optional stdenv.isDarwin ./ghc-8.0.2-no-cpp-warnings.patch ++ stdenv.lib.optional stdenv.isDarwin ./backport-dylib-command-size-limit.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 +105,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) '' @@ -134,7 +137,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 dcc2852a341..2b876552a01 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 @@ -153,7 +151,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 5d8adafa9a7..6cb6930f3aa 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 { @@ -144,7 +143,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 7e1c73d166a..e0de4e7e60e 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 1978115c3b2dfcb33f78673677a0ef3ffa6a0565 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 150d14e1db4..7d2f3791632 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 c3c7690b09f..2e627473fc2 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 2b876552a01..beaf761bd42 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 6cb6930f3aa..449edef662d 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 e0de4e7e60e..f5a7be5156d 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 10b76a4caba015a5252cc88172d3b7d23b14d8f6 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. Need to skip non ELFs (e.g. shell scripts), however. --- pkgs/development/compilers/ghc/8.0.2.nix | 7 ++++--- pkgs/development/compilers/ghc/8.2.2.nix | 7 ++++--- pkgs/development/compilers/ghc/8.4.2.nix | 7 ++++--- pkgs/development/compilers/ghc/head.nix | 7 ++++--- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/pkgs/development/compilers/ghc/8.0.2.nix b/pkgs/development/compilers/ghc/8.0.2.nix index 2e627473fc2..2957846cd59 100644 --- a/pkgs/development/compilers/ghc/8.0.2.nix +++ b/pkgs/development/compilers/ghc/8.0.2.nix @@ -164,10 +164,11 @@ stdenv.mkDerivation rec { # that in turn causes GHCi to abort stripDebugFlags = [ "-S" ] ++ stdenv.lib.optional (!targetPlatform.isDarwin) "--keep-file-symbols"; - # 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}"} + for bin in "$out"/lib/${name}/bin/*; do + isELF "$bin" || continue + paxmark m "$bin" + done # 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 beaf761bd42..c21fd3353c7 100644 --- a/pkgs/development/compilers/ghc/8.2.2.nix +++ b/pkgs/development/compilers/ghc/8.2.2.nix @@ -179,10 +179,11 @@ stdenv.mkDerivation rec { checkTarget = "test"; - # 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}"} + for bin in "$out"/lib/${name}/bin/*; do + isELF "$bin" || continue + paxmark m "$bin" + done # 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 449edef662d..7cdf746c582 100644 --- a/pkgs/development/compilers/ghc/8.4.2.nix +++ b/pkgs/development/compilers/ghc/8.4.2.nix @@ -171,10 +171,11 @@ stdenv.mkDerivation rec { checkTarget = "test"; - # 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}"} + for bin in "$out"/lib/${name}/bin/*; do + isELF "$bin" || continue + paxmark m "$bin" + done # 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 f5a7be5156d..1fe6271033f 100644 --- a/pkgs/development/compilers/ghc/head.nix +++ b/pkgs/development/compilers/ghc/head.nix @@ -169,10 +169,11 @@ stdenv.mkDerivation rec { checkTarget = "test"; - # 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}"} + for bin in "$out"/lib/${name}/bin/*; do + isELF "$bin" || continue + paxmark m "$bin" + done # Install the bash completion file. install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc From c7458ded5c34161a33773f872ab10f0dd0af4b2c 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 7cdf746c582..18b229f95cc 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 1fe6271033f..7e4b26cda25 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 fe1eec9e24ba24f468649c14529be9d7a7c720d4 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 18b229f95cc..0eaf64cad81 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 @@ -134,7 +134,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 7e4b26cda25..88cfcf72579 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"