Skip to content

Commit

Permalink
Add ghc 8.8.1 to the supported compilers (#342)
Browse files Browse the repository at this point in the history
* Add ghc 8.8.1 to the supported compilers

The `overlays/ghc.nix` overrides were not applied to the `ghc` used
to by the `exactDeps` and `envDeps` `passthru` derivations.  This
resulted in each ghc building twice with only one of them being cached
by hydra.

This change fixes this by moving the exactDeps and envDeps for ghc
into sub directories of the output of the ghc derivation itself.

Co-authored-by: Hideaki KAWAI <kayhide@gmail.com>
  • Loading branch information
hamishmack and kayhide committed Feb 4, 2020
1 parent b147d50 commit 122bd81
Show file tree
Hide file tree
Showing 11 changed files with 10,869 additions and 671 deletions.
17 changes: 15 additions & 2 deletions builder/make-config-files.nix
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,12 @@ in { identifier, component, fullName, flags ? {} }:
#
# NOTE [ln -s -f]: we force link, as we may have dependencies that contain shared deps
# (e.g. libiconv), and thus we don't want to fail, but just link it again.
#
# Confusing sed stuff:
# '/^ ./{H;$!d} ; x' Groups lines that start with a space with the initial
# line of a block. Needs a blank line added to the file
# to terminate the last block.
# 's/ /\n/g ; s/\n\n*/\n/g; s/^\n//;' Puts each field on its own line.
+ lib.optionalString stdenv.isDarwin ''
# Work around a limit in the macOS Sierra linker on the number of paths
# referenced by any one dynamic library:
Expand All @@ -122,12 +128,19 @@ in { identifier, component, fullName, flags ? {} }:
# libraries) from all the dependencies.
local dynamicLinksDir="$out/lib/links"
mkdir -p $dynamicLinksDir
for d in $(grep dynamic-library-dirs "$out/package.conf.d/"*|awk '{print $2}'|sort -u); do
local dirsToLink=$(
for f in "$out/package.conf.d/"*.conf; do
(cat $f; echo) | sed -En '/^ ./{H;$!d} ; x ; /^dynamic-library-dirs:/ {s/^dynamic-library-dirs:// ; s/ /\n/g ; s/\n\n*/\n/g; s/^\n//; p}'
done | sort -u
)
for d in $dirsToLink; do
ln -f -s "$d/"*.dylib $dynamicLinksDir
done
# Edit the local package DB to reference the links directory.
for f in "$out/package.conf.d/"*.conf; do
sed -i "s,dynamic-library-dirs: .*,dynamic-library-dirs: $dynamicLinksDir," $f
chmod +w $f
echo >> $f
sed -i -E "/^ ./{H;$!d} ; x ; s,^dynamic-library-dirs:.*,dynamic-library-dirs: $dynamicLinksDir," $f
done
'' + ''
${target-pkg} -v0 --package-db $out/package.conf.d recache
Expand Down
12 changes: 11 additions & 1 deletion nix-tools/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,17 @@ let
}

{
reinstallableLibGhc = true;
# Make Cabal reinstallable
nonReinstallablePkgs =
[ "rts" "ghc-heap" "ghc-prim" "integer-gmp" "integer-simple" "base"
"deepseq" "array" "ghc-boot-th" "pretty" "template-haskell"
"ghc-boot"
"ghc" "Win32" "array" "binary" "bytestring" "containers"
"directory" "filepath" "ghc-boot" "ghc-compact" "ghc-prim"
"hpc"
"mtl" "parsec" "process" "text" "time" "transformers"
"unix" "xhtml"
];
}
] ++ pkgs.lib.optional (args ? ghc) { ghc.package = args.ghc; };
};
Expand Down
119 changes: 79 additions & 40 deletions overlays/bootstrap.nix
Original file line number Diff line number Diff line change
Expand Up @@ -57,51 +57,58 @@ in {
};
ghc-patches = version: let
# Returns true iff this derivation's version is strictly older than ver.
versionOlder = ver: builtins.compareVersions ver version == 1;
versionLessThan = ver: builtins.compareVersions ver version == 1;
# Returns true iff this derivation's verion is greater than or equal to ver.
versionAtLeast = ver: !versionOlder ver;
# Patches for which we know they have been merged into a public release already
in self.lib.optional (versionAtLeast "8.4.4" && versionOlder "8.6") ./patches/ghc/ghc-8.4.4-reinstallable-lib-ghc.patch
++ self.lib.optional (versionOlder "8.6") ./patches/ghc/move-iserv-8.4.2.patch
++ self.lib.optional (versionOlder "8.6") ./patches/ghc/hsc2hs-8.4.2.patch
++ self.lib.optional (versionOlder "8.6") ./patches/ghc/various-8.4.2.patch
++ self.lib.optional (versionOlder "8.6") ./patches/ghc/lowercase-8.4.2.patch
++ self.lib.optional (versionOlder "8.6") ./patches/ghc/cabal-exe-ext-8.4.2.patch
++ self.lib.optional (versionOlder "8.6") ./patches/ghc/ghc-8.4.3-Cabal2201-SMP-test-fix.patch
++ self.lib.optional (versionOlder "8.6") ./patches/ghc/outputtable-assert-8.4.patch
++ self.lib.optional (versionAtLeast "8.6" && versionOlder "8.6.4") ./patches/ghc/MR148--T16104-GhcPlugins.patch
++ self.lib.optional (versionOlder "8.6.4") ./patches/ghc/MR95--ghc-pkg-deadlock-fix.patch

# Patches for which we only know a lower bound.
++ self.lib.optional (versionAtLeast "8.6") ./patches/ghc/iserv-proxy-cleanup.patch # https://gitlab.haskell.org/ghc/ghc/merge_requests/250 -- merged; ghc-8.8.1
++ self.lib.optional (versionAtLeast "8.2") ./patches/ghc/MR545--ghc-pkg-databases.patch # https://gitlab.haskell.org/ghc/ghc/merge_requests/545 -- merged; ghc-8.8.1
++ self.lib.optional (versionAtLeast "8.6") ./patches/ghc/outputtable-assert-8.6.patch
++ self.lib.optional (versionAtLeast "8.6") ./patches/ghc/mistuke-ghc-err_clean_up_error_handler-8ab1a89af89848f1713e6849f189de66c0ed7898.diff # this is part of Phyx- revamped io-manager.
++ self.lib.optional (versionAtLeast "8.6.4") ./patches/ghc/ghc-8.6.4-reenable-th-qq-in-stage1.patch
++ [
./patches/ghc/ghc-add-keepCAFs-to-rts.patch # https://gitlab.haskell.org/ghc/ghc/merge_requests/950 -- open
./patches/ghc/lowercase-8.6.patch # https://gitlab.haskell.org/ghc/ghc/merge_requests/949 -- merged; ghc-8.8.1
./patches/ghc/dll-loader-8.4.2.patch # https://gitlab.haskell.org/ghc/ghc/merge_requests/949 -- open
./patches/ghc/0001-Stop-the-linker-panic.patch # https://phabricator.haskell.org/D5012 -- merged; ghc-8.8.1
./patches/ghc/ghc-8.4.3-Cabal2201-no-hackage-tests.patch # ?
./patches/ghc/ghc-8.4.3-Cabal2201-allow-test-wrapper.patch # https://github.com/haskell/cabal/pulls/5995 -- merged; cabal-3.0.0 (ghc-8.8.1)
./patches/ghc/ghc-8.4.3-Cabal2201-response-file-support.patch # https://github.com/haskell/cabal/pulls/5996 -- merged; cabal-3.0.0 (ghc-8.8.1)
./patches/ghc/ghc-8.6-Cabal-fix-datadir.patch # https://github.com/haskell/cabal/issues/5862
./patches/ghc/MR196--ghc-pkg-shut-up.patch # https://gitlab.haskell.org/ghc/ghc/merge_requests/196 -- merged; ghc-8.8.1
./patches/ghc/MR948--32bit-cross-th.patch # https://gitlab.haskell.org/ghc/ghc/merge_requests/948 -- open
]
versionAtLeast = ver: !versionLessThan ver;
from = start: self.lib.optional (versionAtLeast start);
fromUntil = start: end: self.lib.optional (versionAtLeast start && versionLessThan end);
until = end: self.lib.optional (versionLessThan end);
always = self.lib.optional true;
# Try to avoid reordering the patches unless a patch is added or changed that
# will be applied to most versions of the GHC anyway (reordering the patches
# results in rebuilds of GHC and reduces sharing in /nix/store).
in fromUntil "8.4.4" "8.6" ./patches/ghc/ghc-8.4.4-reinstallable-lib-ghc.patch
++ until "8.6" ./patches/ghc/move-iserv-8.4.2.patch
++ until "8.6" ./patches/ghc/hsc2hs-8.4.2.patch
++ until "8.6" ./patches/ghc/various-8.4.2.patch
++ until "8.6" ./patches/ghc/lowercase-8.4.2.patch
++ until "8.6" ./patches/ghc/cabal-exe-ext-8.4.2.patch
++ until "8.6" ./patches/ghc/ghc-8.4.3-Cabal2201-SMP-test-fix.patch
++ until "8.6" ./patches/ghc/outputtable-assert-8.4.patch
++ fromUntil "8.6" "8.6.4" ./patches/ghc/MR148--T16104-GhcPlugins.patch
++ until "8.6.4" ./patches/ghc/MR95--ghc-pkg-deadlock-fix.patch
++ fromUntil "8.6" "8.8" ./patches/ghc/iserv-proxy-cleanup.patch # https://gitlab.haskell.org/ghc/ghc/merge_requests/250 -- merged; ghc-8.8.1
++ from "8.6" ./patches/ghc/iserv-proxy-cleanup-2.patch
++ from "8.8" ./patches/ghc/iserv-proxy-cleanup-3.patch
++ fromUntil "8.2" "8.8" ./patches/ghc/MR545--ghc-pkg-databases.patch # https://gitlab.haskell.org/ghc/ghc/merge_requests/545 -- merged; ghc-8.8.1
++ fromUntil "8.6" "8.8" ./patches/ghc/outputtable-assert-8.6.patch
++ fromUntil "8.6.4" "8.8" ./patches/ghc/ghc-8.6.4-reenable-th-qq-in-stage1.patch
++ until "8.8" ./patches/ghc/0001-Stop-the-linker-panic.patch # https://phabricator.haskell.org/D5012 -- merged; ghc-8.8.1
++ until "8.8" ./patches/ghc/ghc-8.4.3-Cabal2201-allow-test-wrapper.patch # https://github.com/haskell/cabal/pulls/5995 -- merged; cabal-3.0.0 (ghc-8.8.1)
++ until "8.8" ./patches/ghc/ghc-8.4.3-Cabal2201-response-file-support.patch # https://github.com/haskell/cabal/pulls/5996 -- merged; cabal-3.0.0 (ghc-8.8.1)
++ until "8.8" ./patches/ghc/ghc-8.6-Cabal-fix-datadir.patch # https://github.com/haskell/cabal/issues/5862
++ until "8.8" ./patches/ghc/MR196--ghc-pkg-shut-up.patch # https://gitlab.haskell.org/ghc/ghc/merge_requests/196 -- merged; ghc-8.8.1
++ from "8.6" ./patches/ghc/mistuke-ghc-err_clean_up_error_handler-8ab1a89af89848f1713e6849f189de66c0ed7898.diff # this is part of Phyx- revamped io-manager.
++ always ./patches/ghc/ghc-add-keepCAFs-to-rts.patch # https://gitlab.haskell.org/ghc/ghc/merge_requests/950 -- open
++ always ./patches/ghc/lowercase-8.6.patch # https://gitlab.haskell.org/ghc/ghc/merge_requests/949 -- merged; ghc-8.8.1
++ always ./patches/ghc/dll-loader-8.4.2.patch # https://gitlab.haskell.org/ghc/ghc/merge_requests/949 -- open
++ always ./patches/ghc/ghc-8.4.3-Cabal2201-no-hackage-tests.patch # ?
++ always ./patches/ghc/MR948--32bit-cross-th.patch # https://gitlab.haskell.org/ghc/ghc/merge_requests/948 -- open
++ from "8.8" ./patches/ghc/cabal-host.patch # https://github.com/haskell/cabal/issues/5887
++ fromUntil "8.6.4" "8.8" ./patches/ghc/ghc-8.6.4-prim-no-arm-atomics.patch
++ fromUntil "8.6.4" "8.8" ./patches/ghc/global-offset-table.patch
++ fromUntil "8.6.4" "8.8" ./patches/ghc/global-offset-table-2.patch

# Patches for specific ghc versions.
++ self.lib.optional (version == "8.6.3") ./patches/ghc/T16057--ghci-doa-on-windows.patch
++ self.lib.optional (version == "8.6.3") ./patches/ghc/ghc-8.6.3-reinstallable-lib-ghc.patch
++ self.lib.optional (version == "8.6.4") ./patches/ghc/ghc-8.6.4-reinstallable-lib-ghc.patch
++ self.lib.optional (version == "8.6.5") ./patches/ghc/ghc-8.6.5-reinstallable-lib-ghc.patch
++ self.lib.optional (version == "8.6.4") ./patches/ghc/ghc-8.6.4-better-plusSimplCountErrors.patch
++ self.lib.optional (version == "8.6.3") ./patches/ghc/T16057--ghci-doa-on-windows.patch
++ self.lib.optional (version == "8.6.3") ./patches/ghc/ghc-8.6.3-reinstallable-lib-ghc.patch
++ self.lib.optional (version == "8.6.4") ./patches/ghc/ghc-8.6.4-reinstallable-lib-ghc.patch
++ self.lib.optional (version == "8.6.5") ./patches/ghc/ghc-8.6.5-reinstallable-lib-ghc.patch
++ self.lib.optional (version == "8.8.1") ./patches/ghc/ghc-8.8.1-reinstallable-lib-ghc.patch
++ self.lib.optional (version == "8.8.2") ./patches/ghc/ghc-8.8.2-reinstallable-lib-ghc.patch
++ self.lib.optional (version == "8.6.4") ./patches/ghc/ghc-8.6.4-better-plusSimplCountErrors.patch
++ self.lib.optional (versionAtLeast "8.6.4" && self.stdenv.isDarwin) ./patches/ghc/ghc-macOS-loadArchive-fix.patch
++ self.lib.optional (versionAtLeast "8.4.4" && self.stdenv.isDarwin) ./patches/ghc/ghc-darwin-gcc-version-fix.patch
++ self.lib.optional (versionAtLeast "8.6.4" && versionOlder "8.8") ./patches/ghc/ghc-8.6.4-prim-no-arm-atomics.patch
++ self.lib.optional (versionAtLeast "8.6.4" && versionOlder "8.8") ./patches/ghc/global-offset-table.patch
++ self.lib.optional (versionAtLeast "8.6.4" && versionOlder "8.8") ./patches/ghc/global-offset-table-2.patch
;
in ({
ghc844 = self.callPackage ../compiler/ghc {
Expand Down Expand Up @@ -206,6 +213,38 @@ in {
ghc-patches = ghc-patches "8.6.5"
++ [ D5123-patch haddock-900-patch ];
};
ghc881 = self.callPackage ../compiler/ghc {
extra-passthru = { buildGHC = self.buildPackages.haskell-nix.compiler.ghc881; };

inherit bootPkgs sphinx installDeps;

buildLlvmPackages = self.buildPackages.llvmPackages_7;
llvmPackages = self.llvmPackages_7;

src-spec = rec {
version = "8.8.1";
url = "https://downloads.haskell.org/~ghc/${version}/ghc-${version}-src.tar.xz";
sha256 = "06kj4fhvijinjafiy4s873n60qly323rdlz9bmc79nhlp3cq72lh";
};

ghc-patches = ghc-patches "8.8.1";
};
ghc882 = self.callPackage ../compiler/ghc {
extra-passthru = { buildGHC = self.buildPackages.haskell-nix.compiler.ghc882; };

inherit bootPkgs sphinx installDeps;

buildLlvmPackages = self.buildPackages.llvmPackages_7;
llvmPackages = self.llvmPackages_7;

src-spec = rec {
version = "8.8.2";
url = "https://downloads.haskell.org/~ghc/${version}/ghc-${version}-src.tar.xz";
sha256 = "02qa6wgjpxgakg7hv4zfdlrx9k7zxa5i02wnr6y9fsv8j16sbkh1";
};

ghc-patches = ghc-patches "8.8.2";
};
} // self.lib.optionalAttrs (self.targetPlatform.isGhcjs or false) {
ghc865 = let ghcjs865 = self.callPackage ../compiler/ghcjs/ghcjs.nix {
ghcjsSrcJson = ../compiler/ghcjs/ghcjs-src.json;
Expand Down
13 changes: 11 additions & 2 deletions overlays/ghc-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,11 @@ let

ghc-extra-pkgs = {
ghc = "compiler";
base = "libraries/base";
bytestring = "libraries/bytestring";
ghci = "libraries/ghci";
ghc-boot = "libraries/ghc-boot";
ghc-heap = "libraries/ghc-heap";
libiserv = "libraries/libiserv";
iserv = "utils/iserv";
remote-iserv = "utils/remote-iserv";
Expand Down Expand Up @@ -67,8 +70,13 @@ in rec {
(pkgName: dir: importCabal "${name}-${pkgName}" "${value.passthru.configured-src}/${dir}") ghc-extra-pkgs)
self.buildPackages.haskell-nix.compiler;

ghc-extra-pkgs-cabal-projects = builtins.mapAttrs (name: value: let package-locs = builtins.mapAttrs (_: dir: "${value.passthru.configured-src}/${dir}") ghc-extra-pkgs; in
self.writeTextFile {
ghc-extra-pkgs-cabal-projects = builtins.mapAttrs (name: value:
let package-locs =
builtins.mapAttrs (_: dir: "${value.passthru.configured-src}/${dir}")
# TODO ghc-heap.cabal requires cabal 3. We should update the cabalProject' call
# in `ghc-extra-projects` below to work with this.
(self.lib.filterAttrs (n: _: n != "base" && n != "ghc-heap") ghc-extra-pkgs);
in self.writeTextFile {
name = "ghc-extra-pkgs-cabal-project-${name}";
destination = "/cabal.project";
text = ''
Expand All @@ -86,6 +94,7 @@ in rec {
src = proj;
index-state = "2019-10-31T00:00:00Z";
ghc = self.buildPackages.haskell-nix.compiler.${name};
configureArgs = "--disable-tests"; # avoid failures satisfying bytestring package tests dependencies
})
ghc-extra-pkgs-cabal-projects;

Expand Down
5 changes: 3 additions & 2 deletions overlays/haskell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ self: super: {
}@args:

let
pkg-def = plan-pkgs.pkgs;
pkg-def = excludeBootPackages plan-pkgs.pkgs;
# The compiler referenced in the stack config
compiler = (plan-pkgs.extras hackage).compiler or (pkg-def hackage).compiler;
patchesModule = ghcHackagePatches.${compiler.nix-name} or {};
Expand Down Expand Up @@ -472,7 +472,7 @@ self: super: {
};

haskellNixRoots' = ifdLevel:
let filterSupportedGhc = self.lib.filterAttrs (n: _: n == "ghc865");
let filterSupportedGhc = self.lib.filterAttrs (n: _: n == "ghc865" || n == "ghc882");
in self.recurseIntoAttrs ({
# Things that require no IFD to build
inherit (self.buildPackages.haskell-nix) nix-tools source-pins;
Expand All @@ -486,6 +486,7 @@ self: super: {
happy = self.buildPackages.haskell-nix.bootstrap.packages.happy;
hscolour = self.buildPackages.haskell-nix.bootstrap.packages.hscolour;
ghc865 = self.buildPackages.haskell-nix.compiler.ghc865;
ghc882 = self.buildPackages.haskell-nix.compiler.ghc882;
ghc-extra-projects = self.recurseIntoAttrs (builtins.mapAttrs (_: proj: withInputs proj.plan-nix)
(filterSupportedGhc self.ghc-extra-projects));
} // self.lib.optionalAttrs (ifdLevel > 1) {
Expand Down
13 changes: 13 additions & 0 deletions overlays/patches/ghc/cabal-host.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/libraries/Cabal/Cabal/Distribution/Simple.hs b/libraries/Cabal/Cabal/Distribution/Simple.hs
index e632acc88..1a687bb2e 100644
--- a/libraries/Cabal/Cabal/Distribution/Simple.hs
+++ b/libraries/Cabal/Cabal/Distribution/Simple.hs
@@ -755,7 +755,7 @@ runConfigureScript verbosity backwardsCompatHack flags lbi = do
[("PATH", Just pathEnv) | not (null extraPath)]
hp = hostPlatform lbi
maybeHostFlag = if hp == buildPlatform then [] else ["--host=" ++ show (pretty hp)]
- args' = configureFile':args ++ ["CC=" ++ ccProgShort] ++ maybeHostFlag
+ args' = configureFile':maybeHostFlag ++ args ++ ["CC=" ++ ccProgShort]
shProg = simpleProgram "sh"
progDb = modifyProgramSearchPath
(\p -> map ProgramSearchPathDir extraPath ++ p) emptyProgramDb
Loading

0 comments on commit 122bd81

Please sign in to comment.