diff --git a/community/ghc/0000-alpine.patch b/community/ghc/0000-alpine.patch
deleted file mode 100644
index 0487096862697911ac3ed5b132edea84f839f12b..0000000000000000000000000000000000000000
--- a/community/ghc/0000-alpine.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- ghc-8.0.2/aclocal.m4.orig	2017-02-17 12:00:45.179765870 +0000
-+++ ghc-8.0.2/aclocal.m4	2017-02-17 12:00:56.033299769 +0000
-@@ -227,7 +227,7 @@
- 
-     checkVendor() {
-         case [$]1 in
--        dec|unknown|hp|apple|next|sun|sgi|ibm|montavista|portbld)
-+        dec|unknown|hp|apple|next|sun|sgi|ibm|montavista|portbld|alpine)
-             ;;
-         *)
-             echo "Unknown vendor [$]1"
diff --git a/community/ghc/0001-rm-ghc-pwd.patch b/community/ghc/0001-rm-ghc-pwd.patch
deleted file mode 100644
index cf4417547b4ee2e627b5a72fe46de0a8b8521701..0000000000000000000000000000000000000000
--- a/community/ghc/0001-rm-ghc-pwd.patch
+++ /dev/null
@@ -1,184 +0,0 @@
-commit 4c56ad36ee0d1f8b6f1b2bc0d8fff1c9acd1a389
-Author: Thomas Miedema <thomasmiedema@gmail.com>
-Date:   Mon Jan 4 18:29:49 2016 +0100
-
-    Build system: delete ghc-pwd
-    
-    On Windows, with msys2, `pwd` works (as can be seen by the use of `pwd`
-    that slipped into the validate script), so there is really no need for
-    `ghc-pwd` anymore.
-    
-    Test Plan: try it
-    
-    Reviewers: austin, bgamari, Phyx
-    
-    Reviewed By: Phyx
-    
-    Subscribers: Phyx, erikd
-    
-    Differential Revision: https://phabricator.haskell.org/D1731
-
-diff --git a/aclocal.m4 b/aclocal.m4
-index 8e97726..0c93de4 100644
---- a/aclocal.m4
-+++ b/aclocal.m4
-@@ -1737,33 +1737,9 @@ AC_DEFUN([FP_CURSES],
- # Calculate absolute path to build tree
- # --------------------------------------------------------------
- 
--AC_DEFUN([FP_INTREE_GHC_PWD],[
--AC_MSG_NOTICE(Building in-tree ghc-pwd)
--    dnl This would be
--    dnl     make -C utils/ghc-pwd clean && make -C utils/ghc-pwd
--    dnl except we don't want to have to know what make is called. Sigh.
--    rm -rf utils/ghc-pwd/dist-boot
--    mkdir  utils/ghc-pwd/dist-boot
--    dnl If special linker flags are needed to build things, then allow
--    dnl the user to pass them in via LDFLAGS.
--    changequote(, )dnl
--    GHC_LDFLAGS=`perl -e 'foreach (@ARGV) { print "-optl$_ " }' -- $LDFLAGS`
--    changequote([, ])dnl
--    if ! "$WithGhc" $GHC_LDFLAGS -v0 -no-user-$GHC_PACKAGE_DB_FLAG -hidir utils/ghc-pwd/dist-boot -odir utils/ghc-pwd/dist-boot -stubdir utils/ghc-pwd/dist-boot --make utils/ghc-pwd/Main.hs -o utils/ghc-pwd/dist-boot/ghc-pwd
--    then
--        AC_MSG_ERROR([Building ghc-pwd failed])
--    fi
--
--    GHC_PWD=utils/ghc-pwd/dist-boot/ghc-pwd
--])
--
--AC_DEFUN([FP_BINDIST_GHC_PWD],[
--    GHC_PWD=utils/ghc-pwd/dist-install/build/tmp/ghc-pwd-bindist
--])
--
- AC_DEFUN([FP_FIND_ROOT],[
- AC_MSG_CHECKING(for path to top of build tree)
--    hardtop=`$GHC_PWD`
-+    hardtop=`pwd`
- 
-     dnl Remove common automounter nonsense
-     hardtop=`echo $hardtop | sed 's|^/tmp_mnt.*\(/local/.*\)$|\1|' | sed 's|^/tmp_mnt/|/|'`
-diff --git a/configure.ac b/configure.ac
-index 042b417..ab82bb0 100644
---- a/configure.ac
-+++ b/configure.ac
-@@ -26,6 +26,8 @@ AC_INIT([The Glorious Glasgow Haskell Compilation System], [8.1], [glasgow-haske
- # checkout), then we ship a file 'VERSION' containing the full version
- # when the source distribution was created.
- 
-+FP_FIND_ROOT
-+
- if test ! -f mk/config.h.in; then
-    echo "mk/config.h.in doesn't exist: perhaps you haven't run 'perl boot'?"
-    exit 1
-@@ -258,10 +260,6 @@ AC_ARG_WITH(hc,
- )
- AC_SUBST(WithHc)
- 
--# This uses GHC, so put it after the "GHC is required" check above:
--FP_INTREE_GHC_PWD
--FP_FIND_ROOT
--
- fail() {
-     echo >&2
-     echo "$1" >&2
-diff --git a/distrib/configure.ac.in b/distrib/configure.ac.in
-index 0f68a52..4d57cd8 100644
---- a/distrib/configure.ac.in
-+++ b/distrib/configure.ac.in
-@@ -6,7 +6,6 @@ dnl
- 
- AC_INIT([The Glorious Glasgow Haskell Compilation System], [@ProjectVersion@], [glasgow-haskell-bugs@haskell.org], [ghc])
- 
--FP_BINDIST_GHC_PWD
- FP_FIND_ROOT
- 
- dnl--------------------------------------------------------------------
-diff --git a/ghc.mk b/ghc.mk
-index ba708a1..3ccc496 100644
---- a/ghc.mk
-+++ b/ghc.mk
-@@ -516,7 +516,6 @@ $(foreach pkg,$(PACKAGES_STAGE1),$(eval $(call fixed_pkg_dep,$(pkg),dist-install
- # the stage1 packages, so we have to make sure those packages get configured
- # and registered before we can start with these. Note that they don't depend on
- # eachother, so we can configure them in parallel.
--utils/ghc-pwd/dist-install/package-data.mk: $(fixed_pkg_prev)
- utils/ghc-cabal/dist-install/package-data.mk: $(fixed_pkg_prev)
- utils/hpc/dist-install/package-data.mk: $(fixed_pkg_prev)
- utils/ghc-pkg/dist-install/package-data.mk: $(fixed_pkg_prev)
-@@ -660,7 +659,6 @@ BUILD_DIRS += utils/testremove
- BUILD_DIRS += utils/ghctags
- BUILD_DIRS += utils/check-api-annotations
- BUILD_DIRS += utils/dll-split
--BUILD_DIRS += utils/ghc-pwd
- BUILD_DIRS += utils/ghc-cabal
- BUILD_DIRS += utils/hpc
- BUILD_DIRS += utils/runghc
-@@ -1020,7 +1018,6 @@ $(eval $(call bindist-list,.,\
-     mk/config.mk.in \
-     $(INPLACE_BIN)/mkdirhier \
-     utils/ghc-cabal/dist-install/build/tmp/ghc-cabal \
--    utils/ghc-pwd/dist-install/build/tmp/ghc-pwd \
-     $(BINDIST_WRAPPERS) \
-     $(BINDIST_PERL_SOURCES) \
-     $(BINDIST_LIBS) \
-@@ -1366,9 +1363,6 @@ distclean : clean
- # Internal files generated by ./configure for itself.
- 	$(call removeFiles,config.cache config.status config.log)
- 
--# ./configure build ghc-pwd in utils/ghc-pwd/dist-boot, so clean it up.
--	$(call removeTrees,utils/ghc-pwd/dist-boot)
--
- # The root Makefile makes .old versions of some files that configure
- # generates, so we clean those too.
- 	$(call removeFiles,mk/config.mk.old)
-diff --git a/utils/ghc-pwd/Main.hs b/utils/ghc-pwd/Main.hs
-deleted file mode 100644
-index 91a5606..0000000
---- a/utils/ghc-pwd/Main.hs
-+++ /dev/null
-@@ -1,22 +0,0 @@
--
--module Main where
--
--import System.Directory
--import System.Environment
--import System.Exit
--import System.IO
--
--main :: IO ()
--main = do
--    args <- getArgs
--    case args of
--        [] -> do d <- getCurrentDirectory
--                 putStr $ map forwardifySlashes d
--        _ -> do hPutStrLn stderr ("Bad args: " ++ show args)
--                hPutStrLn stderr "Usage: ghc-pwd"
--                exitFailure
--
--forwardifySlashes :: Char -> Char
--forwardifySlashes '\\' = '/'
--forwardifySlashes c = c
--
-diff --git a/utils/ghc-pwd/Setup.hs b/utils/ghc-pwd/Setup.hs
-deleted file mode 100644
-index 9a994af..0000000
---- a/utils/ghc-pwd/Setup.hs
-+++ /dev/null
-@@ -1,2 +0,0 @@
--import Distribution.Simple
--main = defaultMain
-diff --git a/utils/ghc-pwd/ghc.mk b/utils/ghc-pwd/ghc.mk
-deleted file mode 100644
-index ac6bc76..0000000
---- a/utils/ghc-pwd/ghc.mk
-+++ /dev/null
-@@ -1,9 +0,0 @@
--
--utils/ghc-pwd_USES_CABAL = YES
--utils/ghc-pwd_PACKAGE    = ghc-pwd
--utils/ghc-pwd_dist-install_INSTALL_INPLACE = YES
--utils/ghc-pwd_dist-install_WANT_BINDIST_WRAPPER = YES
--utils/ghc-pwd_dist-install_PROGNAME = ghc-pwd
--
--$(eval $(call build-prog,utils/ghc-pwd,dist-install,1))
--
diff --git a/community/ghc/0002-Correct-issue-with-libffi-and-glibc.patch b/community/ghc/0002-Correct-issue-with-libffi-and-glibc.patch
deleted file mode 100644
index 87420f9928299bd2f965648e41136c2371071cc5..0000000000000000000000000000000000000000
--- a/community/ghc/0002-Correct-issue-with-libffi-and-glibc.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-From 843bd68ea83ba011d593ad7162d1df89c230004b Mon Sep 17 00:00:00 2001
-From: Mitch Tishmack <mitch.tishmack@gmail.com>
-Date: Sat, 15 Oct 2016 21:53:13 -0500
-Subject: [PATCH 1/1] Correct issue with libffi and glibc
-
-Ref: https://github.com/mitchty/alpine-linux-ghc-bootstrap/issues/16
-
-Shamelessly learnt from here
-https://github.com/nilcons/ghc-musl/blob/master/ghc-musl/Dockerfile#L24
----
- libffi/ghc.mk | 1 +
- 1 file changed, 1 insertion(+)
-
-diff --git a/libffi/ghc.mk b/libffi/ghc.mk
-index 404cce9..2034873 100644
---- a/libffi/ghc.mk
-+++ b/libffi/ghc.mk
-@@ -61,6 +61,7 @@ $(libffi_STAMP_CONFIGURE): $(TOUCH_DEP)
- # We have to fake a non-working ln for configure, so that the fallback
- # option (cp -p) gets used instead.  Otherwise the libffi build system
- # will use cygwin symbolic links which cannot be read by mingw gcc.
-+	sed -i s/__gnu_linux__/1/ libffi/build/src/closures.c
- 	chmod +x libffi/ln
- 
- 	# We need to use -MMD rather than -MD, as otherwise we get paths
--- 
-2.9.0
-
diff --git a/community/ghc/0003-do-not-use-SHELL.patch b/community/ghc/0003-do-not-use-SHELL.patch
deleted file mode 100644
index 540efa92b1654cf0277191c444fd436c83db8128..0000000000000000000000000000000000000000
--- a/community/ghc/0003-do-not-use-SHELL.patch
+++ /dev/null
@@ -1,71 +0,0 @@
-Description: Do not use $SHELL
- as $SHELL is the user's preferred interactive shell. We do not want this to
- leak into the wrapper scripts.
-Author: Joachim Breitner <nomeata@debian.org>
-
-Index: ghc/driver/ghci/ghc.mk
-===================================================================
---- ghc.orig/driver/ghci/ghc.mk	2016-07-07 12:40:40.690866042 +0200
-+++ ghc/driver/ghci/ghc.mk	2016-07-07 12:40:40.686863966 +0200
-@@ -21,7 +21,7 @@
- 	$(INSTALL_DIR) "$(DESTDIR)$(bindir)"
- 	$(call removeFiles,                                "$(WRAPPER)")
- 	$(CREATE_SCRIPT)                                   "$(WRAPPER)"
--	echo '#!$(SHELL)'                               >> "$(WRAPPER)"
-+	echo '#!/bin/sh'                                >> "$(WRAPPER)"
- 	echo 'exec "$(bindir)/ghc-$(ProjectVersion)" --interactive "$$@"' >> "$(WRAPPER)"
- 	$(EXECUTABLE_FILE)                                 "$(WRAPPER)"
- 	$(call removeFiles,"$(DESTDIR)$(bindir)/ghci")
-@@ -56,7 +56,7 @@
- install_driver_ghcii:
- 	$(INSTALL_DIR) "$(DESTDIR)$(bindir)"
- 	$(call removeFiles,"$(GHCII_SCRIPT)")
--	echo "#!$(SHELL)"                                  >> $(GHCII_SCRIPT)
-+	echo "#!/bin/sh"                                        >> $(GHCII_SCRIPT)
- 	echo 'exec "$$(dirname "$$0")"/ghc --interactive "$$@"' >> $(GHCII_SCRIPT)
- 	$(EXECUTABLE_FILE) $(GHCII_SCRIPT)
- 	cp $(GHCII_SCRIPT) $(GHCII_SCRIPT_VERSIONED)
-Index: ghc/rules/shell-wrapper.mk
-===================================================================
---- ghc.orig/rules/shell-wrapper.mk	2016-07-07 12:40:40.690866042 +0200
-+++ ghc/rules/shell-wrapper.mk	2016-07-07 12:40:40.686863966 +0200
-@@ -41,7 +41,7 @@
- endif
- $$($1_$2_INPLACE_WRAPPER): $$($1_$2_INPLACE)
- 	$$(call removeFiles,                                                    $$@)
--	echo '#!$$(SHELL)'                                                   >> $$@
-+	echo '#!/bin/sh'                                                     >> $$@
- 	echo 'executablename="$$(TOP)/$$<"'                                  >> $$@
- 	echo 'datadir="$$(TOP)/$$(INPLACE_LIB)"'                             >> $$@
- 	echo 'bindir="$$(TOP)/$$(INPLACE_BIN)"'                              >> $$@
-@@ -80,7 +80,7 @@
- 	$$(INSTALL_DIR) "$$(DESTDIR)$$(bindir)"
- 	$$(call removeFiles,                                        "$$(WRAPPER)")
- 	$$(CREATE_SCRIPT)                                           "$$(WRAPPER)"
--	echo '#!$$(SHELL)'                                       >> "$$(WRAPPER)"
-+	echo '#!/bin/sh'                                         >> "$$(WRAPPER)"
- 	echo 'exedir="$$(ghclibexecdir)/bin"'                    >> "$$(WRAPPER)"
- 	echo 'exeprog="$$($1_$2_PROG)"'                          >> "$$(WRAPPER)"
- 	echo 'executablename="$$$$exedir/$$$$exeprog"'           >> "$$(WRAPPER)"
-@@ -106,7 +106,7 @@
- 
- $$($1_$2_BINDIST_WRAPPER): $1/$2/build/tmp/$$($1_$2_PROG)
- 	$$(call removeFiles,                                                  $$@)
--	echo '#!$$(SHELL)'                                                 >> $$@
-+	echo '#!/bin/sh'                                                    >> $$@
- ifeq "$$(DYNAMIC_GHC_PROGRAMS)" "YES"
- 	echo '$$(call prependLibraryPath,$$($1_$2_DEP_LIB_REL_DIRS_SEARCHPATH))' >> $$@
- endif
-Index: ghc/utils/mkdirhier/ghc.mk
-===================================================================
---- ghc.orig/utils/mkdirhier/ghc.mk	2016-07-07 12:40:40.690866042 +0200
-+++ ghc/utils/mkdirhier/ghc.mk	2016-07-07 12:40:40.686863966 +0200
-@@ -14,7 +14,7 @@
- 	mkdir -p $(INPLACE_BIN)
- 	mkdir -p $(INPLACE_LIB)
- 	$(call removeFiles,$@)
--	echo '#!$(SHELL)'  		 >> $@
-+	echo '#!/bin/sh'		 >> $@
- 	cat utils/mkdirhier/mkdirhier.sh >> $@
- 	$(EXECUTABLE_FILE) $@
- 
diff --git a/community/ghc/0004-reproducible-tmp-names.patch b/community/ghc/0004-reproducible-tmp-names.patch
deleted file mode 100644
index a0417f145d1da198172b067325f092ff77a32968..0000000000000000000000000000000000000000
--- a/community/ghc/0004-reproducible-tmp-names.patch
+++ /dev/null
@@ -1,43 +0,0 @@
-This is an attempt to make GHC build reproducible. The name of .c files may end
-up in the resulting binary (in the debug section), but not the directory.
-
-Instead of using the process id, create a hash from the command line arguments,
-and assume that is going to be unique.
-
-Index: ghc/compiler/main/SysTools.hs
-===================================================================
---- ghc.orig/compiler/main/SysTools.hs	2016-04-23 17:57:12.812255430 +0200
-+++ ghc/compiler/main/SysTools.hs	2016-04-23 17:57:12.808255337 +0200
-@@ -65,6 +65,7 @@
- import Util
- import DynFlags
- import Exception
-+import Fingerprint
- 
- import LlvmCodeGen.Base (llvmVersionStr, supportedLlvmVersion)
- 
-@@ -1158,8 +1159,8 @@
-     mapping <- readIORef dir_ref
-     case Map.lookup tmp_dir mapping of
-         Nothing -> do
--            pid <- getProcessID
--            let prefix = tmp_dir </> "ghc" ++ show pid ++ "_"
-+            pid <- getStableProcessID
-+            let prefix = tmp_dir </> "ghc" ++ pid ++ "_"
-             mask_ $ mkTempDir prefix
-         Just dir -> return dir
-   where
-@@ -1575,6 +1576,13 @@
- getProcessID = System.Posix.Internals.c_getpid >>= return . fromIntegral
- #endif
- 
-+-- Debian-specific hack to get reproducible output, by not using the "random"
-+-- pid, but rather something determinisic
-+getStableProcessID :: IO String
-+getStableProcessID = do
-+    args <- getArgs
-+    return $ take 4 $ show $ fingerprintString $ unwords args
-+
- -- Divvy up text stream into lines, taking platform dependent
- -- line termination into account.
- linesPlatform :: String -> [String]
diff --git a/community/ghc/0006-fix-madvise.patch b/community/ghc/0006-fix-madvise.patch
deleted file mode 100644
index 0672001722dae04b67eeffba3398e72a9ae7834b..0000000000000000000000000000000000000000
--- a/community/ghc/0006-fix-madvise.patch
+++ /dev/null
@@ -1,63 +0,0 @@
-From 6576bf83cdf4eac05eb88a24aa934a736c91e3da Mon Sep 17 00:00:00 2001
-From: Ben Gamari <bgamari.foss@gmail.com>
-Date: Thu, 1 Dec 2016 12:55:23 -0500
-Subject: [PATCH] rts: Ensure we always give MADV_DONTNEED a chance in
- osDecommitMemory
-
-As described in #12865, newer Linux kernels support both MADV_FREE and
-MADV_DONTNEED. Previously a runtime would fail to try MADV_DONTNEED if
-MADV_FREE failed (e.g. since the kernel which the image is running on
-doesn't support the latter). Now we try MADV_DONTNEED if MADV_FREE
-failed to ensure that binaries compiled on a kernel supporting MADV_FREE
-don't fail on decommit.
-
-Test Plan: Validate
-
-Reviewers: austin, erikd, simonmar
-
-Reviewed By: simonmar
-
-Subscribers: thomie
-
-Differential Revision: https://phabricator.haskell.org/D2780
-
-GHC Trac Issues: #12865
----
- rts/posix/OSMem.c | 19 ++++++++++++++++---
- 1 file changed, 16 insertions(+), 3 deletions(-)
-
-diff --git a/rts/posix/OSMem.c b/rts/posix/OSMem.c
-index 5291745..beffeda 100644
---- a/rts/posix/OSMem.c
-+++ b/rts/posix/OSMem.c
-@@ -541,11 +541,24 @@ void osDecommitMemory(void *at, W_ size)
- 
- #ifdef MADV_FREE
-     // Try MADV_FREE first, FreeBSD has both and MADV_DONTNEED
--    // just swaps memory out
-+    // just swaps memory out. Linux >= 4.5 has both DONTNEED and FREE; either
-+    // will work as they both allow the system to free anonymous pages.
-+    // It is important that we try both methods as the kernel which we were
-+    // built on may differ from the kernel we are now running on.
-     r = madvise(at, size, MADV_FREE);
--#else
--    r = madvise(at, size, MADV_DONTNEED);
-+    if(r < 0) {
-+        if (errno == EINVAL) {
-+            // Perhaps the system doesn't support MADV_FREE; fall-through and
-+            // try MADV_DONTNEED.
-+        } else {
-+            sysErrorBelch("unable to decommit memory");
-+        }
-+    } else {
-+        return;
-+    }
- #endif
-+
-+    r = madvise(at, size, MADV_DONTNEED);
-     if(r < 0)
-         sysErrorBelch("unable to decommit memory");
- }
--- 
-1.9.1
-
diff --git a/community/ghc/0007-build-hp2ps-twice.patch b/community/ghc/0007-build-hp2ps-twice.patch
deleted file mode 100644
index 47e8a8f266ce9fadae53ba87908bdfa195de9492..0000000000000000000000000000000000000000
--- a/community/ghc/0007-build-hp2ps-twice.patch
+++ /dev/null
@@ -1,25 +0,0 @@
---- a/utils/hp2ps/ghc.mk	2017-02-25 22:37:12.000000000 -0600
-+++ b/utils/hp2ps/ghc.mk	2017-02-25 23:21:33.000000000 -0600
-@@ -17,10 +17,21 @@
-                                    Utilities.c
- utils/hp2ps_dist_EXTRA_LIBRARIES = m
- utils/hp2ps_dist_PROGNAME        = $(CrossCompilePrefix)hp2ps
--utils/hp2ps_dist_INSTALL         = YES
-+utils/hp2ps_dist_INSTALL         = NO
- utils/hp2ps_dist_INSTALL_INPLACE = YES
- 
- utils/hp2ps_CC_OPTS += $(addprefix -I,$(GHC_INCLUDE_DIRS))
- 
- $(eval $(call build-prog,utils/hp2ps,dist,0))
- 
-+utils/hp2ps_dist-install_C_SRCS  = AreaBelow.c Curves.c Error.c Main.c \
-+                                   Reorder.c TopTwenty.c AuxFile.c Deviation.c \
-+                                   HpFile.c Marks.c Scale.c TraceElement.c \
-+                                   Axes.c Dimensions.c Key.c PsFile.c Shade.c \
-+                                   Utilities.c
-+utils/hp2ps_dist-install_PROGNAME = hp2ps
-+utils/hp2ps_dist-install_TOPDIR  = YES
-+utils/hp2ps_dist-install_INSTALL = YES
-+utils/hp2ps_dist-install_INSTALL_INPLACE = NO
-+
-+$(eval $(call build-prog,utils/hp2ps,dist-install,1))
diff --git a/community/ghc/0008-build-unlit-twice.patch b/community/ghc/0008-build-unlit-twice.patch
deleted file mode 100644
index 91380a5c26179263397dc3df14f668a8c2e05d1f..0000000000000000000000000000000000000000
--- a/community/ghc/0008-build-unlit-twice.patch
+++ /dev/null
@@ -1,58 +0,0 @@
-From eba93774c3ce2f151e7c72f6d068b753f24dbcfa Mon Sep 17 00:00:00 2001
-From: Thomas Miedema <thomasmiedema@gmail.com>
-Date: Wed, 15 Jun 2016 14:56:46 +0200
-Subject: [PATCH] Build system: build unlit twice
-
-See Note [Why build certain utils twice?] in utils/ghc-pkg/ghc.mk
----
- utils/ghc-pkg/ghc.mk |  7 ++++++-
- utils/unlit/ghc.mk   | 10 +++++++++-
- 2 files changed, 15 insertions(+), 2 deletions(-)
-
-diff --git a/utils/ghc-pkg/ghc.mk b/utils/ghc-pkg/ghc.mk
-index f7d97de..410de72 100644
---- a/utils/ghc-pkg/ghc.mk
-+++ b/utils/ghc-pkg/ghc.mk
-@@ -27,7 +27,7 @@ utils/ghc-pkg_PACKAGE = ghc-pkg
- # Note [Why build certain utils twice?]
- #
- # We build certain utils twice: once with stage0, and once with stage1.
--# Examples are ghc-pkg and hsc2hs.
-+# Examples are ghc-pkg, hsc2hs and unlit.
- #
- # These tools are needed during the bootstrapping process, so we have to use
- # stage0 to build them at first (stage1 doesn't exist yet). (side note: they're
-@@ -38,6 +38,11 @@ utils/ghc-pkg_PACKAGE = ghc-pkg
- # dynamically linked. But the stage0 copies are either statically linked, or
- # linked against libraries on the build machine.
- #
-+# Another reason why we can't install the stage0 copies is that they are
-+# built to run on the build(=host) platform, but when installing a
-+# "cross-compiled stage2 compiler" we need copies that run on the target
-+# platform.
-+#
- # Therefore we build fresh copies, using the stage1 compiler, and install them
- # when you run 'make install'. They are not used for any other purpose.
- 
-diff --git a/utils/unlit/ghc.mk b/utils/unlit/ghc.mk
-index e947989..6805c4e 100644
---- a/utils/unlit/ghc.mk
-+++ b/utils/unlit/ghc.mk
-@@ -13,8 +13,16 @@
- utils/unlit_dist_C_SRCS  = unlit.c
- utils/unlit_dist_PROGNAME = unlit
- utils/unlit_dist_TOPDIR  = YES
--utils/unlit_dist_INSTALL = YES
-+utils/unlit_dist_INSTALL = NO
- utils/unlit_dist_INSTALL_INPLACE = YES
- 
- $(eval $(call build-prog,utils/unlit,dist,0))
- 
-+utils/unlit_dist-install_C_SRCS  = unlit.c
-+utils/unlit_dist-install_PROGNAME = unlit
-+utils/unlit_dist-install_TOPDIR  = YES
-+utils/unlit_dist-install_INSTALL = YES
-+utils/unlit_dist-install_INSTALL_INPLACE = NO
-+
-+# See Note [Why build certain utils twice?].
-+$(eval $(call build-prog,utils/unlit,dist-install,1))
diff --git a/community/ghc/APKBUILD b/community/ghc/APKBUILD
index 4d1b271bddb081a8eda54544477c0f593c37efbc..d3e67c070d8dccf75adeee04eb7ff263c9666866 100644
--- a/community/ghc/APKBUILD
+++ b/community/ghc/APKBUILD
@@ -1,74 +1,54 @@
 # Maintainer: Mitch Tishmack <mitch.tishmack@gmail.com>
 pkgname=ghc
-pkgver=8.0.2
-pkgrel=7
+pkgver=8.4.2
+pkgrel=0
+# Normal non rc candidate
+_urlprefix="$pkgver"
+_pkgprefix="$pkgname-$pkgver"
 pkgdesc="The Glasgow Haskell Compiler"
+# Next 5 variables only needed for release candidate testing
+#pkgrcver=8.2.2
+#pkgrc=rc3
+#pkgdate=20171108
+#urlprefix="$pkgrcver-$pkgrc"
+#pkgprefix="ghc-$pkgver.$pkgdate"
 url="http://haskell.org"
-arch="x86_64 armhf"
+arch="x86_64"
 # Note ghc's license is basically BSD-3. If you'd like to know more visit:
 # * https://www.haskell.org/ghc/license
 # * https://ghc.haskell.org/trac/ghc/wiki/Licensing
 license="BSD-3-Clause"
 # Note that ghc is sensitive to the version of llvm used,
-# hence the llvm3.7 package.
+# hence the llvm5 dependency.
 #
 # Ref: https://ghc.haskell.org/trac/ghc/wiki/Status/GHC-8.0.1
 #      https://ghc.haskell.org/trac/ghc/wiki/ImprovedLLVMBackend
-depends="gmp-dev perl gcc>=6.2.1 llvm3.7 libffi-dev"
+depends="gmp-dev perl gcc>=6.2.1 llvm5 libffi-dev"
 # ghc is self-hosted, so we need ghc to build ghc. ghc-bootstrap is provided by
 # this aport (see below).
-makedepends_build="$pkgname-bootstrap haskell-ghc
-	autoconf cpio binutils-gold paxmark libffi-dev ncurses-dev"
+makedepends_build="$pkgname-bootstrap
+	autoconf cpio binutils binutils-gold paxmark libffi-dev ncurses-dev xz coreutils"
 makedepends_host="linux-headers musl-dev zlib-dev gmp-dev binutils-dev libffi-dev ncurses-dev"
 makedepends="$makedepends_build $makedepends_host"
-checkdepends="python2"
+checkdepends="python3"
 # XXX: ghc-bootstrap is a hack to allow this abuild to depend on itself.
 # Adding "ghc" to makedepends would not work, because abuild implicitly removes
 # $pkgname and $subpackages from the abuild's dependencies.
-provides="
-	$pkgname-bootstrap=$pkgver-r$pkgrel
-	haskell-cabal=1.24.2.0
-	haskell-bytestring=0.10.8.1
-	haskell-containers=0.5.7.1
-	haskell-deepseq=1.4.2.0
-	haskell-directory=1.3.0.0
-	haskell-filepath=1.4.1.1
-	haskell-ghc=8.0.2
-	haskell-ghc-boot=8.0.2
-	haskell-ghc-boot-th=8.0.2
-	haskell-ghc-prim=0.5.0.0
-	haskell-ghci=8.0.2
-	haskell-haskeline=0.7.3.0
-	haskell-hoopl=3.10.2.1
-	haskell-hpc=0.6.0.3
-	haskell-integer-gmp=1.0.0.1
-	haskell-pretty=1.1.3.3
-	haskell-process=1.4.3.0
-	haskell-rts=1.0
-	haskell-template-haskell=2.11.1.0
-	haskell-terminfo=0.4.0.2
-	haskell-time=1.6.0.1
-	haskell-transformers=0.5.2.0
-	haskell-unix=2.7.2.1
-	haskell-xhtml=3000.2.1
-	"
+provides="$pkgname-bootstrap=$pkgver-r$pkgrel"
 subpackages="$pkgname-doc $pkgname-dev"
 install="$pkgname.post-install"
 options="!strip"  # we strip it manually in build()
-source="http://downloads.haskell.org/~ghc/$pkgver/ghc-$pkgver-src.tar.xz
-	http://downloads.haskell.org/~ghc/$pkgver/ghc-$pkgver-testsuite.tar.xz
-	0000-alpine.patch
-	0000-bootstrap.patch
-	0001-rm-ghc-pwd.patch
-	0002-Correct-issue-with-libffi-and-glibc.patch
-	0003-do-not-use-SHELL.patch
-	0004-reproducible-tmp-names.patch
-	0005-buildpath-abi-stability.patch
-	0006-fix-madvise.patch
-	0007-build-hp2ps-twice.patch
-	0008-build-unlit-twice.patch
-	"
-builddir="$srcdir/$pkgname-$pkgver"
+source="https://downloads.haskell.org/~ghc/$_urlprefix/$_pkgprefix-src.tar.xz
+        https://downloads.haskell.org/~ghc/$_urlprefix/$_pkgprefix-testsuite.tar.xz
+        0005-buildpath-abi-stability.patch
+        "
+
+# We only need the bootstrap patch when bootstrapping a new arches ghc.
+if [ "$CBUILD" != "$CTARGET" ]; then
+	source="$source 0000-bootstrap.patch"
+fi
+
+builddir="$srcdir/$_pkgprefix"
 
 prepare() {
 	default_prepare
@@ -79,7 +59,6 @@ prepare() {
 		BuildFlavour         = perf-llvm
 		INTEGER_LIBRARY      = integer-gmp
 		BeConservative       = YES
-		V                    = 0
 		GhcStage3HcOpts     += -O3
 		SplitSections        = YES
 	EOF
@@ -104,6 +83,8 @@ build() {
 	local ffi_inc=$(pkg-config libffi --cflags-only-I); ffi_inc="${ffi_inc%% }"
 	local ffi_lib=$(pkg-config libffi --libs-only-L); ffi_lib="${ffi_lib%% }"
 
+	GHCLD=${CROSS_COMPILE}ld.gold
+
 	# NOTE: ghc build system requires host == build, and it ends up
 	# compiling the cross-compiler (stage1) and cross-compiling with
 	# that the native compiler (stage2)
@@ -119,8 +100,17 @@ build() {
 		--with-nm=${CROSS_COMPILE}nm \
 		--with-ranlib=${CROSS_COMPILE}ranlib \
 		--with-objdump=${CROSS_COMPILE}objdump \
-		--with-ld=${CROSS_COMPILE}ld.gold \
-		--with-ld.gold=${CROSS_COMPILE}ld.gold
+		--disable-ld-override \
+		CONF_CPP_OPTS_STAGE0=" $ffi_inc $ffi_lib " \
+		CONF_CC_OPTS_STAGE0=" $ffi_inc $ffi_lib " \
+		LD=$GHCLD
+
+	# Switch llvm-targets from unknown-linux-gnueabihf->alpine-linux
+	# so we can match the llvm vendor string alpine uses
+	sed -i -e 's/unknown-linux-gnueabihf/alpine-linux/g' llvm-targets
+	sed -i -e 's/unknown-linux-gnueabi/alpine-linux/g' llvm-targets
+	sed -i -e 's/unknown-linux-gnu/alpine-linux/g' llvm-targets
+
 	make
 }
 
@@ -193,16 +183,6 @@ dev() {
 	echo "$pfiles" | cpio -pamVd "$subpkgdir"
 	echo "$pfiles" | xargs rm -fr
 }
-
-sha512sums="58ea3853cd93b556ecdc4abd0be079b2621171b8491f59004ea4e036a4cba4470aaafe6591b942e0a50a64bdc47540e01fe6900212a1ef7087850112d9bfc5ef  ghc-8.0.2-src.tar.xz
-1b35fc6a5f482dc1e33f21ddf4c4fe17591990f16a4105c787225980a5f4dbaa42205204faf547f8e1b53f6356aefde9d3ff50cc416c9bf1a9ac08feadd74a99  ghc-8.0.2-testsuite.tar.xz
-23a52467fe83322e7b1d5f3e17a9defd08969666acb5a40e40ad93aa4f3feec028389448d4620edbe3ee8b246b3b6e338b267dce09cb14bdd0949b98e75d7562  0000-alpine.patch
-82cecce9e42c12cc3c8d484331b76ac5c6d2529887cd73181d4798f95057883be47489919379e6ebf7daba95b7c25b5d9d689b30ed8d01b13dda20a3b921ce3d  0000-bootstrap.patch
-128eece1b103f286b915a1563a628b638f03509d18cdb2e6510957d26eb56a4ae66e33c946c0e6c2aac2f947b9646dc88c1f390c69ea21f9dc64e0bef4de4e97  0001-rm-ghc-pwd.patch
-6f90b0de1e34c286e54ef14514ffabe17f9012fbc5448b4aacb3687aac065942e0a3a2c1c57b6338121140369a8870b4ce2a6b355c83c43344d4de8909a253a4  0002-Correct-issue-with-libffi-and-glibc.patch
-59194e6994c8344c579ec16c3adf3e0cdc7c356b524b12f8b10ec940191463d686782e525537c94ffa8e1bf9efcc36a2b3da3004183586ab0e354ab0a7036e0a  0003-do-not-use-SHELL.patch
-b5a5e73a2f01c0cabc96a49776d0d0f3d1d7a10759bb0b2982e7c7f6dc525d0559c0183ee779feb77ec6f2cec3bac17c1a5ba4c3bc0c6f780dfc1ed3dcf6c80e  0004-reproducible-tmp-names.patch
-e1c2cef06d307eda4b35521204e95eb54ace5dbcd22de659e95356f884b4424d6304365e4ab45c5116192cba4c095e2e91114bc7cb73d7c7173a7035287d0854  0005-buildpath-abi-stability.patch
-478f9c9990ee01b70e88daf97138f853816d862731a02e9286ad787845dcb40c1443a30520598d805d0ff7cea8c3d604ed5d9033dbe8e572e8a85911ee739ff7  0006-fix-madvise.patch
-a1032b800515908eae1602454c03bd80c92e39faa4004b52dba698d84166abea1bb4ce4afc2b69aad4a25a4e9acb2d12704453e512ab2b2ceae02c6df180bd76  0007-build-hp2ps-twice.patch
-0a53264a2066869379cbcb3a6175b93d4461d9a9fe6d2594bf0c9438daa176fbccf033832fa61bd482a23335c4528d8087301e3bdc08d08160acb789befbe005  0008-build-unlit-twice.patch"
+sha512sums="aeb17c986c597762381d9887679eb0eec194c2938a92b5a33e66b4c80002ead02d672b4aa968e1061ab5652b74e46a3c9f9e3d58d5be4a0ae47aa8aed288cf1f  ghc-8.4.2-src.tar.xz
+67ce9cb89ea5b04c4d4dec4252a00c990d16ebca917959d2b251e6f230e14d297cd7b5a29f5acf5a2d1e0ff33ffa65b33688cdd2eab8bdb4d4e88245c7a6e53e  ghc-8.4.2-testsuite.tar.xz
+e1c2cef06d307eda4b35521204e95eb54ace5dbcd22de659e95356f884b4424d6304365e4ab45c5116192cba4c095e2e91114bc7cb73d7c7173a7035287d0854  0005-buildpath-abi-stability.patch"