mirror of
https://github.com/ilyakooo0/haskell.nix.git
synced 2024-09-19 02:47:34 +03:00
Add patches speeding up cabal build-tool-depends (#1200)
* Add patches speeding up cabal build-tool-depends * Add missing brackets and fix paths * Fix up patches for 3.4 * Fix missing file from patch * Add comments
This commit is contained in:
parent
ed6d223e9b
commit
f8a0b92bc3
@ -3,7 +3,14 @@
|
||||
# package sets out of this repo. Ideally, this file is only used for
|
||||
# fixing things that are broken due to the Nix infrastructure.
|
||||
|
||||
{ pkgs, ... }: {
|
||||
{ pkgs, ... }:
|
||||
let
|
||||
fromUntil = from: until: patch: { version, revision }:
|
||||
if builtins.compareVersions version from >= 0
|
||||
&& builtins.compareVersions version until < 0
|
||||
then patch
|
||||
else null;
|
||||
in {
|
||||
# terminfo doesn't list libtinfo in its cabal file. We could ignore
|
||||
# this if we used the terminfo shipped with GHC, but this package is
|
||||
# reinstallable so we'd rather have it defined in the plan.
|
||||
@ -26,4 +33,19 @@
|
||||
packages.hscolour.package.license = pkgs.lib.mkForce "LGPL-2.1-only";
|
||||
packages.cpphs.package.license = pkgs.lib.mkForce "LGPL-2.1-only";
|
||||
packages.polyparse.package.license = pkgs.lib.mkForce "LGPL-2.1-only";
|
||||
|
||||
# These two patches are needed by GHCJS
|
||||
packages.Cabal.patches = [
|
||||
(fromUntil "3.2.0.0" "3.5" ../overlays/patches/Cabal/Cabal-3.0.0.0-drop-pkg-db-check.diff)
|
||||
(fromUntil "3.2.0.0" "3.5" ../overlays/patches/Cabal/Cabal-3.0.0.0-no-final-checks.diff)
|
||||
];
|
||||
|
||||
# These two patches are:
|
||||
# https://github.com/haskell/cabal/pull/7490
|
||||
# https://github.com/haskell/cabal/pull/7532
|
||||
# back poerted to cabal 3.4
|
||||
packages.cabal-install.patches = [
|
||||
(fromUntil "3.4.0.0" "3.5" ../overlays/patches/Cabal/Cabal-3.4-defer-build-tool-depends-7532.patch)
|
||||
(fromUntil "3.4.0.0" "3.5" ../overlays/patches/Cabal/Cabal-3.4-speedup-solver-when-tests-enabled-7490.patch)
|
||||
];
|
||||
}
|
||||
|
@ -18,11 +18,6 @@ final: prev:
|
||||
"mtl" "parsec" "process" "text" "time" "transformers"
|
||||
"unix" "xhtml" "terminfo"
|
||||
];
|
||||
# Include patches for custom setups
|
||||
packages.Cabal.patches = [
|
||||
./patches/Cabal/Cabal-3.0.0.0-drop-pkg-db-check.diff
|
||||
./patches/Cabal/Cabal-3.0.0.0-no-final-checks.diff
|
||||
];
|
||||
testWrapper = [((final.writeScriptBin "node-wrapper" ''
|
||||
set -euo pipefail
|
||||
exe=$1
|
||||
|
@ -23,14 +23,6 @@ in { haskell-nix = prev.haskell-nix // {
|
||||
(lib.optionalAttrs (version == "3.2.0.0") {
|
||||
packages.cabal-install.src = final.haskell-nix.sources.cabal-32 + "/cabal-install";
|
||||
})
|
||||
(lib.optionalAttrs (builtins.compareVersions version "3.0.0.0" >= 0
|
||||
&& builtins.compareVersions version "3.5" < 0) {
|
||||
# Include patches needed for ghcjs
|
||||
packages.Cabal.patches = [
|
||||
./patches/Cabal/Cabal-3.0.0.0-drop-pkg-db-check.diff
|
||||
./patches/Cabal/Cabal-3.0.0.0-no-final-checks.diff
|
||||
];
|
||||
})
|
||||
];
|
||||
};
|
||||
|
||||
|
@ -0,0 +1,63 @@
|
||||
From 3ac512e46f7b744597aaea12c7dfed95723b3665 Mon Sep 17 00:00:00 2001
|
||||
From: Gershom Bazerman <gershom@arista.com>
|
||||
Date: Wed, 11 Aug 2021 16:07:07 -0400
|
||||
Subject: [PATCH] defer build-tools-depends choices as well as setup choices
|
||||
|
||||
---
|
||||
.../Distribution/Solver/Modular/Preference.hs | 19 ++++++++++---------
|
||||
.../Distribution/Solver/Modular/Solver.hs | 2 +-
|
||||
2 files changed, 11 insertions(+), 10 deletions(-)
|
||||
|
||||
diff --git a/Distribution/Solver/Modular/Preference.hs b/Distribution/Solver/Modular/Preference.hs
|
||||
index ed5adfbf8b2..35a43d4cf3b 100644
|
||||
--- a/Distribution/Solver/Modular/Preference.hs
|
||||
+++ b/Distribution/Solver/Modular/Preference.hs
|
||||
@@ -2,7 +2,7 @@
|
||||
-- | Reordering or pruning the tree in order to prefer or make certain choices.
|
||||
module Distribution.Solver.Modular.Preference
|
||||
( avoidReinstalls
|
||||
- , deferSetupChoices
|
||||
+ , deferSetupExeChoices
|
||||
, deferWeakFlagChoices
|
||||
, enforceManualFlags
|
||||
, enforcePackageConstraints
|
||||
@@ -407,17 +407,18 @@ preferBaseGoalChoice = trav go
|
||||
isBase (Goal (P (Q _pp pn)) _) = unPN pn == "base"
|
||||
isBase _ = False
|
||||
|
||||
--- | Deal with setup dependencies after regular dependencies, so that we can
|
||||
--- will link setup dependencies against package dependencies when possible
|
||||
-deferSetupChoices :: Tree d c -> Tree d c
|
||||
-deferSetupChoices = trav go
|
||||
+-- | Deal with setup and build-tool-depends dependencies after regular dependencies,
|
||||
+-- so we will link setup/exe dependencies against package dependencies when possible
|
||||
+deferSetupExeChoices :: Tree d c -> Tree d c
|
||||
+deferSetupExeChoices = trav go
|
||||
where
|
||||
- go (GoalChoiceF rdm xs) = GoalChoiceF rdm (P.preferByKeys noSetup xs)
|
||||
+ go (GoalChoiceF rdm xs) = GoalChoiceF rdm (P.preferByKeys noSetupOrExe xs)
|
||||
go x = x
|
||||
|
||||
- noSetup :: Goal QPN -> Bool
|
||||
- noSetup (Goal (P (Q (PackagePath _ns (QualSetup _)) _)) _) = False
|
||||
- noSetup _ = True
|
||||
+ noSetupOrExe :: Goal QPN -> Bool
|
||||
+ noSetupOrExe (Goal (P (Q (PackagePath _ns (QualSetup _)) _)) _) = False
|
||||
+ noSetupOrExe (Goal (P (Q (PackagePath _ns (QualExe _ _)) _)) _) = False
|
||||
+ noSetupOrExe _ = True
|
||||
|
||||
-- | Transformation that tries to avoid making weak flag choices early.
|
||||
-- Weak flags are trivial flags (not influencing dependencies) or such
|
||||
diff --git a/Distribution/Solver/Modular/Solver.hs b/Distribution/Solver/Modular/Solver.hs
|
||||
index 83c597cd9e6..fe4b6160e39 100644
|
||||
--- a/Distribution/Solver/Modular/Solver.hs
|
||||
+++ b/Distribution/Solver/Modular/Solver.hs
|
||||
@@ -117,7 +117,7 @@ solve sc cinfo idx pkgConfigDB userPrefs userConstraints userGoals =
|
||||
sortGoals = case goalOrder sc of
|
||||
Nothing -> goalChoiceHeuristics .
|
||||
heuristicsTree .
|
||||
- P.deferSetupChoices .
|
||||
+ P.deferSetupExeChoices .
|
||||
P.deferWeakFlagChoices .
|
||||
P.preferBaseGoalChoice
|
||||
Just order -> P.firstGoal .
|
@ -0,0 +1,147 @@
|
||||
From fa47bff82b0f0f0bda7ca7e01b15e5740b63f775 Mon Sep 17 00:00:00 2001
|
||||
From: Gershom Bazerman <gershom@arista.com>
|
||||
Date: Fri, 23 Jul 2021 11:24:42 -0400
|
||||
Subject: [PATCH 1/4] attempt to speed solving when test is enable projectwide
|
||||
|
||||
---
|
||||
.../Distribution/Solver/Modular/Preference.hs | 6 ++++--
|
||||
.../Distribution/Client/ProjectPlanning.hs | 13 ++++---------
|
||||
2 files changed, 8 insertions(+), 11 deletions(-)
|
||||
|
||||
diff --git a/Distribution/Solver/Modular/Preference.hs b/Distribution/Solver/Modular/Preference.hs
|
||||
index d25ef846356..4275563006e 100644
|
||||
--- a/Distribution/Solver/Modular/Preference.hs
|
||||
+++ b/Distribution/Solver/Modular/Preference.hs
|
||||
@@ -127,11 +127,13 @@ preferPackagePreferences pcs =
|
||||
|
||||
-- | Traversal that tries to establish package stanza enable\/disable
|
||||
-- preferences. Works by reordering the branches of stanza choices.
|
||||
+-- Note that this works on packages lower in the path as well as at the top level,
|
||||
+-- as lower choices need to remain compatible with top level choices.
|
||||
preferPackageStanzaPreferences :: (PN -> PackagePreferences) -> Tree d c -> Tree d c
|
||||
preferPackageStanzaPreferences pcs = trav go
|
||||
where
|
||||
- go (SChoiceF qsn@(SN (Q pp pn) s) rdm gr _tr ts)
|
||||
- | primaryPP pp && enableStanzaPref pn s =
|
||||
+ go (SChoiceF qsn@(SN (Q _pp pn) s) rdm gr _tr ts)
|
||||
+ | enableStanzaPref pn s =
|
||||
-- move True case first to try enabling the stanza
|
||||
let ts' = W.mapWeightsWithKey (\k w -> weight k : w) ts
|
||||
weight k = if k then 0 else 1
|
||||
diff --git a/Distribution/Client/ProjectPlanning.hs b/Distribution/Client/ProjectPlanning.hs
|
||||
index 077c6422be4..18a4bf43a0d 100644
|
||||
--- a/Distribution/Client/ProjectPlanning.hs
|
||||
+++ b/Distribution/Client/ProjectPlanning.hs
|
||||
@@ -1024,14 +1024,9 @@ planPackages verbosity comp platform solver SolverSettings{..}
|
||||
| (pc, src) <- solverSettingConstraints ]
|
||||
|
||||
. addPreferences
|
||||
- -- enable stanza preference where the user did not specify
|
||||
- [ PackageStanzasPreference pkgname stanzas
|
||||
- | pkg <- localPackages
|
||||
- , let pkgname = pkgSpecifierTarget pkg
|
||||
- stanzaM = Map.findWithDefault Map.empty pkgname pkgStanzasEnable
|
||||
- stanzas = [ stanza | stanza <- [minBound..maxBound]
|
||||
- , Map.lookup stanza stanzaM == Nothing ]
|
||||
- , not (null stanzas)
|
||||
+ -- enable stanza preference unilaterally, even when the user asked to enable as well, to help hint the solver.
|
||||
+ [ PackageStanzasPreference pkgname [minBound..maxBound]
|
||||
+ | pkgname <- map pkgSpecifierTarget localPackages
|
||||
]
|
||||
|
||||
. addConstraints
|
||||
From 624b8dc2069964de7c99cb7c9fa8c8674db797de Mon Sep 17 00:00:00 2001
|
||||
From: Gershom Bazerman <gershom@arista.com>
|
||||
Date: Tue, 3 Aug 2021 17:35:12 -0400
|
||||
Subject: [PATCH 2/4] fix bug in preferences
|
||||
|
||||
---
|
||||
cabal-install/Distribution/Client/ProjectPlanning.hs | 7 ++++++-
|
||||
1 file changed, 6 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/Distribution/Client/ProjectPlanning.hs b/Distribution/Client/ProjectPlanning.hs
|
||||
index 18a4bf43a0d..42fe5be8f3d 100644
|
||||
--- a/Distribution/Client/ProjectPlanning.hs
|
||||
+++ b/Distribution/Client/ProjectPlanning.hs
|
||||
@@ -1026,7 +1026,12 @@ planPackages verbosity comp platform solver SolverSettings{..}
|
||||
. addPreferences
|
||||
-- enable stanza preference unilaterally, even when the user asked to enable as well, to help hint the solver.
|
||||
[ PackageStanzasPreference pkgname [minBound..maxBound]
|
||||
- | pkgname <- map pkgSpecifierTarget localPackages
|
||||
+ | pkg <- localPackages
|
||||
+ , let pkgname = pkgSpecifierTarget pkg
|
||||
+ stanzaM = Map.findWithDefault Map.empty pkgname pkgStanzasEnable
|
||||
+ stanzas = [ stanza | stanza <- [minBound..maxBound]
|
||||
+ , Map.lookup stanza stanzaM /= Just False ]
|
||||
+ , not (null stanzas)
|
||||
]
|
||||
|
||||
. addConstraints
|
||||
|
||||
From a5d04451d3d45bcfc8f679340f1dfd1e0e2993ed Mon Sep 17 00:00:00 2001
|
||||
From: Gershom Bazerman <gershom@arista.com>
|
||||
Date: Mon, 9 Aug 2021 18:17:49 -0400
|
||||
Subject: [PATCH 3/4] fix bug
|
||||
|
||||
---
|
||||
cabal-install/Distribution/Client/ProjectPlanning.hs | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/Distribution/Client/ProjectPlanning.hs b/Distribution/Client/ProjectPlanning.hs
|
||||
index 42fe5be8f3d..3aefe9242f8 100644
|
||||
--- a/Distribution/Client/ProjectPlanning.hs
|
||||
+++ b/Distribution/Client/ProjectPlanning.hs
|
||||
@@ -1025,7 +1025,7 @@ planPackages verbosity comp platform solver SolverSettings{..}
|
||||
|
||||
. addPreferences
|
||||
-- enable stanza preference unilaterally, even when the user asked to enable as well, to help hint the solver.
|
||||
- [ PackageStanzasPreference pkgname [minBound..maxBound]
|
||||
+ [ PackageStanzasPreference pkgname stanzas
|
||||
| pkg <- localPackages
|
||||
, let pkgname = pkgSpecifierTarget pkg
|
||||
stanzaM = Map.findWithDefault Map.empty pkgname pkgStanzasEnable
|
||||
|
||||
From fdf3f7f0a633de79b4c8f1298eaf433cdf558250 Mon Sep 17 00:00:00 2001
|
||||
From: Gershom Bazerman <gershom@arista.com>
|
||||
Date: Wed, 11 Aug 2021 13:57:57 -0400
|
||||
Subject: [PATCH 4/4] touchup comments
|
||||
|
||||
---
|
||||
.../Distribution/Solver/Modular/Preference.hs | 9 +++++++--
|
||||
cabal-install/Distribution/Client/ProjectPlanning.hs | 3 ++-
|
||||
2 files changed, 9 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/Distribution/Solver/Modular/Preference.hs b/Distribution/Solver/Modular/Preference.hs
|
||||
index 4275563006e..ed5adfbf8b2 100644
|
||||
--- a/Distribution/Solver/Modular/Preference.hs
|
||||
+++ b/Distribution/Solver/Modular/Preference.hs
|
||||
@@ -127,8 +127,13 @@ preferPackagePreferences pcs =
|
||||
|
||||
-- | Traversal that tries to establish package stanza enable\/disable
|
||||
-- preferences. Works by reordering the branches of stanza choices.
|
||||
--- Note that this works on packages lower in the path as well as at the top level,
|
||||
--- as lower choices need to remain compatible with top level choices.
|
||||
+-- Note that this works on packages lower in the path as well as at the top level.
|
||||
+-- This is because stanza preferences apply to local packages only
|
||||
+-- and for local packages, a single version is fixed, which means
|
||||
+-- (for now) that all stanza preferences must be uniform at all levels.
|
||||
+-- Further, even when we can have multiple versions of the same package,
|
||||
+-- the build plan will be more efficient if we can attempt to keep
|
||||
+-- stanza preferences aligned at all levels.
|
||||
preferPackageStanzaPreferences :: (PN -> PackagePreferences) -> Tree d c -> Tree d c
|
||||
preferPackageStanzaPreferences pcs = trav go
|
||||
where
|
||||
diff --git a/Distribution/Client/ProjectPlanning.hs b/Distribution/Client/ProjectPlanning.hs
|
||||
index 3aefe9242f8..fc6d9a17383 100644
|
||||
--- a/Distribution/Client/ProjectPlanning.hs
|
||||
+++ b/Distribution/Client/ProjectPlanning.hs
|
||||
@@ -1024,7 +1024,8 @@ planPackages verbosity comp platform solver SolverSettings{..}
|
||||
| (pc, src) <- solverSettingConstraints ]
|
||||
|
||||
. addPreferences
|
||||
- -- enable stanza preference unilaterally, even when the user asked to enable as well, to help hint the solver.
|
||||
+ -- enable stanza preference unilaterally, regardless if the user asked
|
||||
+ -- accordingly or expressed no preference, to help hint the solver
|
||||
[ PackageStanzasPreference pkgname stanzas
|
||||
| pkg <- localPackages
|
||||
, let pkgname = pkgSpecifierTarget pkg
|
Loading…
Reference in New Issue
Block a user