about summary refs log tree commit diff
path: root/pkgs/development/compilers/ghc/8.10.7.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development/compilers/ghc/8.10.7.nix')
-rw-r--r--pkgs/development/compilers/ghc/8.10.7.nix31
1 files changed, 25 insertions, 6 deletions
diff --git a/pkgs/development/compilers/ghc/8.10.7.nix b/pkgs/development/compilers/ghc/8.10.7.nix
index 6b26f2fb8517..03e4facd0198 100644
--- a/pkgs/development/compilers/ghc/8.10.7.nix
+++ b/pkgs/development/compilers/ghc/8.10.7.nix
@@ -32,7 +32,9 @@
 , # If enabled, use -fPIC when compiling static libs.
   enableRelocatedStaticLibs ? stdenv.targetPlatform != stdenv.hostPlatform
 
-, enableProfiledLibs ? true
+  # Exceeds Hydra output limit (at the time of writing ~3GB) when cross compiled to riscv64.
+  # A riscv64 cross-compiler fits into the limit comfortably.
+, enableProfiledLibs ? !stdenv.hostPlatform.isRiscV64
 
 , # Whether to build dynamic libs for the standard library (on the target
   # platform). Static libs are always built.
@@ -202,7 +204,10 @@ let
     (lib.optionalString enableIntegerSimple "-integer-simple")
   ];
 
-  libffi_name = if stdenv.isDarwin && stdenv.isAarch64 then "libffi" else "libffi_3_3";
+  libffi_name =
+    if stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64
+    then "libffi"
+    else "libffi_3_3";
 
   # These libraries are library dependencies of the standard libraries bundled
   # by GHC (core libs) users will link their compiled artifacts again. Thus,
@@ -293,7 +298,21 @@ stdenv.mkDerivation (rec {
       url = "https://gitlab.haskell.org/ghc/ghc/-/commit/8f7dd5710b80906ea7a3e15b7bb56a883a49fed8.patch";
       hash = "sha256-C636Nq2U8YOG/av7XQmG3L1rU0bmC9/7m7Hty5pm5+s=";
     })
-  ] ++ lib.optionals stdenv.isDarwin [
+
+    # Backport part of <https://gitlab.haskell.org/ghc/ghc/-/merge_requests/7111> to 8.10.7
+    # The change we are interested in is that Cabal no longer sets include-dirs
+    # for the GHCi library delegating to the system search path or (in our case)
+    # cc-wrapper. Without this patch, the target libffi ends up in there (which
+    # we provide via --with-ffi-includes) which breaks bootstrapping e.g. when
+    # cross compiling GHC. Without include-dirs, cc-wrapper and splicing will
+    # correctly pick the suitable libffi out of the build environment.
+    (fetchpatch {
+      name = "ghci-no-libffi-include.patch";
+      url = "https://gitlab.haskell.org/ghc/ghc/-/commit/b2721819f391ab49871271283f32df54810c4387.patch";
+      sha256 = "1rmv3132xhxbka97v0rx7r6larx5f5nnvs4mgm9q3rmgpjyd1vf9";
+      includes = [ "libraries/ghci/ghci.cabal.in" ];
+    })
+  ] ++ lib.optionals stdenv.hostPlatform.isDarwin [
     # Make Block.h compile with c++ compilers. Remove with the next release
     (fetchpatch {
       url = "https://gitlab.haskell.org/ghc/ghc/-/commit/97d0b0a367e4c6a52a17c3299439ac7de129da24.patch";
@@ -359,9 +378,9 @@ stdenv.mkDerivation (rec {
 
     echo -n "${buildMK}" > mk/build.mk
     sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure
-  '' + lib.optionalString (!stdenv.isDarwin) ''
+  '' + lib.optionalString (!stdenv.hostPlatform.isDarwin) ''
     export NIX_LDFLAGS+=" -rpath $out/lib/ghc-${version}"
-  '' + lib.optionalString stdenv.isDarwin ''
+  '' + lib.optionalString stdenv.hostPlatform.isDarwin ''
     export NIX_LDFLAGS+=" -no_dtrace_dof"
 
     # GHC tries the host xattr /usr/bin/xattr by default which fails since it expects python to be 2.7
@@ -431,7 +450,7 @@ stdenv.mkDerivation (rec {
     perl autoreconfHook autoconf automake m4 python3
     bootPkgs.alex bootPkgs.happy bootPkgs.hscolour
     bootPkgs.ghc-settings-edit
-  ] ++ lib.optionals (stdenv.isDarwin && stdenv.isAarch64) [
+  ] ++ lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) [
     autoSignDarwinBinariesHook
   ] ++ lib.optionals enableDocs [
     sphinx