aboutsummaryrefslogtreecommitdiffstats
path: root/testing
diff options
context:
space:
mode:
authorMitch Tishmack <mitch.tishmack@gmail.com>2016-07-14 21:14:26 -0500
committerTimo Teräs <timo.teras@iki.fi>2017-02-13 13:39:04 +0000
commit8400dc7b515d800c1005ae28a39c444a99877ecb (patch)
treecd8ffa408b05fb9362fc9497079f43c57276707d /testing
parent554459256ca271d066f87107ad88b023efc11c0b (diff)
testing/ghc: new aport
The Glasgow Haskell Compiler http://haskell.org [TT: Add madvise patch, remove redundant depends, add provides for ghc-bootstrap]
Diffstat (limited to 'testing')
-rw-r--r--testing/ghc/0001-rm-ghc-pwd.patch184
-rw-r--r--testing/ghc/0002-Correct-issue-with-libffi-and-glibc.patch28
-rw-r--r--testing/ghc/0003-do-not-use-SHELL.patch71
-rw-r--r--testing/ghc/0004-reproducible-tmp-names.patch43
-rw-r--r--testing/ghc/0005-buildpath-abi-stability.patch25
-rw-r--r--testing/ghc/0006-fix-madvise.patch63
-rw-r--r--testing/ghc/APKBUILD97
7 files changed, 511 insertions, 0 deletions
diff --git a/testing/ghc/0001-rm-ghc-pwd.patch b/testing/ghc/0001-rm-ghc-pwd.patch
new file mode 100644
index 00000000000..cf4417547b4
--- /dev/null
+++ b/testing/ghc/0001-rm-ghc-pwd.patch
@@ -0,0 +1,184 @@
+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/testing/ghc/0002-Correct-issue-with-libffi-and-glibc.patch b/testing/ghc/0002-Correct-issue-with-libffi-and-glibc.patch
new file mode 100644
index 00000000000..87420f99282
--- /dev/null
+++ b/testing/ghc/0002-Correct-issue-with-libffi-and-glibc.patch
@@ -0,0 +1,28 @@
+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/testing/ghc/0003-do-not-use-SHELL.patch b/testing/ghc/0003-do-not-use-SHELL.patch
new file mode 100644
index 00000000000..540efa92b16
--- /dev/null
+++ b/testing/ghc/0003-do-not-use-SHELL.patch
@@ -0,0 +1,71 @@
+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/testing/ghc/0004-reproducible-tmp-names.patch b/testing/ghc/0004-reproducible-tmp-names.patch
new file mode 100644
index 00000000000..a0417f145d1
--- /dev/null
+++ b/testing/ghc/0004-reproducible-tmp-names.patch
@@ -0,0 +1,43 @@
+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/testing/ghc/0005-buildpath-abi-stability.patch b/testing/ghc/0005-buildpath-abi-stability.patch
new file mode 100644
index 00000000000..8add0fcd1c9
--- /dev/null
+++ b/testing/ghc/0005-buildpath-abi-stability.patch
@@ -0,0 +1,25 @@
+Forwarded to https://ghc.haskell.org/trac/ghc/ticket/10424
+
+Index: ghc/compiler/iface/MkIface.hs
+===================================================================
+--- ghc.orig/compiler/iface/MkIface.hs 2016-04-19 09:26:40.075170754 +0200
++++ ghc/compiler/iface/MkIface.hs 2016-04-19 09:26:40.071170684 +0200
+@@ -556,7 +556,7 @@
+ iface_hash <- computeFingerprint putNameLiterally
+ (mod_hash,
+ ann_fn (mkVarOcc "module"), -- See mkIfaceAnnCache
+- mi_usages iface0,
++ usages,
+ sorted_deps,
+ mi_hpc iface0)
+
+@@ -589,6 +589,9 @@
+ (non_orph_fis, orph_fis) = mkOrphMap ifFamInstOrph (mi_fam_insts iface0)
+ fix_fn = mi_fix_fn iface0
+ ann_fn = mkIfaceAnnCache (mi_anns iface0)
++ -- Do not allow filenames to affect the interface
++ usages = [ case u of UsageFile _ fp -> UsageFile "" fp; _ -> u | u <- mi_usages iface0 ]
++
+
+ getOrphanHashes :: HscEnv -> [Module] -> IO [Fingerprint]
+ getOrphanHashes hsc_env mods = do
diff --git a/testing/ghc/0006-fix-madvise.patch b/testing/ghc/0006-fix-madvise.patch
new file mode 100644
index 00000000000..0672001722d
--- /dev/null
+++ b/testing/ghc/0006-fix-madvise.patch
@@ -0,0 +1,63 @@
+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/testing/ghc/APKBUILD b/testing/ghc/APKBUILD
new file mode 100644
index 00000000000..f59bfa02197
--- /dev/null
+++ b/testing/ghc/APKBUILD
@@ -0,0 +1,97 @@
+#-*-mode: Shell-script; coding: utf-8;-*-
+# Maintainer: Mitch Tishmack <mitch.tishmack@gmail.com>
+pkgname=ghc
+pkgver=8.0.2
+pkgrel=0
+pkgdesc="The Glasgow Haskell Compiler"
+url="http://haskell.org"
+subpackages="$pkgname-doc"
+arch="x86_64"
+builddir="$srcdir/$pkgname-$pkgver"
+source="http://downloads.haskell.org/~ghc/${pkgver}/ghc-${pkgver}-src.tar.xz
+ 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
+ "
+
+# Note ghc's license is basically bsd3. If you'd like to know more visit:
+# https://www.haskell.org/ghc/license
+# https://ghc.haskell.org/trac/ghc/wiki/Licensing
+#
+# Note also that ghc is sensitive to the version of llvm used, hence the
+# llvm3.7 package.
+#
+# Ref: https://ghc.haskell.org/trac/ghc/wiki/Status/GHC-8.0.1
+# https://ghc.haskell.org/trac/ghc/wiki/ImprovedLLVMBackend
+license="custom:bsd3"
+
+# Note, gcc supports --no-pie on alpine linux 3.5+ only. We test for
+# that version as it greatly simplifies the apkbuild process. The
+# apks built on 3.5 will not work on any prior version of alpine linux.
+depends="gmp-dev perl gcc>=6.2.1 llvm3.7"
+provides="ghc-bootstrap=$pkgver-r$pkgrel"
+install=""
+
+# ghc build dependencies
+makedepends="
+ $depends
+ autoconf
+ linux-headers
+ musl-dev
+ ncurses-dev
+ gmp-dev
+ libffi-dev
+ zlib-dev
+ binutils-dev
+ binutils-gold
+ paxmark
+ ghc-bootstrap
+ "
+
+_ghc_build_tmp="$builddir/tmp"
+
+build() {
+ cd "$builddir"
+ cp mk/build.mk.sample mk/build.mk || return 1
+ cat >> mk/build.mk <<-EOF
+ BuildFlavour = perf-llvm
+ INTEGER_LIBRARY = integer-gmp
+ BeConservative = YES
+ V = 0
+ GhcStage3HcOpts += -O3
+ SplitSections = YES
+ EOF
+
+ # Due to patches to the configure script
+ autoreconf || return 1
+
+ ./configure \
+ --prefix=/usr \
+ --with-ld=ld.gold || return 1
+ make || return 1
+}
+
+doc() {
+ default_doc
+ install -Dm644 "$builddir/LICENSE" "$subpkgdir/usr/share/licenses/$subpkgname/LICENSE" || return 1
+}
+
+package() {
+ cd "$builddir"
+ make -j1 DESTDIR="$pkgdir" install || return 1
+ paxmark -m "$pkgdir/usr/lib/ghc-$pkgver/bin/ghc"
+ paxmark -m "$pkgdir/usr/lib/ghc-$pkgver/bin/ghc-iserv"
+ paxmark -m "$pkgdir/usr/lib/ghc-$pkgver/bin/ghc-iserv-dyn"
+ paxmark -m "$pkgdir/usr/lib/ghc-$pkgver/bin/ghc-iserv-prof"
+}
+
+sha512sums="58ea3853cd93b556ecdc4abd0be079b2621171b8491f59004ea4e036a4cba4470aaafe6591b942e0a50a64bdc47540e01fe6900212a1ef7087850112d9bfc5ef ghc-8.0.2-src.tar.xz
+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"