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.nix33
1 files changed, 18 insertions, 15 deletions
diff --git a/pkgs/development/compilers/ghc/8.10.7.nix b/pkgs/development/compilers/ghc/8.10.7.nix
index c8669a2761f82..a6694e2e99c9c 100644
--- a/pkgs/development/compilers/ghc/8.10.7.nix
+++ b/pkgs/development/compilers/ghc/8.10.7.nix
@@ -9,7 +9,11 @@
 , libiconv ? null, ncurses
 
 , # GHC can be built with system libffi or a bundled one.
+  # we explicitly use libffi-3.3 here because 3.4 removes a flag that causes
+  # problems for ghc-8.10.7's RTS. See #324384.
+  # Save for aarch_darwin since libffi-3.3 is broken there but the issue isn't present anyway
   libffi ? null
+, libffi_3_3 ? null
 
 , useLLVM ? !(stdenv.targetPlatform.isx86
               || stdenv.targetPlatform.isPower
@@ -56,7 +60,7 @@
 , # Whether to disable the large address space allocator
   # necessary fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/
   disableLargeAddressSpace ? stdenv.targetPlatform.isiOS
-}:
+}@args:
 
 assert !enableIntegerSimple -> gmp != null;
 
@@ -65,6 +69,7 @@ assert !enableIntegerSimple -> gmp != null;
 assert (stdenv.targetPlatform != stdenv.hostPlatform) -> !enableHaddockProgram;
 
 let
+  libffi_name = if stdenv.isDarwin && stdenv.isAarch64 then "libffi" else "libffi_3_3";
   inherit (stdenv) buildPlatform hostPlatform targetPlatform;
 
   inherit (bootPkgs) ghc;
@@ -119,7 +124,7 @@ let
 
   # Splicer will pull out correct variations
   libDeps = platform: lib.optional enableTerminfo ncurses
-    ++ [libffi]
+    ++ [args.${libffi_name}]
     ++ lib.optional (!enableIntegerSimple) gmp
     ++ lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv;
 
@@ -152,18 +157,16 @@ let
 
         otool = cc.bintools.bintools;
 
-        # GHC needs install_name_tool on all darwin platforms. On aarch64-darwin it is
-        # part of the bintools wrapper (due to codesigning requirements), but not on
-        # x86_64-darwin. We decide based on target platform to have consistent tools
-        # across all GHC stages.
-        install_name_tool =
-          if stdenv.targetPlatform.isAarch64
-          then cc.bintools
-          else cc.bintools.bintools;
-        # Same goes for strip.
+        # GHC needs install_name_tool on all darwin platforms. The same one can
+        # be used on both platforms. It is safe to use with linker-generated
+        # signatures because it will update the signatures automatically after
+        # modifying the target binary.
+        install_name_tool = cc.bintools.bintools;
+
+        # strip on darwin is wrapped to enable deterministic mode.
         strip =
           # TODO(@sternenseemann): also use wrapper if linker == "bfd" or "gold"
-          if stdenv.targetPlatform.isAarch64 && stdenv.targetPlatform.isDarwin
+          if stdenv.targetPlatform.isDarwin
           then cc.bintools
           else cc.bintools.bintools;
       }.${name};
@@ -334,10 +337,10 @@ stdenv.mkDerivation (rec {
   configureFlags = [
     "--datadir=$doc/share/doc/ghc"
     "--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib"
-  ] ++ lib.optionals (libffi != null) [
+  ] ++ lib.optionals (args.${libffi_name} != null) [
     "--with-system-libffi"
-    "--with-ffi-includes=${targetPackages.libffi.dev}/include"
-    "--with-ffi-libraries=${targetPackages.libffi.out}/lib"
+    "--with-ffi-includes=${targetPackages.${libffi_name}.dev}/include"
+    "--with-ffi-libraries=${targetPackages.${libffi_name}.out}/lib"
   ] ++ lib.optionals (targetPlatform == hostPlatform && !enableIntegerSimple) [
     "--with-gmp-includes=${targetPackages.gmp.dev}/include"
     "--with-gmp-libraries=${targetPackages.gmp.out}/lib"