From 675bcbb917a13567e3fad8bb00afada19db791d6 Mon Sep 17 00:00:00 2001 From: sternenseemann Date: Wed, 17 Apr 2024 00:45:17 +0200 Subject: [PATCH] haskell.compiler.ghc9{6,8}: pass patched source to hadrian MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We'll want to (slowly) unify the source used by the different derivations we use to build GHC. As a first step, use the same base source for building GHC and all hadrian related packages. This is achieved by wrapping the fetcher result in `srcOnly` to apply GHC patches immediately. To modify the patches (and source) used by GHC we now have a changed overriding interface for >= 9.6: ``` oldGhc.override { ghcSrc = oldGhc.src.overrideAttrs (oldAttrs: { src = …; patches = …; }); } ``` --- .../compilers/ghc/common-hadrian.nix | 54 +++++++++++-------- 1 file changed, 31 insertions(+), 23 deletions(-) diff --git a/pkgs/development/compilers/ghc/common-hadrian.nix b/pkgs/development/compilers/ghc/common-hadrian.nix index 522bcb10222b..f1f160c1224c 100644 --- a/pkgs/development/compilers/ghc/common-hadrian.nix +++ b/pkgs/development/compilers/ghc/common-hadrian.nix @@ -29,6 +29,7 @@ , xattr , autoSignDarwinBinariesHook , bash +, srcOnly , libiconv ? null, ncurses , glibcLocales ? null @@ -145,18 +146,40 @@ return $ verbosity >= Verbose '' -, ghcSrc ? (if rev != null then fetchgit else fetchurl) ({ - inherit url sha256; - } // lib.optionalAttrs (rev != null) { - inherit rev; - } // lib.optionalAttrs (postFetch != null) { - inherit postFetch; - }) +, ghcSrc ? + srcOnly { + name = "ghc-${version}"; # -source appended by srcOnly + src = + (if rev != null then fetchgit else fetchurl) ({ + inherit url sha256; + } // lib.optionalAttrs (rev != null) { + inherit rev; + } // lib.optionalAttrs (postFetch != null) { + inherit postFetch; + }); + + patches = + [ + # Fix docs build with Sphinx >= 7 https://gitlab.haskell.org/ghc/ghc/-/issues/24129 + (if lib.versionAtLeast version "9.8" + then ./docs-sphinx-7-ghc98.patch + else ./docs-sphinx-7.patch ) + ] + ++ lib.optionals (stdenv.targetPlatform.isDarwin && stdenv.targetPlatform.isAarch64) [ + # Prevent the paths module from emitting symbols that we don't use + # when building with separate outputs. + # + # These cause problems as they're not eliminated by GHC's dead code + # elimination on aarch64-darwin. (see + # https://github.com/NixOS/nixpkgs/issues/140774 for details). + ./Cabal-at-least-3.6-paths-fix-cycle-aarch64-darwin.patch + ] + } # GHC's build system hadrian built from the GHC-to-build's source tree # using our bootstrap GHC. , hadrian ? import ../../tools/haskell/hadrian/make-hadrian.nix { inherit bootPkgs lib; } { - ghcSrc = ghcSrc; + inherit ghcSrc; ghcVersion = version; userSettings = hadrianUserSettings; # Disable haddock generating pretty source listings to stay under 3GB on aarch64-linux @@ -269,21 +292,6 @@ stdenv.mkDerivation ({ enableParallelBuilding = true; - patches = [ - # Fix docs build with Sphinx >= 7 https://gitlab.haskell.org/ghc/ghc/-/issues/24129 - (if lib.versionAtLeast version "9.8" - then ./docs-sphinx-7-ghc98.patch - else ./docs-sphinx-7.patch ) - ] ++ lib.optionals (stdenv.targetPlatform.isDarwin && stdenv.targetPlatform.isAarch64) [ - # Prevent the paths module from emitting symbols that we don't use - # when building with separate outputs. - # - # These cause problems as they're not eliminated by GHC's dead code - # elimination on aarch64-darwin. (see - # https://github.com/NixOS/nixpkgs/issues/140774 for details). - ./Cabal-at-least-3.6-paths-fix-cycle-aarch64-darwin.patch - ]; - postPatch = '' patchShebangs --build . '';