about summary refs log tree commit diff
path: root/pkgs/development/compilers/ghc
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2018-05-14 23:33:03 -0400
committerJohn Ericson <John.Ericson@Obsidian.Systems>2018-05-14 23:33:03 -0400
commit5e17335bd7ff853379122e08dadfaa2fc1c020b7 (patch)
tree911e75d700bebef1aa60fedcaa6a29b5032d6428 /pkgs/development/compilers/ghc
parent330ca731e88ec015181c43d92ae8f7c77cf0226a (diff)
parent0fc21a364bfd6b2dea9010fdf21415ff3de1805a (diff)
downloadnixlib-5e17335bd7ff853379122e08dadfaa2fc1c020b7.tar
nixlib-5e17335bd7ff853379122e08dadfaa2fc1c020b7.tar.gz
nixlib-5e17335bd7ff853379122e08dadfaa2fc1c020b7.tar.bz2
nixlib-5e17335bd7ff853379122e08dadfaa2fc1c020b7.tar.lz
nixlib-5e17335bd7ff853379122e08dadfaa2fc1c020b7.tar.xz
nixlib-5e17335bd7ff853379122e08dadfaa2fc1c020b7.tar.zst
nixlib-5e17335bd7ff853379122e08dadfaa2fc1c020b7.zip
Merge remote-tracking branch 'upstream/staging' into strictDeps
Diffstat (limited to 'pkgs/development/compilers/ghc')
-rw-r--r--pkgs/development/compilers/ghc/7.0.4-binary.nix146
-rw-r--r--pkgs/development/compilers/ghc/7.0.4.nix67
-rw-r--r--pkgs/development/compilers/ghc/7.4.2-binary.nix148
-rw-r--r--pkgs/development/compilers/ghc/7.4.2.nix77
-rw-r--r--pkgs/development/compilers/ghc/7.6.3.nix103
-rw-r--r--pkgs/development/compilers/ghc/7.8.4-binary.nix156
-rw-r--r--pkgs/development/compilers/ghc/7.8.4.nix91
-rw-r--r--pkgs/development/compilers/ghc/8.2.1-binary.nix3
-rw-r--r--pkgs/development/compilers/ghc/8.2.2.nix3
-rw-r--r--pkgs/development/compilers/ghc/8.4.2.nix (renamed from pkgs/development/compilers/ghc/8.4.1.nix)40
-rw-r--r--pkgs/development/compilers/ghc/abi-depends-determinism.nix12
-rw-r--r--pkgs/development/compilers/ghc/fix-7.0.4-clang.patch74
-rw-r--r--pkgs/development/compilers/ghc/fix-7.2.2-clang.patch74
-rw-r--r--pkgs/development/compilers/ghc/fix-7.4.2-clang.patch57
-rw-r--r--pkgs/development/compilers/ghc/fix-7.6.3-clang.patch71
-rw-r--r--pkgs/development/compilers/ghc/head.nix4
-rw-r--r--pkgs/development/compilers/ghc/hpc-7.8.4.patch13
17 files changed, 37 insertions, 1102 deletions
diff --git a/pkgs/development/compilers/ghc/7.0.4-binary.nix b/pkgs/development/compilers/ghc/7.0.4-binary.nix
deleted file mode 100644
index 8758ee59d384..000000000000
--- a/pkgs/development/compilers/ghc/7.0.4-binary.nix
+++ /dev/null
@@ -1,146 +0,0 @@
-{ stdenv
-, fetchurl, perl
-, ncurses5, gmp, libiconv
-}:
-
-# Prebuilt only does native
-assert stdenv.targetPlatform == stdenv.hostPlatform;
-
-let
-  libPath = stdenv.lib.makeLibraryPath ([
-    ncurses5 gmp
-  ] ++ stdenv.lib.optional (stdenv.hostPlatform.isDarwin) libiconv);
-
-  libEnvVar = stdenv.lib.optionalString stdenv.hostPlatform.isDarwin "DY"
-    + "LD_LIBRARY_PATH";
-
-in
-
-stdenv.mkDerivation rec {
-  version = "7.0.4";
-
-  name = "ghc-${version}-binary";
-
-  src = fetchurl ({
-    "i686-linux" = {
-      url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-i386-unknown-linux.tar.bz2";
-      sha256 = "0mfnihiyjl06f5w1yrjp36sw9g67g2ymg5sdl0g23h1pab99jx63";
-    };
-    "x86_64-linux" = {
-      url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-x86_64-unknown-linux.tar.bz2";
-      sha256 = "0mc4rhqcxz427wq4zgffmnn0d2yjqvy6af4x9mha283p1gdj5q99";
-    };
-    "i686-darwin" = {
-      url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-i386-apple-darwin.tar.bz2";
-      sha256 = "0qj45hslrrr8zfks8m1jcb3awwx9rh35ndnpfmb0gwb6j7azq5n3";
-    };
-    "x86_64-darwin" = {
-      url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-x86_64-apple-darwin.tar.bz2";
-      sha256 = "1m2ml88p1swf4dnv2vq8hz4drcp46n3ahpfi05wh01ajkf8hnn3l";
-    };
-  }.${stdenv.hostPlatform.system}
-    or (throw "cannot bootstrap GHC on this platform"));
-
-  nativeBuildInputs = [ perl ];
-
-  # Cannot patchelf beforehand due to relative RPATHs that anticipate
-  # the final install location/
-  ${libEnvVar} = libPath;
-
-  postUnpack =
-    # GHC has dtrace probes, which causes ld to try to open /usr/lib/libdtrace.dylib
-    # during linking
-    stdenv.lib.optionalString stdenv.isDarwin ''
-      export NIX_LDFLAGS+=" -no_dtrace_dof"
-    '' +
-
-    # Strip is harmful, see also below. It's important that this happens
-    # first. The GHC Cabal build system makes use of strip by default and
-    # has hardcoded paths to /usr/bin/strip in many places. We replace
-    # those below, making them point to our dummy script.
-    ''
-      mkdir "$TMP/bin"
-      for i in strip; do
-        echo '#! ${stdenv.shell}' > "$TMP/bin/$i"
-        chmod +x "$TMP/bin/$i"
-      done
-      PATH="$TMP/bin:$PATH"
-    '' +
-    # We have to patch the GMP paths for the integer-gmp package.
-    ''
-      find . -name integer-gmp.buildinfo \
-          -exec sed -i "s@extra-lib-dirs: @extra-lib-dirs: ${gmp.out}/lib@" {} \;
-    '' + stdenv.lib.optionalString stdenv.isDarwin ''
-      find . -name base.buildinfo \
-          -exec sed -i "s@extra-lib-dirs: @extra-lib-dirs: ${libiconv}/lib@" {} \;
-    '' +
-    # Rename needed libraries and binaries, fix interpreter
-    stdenv.lib.optionalString stdenv.isLinux ''
-      find . -type f -perm -0100 -exec patchelf \
-          --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" {} \;
-
-      paxmark m ./ghc-${version}/ghc/stage2/build/tmp/ghc-stage2
-
-      sed -i "s|/usr/bin/perl|perl\x00        |" ghc-${version}/ghc/stage2/build/tmp/ghc-stage2
-      sed -i "s|/usr/bin/gcc|gcc\x00        |" ghc-${version}/ghc/stage2/build/tmp/ghc-stage2
-      for prog in ld ar gcc strip ranlib; do
-        find . -name "setup-config" -exec sed -i "s@/usr/bin/$prog@$(type -p $prog)@g" {} \;
-      done
-    '';
-
-  configurePlatforms = [ ];
-  configureFlags = [
-    "--with-gmp-libraries=${stdenv.lib.getLib gmp}/lib"
-    "--with-gmp-includes=${stdenv.lib.getDev gmp}/include"
-  ] ++ stdenv.lib.optional stdenv.isDarwin "--with-gcc=${./gcc-clang-wrapper.sh}";
-
-  # Stripping combined with patchelf breaks the executables (they die
-  # with a segfault or the kernel even refuses the execve). (NIXPKGS-85)
-  dontStrip = true;
-
-  # No building is necessary, but calling make without flags ironically
-  # calls install-strip ...
-  dontBuild = true;
-
-  # On Linux, use patchelf to modify the executables so that they can
-  # find editline/gmp.
-  preFixup = stdenv.lib.optionalString stdenv.isLinux ''
-    find "$out" -type f -executable \
-        -exec patchelf --set-rpath "${libPath}" {} \;
-  '' + stdenv.lib.optionalString stdenv.isDarwin ''
-    # not enough room in the object files for the full path to libiconv :(
-    for exe in $(find "$out" -type f -executable); do
-      isScript $exe && continue
-      ln -fs ${libiconv}/lib/libiconv.dylib $(dirname $exe)/libiconv.dylib
-      install_name_tool -change /usr/lib/libiconv.2.dylib @executable_path/libiconv.dylib $exe
-    done
-
-    for file in $(find "$out" -name setup-config); do
-      substituteInPlace $file --replace /usr/bin/ranlib "$(type -P ranlib)"
-    done
-  '';
-
-  doInstallCheck = true;
-  installCheckPhase = ''
-    # Sanity check, can ghc create executables?
-    cd $TMP
-    mkdir test-ghc; cd test-ghc
-    cat > main.hs << EOF
-      module Main where
-      main = putStrLn "yes"
-    EOF
-    $out/bin/ghc --make main.hs
-    echo compilation ok
-    [ $(./main) == "yes" ]
-  '';
-
-  passthru = {
-    targetPrefix = "";
-
-    # Our Cabal compiler name
-    haskellCompilerName = "ghc-7.0.4";
-  };
-
-  meta.license = stdenv.lib.licenses.bsd3;
-  meta.platforms = ["x86_64-linux" "i686-linux" "x86_64-darwin"];
-}
diff --git a/pkgs/development/compilers/ghc/7.0.4.nix b/pkgs/development/compilers/ghc/7.0.4.nix
deleted file mode 100644
index 5bd05b257ca5..000000000000
--- a/pkgs/development/compilers/ghc/7.0.4.nix
+++ /dev/null
@@ -1,67 +0,0 @@
-{ stdenv, fetchurl, ghc, perl, gmp, ncurses, libiconv }:
-
-# TODO(@Ericson2314): Cross compilation support
-assert stdenv.targetPlatform == stdenv.hostPlatform;
-
-stdenv.mkDerivation rec {
-  version = "7.0.4";
-  name = "ghc-${version}";
-
-  src = fetchurl {
-    url = "https://downloads.haskell.org/~ghc/${version}/ghc-${version}-src.tar.bz2";
-    sha256 = "1a9b78d9d66c9c21de6c0932e36bb87406a4856f1611bf83bd44539bdc6ed0ed";
-  };
-
-  patches = [ ./fix-7.0.4-clang.patch ./relocation.patch ];
-
-  buildInputs = [ ghc perl gmp ncurses ];
-
-  buildMK = ''
-    libraries/integer-gmp_CONFIGURE_OPTS += --configure-option=--with-gmp-libraries="${gmp.out}/lib"
-    libraries/integer-gmp_CONFIGURE_OPTS += --configure-option=--with-gmp-includes="${gmp.dev}/include"
-    libraries/terminfo_CONFIGURE_OPTS += --configure-option=--with-curses-includes="${ncurses.dev}/include"
-    libraries/terminfo_CONFIGURE_OPTS += --configure-option=--with-curses-libraries="${ncurses.out}/lib"
-    ${stdenv.lib.optionalString stdenv.isDarwin ''
-      libraries/base_CONFIGURE_OPTS += --configure-option=--with-iconv-includes="${libiconv}/include"
-      libraries/base_CONFIGURE_OPTS += --configure-option=--with-iconv-libraries="${libiconv}/lib"
-    ''}
-  '';
-
-  preConfigure = ''
-    echo -n "${buildMK}" > mk/build.mk
-    sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure
-  '' + stdenv.lib.optionalString stdenv.isDarwin ''
-    find . -name '*.hs'  | xargs sed -i -e 's|ASSERT (|ASSERT(|' -e 's|ASSERT2 (|ASSERT2(|' -e 's|WARN (|WARN(|'
-    find . -name '*.lhs' | xargs sed -i -e 's|ASSERT (|ASSERT(|' -e 's|ASSERT2 (|ASSERT2(|' -e 's|WARN (|WARN(|'
-    export NIX_LDFLAGS+=" -no_dtrace_dof"
-  '';
-
-  configureFlags = if stdenv.isDarwin then "--with-gcc=${./gcc-clang-wrapper.sh}"
-                                      else "--with-gcc=${stdenv.cc}/bin/gcc";
-
-  NIX_CFLAGS_COMPILE = "-fomit-frame-pointer";
-
-  # required, because otherwise all symbols from HSffi.o are stripped, and
-  # that in turn causes GHCi to abort
-  stripDebugFlags=["-S" "--keep-file-symbols"];
-
-  passthru = {
-    targetPrefix = "";
-
-    # Our Cabal compiler name
-    haskellCompilerName = "ghc-7.0.4";
-  };
-
-  meta = {
-    homepage = http://haskell.org/ghc;
-    description = "The Glasgow Haskell Compiler";
-    maintainers = [
-      stdenv.lib.maintainers.marcweber
-      stdenv.lib.maintainers.andres
-      stdenv.lib.maintainers.peti
-    ];
-    platforms = ["x86_64-linux" "i686-linux"];  # Darwin is not supported.
-    inherit (ghc.meta) license;
-  };
-
-}
diff --git a/pkgs/development/compilers/ghc/7.4.2-binary.nix b/pkgs/development/compilers/ghc/7.4.2-binary.nix
deleted file mode 100644
index 988392e74b9e..000000000000
--- a/pkgs/development/compilers/ghc/7.4.2-binary.nix
+++ /dev/null
@@ -1,148 +0,0 @@
-{ stdenv
-, fetchurl, perl
-, ncurses5, gmp, libiconv
-}:
-
-# Prebuilt only does native
-assert stdenv.targetPlatform == stdenv.hostPlatform;
-
-let
-  libPath = stdenv.lib.makeLibraryPath ([
-    ncurses5 gmp
-  ] ++ stdenv.lib.optional (stdenv.hostPlatform.isDarwin) libiconv);
-
-  libEnvVar = stdenv.lib.optionalString stdenv.hostPlatform.isDarwin "DY"
-    + "LD_LIBRARY_PATH";
-
-in
-
-stdenv.mkDerivation rec {
-  version = "7.4.2";
-
-  name = "ghc-${version}-binary";
-
-  src = fetchurl ({
-    "i686-linux" = {
-      url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-i386-unknown-linux.tar.bz2";
-      sha256 = "0gny7knhss0w0d9r6jm1gghrcb8kqjvj94bb7hxf9syrk4fxlcxi";
-    };
-    "x86_64-linux" = {
-      url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-x86_64-unknown-linux.tar.bz2";
-      sha256 = "043jabd0lh6n1zlqhysngbpvlsdznsa2mmsj08jyqgahw9sjb5ns";
-    };
-    "i686-darwin" = {
-      url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-i386-apple-darwin.tar.bz2";
-      sha256 = "1vrbs3pzki37hzym1f1nh07lrqh066z3ypvm81fwlikfsvk4djc0";
-    };
-    "x86_64-darwin" = {
-      url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-x86_64-apple-darwin.tar.bz2";
-      sha256 = "1imzqc0slpg0r6p40n5a9m18cbcm0m86z8dgyhfxcckksw54mzwf";
-    };
-  }.${stdenv.hostPlatform.system}
-    or (throw "cannot bootstrap GHC on this platform"));
-
-  nativeBuildInputs = [ perl ];
-
-  # Cannot patchelf beforehand due to relative RPATHs that anticipate
-  # the final install location/
-  ${libEnvVar} = libPath;
-
-  postUnpack =
-    # GHC has dtrace probes, which causes ld to try to open /usr/lib/libdtrace.dylib
-    # during linking
-    stdenv.lib.optionalString stdenv.isDarwin ''
-      export NIX_LDFLAGS+=" -no_dtrace_dof"
-    '' +
-
-    # Strip is harmful, see also below. It's important that this happens
-    # first. The GHC Cabal build system makes use of strip by default and
-    # has hardcoded paths to /usr/bin/strip in many places. We replace
-    # those below, making them point to our dummy script.
-    ''
-      mkdir "$TMP/bin"
-      for i in strip; do
-        echo '#! ${stdenv.shell}' > "$TMP/bin/$i"
-        chmod +x "$TMP/bin/$i"
-      done
-      PATH="$TMP/bin:$PATH"
-    '' +
-    # We have to patch the GMP paths for the integer-gmp package.
-    ''
-      find . -name integer-gmp.buildinfo \
-          -exec sed -i "s@extra-lib-dirs: @extra-lib-dirs: ${gmp.out}/lib@" {} \;
-    '' + stdenv.lib.optionalString stdenv.isDarwin ''
-      find . -name base.buildinfo \
-          -exec sed -i "s@extra-lib-dirs: @extra-lib-dirs: ${libiconv}/lib@" {} \;
-    '' +
-    # Rename needed libraries and binaries, fix interpreter
-    stdenv.lib.optionalString stdenv.isLinux ''
-      find . -type f -perm -0100 -exec patchelf \
-          --replace-needed libncurses${stdenv.lib.optionalString stdenv.is64bit "w"}.so.5 libncurses.so \
-          --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" {} \;
-
-      paxmark m ./ghc-${version}/ghc/stage2/build/tmp/ghc-stage2
-
-      sed -i "s|/usr/bin/perl|perl\x00        |" ghc-${version}/ghc/stage2/build/tmp/ghc-stage2
-      sed -i "s|/usr/bin/gcc|gcc\x00        |" ghc-${version}/ghc/stage2/build/tmp/ghc-stage2
-      for prog in ld ar gcc strip ranlib; do
-        find . -name "setup-config" -exec sed -i "s@/usr/bin/$prog@$(type -p $prog)@g" {} \;
-      done
-    '';
-
-  configurePlatforms = [ ];
-  configureFlags = [
-    "--with-gmp-libraries=${stdenv.lib.getLib gmp}/lib"
-    "--with-gmp-includes=${stdenv.lib.getDev gmp}/include"
-  ] ++ stdenv.lib.optional stdenv.isDarwin "--with-gcc=${./gcc-clang-wrapper.sh}";
-
-  # Stripping combined with patchelf breaks the executables (they die
-  # with a segfault or the kernel even refuses the execve). (NIXPKGS-85)
-  dontStrip = true;
-
-  # No building is necessary, but calling make without flags ironically
-  # calls install-strip ...
-  dontBuild = true;
-
-  # On Linux, use patchelf to modify the executables so that they can
-  # find editline/gmp.
-  preFixup = stdenv.lib.optionalString stdenv.isLinux ''
-    find "$out" -type f -executable \
-        -exec patchelf --set-rpath "${libPath}" {} \;
-  '' + stdenv.lib.optionalString stdenv.isDarwin ''
-    # not enough room in the object files for the full path to libiconv :(
-    for exe in $(find "$out" -type f -executable); do
-      isScript $exe && continue
-      ln -fs ${libiconv}/lib/libiconv.dylib $(dirname $exe)/libiconv.dylib
-      install_name_tool -change /usr/lib/libiconv.2.dylib @executable_path/libiconv.dylib $exe
-    done
-
-    for file in $(find "$out" -name setup-config); do
-      substituteInPlace $file --replace /usr/bin/ranlib "$(type -P ranlib)"
-    done
-  '';
-
-  doInstallCheck = true;
-  installCheckPhase = ''
-    # Sanity check, can ghc create executables?
-    cd $TMP
-    mkdir test-ghc; cd test-ghc
-    cat > main.hs << EOF
-      {-# LANGUAGE TemplateHaskell #-}
-      module Main where
-      main = putStrLn \$([|"yes"|])
-    EOF
-    $out/bin/ghc --make main.hs || exit 1
-    echo compilation ok
-    [ $(./main) == "yes" ]
-  '';
-
-  passthru = {
-    targetPrefix = "";
-
-    # Our Cabal compiler name
-    haskellCompilerName = "ghc-7.4.2";
-  };
-
-  meta.license = stdenv.lib.licenses.bsd3;
-  meta.platforms = ["x86_64-linux" "i686-linux" "x86_64-darwin"];
-}
diff --git a/pkgs/development/compilers/ghc/7.4.2.nix b/pkgs/development/compilers/ghc/7.4.2.nix
deleted file mode 100644
index 86925c406cfc..000000000000
--- a/pkgs/development/compilers/ghc/7.4.2.nix
+++ /dev/null
@@ -1,77 +0,0 @@
-{ stdenv, fetchurl, ghc, perl, ncurses, libiconv
-
-, # If enabled, GHC will be built with the GPL-free but slower integer-simple
-  # library instead of the faster but GPLed integer-gmp library.
-  enableIntegerSimple ? false, gmp ? null
-}:
-
-# TODO(@Ericson2314): Cross compilation support
-assert stdenv.targetPlatform == stdenv.hostPlatform;
-assert !enableIntegerSimple -> gmp != null;
-
-stdenv.mkDerivation rec {
-  version = "7.4.2";
-
-  name = "ghc-${version}";
-
-  src = fetchurl {
-    url = "https://downloads.haskell.org/~ghc/${version}/ghc-${version}-src.tar.bz2";
-    sha256 = "0vc3zmxqi4gflssmj35n5c8idbvyrhd88abi50whbirwlf4i5vpj";
-  };
-
-  patches = [ ./fix-7.4.2-clang.patch ./relocation.patch ];
-
-  buildInputs = [ ghc perl ncurses ]
-                ++ stdenv.lib.optional (!enableIntegerSimple) gmp;
-
-  buildMK = ''
-    libraries/terminfo_CONFIGURE_OPTS += --configure-option=--with-curses-includes="${ncurses.dev}/include"
-    libraries/terminfo_CONFIGURE_OPTS += --configure-option=--with-curses-libraries="${ncurses.out}/lib"
-    ${stdenv.lib.optionalString stdenv.isDarwin ''
-      libraries/base_CONFIGURE_OPTS += --configure-option=--with-iconv-includes="${libiconv}/include"
-      libraries/base_CONFIGURE_OPTS += --configure-option=--with-iconv-libraries="${libiconv}/lib"
-    ''}
-  '' + (if enableIntegerSimple then ''
-    INTEGER_LIBRARY = integer-simple
-  '' else ''
-    libraries/integer-gmp_CONFIGURE_OPTS += --configure-option=--with-gmp-libraries="${gmp.out}/lib"
-    libraries/integer-gmp_CONFIGURE_OPTS += --configure-option=--with-gmp-includes="${gmp.dev}/include"
-  '');
-
-  preConfigure = ''
-    echo -n "${buildMK}" > mk/build.mk
-    sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure
-  '' + stdenv.lib.optionalString (!stdenv.isDarwin) ''
-    export NIX_LDFLAGS+=" -rpath $out/lib/ghc-${version}"
-  '' + stdenv.lib.optionalString stdenv.isDarwin ''
-    find . -name '*.hs'  | xargs sed -i -e 's|ASSERT (|ASSERT(|' -e 's|ASSERT2 (|ASSERT2(|' -e 's|WARN (|WARN(|'
-    find . -name '*.lhs' | xargs sed -i -e 's|ASSERT (|ASSERT(|' -e 's|ASSERT2 (|ASSERT2(|' -e 's|WARN (|WARN(|'
-    export NIX_LDFLAGS+=" -no_dtrace_dof"
-  '';
-
-  configureFlags = if stdenv.isDarwin then "--with-gcc=${./gcc-clang-wrapper.sh}"
-                                      else "--with-gcc=${stdenv.cc}/bin/gcc";
-
-  # required, because otherwise all symbols from HSffi.o are stripped, and
-  # that in turn causes GHCi to abort
-  stripDebugFlags = [ "-S" ] ++ stdenv.lib.optional (!stdenv.isDarwin) "--keep-file-symbols";
-
-  passthru = {
-    targetPrefix = "";
-
-    # Our Cabal compiler name
-    haskellCompilerName = "ghc-7.4.2";
-  };
-
-  meta = {
-    homepage = http://haskell.org/ghc;
-    description = "The Glasgow Haskell Compiler";
-    maintainers = [
-      stdenv.lib.maintainers.marcweber
-      stdenv.lib.maintainers.andres
-      stdenv.lib.maintainers.peti
-    ];
-    inherit (ghc.meta) license platforms;
-  };
-
-}
diff --git a/pkgs/development/compilers/ghc/7.6.3.nix b/pkgs/development/compilers/ghc/7.6.3.nix
deleted file mode 100644
index 982008563a06..000000000000
--- a/pkgs/development/compilers/ghc/7.6.3.nix
+++ /dev/null
@@ -1,103 +0,0 @@
-{ stdenv, fetchurl, ghc, perl, ncurses, libiconv
-
-, # If enabled, GHC will be built with the GPL-free but slower integer-simple
-  # library instead of the faster but GPLed integer-gmp library.
-  enableIntegerSimple ? false, gmp ? null
-}:
-
-# TODO(@Ericson2314): Cross compilation support
-assert stdenv.targetPlatform == stdenv.hostPlatform;
-assert !enableIntegerSimple -> gmp != null;
-
-let
-  # The "-Wa,--noexecstack" options might be needed only with GNU ld (as opposed
-  # to the gold linker). It prevents binaries' stacks from being marked as
-  # executable, which fails to run on a grsecurity/PaX kernel.
-  ghcFlags = "-optc-Wa,--noexecstack -opta-Wa,--noexecstack";
-  cFlags = "-Wa,--noexecstack";
-
-in stdenv.mkDerivation rec {
-  version = "7.6.3";
-
-  name = "ghc-${version}";
-
-  src = fetchurl {
-    url = "https://downloads.haskell.org/~ghc/${version}/ghc-${version}-src.tar.bz2";
-    sha256 = "1669m8k9q72rpd2mzs0bh2q6lcwqiwd1ax3vrard1dgn64yq4hxx";
-  };
-
-  patches = [ ./fix-7.6.3-clang.patch ./relocation.patch ];
-
-  buildInputs = [ ghc perl ncurses ]
-                ++ stdenv.lib.optional (!enableIntegerSimple) gmp;
-
-  buildMK = ''
-    libraries/terminfo_CONFIGURE_OPTS += --configure-option=--with-curses-includes="${ncurses.dev}/include"
-    libraries/terminfo_CONFIGURE_OPTS += --configure-option=--with-curses-libraries="${ncurses.out}/lib"
-    ${stdenv.lib.optionalString stdenv.isDarwin ''
-      libraries/base_CONFIGURE_OPTS += --configure-option=--with-iconv-includes="${libiconv}/include"
-      libraries/base_CONFIGURE_OPTS += --configure-option=--with-iconv-libraries="${libiconv}/lib"
-    ''}
-  '' + stdenv.lib.optionalString stdenv.isLinux ''
-    # Set ghcFlags for building ghc itself
-    SRC_HC_OPTS += ${ghcFlags}
-    SRC_CC_OPTS += ${cFlags}
-  '' + (if enableIntegerSimple then ''
-    INTEGER_LIBRARY = integer-simple
-  '' else ''
-    libraries/integer-gmp_CONFIGURE_OPTS += --configure-option=--with-gmp-libraries="${gmp.out}/lib"
-    libraries/integer-gmp_CONFIGURE_OPTS += --configure-option=--with-gmp-includes="${gmp.dev}/include"
-  '');
-
-  preConfigure = ''
-    echo -n "${buildMK}" > mk/build.mk
-    sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure
-
-  '' + stdenv.lib.optionalString stdenv.isLinux ''
-    # Set ghcFlags for binaries that ghc builds
-    sed -i -e 's|"\$topdir"|"\$topdir" ${ghcFlags}|' ghc/ghc.wrapper
-
-  '' + stdenv.lib.optionalString (!stdenv.isDarwin) ''
-    export NIX_LDFLAGS+=" -rpath $out/lib/ghc-${version}"
-  '' + stdenv.lib.optionalString stdenv.isDarwin ''
-    find . -name '*.hs'  | xargs sed -i -e 's|ASSERT (|ASSERT(|' -e 's|ASSERT2 (|ASSERT2(|' -e 's|WARN (|WARN(|'
-    find . -name '*.lhs' | xargs sed -i -e 's|ASSERT (|ASSERT(|' -e 's|ASSERT2 (|ASSERT2(|' -e 's|WARN (|WARN(|'
-    export NIX_LDFLAGS+=" -no_dtrace_dof"
-  '';
-
-  configureFlags = if stdenv.isDarwin then "--with-gcc=${./gcc-clang-wrapper.sh}"
-                                      else "--with-gcc=${stdenv.cc}/bin/gcc";
-
-  postInstall = ''
-    # ghci uses mmap with rwx protection at it implements dynamic
-    # linking on its own. See:
-    # - https://bugs.gentoo.org/show_bug.cgi?id=299709
-    # - https://ghc.haskell.org/trac/ghc/ticket/4244
-    # Therefore, we have to pax-mark the resulting binary.
-    # Haddock also seems to run with ghci, so mark it as well.
-    paxmark m $out/lib/${name}/{ghc,haddock}
-  '';
-
-  # required, because otherwise all symbols from HSffi.o are stripped, and
-  # that in turn causes GHCi to abort
-  stripDebugFlags = [ "-S" ] ++ stdenv.lib.optional (!stdenv.isDarwin) "--keep-file-symbols";
-
-  passthru = {
-    targetPrefix = "";
-
-    # Our Cabal compiler name
-    haskellCompilerName = "ghc-7.6.3";
-  };
-
-  meta = {
-    homepage = http://haskell.org/ghc;
-    description = "The Glasgow Haskell Compiler";
-    maintainers = [
-      stdenv.lib.maintainers.marcweber
-      stdenv.lib.maintainers.andres
-      stdenv.lib.maintainers.peti
-    ];
-    inherit (ghc.meta) license platforms;
-  };
-
-}
diff --git a/pkgs/development/compilers/ghc/7.8.4-binary.nix b/pkgs/development/compilers/ghc/7.8.4-binary.nix
deleted file mode 100644
index 58a9370b3213..000000000000
--- a/pkgs/development/compilers/ghc/7.8.4-binary.nix
+++ /dev/null
@@ -1,156 +0,0 @@
-{ stdenv
-, fetchurl, perl
-, ncurses5, gmp, libiconv
-}:
-
-# Prebuilt only does native
-assert stdenv.targetPlatform == stdenv.hostPlatform;
-
-let
-  libPath = stdenv.lib.makeLibraryPath ([
-    ncurses5 gmp
-  ] ++ stdenv.lib.optional (stdenv.hostPlatform.isDarwin) libiconv);
-
-  libEnvVar = stdenv.lib.optionalString stdenv.hostPlatform.isDarwin "DY"
-    + "LD_LIBRARY_PATH";
-
-in
-
-stdenv.mkDerivation rec {
-  version = "7.8.4";
-
-  name = "ghc-${version}-binary";
-
-  src = fetchurl ({
-    "i686-linux" = {
-      url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-i386-unknown-linux-deb7.tar.bz2";
-      sha256 = "5da2cf45986f33319a92a666f1f0149915334a7b64b41892ab94f4557242b406";
-    };
-    "x86_64-linux" = {
-      url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-x86_64-unknown-linux-deb7.tar.bz2";
-      sha256 = "20b5731d268613bbf6e977dbb192a3a3b7b78d954c35edbfca4fb36b652e24f7";
-    };
-    "x86_64-darwin" = {
-      url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-x86_64-apple-darwin.tar.bz2";
-      sha256 = "dfa161c2a136ee16214a49d5902e2377407c8292dbbdbb14fa0fa6b17220cae6";
-    };
-  }.${stdenv.hostPlatform.system}
-    or (throw "cannot bootstrap GHC on this platform"));
-
-  nativeBuildInputs = [ perl ];
-
-  # Cannot patchelf beforehand due to relative RPATHs that anticipate
-  # the final install location/
-  ${libEnvVar} = libPath;
-
-  postUnpack =
-    # GHC has dtrace probes, which causes ld to try to open /usr/lib/libdtrace.dylib
-    # during linking
-    stdenv.lib.optionalString stdenv.isDarwin ''
-      export NIX_LDFLAGS+=" -no_dtrace_dof"
-      # not enough room in the object files for the full path to libiconv :(
-      for exe in $(find . -type f -executable); do
-        isScript $exe && continue
-        ln -fs ${libiconv}/lib/libiconv.dylib $(dirname $exe)/libiconv.dylib
-        install_name_tool -change /usr/lib/libiconv.2.dylib @executable_path/libiconv.dylib $exe
-        for file in $(find . -name setup-config); do
-          substituteInPlace $file --replace /usr/bin/ranlib "$(type -P ranlib)"
-        done
-      done
-    '' +
-
-    # Some scripts used during the build need to have their shebangs patched
-    ''
-      patchShebangs ghc-${version}/utils/
-    '' +
-
-    # Strip is harmful, see also below. It's important that this happens
-    # first. The GHC Cabal build system makes use of strip by default and
-    # has hardcoded paths to /usr/bin/strip in many places. We replace
-    # those below, making them point to our dummy script.
-    ''
-      mkdir "$TMP/bin"
-      for i in strip; do
-        echo '#! ${stdenv.shell}' > "$TMP/bin/$i"
-        chmod +x "$TMP/bin/$i"
-      done
-      PATH="$TMP/bin:$PATH"
-    '' +
-    # We have to patch the GMP paths for the integer-gmp package.
-    ''
-      find . -name integer-gmp.buildinfo \
-          -exec sed -i "s@extra-lib-dirs: @extra-lib-dirs: ${gmp.out}/lib@" {} \;
-    '' + stdenv.lib.optionalString stdenv.isDarwin ''
-      find . -name base.buildinfo \
-          -exec sed -i "s@extra-lib-dirs: @extra-lib-dirs: ${libiconv}/lib@" {} \;
-    '' +
-    # Rename needed libraries and binaries, fix interpreter
-    stdenv.lib.optionalString stdenv.isLinux ''
-      find . -type f -perm -0100 -exec patchelf \
-          --replace-needed libncurses${stdenv.lib.optionalString stdenv.is64bit "w"}.so.5 libncurses.so \
-          --replace-needed libtinfo.so libtinfo.so.5 \
-          --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" {} \;
-
-      paxmark m ./ghc-${version}/ghc/stage2/build/tmp/ghc-stage2
-
-      sed -i "s|/usr/bin/perl|perl\x00        |" ghc-${version}/ghc/stage2/build/tmp/ghc-stage2
-      sed -i "s|/usr/bin/gcc|gcc\x00        |" ghc-${version}/ghc/stage2/build/tmp/ghc-stage2
-    '';
-
-  configurePlatforms = [ ];
-  configureFlags = [
-    "--with-gmp-libraries=${stdenv.lib.getLib gmp}/lib"
-    "--with-gmp-includes=${stdenv.lib.getDev gmp}/include"
-  ] ++ stdenv.lib.optional stdenv.isDarwin "--with-gcc=${./gcc-clang-wrapper.sh}";
-
-  # Stripping combined with patchelf breaks the executables (they die
-  # with a segfault or the kernel even refuses the execve). (NIXPKGS-85)
-  dontStrip = true;
-
-  # No building is necessary, but calling make without flags ironically
-  # calls install-strip ...
-  dontBuild = true;
-
-  # On Linux, use patchelf to modify the executables so that they can
-  # find editline/gmp.
-  preFixup = stdenv.lib.optionalString stdenv.isLinux ''
-    for p in $(find "$out" -type f -executable); do
-      if isELF "$p"; then
-        echo "Patchelfing $p"
-        patchelf --set-rpath "${libPath}:$(patchelf --print-rpath $p)" $p
-      fi
-    done
-  '' + stdenv.lib.optionalString stdenv.isDarwin ''
-    # not enough room in the object files for the full path to libiconv :(
-    for exe in $(find "$out" -type f -executable); do
-      isScript $exe && continue
-      ln -fs ${libiconv}/lib/libiconv.dylib $(dirname $exe)/libiconv.dylib
-      install_name_tool -change /usr/lib/libiconv.2.dylib @executable_path/libiconv.dylib $exe
-    done
-
-    for file in $(find "$out" -name setup-config); do
-      substituteInPlace $file --replace /usr/bin/ranlib "$(type -P ranlib)"
-    done
-  '';
-
-  doInstallCheck = true;
-  installCheckPhase = ''
-    unset ${libEnvVar}
-    # Sanity check, can ghc create executables?
-    cd $TMP
-    mkdir test-ghc; cd test-ghc
-    cat > main.hs << EOF
-      {-# LANGUAGE TemplateHaskell #-}
-      module Main where
-      main = putStrLn \$([|"yes"|])
-    EOF
-    $out/bin/ghc --make main.hs || exit 1
-    echo compilation ok
-    [ $(./main) == "yes" ]
-  '';
-
-  passthru = { targetPrefix = ""; };
-
-  meta.license = stdenv.lib.licenses.bsd3;
-  meta.platforms = ["x86_64-linux" "i686-linux" "x86_64-darwin"];
-}
diff --git a/pkgs/development/compilers/ghc/7.8.4.nix b/pkgs/development/compilers/ghc/7.8.4.nix
deleted file mode 100644
index 47fc090c1ff1..000000000000
--- a/pkgs/development/compilers/ghc/7.8.4.nix
+++ /dev/null
@@ -1,91 +0,0 @@
-{ stdenv, targetPackages
-
-, fetchurl, ghc, perl
-, libffi, libiconv ? null, ncurses
-
-, # If enabled, GHC will be built with the GPL-free but slower integer-simple
-  # library instead of the faster but GPLed integer-gmp library.
-  enableIntegerSimple ? false, gmp ? null
-}:
-
-# TODO(@Ericson2314): Cross compilation support
-assert stdenv.targetPlatform == stdenv.hostPlatform;
-assert !enableIntegerSimple -> gmp != null;
-
-let
-  buildMK = ''
-    libraries/terminfo_CONFIGURE_OPTS += --configure-option=--with-curses-includes="${ncurses.dev}/include"
-    libraries/terminfo_CONFIGURE_OPTS += --configure-option=--with-curses-libraries="${ncurses.out}/lib"
-    DYNAMIC_BY_DEFAULT = NO
-    ${stdenv.lib.optionalString (stdenv.hostPlatform.libc != "glibc") ''
-      libraries/base_CONFIGURE_OPTS += --configure-option=--with-iconv-includes="${libiconv}/include"
-      libraries/base_CONFIGURE_OPTS += --configure-option=--with-iconv-libraries="${libiconv}/lib"
-    ''}
-  '' + (if enableIntegerSimple then ''
-    INTEGER_LIBRARY = integer-simple
-  '' else ''
-    libraries/integer-gmp_CONFIGURE_OPTS += --configure-option=--with-gmp-libraries="${gmp.out}/lib"
-    libraries/integer-gmp_CONFIGURE_OPTS += --configure-option=--with-gmp-includes="${gmp.dev}/include"
-  '');
-
-  # Splicer will pull out correct variations
-  libDeps = [ ncurses ]
-    ++ stdenv.lib.optional (!enableIntegerSimple) gmp
-    ++ stdenv.lib.optional (stdenv.hostPlatform.libc != "glibc") libiconv;
-
-in
-
-stdenv.mkDerivation rec {
-  version = "7.8.4";
-  name = "ghc-${version}";
-
-  src = fetchurl {
-    url = "http://www.haskell.org/ghc/dist/${version}/${name}-src.tar.xz";
-    sha256 = "1i4254akbb4ym437rf469gc0m40bxm31blp6s1z1g15jmnacs6f3";
-  };
-
-  enableParallelBuilding = true;
-
-  patches = [ ./relocation.patch ]
-    ++ stdenv.lib.optional stdenv.isDarwin ./hpc-7.8.4.patch;
-
-  preConfigure = ''
-    echo -n "${buildMK}" > mk/build.mk
-    sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure
-  '' + stdenv.lib.optionalString (!stdenv.isDarwin) ''
-    export NIX_LDFLAGS+=" -rpath $out/lib/ghc-${version}"
-  '' + stdenv.lib.optionalString stdenv.isDarwin ''
-    export NIX_LDFLAGS+=" -no_dtrace_dof"
-  '';
-
-  # TODO(@Ericson2314): Always pass "--target" and always prefix.
-  configurePlatforms = [ "build" "host" ];
-
-  nativeBuildInputs = [ ghc perl ];
-  depsBuildTarget = [ targetPackages.stdenv.cc ];
-
-  buildInputs = libDeps;
-  propagatedBuildInputs = [ targetPackages.stdenv.cc ];
-
-  depsTargetTarget = map stdenv.lib.getDev libDeps;
-  depsTargetTargetPropagated = map (stdenv.lib.getOutput "out") libDeps;
-
-  # required, because otherwise all symbols from HSffi.o are stripped, and
-  # that in turn causes GHCi to abort
-  stripDebugFlags = [ "-S" ] ++ stdenv.lib.optional (!stdenv.isDarwin) "--keep-file-symbols";
-
-  passthru = {
-    targetPrefix = "";
-
-    # Our Cabal compiler name
-    haskellCompilerName = "ghc-7.8.4";
-  };
-
-  meta = {
-    homepage = http://haskell.org/ghc;
-    description = "The Glasgow Haskell Compiler";
-    maintainers = with stdenv.lib.maintainers; [ marcweber andres peti ];
-    inherit (ghc.meta) license platforms;
-  };
-
-}
diff --git a/pkgs/development/compilers/ghc/8.2.1-binary.nix b/pkgs/development/compilers/ghc/8.2.1-binary.nix
index c0bc2a9dd736..c88d2a8685a6 100644
--- a/pkgs/development/compilers/ghc/8.2.1-binary.nix
+++ b/pkgs/development/compilers/ghc/8.2.1-binary.nix
@@ -158,5 +158,6 @@ stdenv.mkDerivation rec {
   passthru = { targetPrefix = ""; };
 
   meta.license = stdenv.lib.licenses.bsd3;
-  meta.platforms = ["x86_64-linux" "i686-linux" "x86_64-darwin" "armv7l-linux" "aarch64-linux"];
+  # AArch64 should work in theory but eventually some builds start segfaulting
+  meta.platforms = ["x86_64-linux" "i686-linux" "x86_64-darwin" "armv7l-linux" /* "aarch64-linux" */];
 }
diff --git a/pkgs/development/compilers/ghc/8.2.2.nix b/pkgs/development/compilers/ghc/8.2.2.nix
index c8b8451ea600..d80b4edf26e7 100644
--- a/pkgs/development/compilers/ghc/8.2.2.nix
+++ b/pkgs/development/compilers/ghc/8.2.2.nix
@@ -4,6 +4,7 @@
 # build-tools
 , bootPkgs, alex, happy, hscolour
 , autoconf, autoreconfHook, automake, coreutils, fetchurl, fetchpatch, perl, python3, sphinx
+, runCommand
 
 , libffi, libiconv ? null, ncurses
 
@@ -89,6 +90,7 @@ stdenv.mkDerivation rec {
       url = "https://git.haskell.org/ghc.git/commitdiff_plain/2fc8ce5f0c8c81771c26266ac0b150ca9b75c5f3";
       sha256 = "03253ci40np1v6k0wmi4aypj3nmj3rdyvb1k6rwqipb30nfc719f";
     })
+    (import ./abi-depends-determinism.nix { inherit fetchpatch runCommand; })
   ] ++ stdenv.lib.optional deterministicProfiling
     (fetchpatch { # Backport of https://phabricator.haskell.org/D4388 for more determinism
       url = "https://github.com/shlevy/ghc/commit/fec1b8d3555c447c0d8da0e96b659be67c8bb4bc.patch";
@@ -166,6 +168,7 @@ stdenv.mkDerivation rec {
   stripDebugFlags = [ "-S" ] ++ stdenv.lib.optional (!targetPlatform.isDarwin) "--keep-file-symbols";
 
   checkTarget = "test";
+  doCheck = false; # fails with "testsuite/tests: No such file or directory.  Stop."
 
   # zsh and other shells are smart about `{ghc}` but bash isn't, and doesn't
   # treat that as a unary `{x,y,z,..}` repetition.
diff --git a/pkgs/development/compilers/ghc/8.4.1.nix b/pkgs/development/compilers/ghc/8.4.2.nix
index 14c94887d62a..8aad8861d97a 100644
--- a/pkgs/development/compilers/ghc/8.4.1.nix
+++ b/pkgs/development/compilers/ghc/8.4.2.nix
@@ -3,7 +3,7 @@
 
 # build-tools
 , bootPkgs, alex, happy
-, autoconf, automake, coreutils, fetchgit, fetchpatch, perl, python3
+, autoconf, automake, coreutils, fetchurl, fetchpatch, perl, python3
 
 , libffi, libiconv ? null, ncurses
 
@@ -15,20 +15,16 @@
 
 , # If enabled, GHC will be built with the GPL-free but slower integer-simple
   # library instead of the faster but GPLed integer-gmp library.
-  enableIntegerSimple ? false, gmp ? null
+  enableIntegerSimple ? false, gmp ? null, m4
 
 , # If enabled, use -fPIC when compiling static libs.
   enableRelocatedStaticLibs ? targetPlatform != hostPlatform
 
 , # Whether to build dynamic libs for the standard library (on the target
   # platform). Static libs are always built.
-  enableShared ? true
+  enableShared ? !targetPlatform.useAndroidPrebuilt
 
-, version ? "8.4.0.20180224"
-, # Whether to backport https://phabricator.haskell.org/D4388 for
-  # deterministic profiling symbol names, at the cost of a slightly
-  # non-standard GHC API
-  deterministicProfiling ? false
+, version ? "8.4.2"
 }:
 
 assert !enableIntegerSimple -> gmp != null;
@@ -54,6 +50,8 @@ let
   '' + stdenv.lib.optionalString enableRelocatedStaticLibs ''
     GhcLibHcOpts += -fPIC
     GhcRtsHcOpts += -fPIC
+  '' + stdenv.lib.optionalString targetPlatform.useAndroidPrebuilt ''
+    EXTRA_CC_OPTS += -std=gnu99
   '';
 
   # Splicer will pull out correct variations
@@ -72,24 +70,23 @@ let
 in
 stdenv.mkDerivation rec {
   inherit version;
-  inherit (src) rev;
   name = "${targetPrefix}ghc-${version}";
 
-  src = fetchgit {
-    url = "git://git.haskell.org/ghc.git";
-    rev = "a1e15c8f59092ef2d11be7966bd20688d8dc01e6";
-    sha256 = "1pimf5ryl76r3vwnc2n0qzk4yh7zckp2r2g5rlz8nbddsws2v893";
+  src = fetchurl {
+    url = "https://downloads.haskell.org/~ghc/${version}/ghc-${version}-src.tar.xz";
+    sha256 = "0yq4y0smn92sksnjjva28b8847krxizns6rm50j3pgq69br35k01";
   };
 
   enableParallelBuilding = true;
 
   outputs = [ "out" "doc" ];
 
-  patches = stdenv.lib.optional deterministicProfiling
-    (fetchpatch { # https://phabricator.haskell.org/D4388 for more determinism
-      url = "https://github.com/shlevy/ghc/commit/8b2dbd869d1a64de3e99fa8b1c9bb1140eee7099.patch";
-      sha256 = "0hxpiwhbg64rsyjdr4psh6dwyp58b96mad3adccvfr0x8hc6ba2m";
-    });
+  patches = [(fetchpatch {
+    url = "https://git.haskell.org/hsc2hs.git/patch/738f3666c878ee9e79c3d5e819ef8b3460288edf";
+    sha256 = "0plzsbfaq6vb1023lsarrjglwgr9chld4q3m99rcfzx0yx5mibp3";
+    extraPrefix = "utils/hsc2hs/";
+    stripLen = 1;
+  })];
 
   postPatch = "patchShebangs .";
 
@@ -112,9 +109,6 @@ stdenv.mkDerivation rec {
     export STRIP="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}strip"
 
     echo -n "${buildMK}" > mk/build.mk
-    echo ${version} >VERSION
-    echo ${src.rev} >GIT_COMMIT_ID
-    ./boot
     sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure
   '' + stdenv.lib.optionalString (!stdenv.isDarwin) ''
     export NIX_LDFLAGS+=" -rpath $out/lib/ghc-${version}"
@@ -147,7 +141,7 @@ stdenv.mkDerivation rec {
   # Make sure we never relax`$PATH` and hooks support for compatability.
   strictDeps = true;
 
-  nativeBuildInputs = [ ghc perl autoconf automake happy alex python3 ];
+  nativeBuildInputs = [ ghc perl autoconf automake m4 happy alex python3 ];
 
   # For building runtime libs
   depsBuildTarget = toolsForTarget;
@@ -188,7 +182,7 @@ stdenv.mkDerivation rec {
     inherit llvmPackages;
 
     # Our Cabal compiler name
-    haskellCompilerName = "ghc-8.4.1";
+    haskellCompilerName = "ghc-8.4.2";
   };
 
   meta = {
diff --git a/pkgs/development/compilers/ghc/abi-depends-determinism.nix b/pkgs/development/compilers/ghc/abi-depends-determinism.nix
new file mode 100644
index 000000000000..bc803b74617f
--- /dev/null
+++ b/pkgs/development/compilers/ghc/abi-depends-determinism.nix
@@ -0,0 +1,12 @@
+# https://phabricator.haskell.org/D4159 to fix non-determinism in
+# cached abi-depends fields in package databases, modified to only
+# contain hunks that exist in distribution tarballs.
+{ fetchpatch, runCommand }: let
+  base = fetchpatch rec { # Non-determinism in cached abi-depends fields
+    # Originally https://phabricator-files.haskell.org/file/data/4pqrbo5b62sifktfbrls/PHID-FILE-4g4zjiqlfxmmlaos7lz7/D4159.diff
+    url = "http://tarballs.nixos.org/sha256/${sha256}";
+    name = "D4159.diff";
+    sha256 = "0b8a08sisf1swmarm6nh9rgw7cpzi2rwdzvrd6ny49c7wk0f7x4b";
+  };
+in runCommand base.name {}
+  "sed -n '/utils\\/ghc-pkg/,$p' ${base} >$out"
diff --git a/pkgs/development/compilers/ghc/fix-7.0.4-clang.patch b/pkgs/development/compilers/ghc/fix-7.0.4-clang.patch
deleted file mode 100644
index 51323c69c201..000000000000
--- a/pkgs/development/compilers/ghc/fix-7.0.4-clang.patch
+++ /dev/null
@@ -1,74 +0,0 @@
-diff --git a/compiler/codeGen/CgInfoTbls.hs b/compiler/codeGen/CgInfoTbls.hs
-index f704a69..37753fd 100644
---- a/compiler/codeGen/CgInfoTbls.hs
-+++ b/compiler/codeGen/CgInfoTbls.hs
-@@ -211,9 +211,7 @@ mkStackLayout = do
-                     [(offset - frame_sp - retAddrSizeW, b)
-                     | (offset, b) <- binds]
- 
--  WARN( not (all (\bind -> fst bind >= 0) rel_binds),
--	ppr binds $$ ppr rel_binds $$
--        ppr frame_size $$ ppr real_sp $$ ppr frame_sp )
-+  WARN( not (all (\bind -> fst bind >= 0) rel_binds), ppr binds $$ ppr rel_binds $$ ppr frame_size $$ ppr real_sp $$ ppr frame_sp )
-     return $ stack_layout rel_binds frame_size
- 
- stack_layout :: [(VirtualSpOffset, CgIdInfo)]
-diff --git a/compiler/main/GHC.hs b/compiler/main/GHC.hs
-index 638e1db..0aee4b7 100644
---- a/compiler/main/GHC.hs
-+++ b/compiler/main/GHC.hs
-@@ -788,8 +788,7 @@ load2 how_much mod_graph = do
- 	    -- is stable).
- 	    partial_mg
- 		| LoadDependenciesOf _mod <- how_much
--		= ASSERT( case last partial_mg0 of 
--			    AcyclicSCC ms -> ms_mod_name ms == _mod; _ -> False )
-+		= ASSERT( case last partial_mg0 of AcyclicSCC ms -> ms_mod_name ms == _mod; _ -> False )
- 		  List.init partial_mg0
- 		| otherwise
- 		= partial_mg0
-@@ -879,8 +878,7 @@ load2 how_much mod_graph = do
- 	      liftIO $ cleanTempFilesExcept dflags (ppFilesFromSummaries mods_to_keep)
- 
- 	      -- there should be no Nothings where linkables should be, now
--	      ASSERT(all (isJust.hm_linkable) 
--			(eltsUFM (hsc_HPT hsc_env))) do
-+	      ASSERT(all (isJust.hm_linkable) (eltsUFM (hsc_HPT hsc_env))) do
- 	
- 	      -- Link everything together
-               linkresult <- liftIO $ link (ghcLink dflags) dflags False hpt4
-diff --git a/compiler/simplCore/SimplUtils.lhs b/compiler/simplCore/SimplUtils.lhs
-index 99a63e4..3268726 100644
---- a/compiler/simplCore/SimplUtils.lhs
-+++ b/compiler/simplCore/SimplUtils.lhs
-@@ -388,8 +388,7 @@ mkArgInfo fun rules n_val_args call_cont
- 		   else
- 			map isStrictDmd demands ++ vanilla_stricts
- 	       | otherwise
--	       -> WARN( True, text "More demands than arity" <+> ppr fun <+> ppr (idArity fun) 
--				<+> ppr n_val_args <+> ppr demands ) 
-+	       -> WARN( True, text "More demands than arity" <+> ppr fun <+> ppr (idArity fun) <+> ppr n_val_args <+> ppr demands ) 
- 		   vanilla_stricts	-- Not enough args, or no strictness
- 
-     add_type_str :: Type -> [Bool] -> [Bool]
-@@ -1812,4 +1811,4 @@ without getting changed to c1=I# c2.
- I don't think this is worth fixing, even if I knew how. It'll
- all come out in the next pass anyway.
- 
--  
-\ No newline at end of file
-+  
-diff --git a/compiler/simplCore/Simplify.lhs b/compiler/simplCore/Simplify.lhs
-index d0fbd8d..ef87996 100644
---- a/compiler/simplCore/Simplify.lhs
-+++ b/compiler/simplCore/Simplify.lhs
-@@ -2071,8 +2071,7 @@ mkDupableAlt env case_bndr (con, bndrs', rhs')
- 		      	     rhs = mkConApp dc (map Type (tyConAppArgs scrut_ty)
- 			     	   	        ++ varsToCoreExprs bndrs')
- 
--		      LitAlt {} -> WARN( True, ptext (sLit "mkDupableAlt")
--		      	     	   	        <+> ppr case_bndr <+> ppr con )
-+		      LitAlt {} -> WARN( True, ptext (sLit "mkDupableAlt") <+> ppr case_bndr <+> ppr con )
- 			           case_bndr
- 		      	   -- The case binder is alive but trivial, so why has 
- 		      	   -- it not been substituted away?
diff --git a/pkgs/development/compilers/ghc/fix-7.2.2-clang.patch b/pkgs/development/compilers/ghc/fix-7.2.2-clang.patch
deleted file mode 100644
index 9592d54188ed..000000000000
--- a/pkgs/development/compilers/ghc/fix-7.2.2-clang.patch
+++ /dev/null
@@ -1,74 +0,0 @@
-diff --git a/compiler/codeGen/CgInfoTbls.hs b/compiler/codeGen/CgInfoTbls.hs
-index dbd22f3..42208f9 100644
---- a/compiler/codeGen/CgInfoTbls.hs
-+++ b/compiler/codeGen/CgInfoTbls.hs
-@@ -210,9 +210,7 @@ mkStackLayout = do
-                     [(offset - frame_sp - retAddrSizeW, b)
-                     | (offset, b) <- binds]
- 
--  WARN( not (all (\bind -> fst bind >= 0) rel_binds),
--	ppr binds $$ ppr rel_binds $$
--        ppr frame_size $$ ppr real_sp $$ ppr frame_sp )
-+  WARN( not (all (\bind -> fst bind >= 0) rel_binds), ppr binds $$ ppr rel_binds $$ ppr frame_size $$ ppr real_sp $$ ppr frame_sp )
-     return $ stack_layout rel_binds frame_size
- 
- stack_layout :: [(VirtualSpOffset, CgIdInfo)]
-diff --git a/compiler/main/GhcMake.hs b/compiler/main/GhcMake.hs
-index dece548..9643f30 100644
---- a/compiler/main/GhcMake.hs
-+++ b/compiler/main/GhcMake.hs
-@@ -236,8 +236,7 @@ load2 how_much mod_graph = do
- 	    -- is stable).
- 	    partial_mg
- 		| LoadDependenciesOf _mod <- how_much
--		= ASSERT( case last partial_mg0 of 
--			    AcyclicSCC ms -> ms_mod_name ms == _mod; _ -> False )
-+		= ASSERT( case last partial_mg0 of AcyclicSCC ms -> ms_mod_name ms == _mod; _ -> False )
- 		  List.init partial_mg0
- 		| otherwise
- 		= partial_mg0
-@@ -331,8 +330,7 @@ load2 how_much mod_graph = do
-               liftIO $ intermediateCleanTempFiles dflags mods_to_keep hsc_env1
- 
- 	      -- there should be no Nothings where linkables should be, now
--	      ASSERT(all (isJust.hm_linkable) 
--			(eltsUFM (hsc_HPT hsc_env))) do
-+	      ASSERT(all (isJust.hm_linkable) (eltsUFM (hsc_HPT hsc_env))) do
- 	
- 	      -- Link everything together
-               linkresult <- liftIO $ link (ghcLink dflags) dflags False hpt4
-diff --git a/compiler/simplCore/SimplUtils.lhs b/compiler/simplCore/SimplUtils.lhs
-index dd0ce4b..9501e73 100644
---- a/compiler/simplCore/SimplUtils.lhs
-+++ b/compiler/simplCore/SimplUtils.lhs
-@@ -393,8 +393,7 @@ mkArgInfo fun rules n_val_args call_cont
- 		   else
- 			map isStrictDmd demands ++ vanilla_stricts
- 	       | otherwise
--	       -> WARN( True, text "More demands than arity" <+> ppr fun <+> ppr (idArity fun) 
--				<+> ppr n_val_args <+> ppr demands ) 
-+	       -> WARN( True, text "More demands than arity" <+> ppr fun <+> ppr (idArity fun) <+> ppr n_val_args <+> ppr demands ) 
- 		   vanilla_stricts	-- Not enough args, or no strictness
- 
-     add_type_str :: Type -> [Bool] -> [Bool]
-@@ -1845,4 +1844,4 @@ without getting changed to c1=I# c2.
- I don't think this is worth fixing, even if I knew how. It'll
- all come out in the next pass anyway.
- 
--  
-\ No newline at end of file
-+  
-diff --git a/compiler/simplCore/Simplify.lhs b/compiler/simplCore/Simplify.lhs
-index adcaf13..06d939d 100644
---- a/compiler/simplCore/Simplify.lhs
-+++ b/compiler/simplCore/Simplify.lhs
-@@ -2185,8 +2185,7 @@ mkDupableAlt env case_bndr (con, bndrs', rhs')
- 		      	     rhs = mkConApp dc (map Type (tyConAppArgs scrut_ty)
- 			     	   	        ++ varsToCoreExprs bndrs')
- 
--		      LitAlt {} -> WARN( True, ptext (sLit "mkDupableAlt")
--		      	     	   	        <+> ppr case_bndr <+> ppr con )
-+		      LitAlt {} -> WARN( True, ptext (sLit "mkDupableAlt") <+> ppr case_bndr <+> ppr con )
- 			           case_bndr
- 		      	   -- The case binder is alive but trivial, so why has 
- 		      	   -- it not been substituted away?
diff --git a/pkgs/development/compilers/ghc/fix-7.4.2-clang.patch b/pkgs/development/compilers/ghc/fix-7.4.2-clang.patch
deleted file mode 100644
index ce1593b3e31d..000000000000
--- a/pkgs/development/compilers/ghc/fix-7.4.2-clang.patch
+++ /dev/null
@@ -1,57 +0,0 @@
-diff --git a/compiler/codeGen/CgInfoTbls.hs b/compiler/codeGen/CgInfoTbls.hs
-index 25ba154..fbb7874 100644
---- a/compiler/codeGen/CgInfoTbls.hs
-+++ b/compiler/codeGen/CgInfoTbls.hs
-@@ -178,9 +178,7 @@ mkStackLayout = do
-                     [(offset - frame_sp - retAddrSizeW, b)
-                     | (offset, b) <- binds]
- 
--  WARN( not (all (\bind -> fst bind >= 0) rel_binds),
--        pprPlatform platform binds $$ pprPlatform platform rel_binds $$
--        ppr frame_size $$ ppr real_sp $$ ppr frame_sp )
-+  WARN( not (all (\bind -> fst bind >= 0) rel_binds), pprPlatform platform binds $$ pprPlatform platform rel_binds $$ ppr frame_size $$ ppr real_sp $$ ppr frame_sp )
-     return $ stack_layout rel_binds frame_size
- 
- stack_layout :: [(VirtualSpOffset, CgIdInfo)]
-diff --git a/compiler/main/GhcMake.hs b/compiler/main/GhcMake.hs
-index 091e1be..23447e4 100644
---- a/compiler/main/GhcMake.hs
-+++ b/compiler/main/GhcMake.hs
-@@ -338,8 +338,7 @@ load2 how_much mod_graph = do
-               liftIO $ intermediateCleanTempFiles dflags mods_to_keep hsc_env1
- 
-               -- there should be no Nothings where linkables should be, now
--              ASSERT(all (isJust.hm_linkable) 
--                        (eltsUFM (hsc_HPT hsc_env))) do
-+              ASSERT(all (isJust.hm_linkable) (eltsUFM (hsc_HPT hsc_env))) do
-         
-               -- Link everything together
-               linkresult <- liftIO $ link (ghcLink dflags) dflags False hpt4
-diff --git a/compiler/simplCore/SimplUtils.lhs b/compiler/simplCore/SimplUtils.lhs
-index 86dc88d..ecde4fd 100644
---- a/compiler/simplCore/SimplUtils.lhs
-+++ b/compiler/simplCore/SimplUtils.lhs
-@@ -407,8 +407,7 @@ mkArgInfo fun rules n_val_args call_cont
- 		   else
- 			map isStrictDmd demands ++ vanilla_stricts
- 	       | otherwise
--	       -> WARN( True, text "More demands than arity" <+> ppr fun <+> ppr (idArity fun) 
--				<+> ppr n_val_args <+> ppr demands ) 
-+	       -> WARN( True, text "More demands than arity" <+> ppr fun <+> ppr (idArity fun) <+> ppr n_val_args <+> ppr demands ) 
- 		   vanilla_stricts	-- Not enough args, or no strictness
- 
-     add_type_str :: Type -> [Bool] -> [Bool]
-diff --git a/compiler/simplCore/Simplify.lhs b/compiler/simplCore/Simplify.lhs
-index 3bd95a7..4c9ee7c 100644
---- a/compiler/simplCore/Simplify.lhs
-+++ b/compiler/simplCore/Simplify.lhs
-@@ -2336,8 +2336,7 @@ mkDupableAlt env case_bndr (con, bndrs', rhs')
- 		      	     rhs = mkConApp dc (map Type (tyConAppArgs scrut_ty)
- 			     	   	        ++ varsToCoreExprs bndrs')
- 
--		      LitAlt {} -> WARN( True, ptext (sLit "mkDupableAlt")
--		      	     	   	        <+> ppr case_bndr <+> ppr con )
-+		      LitAlt {} -> WARN( True, ptext (sLit "mkDupableAlt") <+> ppr case_bndr <+> ppr con )
- 			           case_bndr
- 		      	   -- The case binder is alive but trivial, so why has 
- 		      	   -- it not been substituted away?
diff --git a/pkgs/development/compilers/ghc/fix-7.6.3-clang.patch b/pkgs/development/compilers/ghc/fix-7.6.3-clang.patch
deleted file mode 100644
index e83fd252d72c..000000000000
--- a/pkgs/development/compilers/ghc/fix-7.6.3-clang.patch
+++ /dev/null
@@ -1,71 +0,0 @@
-diff --git a/compiler/codeGen/CgInfoTbls.hs b/compiler/codeGen/CgInfoTbls.hs
-index 7cdb1b6..e953507 100644
---- a/compiler/codeGen/CgInfoTbls.hs
-+++ b/compiler/codeGen/CgInfoTbls.hs
-@@ -157,9 +157,7 @@ mkStackLayout = do
-                     [(offset - frame_sp - retAddrSizeW, b)
-                     | (offset, b) <- binds]
- 
--  WARN( not (all (\bind -> fst bind >= 0) rel_binds),
--        ppr binds $$ ppr rel_binds $$
--        ppr frame_size $$ ppr real_sp $$ ppr frame_sp )
-+  WARN( not (all (\bind -> fst bind >= 0) rel_binds), ppr binds $$ ppr rel_binds $$ ppr frame_size $$ ppr real_sp $$ ppr frame_sp )
-     return $ stack_layout rel_binds frame_size
- 
- stack_layout :: [(VirtualSpOffset, CgIdInfo)]
-diff --git a/compiler/main/GhcMake.hs b/compiler/main/GhcMake.hs
-index f563cd9..4ac7812 100644
---- a/compiler/main/GhcMake.hs
-+++ b/compiler/main/GhcMake.hs
-@@ -331,8 +331,7 @@ load how_much = do
-           liftIO $ intermediateCleanTempFiles dflags mods_to_keep hsc_env1
- 
-           -- there should be no Nothings where linkables should be, now
--          ASSERT(all (isJust.hm_linkable) 
--                    (eltsUFM (hsc_HPT hsc_env))) do
-+          ASSERT(all (isJust.hm_linkable) (eltsUFM (hsc_HPT hsc_env))) do
-     
-           -- Link everything together
-           linkresult <- liftIO $ link (ghcLink dflags) dflags False hpt4
-diff --git a/compiler/simplCore/SimplUtils.lhs b/compiler/simplCore/SimplUtils.lhs
-index 87aefba..479d2ef 100644
---- a/compiler/simplCore/SimplUtils.lhs
-+++ b/compiler/simplCore/SimplUtils.lhs
-@@ -415,8 +415,7 @@ mkArgInfo fun rules n_val_args call_cont
- 		   else
- 			map isStrictDmd demands ++ vanilla_stricts
- 	       | otherwise
--	       -> WARN( True, text "More demands than arity" <+> ppr fun <+> ppr (idArity fun) 
--				<+> ppr n_val_args <+> ppr demands ) 
-+	       -> WARN( True, text "More demands than arity" <+> ppr fun <+> ppr (idArity fun) <+> ppr n_val_args <+> ppr demands ) 
- 		   vanilla_stricts	-- Not enough args, or no strictness
- 
-     add_type_str :: Type -> [Bool] -> [Bool]
-diff --git a/compiler/simplCore/Simplify.lhs b/compiler/simplCore/Simplify.lhs
-index f2ed224..464fad6 100644
---- a/compiler/simplCore/Simplify.lhs
-+++ b/compiler/simplCore/Simplify.lhs
-@@ -2359,8 +2359,7 @@ mkDupableAlt env case_bndr (con, bndrs', rhs')
- 		      	     rhs = mkConApp dc (map Type (tyConAppArgs scrut_ty)
- 			     	   	        ++ varsToCoreExprs bndrs')
- 
--		      LitAlt {} -> WARN( True, ptext (sLit "mkDupableAlt")
--		      	     	   	        <+> ppr case_bndr <+> ppr con )
-+		      LitAlt {} -> WARN( True, ptext (sLit "mkDupableAlt") <+> ppr case_bndr <+> ppr con )
- 			           case_bndr
- 		      	   -- The case binder is alive but trivial, so why has 
- 		      	   -- it not been substituted away?
-diff --git a/compiler/types/Coercion.lhs b/compiler/types/Coercion.lhs
-index 42e54ba..9b420ae 100644
---- a/compiler/types/Coercion.lhs
-+++ b/compiler/types/Coercion.lhs
-@@ -498,8 +498,7 @@ splitForAllCo_maybe _                = Nothing
- coVarKind :: CoVar -> (Type,Type) 
- coVarKind cv
-  | Just (tc, [_kind,ty1,ty2]) <- splitTyConApp_maybe (varType cv)
-- = ASSERT (tc `hasKey` eqPrimTyConKey)
--   (ty1,ty2)
-+ = ASSERT (tc `hasKey` eqPrimTyConKey) (ty1,ty2)
-  | otherwise = panic "coVarKind, non coercion variable"
- 
- -- | Makes a coercion type from two types: the types whose equality 
diff --git a/pkgs/development/compilers/ghc/head.nix b/pkgs/development/compilers/ghc/head.nix
index da38230d4854..c0f1091b04d7 100644
--- a/pkgs/development/compilers/ghc/head.nix
+++ b/pkgs/development/compilers/ghc/head.nix
@@ -22,7 +22,7 @@
 
 , # Whether to build dynamic libs for the standard library (on the target
   # platform). Static libs are always built.
-  enableShared ? true
+  enableShared ? !targetPlatform.useAndroidPrebuilt
 
 , version ? "8.5.20180118"
 }:
@@ -50,6 +50,8 @@ let
   '' + stdenv.lib.optionalString enableRelocatedStaticLibs ''
     GhcLibHcOpts += -fPIC
     GhcRtsHcOpts += -fPIC
+  '' + stdenv.lib.optionalString targetPlatform.useAndroidPrebuilt ''
+    EXTRA_CC_OPTS += -std=gnu99
   '';
 
   # Splicer will pull out correct variations
diff --git a/pkgs/development/compilers/ghc/hpc-7.8.4.patch b/pkgs/development/compilers/ghc/hpc-7.8.4.patch
deleted file mode 100644
index 212989200bc5..000000000000
--- a/pkgs/development/compilers/ghc/hpc-7.8.4.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-diff --git a/compiler/cmm/CLabel.hs b/compiler/cmm/CLabel.hs
-index 991fc57..0aad221 100644
---- a/compiler/cmm/CLabel.hs
-+++ b/compiler/cmm/CLabel.hs
-@@ -877,7 +877,7 @@ labelDynamic dflags this_pkg this_mod lbl =
- 
-    PlainModuleInitLabel m -> not (gopt Opt_Static dflags) && this_pkg /= (modulePackageId m)
- 
--   HpcTicksLabel m        -> not (gopt Opt_Static dflags) && this_pkg /= (modulePackageId m)
-+   HpcTicksLabel m        -> not (gopt Opt_Static dflags) && this_mod /= m
- 
-    -- Note that DynamicLinkerLabels do NOT require dynamic linking themselves.
-    _                 -> False