haskell.compiler.ghc9{6,8}: apply hadrian patches to shared ghcSrc

This makes the hadrian expressions much simpler as we no longer need to
thread through extra arguments for special workarounds.
common-hadrian.nix decides in one place which patches we need and
directly applies them to the source used to build everything.
This commit is contained in:
sternenseemann 2024-04-17 00:51:15 +02:00
parent 675bcbb917
commit c93aff17d5
5 changed files with 23 additions and 22 deletions

View File

@ -159,6 +159,12 @@
});
patches =
let
# Disable haddock generating pretty source listings to stay under 3GB on aarch64-linux
enableHyperlinkedSource =
lib.versionAtLeast version "9.8" ||
!(stdenv.hostPlatform.isAarch64 && stdenv.hostPlatform.isLinux);
in
[
# Fix docs build with Sphinx >= 7 https://gitlab.haskell.org/ghc/ghc/-/issues/24129
(if lib.versionAtLeast version "9.8"
@ -174,6 +180,18 @@
# https://github.com/NixOS/nixpkgs/issues/140774 for details).
./Cabal-at-least-3.6-paths-fix-cycle-aarch64-darwin.patch
]
# Prevents passing --hyperlinked-source to haddock. This is a custom
# workaround as we wait for this to be configurable via userSettings or
# similar. https://gitlab.haskell.org/ghc/ghc/-/issues/23625
++ lib.optionals (!enableHyperlinkedSource) [
# TODO(@sternenseemann): Doesn't apply for GHC >= 9.8
../../tools/haskell/hadrian/disable-hyperlinked-source.patch
]
# Incorrect bounds on Cabal in hadrian
# https://gitlab.haskell.org/ghc/ghc/-/issues/24100
++ lib.optionals (lib.elem version [ "9.8.1" "9.8.2" ]) [
../../tools/haskell/hadrian/hadrian-9.8.1-allow-Cabal-3.10.patch
];
}
# GHC's build system hadrian built from the GHC-to-build's source tree
@ -182,11 +200,6 @@
inherit ghcSrc;
ghcVersion = version;
userSettings = hadrianUserSettings;
# Disable haddock generating pretty source listings to stay under 3GB on aarch64-linux
enableHyperlinkedSource =
# TODO(@sternenseemann): Disabling currently doesn't work with GHC >= 9.8
lib.versionAtLeast version "9.8" ||
!(stdenv.hostPlatform.isAarch64 && stdenv.hostPlatform.isLinux);
}
, # Whether to build sphinx documentation.

View File

@ -1,7 +1,7 @@
diff --git a/hadrian/src/Settings/Builders/Haddock.hs b/hadrian/src/Settings/Builders/Haddock.hs
index 902b2f85e2..429a441c3b 100644
--- a/src/Settings/Builders/Haddock.hs
+++ b/src/Settings/Builders/Haddock.hs
--- a/hadrian/src/Settings/Builders/Haddock.hs
+++ b/hadrian/src/Settings/Builders/Haddock.hs
@@ -57,7 +57,6 @@ haddockBuilderArgs = mconcat
, arg $ "--odir=" ++ takeDirectory output
, arg $ "--dump-interface=" ++ output

View File

@ -1,7 +1,7 @@
diff --git a/hadrian.cabal b/hadrian.cabal
index 70fded11aa..3893537f05 100644
--- a/hadrian.cabal
+++ b/hadrian.cabal
--- a/hadrian/hadrian.cabal
+++ b/hadrian/hadrian.cabal
@@ -150,7 +150,7 @@ executable hadrian
, TypeOperators
other-extensions: MultiParamTypeClasses

View File

@ -11,7 +11,6 @@
, ghcVersion
# Customization
, userSettings ? null
, enableHyperlinkedSource
}:
mkDerivation {
@ -21,13 +20,6 @@ mkDerivation {
postUnpack = ''
sourceRoot="$sourceRoot/hadrian"
'';
patches = lib.optionals (!enableHyperlinkedSource) [
./disable-hyperlinked-source.patch
] ++ lib.optionals (lib.elem ghcVersion [ "9.8.1" "9.8.2" ]) [
# Incorrect bounds on Cabal
# https://gitlab.haskell.org/ghc/ghc/-/issues/24100
./hadrian-9.8.1-allow-Cabal-3.10.patch
];
# Overwrite UserSettings.hs with a provided custom one
postPatch = lib.optionalString (userSettings != null) ''
install -m644 "${writeText "UserSettings.hs" userSettings}" src/UserSettings.hs

View File

@ -32,10 +32,6 @@
# Contents of a non-default UserSettings.hs to use when building hadrian, if any.
# Should be a string or null.
, userSettings ? null
# Whether to pass --hyperlinked-source to haddock or not. This is a custom
# workaround as we wait for this to be configurable via userSettings or similar.
# https://gitlab.haskell.org/ghc/ghc/-/issues/23625
, enableHyperlinkedSource ? false
}:
let
@ -50,7 +46,7 @@ let
in
callPackage' ./hadrian.nix ({
inherit userSettings enableHyperlinkedSource;
inherit userSettings;
} // lib.optionalAttrs (lib.versionAtLeast ghcVersion "9.9") {
# Starting with GHC 9.9 development, additional in tree packages are required
# to build hadrian. (Hackage-released conditional dependencies are handled