public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] repo/gentoo:master commit in: dev-lang/ghc/, dev-lang/ghc/files/
@ 2022-08-21  2:25 Sam James
  0 siblings, 0 replies; 15+ messages in thread
From: Sam James @ 2022-08-21  2:25 UTC (permalink / raw
  To: gentoo-commits

commit:     cf7899db70b1379f1633f88e848a0ca3bcd92f62
Author:     matoro <matoro <AT> users <DOT> noreply <DOT> github <DOT> com>
AuthorDate: Fri Aug 19 00:00:22 2022 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun Aug 21 02:25:05 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=cf7899db

dev-lang/ghc: add big-endian ppc64 binary

This requires a patch to work correctly on BE systems.  Apply the patch
unconditionally since it is already includes the appropriate checks in
the code.  Delete a few lines of commented-out obsolete patches.

Closes: https://bugs.gentoo.org/865311
Thanks-to: Marcus Comstedt <marcus <AT> mc.pp.se>
Closes: https://github.com/gentoo/gentoo/pull/26921
Signed-off-by: Sam James <sam <AT> gentoo.org>

 dev-lang/ghc/Manifest                              |  1 +
 .../files/ghc-9.0.2-disable-unboxed-arrays.patch   | 39 ++++++++++++++++++++++
 dev-lang/ghc/ghc-9.0.2.ebuild                      | 28 ++++------------
 3 files changed, 46 insertions(+), 22 deletions(-)

diff --git a/dev-lang/ghc/Manifest b/dev-lang/ghc/Manifest
index f6130b71837e..370504e5c02c 100644
--- a/dev-lang/ghc/Manifest
+++ b/dev-lang/ghc/Manifest
@@ -5,5 +5,6 @@ DIST ghc-9.0.2-testsuite.tar.xz 2403564 BLAKE2B 0e7f6fefb9c972f94073aca8b1514791
 DIST ghc-bin-8.10.6-i686-pc-linux-gnu.tbz2 124324289 BLAKE2B afb34984872b35fdedbdedeb8756cc7c33e5b943dba57dd86910b076d483bb643265d0ab0027784dec5dc489eabd65b5ab17474f25fb2ce657925aa0efaa9033 SHA512 4be13e6dba298d12a4d49ae4633eec83cfaaaf22b5f8cfca5f5952aa294ae52fb3601490beed3bda5a7f7b6a5bd81e0ecc9fc39e8df836cc8fd377a0d0b783a0
 DIST ghc-bin-8.10.6-x86_64-pc-linux-gnu.tbz2 122871118 BLAKE2B 527b36abf60390c91f91bc650ee25484d39d377739da87b5b6fd1a752705c1f3bc0ce0c68644657c9a7c1fc9a3b858b9dd7d84b25eab1a89125fccb6eb1f6250 SHA512 42b7fae339e82a6078fae8920efea8d0992e4774ea66b100e22dd9df168be57d8bce52558b8501c3c567c40776389d94bde3f17d26d63535140ce26ac16c27e1
 DIST ghc-bin-9.0.2-i686-pc-linux-gnu.tbz2 123509908 BLAKE2B 45614984803a7bfa266f99d4adb4b5f2ab7b9e5e89c6ecd501296fc99a1d96e798ccb9c832f8dcb15fff9725beb918a7b63e62ff13f59b6506a2ef17930c45d2 SHA512 e0b7f4474c16f0763a2f787027fbdfeb3125b48c987fa1196bc189fefad9f0bfa2806da62af46d61ca911f5275b578076e2b326acf39e0894a8daa9deda0843a
+DIST ghc-bin-9.0.2-powerpc64-unknown-linux-gnu.tar.gz 235636284 BLAKE2B 878ac300cca5d2cbc5cb21dbb347da755b4027cbf63ec77464740854fa8010569de5e03acef67cd877da13665c906b2fd04e24e226e9eb39b57ba979093c732b SHA512 28f096e965abdac9cc370c882639f10285b9073ba5332f7af215eccff948e41c01c3d6bb3bc8e3b4e809e12867a95b49f82dd76e0090b974088f75ab9d1bc199
 DIST ghc-bin-9.0.2-powerpc64le-unknown-linux-gnu.tar.gz 275226316 BLAKE2B 10ade2359432b0ede7431ee543f0ff47f4b203465d81719da579ad63ca467359eb9fcf7336a12feb6ff75a480f349576ff8ea1b4ebe1094fff228ae4fd00d6e0 SHA512 64b4c84d149358b8d3a6cb29a6d3a75af11e7b14e6d910c9789c9949262e4ed2a17f8a0d1e5dd297121957061fe2395d6f43acae6b4ab28851e3cd414cd9c89c
 DIST ghc-bin-9.0.2-x86_64-pc-linux-gnu.tbz2 121536759 BLAKE2B 4433e2d266f065d2b2944b711d622ec26288a2187ac03562257a671744b44da35110ce16ac6d76f7062a563488885326be073e0ff03c7e48250051c3b4763d96 SHA512 2de29a9ddbfd0fac797cdd628f3657ff38e6a153151849508bba75d36f84394ed77750435ff5cc1bdfcd30ef2b6e009bde965bd0a83e0496b5027239642f4b6c

diff --git a/dev-lang/ghc/files/ghc-9.0.2-disable-unboxed-arrays.patch b/dev-lang/ghc/files/ghc-9.0.2-disable-unboxed-arrays.patch
new file mode 100644
index 000000000000..599762b95454
--- /dev/null
+++ b/dev-lang/ghc/files/ghc-9.0.2-disable-unboxed-arrays.patch
@@ -0,0 +1,39 @@
+https://gitlab.haskell.org/ghc/packages/containers/-/commit/f5a511f1ff2cf16e710342948792cb8d7576e27c
+https://bugs.gentoo.org/865311
+
+From f5a511f1ff2cf16e710342948792cb8d7576e27c Mon Sep 17 00:00:00 2001
+From: Peter Trommler <ptrommler@acm.org>
+Date: Fri, 31 Dec 2021 18:20:45 +0100
+Subject: [PATCH] Disable unboxed arrays on big-endian
+
+Unboxed arrays are broken on big-endian architectures, see
+https://gitlab.haskell.org/ghc/ghc/-/issues/16998 for details.
+This patch makes the use of unboxed arrays conditional on
+little-endian architecture.
+
+Fixes #673
+---
+ libraries/containers/containers/include/containers.h | 6 ++++++
+ 1 file changed, 6 insertions(+)
+
+diff --git a/libraries/containers/containers/include/containers.h b/libraries/containers/containers/include/containers.h
+index cd201ca3..fc2a0e84 100644
+--- a/libraries/containers/containers/include/containers.h	2022-08-16 07:50:42.844217960 +0200
++++ b/libraries/containers/containers/include/containers.h	2022-08-16 07:50:49.327446486 +0200
+@@ -35,7 +35,13 @@
+ 
+ #ifdef __GLASGOW_HASKELL__
+ # define USE_ST_MONAD 1
++#ifndef WORDS_BIGENDIAN
++/*
++ * Unboxed arrays are broken on big-endian architectures.
++ * See https://gitlab.haskell.org/ghc/ghc/-/issues/16998
++ */
+ # define USE_UNBOXED_ARRAYS 1
+ #endif
++#endif
+ 
+ #endif
+-- 
+GitLab
+

diff --git a/dev-lang/ghc/ghc-9.0.2.ebuild b/dev-lang/ghc/ghc-9.0.2.ebuild
index 5f55fd44965a..e0cd53611f2c 100644
--- a/dev-lang/ghc/ghc-9.0.2.ebuild
+++ b/dev-lang/ghc/ghc-9.0.2.ebuild
@@ -32,8 +32,10 @@ BIN_PV=${PV}
 arch_binaries="$arch_binaries amd64? ( https://eidetic.codes/ghc-bin-${PV}-x86_64-pc-linux-gnu.tbz2 )"
 #arch_binaries="$arch_binaries ia64?  ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-ia64-fixed-fiw.tbz2 )"
 #arch_binaries="$arch_binaries ppc? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-ppc.tbz2 )"
-#arch_binaries="$arch_binaries ppc64? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-ppc64.tbz2 )"
-arch_binaries="$arch_binaries ppc64? ( !big-endian? ( https://github.com/matoro/ghc/releases/download/${PV}/ghc-bin-${PV}-powerpc64le-unknown-linux-gnu.tar.gz ) )"
+arch_binaries="$arch_binaries ppc64? (
+	big-endian? ( https://github.com/matoro/ghc/releases/download/${PV}/ghc-bin-${PV}-powerpc64-unknown-linux-gnu.tar.gz )
+	!big-endian? ( https://github.com/matoro/ghc/releases/download/${PV}/ghc-bin-${PV}-powerpc64le-unknown-linux-gnu.tar.gz )
+)"
 #arch_binaries="$arch_binaries sparc? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-sparc.tbz2 )"
 arch_binaries="$arch_binaries x86? ( https://eidetic.codes/ghc-bin-${PV}-i686-pc-linux-gnu.tbz2 )"
 
@@ -49,9 +51,7 @@ yet_binary() {
 		amd64) return 0 ;;
 		#ia64) return 0 ;;
 		#ppc) return 0 ;;
-		ppc64)
-			use big-endian || return 0
-			;;
+		ppc64) return 0 ;;
 		#sparc) return 0 ;;
 		x86) return 0 ;;
 		*) return 1 ;;
@@ -506,30 +506,14 @@ src_prepare() {
 
 		eapply "${FILESDIR}"/${PN}-9.0.2-CHOST-prefix.patch
 		eapply "${FILESDIR}"/${PN}-9.0.2-darwin.patch
-
-		# Incompatible with ghc-9.0.2-modorigin-semigroup.patch
-		# Below patch should not be needed by ghc-9.2
-		#eapply "${FILESDIR}"/${PN}-9.0.2-modorigin.patch
-
-		# ModUnusable pretty-printing should include the reason
-		#eapply "${FILESDIR}/${PN}-9.0.2-verbose-modunusable.patch"
-
 		# Fixes panic when compiling some packages
 		# https://github.com/gentoo-haskell/gentoo-haskell/issues/1250#issuecomment-1044257595
 		# https://gitlab.haskell.org/ghc/ghc/-/issues/21097
 		eapply "${FILESDIR}/${PN}-9.0.2-modorigin-semigroup.patch"
-
 		# Needed for testing with python-3.10
 		use test && eapply "${FILESDIR}/${PN}-9.0.2-fix-tests-python310.patch"
-
-		#needs a port?
-		#eapply "${FILESDIR}"/${PN}-8.8.1-revert-CPP.patch
 		eapply "${FILESDIR}"/${PN}-8.10.1-allow-cross-bootstrap.patch
-		#eapply "${FILESDIR}"/${PN}-8.10.3-C99-typo-ac270.patch
-
-		# a bunch of crosscompiler patches
-		# needs newer version:
-		#eapply "${FILESDIR}"/${PN}-8.2.1_rc1-hp2ps-cross.patch
+		eapply "${FILESDIR}"/${PN}-9.0.2-disable-unboxed-arrays.patch
 
 		# mingw32 target
 		pushd "${S}/libraries/Win32"


^ permalink raw reply related	[flat|nested] 15+ messages in thread
* [gentoo-commits] repo/gentoo:master commit in: dev-lang/ghc/, dev-lang/ghc/files/
@ 2023-02-04 23:11 Sam James
  0 siblings, 0 replies; 15+ messages in thread
From: Sam James @ 2023-02-04 23:11 UTC (permalink / raw
  To: gentoo-commits

commit:     9a6e2ac2de6dfe8c28396239cc5d41a1f441a64a
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sat Feb  4 23:10:36 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sat Feb  4 23:10:36 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=9a6e2ac2

dev-lang/ghc: fix build w/ sphinx 6

Closes: https://bugs.gentoo.org/890563
Signed-off-by: Sam James <sam <AT> gentoo.org>

 dev-lang/ghc/files/ghc-9.0.2-sphinx-6.patch | 41 +++++++++++++++++++++++++++++
 dev-lang/ghc/ghc-9.0.2-r3.ebuild            |  1 +
 2 files changed, 42 insertions(+)

diff --git a/dev-lang/ghc/files/ghc-9.0.2-sphinx-6.patch b/dev-lang/ghc/files/ghc-9.0.2-sphinx-6.patch
new file mode 100644
index 000000000000..02364dd8eea5
--- /dev/null
+++ b/dev-lang/ghc/files/ghc-9.0.2-sphinx-6.patch
@@ -0,0 +1,41 @@
+https://bugs.gentoo.org/890563
+https://gitlab.haskell.org/ghc/ghc/-/commit/00dc51060881df81258ba3b3bdf447294618a4de
+https://gitlab.haskell.org/ghc/ghc/-/issues/22690
+
+From 00dc51060881df81258ba3b3bdf447294618a4de Mon Sep 17 00:00:00 2001
+From: Matthew Pickering <matthewtpickering@gmail.com>
+Date: Tue, 3 Jan 2023 15:56:37 +0000
+Subject: [PATCH] sphinx: Use modern syntax for extlinks
+
+This fixes the following build error:
+
+```
+  Command line: /opt/homebrew/opt/sphinx-doc/bin/sphinx-build -b man -d /private/tmp/extra-dir-55768274273/.doctrees-man -n -w /private/tmp/extra-dir-55768274273/.log docs/users_guide /private/tmp/extra-dir-55768274273
+  ===> Command failed with error code: 2
+
+  Exception occurred:
+    File "/opt/homebrew/Cellar/sphinx-doc/6.0.0/libexec/lib/python3.11/site-packages/sphinx/ext/extlinks.py", line 101, in role
+      title = caption % part
+              ~~~~~~~~^~~~~~
+  TypeError: not all arguments converted during string formatting
+```
+
+I tested on Sphinx-5.1.1 and Sphinx-6.0.0
+
+Thanks for sterni for providing instructions about how to test using
+sphinx-6.0.0.
+
+Fixes #22690
+--- a/docs/users_guide/ghc_config.py.in
++++ b/docs/users_guide/ghc_config.py.in
+@@ -1,6 +1,6 @@
+ extlinks = {
+-    'ghc-ticket': ('https://gitlab.haskell.org/ghc/ghc/issues/%s', '#'),
+-    'ghc-wiki': ('https://gitlab.haskell.org/ghc/ghc/wikis/%s', '#'),
++    'ghc-ticket': ('https://gitlab.haskell.org/ghc/ghc/issues/%s', '%s'),
++    'ghc-wiki': ('https://gitlab.haskell.org/ghc/ghc/wikis/%s', '#%s'),
+ }
+ 
+ libs_base_uri = '../libraries'
+-- 
+GitLab

diff --git a/dev-lang/ghc/ghc-9.0.2-r3.ebuild b/dev-lang/ghc/ghc-9.0.2-r3.ebuild
index b7d4466a00c3..1cd220d817eb 100644
--- a/dev-lang/ghc/ghc-9.0.2-r3.ebuild
+++ b/dev-lang/ghc/ghc-9.0.2-r3.ebuild
@@ -544,6 +544,7 @@ src_prepare() {
 		eapply "${FILESDIR}"/latomic-subword
 		eapply "${WORKDIR}"/${P}-riscv64-llvm.patch
 		eapply "${FILESDIR}"/${PN}-9.0.2-fptools.patch # clang-16 workaround
+		eapply "${FILESDIR}"/${PN}-9.0.2-sphinx-6.patch
 
 		# mingw32 target
 		pushd "${S}/libraries/Win32"


^ permalink raw reply related	[flat|nested] 15+ messages in thread
* [gentoo-commits] repo/gentoo:master commit in: dev-lang/ghc/, dev-lang/ghc/files/
@ 2022-08-14 20:52 Sam James
  0 siblings, 0 replies; 15+ messages in thread
From: Sam James @ 2022-08-14 20:52 UTC (permalink / raw
  To: gentoo-commits

commit:     504bd4bb9d4e5e2312b12ba3f5507a843fe24f6f
Author:     matoro <matoro <AT> users <DOT> noreply <DOT> github <DOT> com>
AuthorDate: Thu Aug  4 04:16:20 2022 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun Aug 14 20:51:56 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=504bd4bb

dev-lang/ghc: drop 8.8.4-r1, 8.10.4-r1

Signed-off-by: Sam James <sam <AT> gentoo.org>

 dev-lang/ghc/Manifest                              |   8 -
 .../ghc/files/ghc-8.0.2-no-relax-everywhere.patch  |  17 -
 dev-lang/ghc/files/ghc-8.10.4-sphinx-quote.patch   |  27 -
 .../files/ghc-8.4.2-allow-cross-bootstrap.patch    |  23 -
 dev-lang/ghc/files/ghc-8.6.5-numa.patch            |  22 -
 dev-lang/ghc/files/ghc-8.8.4-autoconf-2.71.patch   |  22 -
 dev-lang/ghc/ghc-8.10.4-r1.ebuild                  | 812 --------------------
 dev-lang/ghc/ghc-8.8.4-r1.ebuild                   | 824 ---------------------
 8 files changed, 1755 deletions(-)

diff --git a/dev-lang/ghc/Manifest b/dev-lang/ghc/Manifest
index 42cde67ad2d9..caa6661e3f42 100644
--- a/dev-lang/ghc/Manifest
+++ b/dev-lang/ghc/Manifest
@@ -1,17 +1,9 @@
-DIST ghc-8.10.4-src.tar.xz 19818108 BLAKE2B 069dd8436c373ccf73c20d8b577243792ffdd3a031e869edd612fe1e273126e60803326542695012dbe62e57654ada18af9342bbe1a741b2bebb41cdb0d86035 SHA512 9bb078cb72535a352243b83b671c871392564efd09e478549f27ae58fc6f46e337a0782f5500d26d5704ad96eace22e77bb36031a1fe9b7e175f265b0b9c028b
-DIST ghc-8.10.4-testsuite.tar.xz 2236932 BLAKE2B 17d0520ad5c6daa0cc60530279ae7e617e4d79328b9f436abbe75e72f0803d9a997fb9e1ae61425326b070f45794a488d8507957fec9a6ed49eea86d30a1e579 SHA512 1bf129c8d872e3ceff7c19929605adc5d68daab9ded9aa2e5109b0de162089631472c66f04993adf8481291f8128bf804fe64a9d344c81e257f1b962ba5e382c
 DIST ghc-8.10.6-src.tar.xz 19932832 BLAKE2B f5d0c43aa5df87648e32beeb5ed6866b231cbce4f344fb03110db826b36bbac435f5e89d9ffeef3f87c15e830fdee6b95150b7bdcd06906575bfcd9c83797dff SHA512 6314eb9744d47d803b30b621bd12bf6179dad5cc578ec267b3a65b89e9c9b431bdb4913936f040c7ca4fcc71a676a43e78b5f6173d123a844e7f29004405b8b6
 DIST ghc-8.10.6-testsuite.tar.xz 2265044 BLAKE2B 72a1e955acecc92a720ee2747d96cacf56f2968c9deabb254c882a969c154baa0fdb639a857844ec91a4e47ee553dd13b58c3b790202e7e73500095c1ec85ee9 SHA512 f74d743bd8f889c2941be8fd5348e92abcaf75bce48140f7f9cc0c6ce33ba24a8479bef48631ffe2a10397c0ecf166b3bddb6ca8ee905859c029175de5d43f2a
-DIST ghc-8.8.4-src.tar.xz 19395252 BLAKE2B 6fa898b9552398a724f0452f5cc88ba073264a5645288c73507258959efec40ce5a56a0eaafdabe58f15c5a9210b2c9da5954411dff5c81c52e061569d6a350a SHA512 efd23bd819f7429486696a3a929a040471db7ea8a2d1f1d832e4cf0825b9e1e0c5e6ecad0ab8376f58b74e9c28c1d2f773bd126596d6d853c9e57d57e5ceb090
-DIST ghc-8.8.4-testsuite.tar.xz 1965820 BLAKE2B 3b715700561788b8abdc986961d533b91399461d57a1686ededb4ccc36881503cdc3fc126b9a7b204a728c24b9a9ca97320142348644367aca9b47c87a5b3b51 SHA512 79d8fb0ba8de0fb48c938bd54c8c3278f1895d8ce5c700ce8cf6b3fc550073bb757208e85d4f9818400ebecca96f51d9248b8bbdac9eb2995671756164d08c16
 DIST ghc-9.0.2-src.tar.xz 27270396 BLAKE2B 0a73d910d3ef11161f895849025fe37ce231932f7cde441fdf620cf8c51678060a804467879eb0ee5c0a30413604c56e28e2aa1cde01e45c620b76987d9c0c0e SHA512 32994c7d2b8f47bae604cd825bfcf9c788d79ce26d1d5f58bd73a7093e11ae6c3c17b31dc0c9e454dbf67ca169b942f92213c388d615768cae86055bf6094dee
 DIST ghc-9.0.2-testsuite.tar.xz 2403564 BLAKE2B 0e7f6fefb9c972f94073aca8b15147913ffa8d3cd3ff7fc63ef7e20b4efd8b443cf21f12e1ab0f5044790f6d8af6cf7788bda85a21b2f356ddface86eb896670 SHA512 b2375500ae837d74af8085d099899b5a7a589c59bdcc033ca0bd6e00f33c4f8d90b481e0c7c3de113e607fcfafdfe8edde4713e6d242b2d4ee87df2eb960c9c7
-DIST ghc-bin-8.10.4-i686-pc-linux-gnu.tbz2 123831294 BLAKE2B 1ca4c1b5c34c948011049a73d409c741db89658d10e311cffbe464c631c3733278fc7dede6ad27474832295ded2c26fd4d6419c760505255e29f7cb232a670a4 SHA512 1f87cf63651f7c0e5f7f55d1f4d7d7c48b0a911cc6673a899d4b92190d765b359f9c7d73c329969c1b76f1af102b7e2c18a80382c81d5dade9ac7dd57de4ef65
-DIST ghc-bin-8.10.4-x86_64-pc-linux-gnu.tbz2 122558873 BLAKE2B 9f07c7bdc3beccfa629d28b2524ccd2f4688a5c0036a45408f5ace2d530a2a0e42f95b3cda5037ebb365317999e1ae776c6f9d21692867abfe85e33f2892b1be SHA512 68bd70f94961547746a696aa2839e156c95858fda0c7ec5b2ecf802070724ab7102b0aa86bcbf93432170d521cce4af10f46b851b470e5dc49dfa5b07380f46d
 DIST ghc-bin-8.10.6-i686-pc-linux-gnu.tbz2 124324289 BLAKE2B afb34984872b35fdedbdedeb8756cc7c33e5b943dba57dd86910b076d483bb643265d0ab0027784dec5dc489eabd65b5ab17474f25fb2ce657925aa0efaa9033 SHA512 4be13e6dba298d12a4d49ae4633eec83cfaaaf22b5f8cfca5f5952aa294ae52fb3601490beed3bda5a7f7b6a5bd81e0ecc9fc39e8df836cc8fd377a0d0b783a0
 DIST ghc-bin-8.10.6-x86_64-pc-linux-gnu.tbz2 122871118 BLAKE2B 527b36abf60390c91f91bc650ee25484d39d377739da87b5b6fd1a752705c1f3bc0ce0c68644657c9a7c1fc9a3b858b9dd7d84b25eab1a89125fccb6eb1f6250 SHA512 42b7fae339e82a6078fae8920efea8d0992e4774ea66b100e22dd9df168be57d8bce52558b8501c3c567c40776389d94bde3f17d26d63535140ce26ac16c27e1
-DIST ghc-bin-8.8.4-i686-pc-linux-gnu.tbz2 120336081 BLAKE2B 55dfbb90d5e55c2af5e93c69249828a85cd9171c164b80dfdaf86512972b2c6854c8e4f07426af4ab52a5fb1a85d96a58c2cf003fb02372c55428001cfaea491 SHA512 ad3b83344349976d3253934195b2dc6299648391572b13735943c5ea2239c031c19b0cafd86c16cfb0c061e73bc72e9248f9c1731494a9a15fbe188f02913c12
-DIST ghc-bin-8.8.4-x86_64-pc-linux-gnu.tbz2 118897883 BLAKE2B a180b2dd1a3bc222044ece809ad700aee29d0c3e75b57ee9af3ca33c9c0f59dbf36f68202f746d99f80915cb717a9c41fc12db507f1cb469981732703a06b9cc SHA512 9d4be02dbd9704c93ef18feb92ea30bd5d590df31f288bf1b364818424c5019ca9ada26eec88418199f90ae8f4459d0a9352104e3f3186bbdc241891eb1b66c4
 DIST ghc-bin-9.0.2-i686-pc-linux-gnu.tbz2 123509908 BLAKE2B 45614984803a7bfa266f99d4adb4b5f2ab7b9e5e89c6ecd501296fc99a1d96e798ccb9c832f8dcb15fff9725beb918a7b63e62ff13f59b6506a2ef17930c45d2 SHA512 e0b7f4474c16f0763a2f787027fbdfeb3125b48c987fa1196bc189fefad9f0bfa2806da62af46d61ca911f5275b578076e2b326acf39e0894a8daa9deda0843a
 DIST ghc-bin-9.0.2-powerpc64le-unknown-linux-gnu.tar.gz 275228045 BLAKE2B d1c68d8396d675f5d4f3712b2ed5bc3c328a4304f9ae4441be586d24eaf3e7d34c36c6cd3bc4d85def3647919a44c3d97cf9199b43c158e3dcc6a304cfb9220b SHA512 2a277eb854b33d7361b5d93dee2747f81fc93dcc08bb3579d6706634313352675a15429eec0b6f4f19a8bd36e8f51f1c09729a2bf4a3bba34ba35dcf2b37f4e0
 DIST ghc-bin-9.0.2-x86_64-pc-linux-gnu.tbz2 121536759 BLAKE2B 4433e2d266f065d2b2944b711d622ec26288a2187ac03562257a671744b44da35110ce16ac6d76f7062a563488885326be073e0ff03c7e48250051c3b4763d96 SHA512 2de29a9ddbfd0fac797cdd628f3657ff38e6a153151849508bba75d36f84394ed77750435ff5cc1bdfcd30ef2b6e009bde965bd0a83e0496b5027239642f4b6c

diff --git a/dev-lang/ghc/files/ghc-8.0.2-no-relax-everywhere.patch b/dev-lang/ghc/files/ghc-8.0.2-no-relax-everywhere.patch
deleted file mode 100644
index d6cff3373801..000000000000
--- a/dev-lang/ghc/files/ghc-8.0.2-no-relax-everywhere.patch
+++ /dev/null
@@ -1,17 +0,0 @@
-https://github.com/gentoo-haskell/gentoo-haskell/issues/704
-
-Allow users to specify -W,--relax externally and pass
--Wl,-no-relax unconditonally on all arches.
-
-Reported-by: wmyrda
-diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs
-index acd0d61..5830517 100644
---- a/compiler/main/DriverPipeline.hs
-+++ b/compiler/main/DriverPipeline.hs
-@@ -2172,5 +2172,3 @@ joinObjectFiles dflags o_files output_fn = do
-                         -- disable --relax explicitly.
--                     ++ (if platformArch (targetPlatform dflags)
--                                `elem` [ArchSPARC, ArchSPARC64]
--                         && ldIsGnuLd
-+                     ++ (if ldIsGnuLd
-                             then [SysTools.Option "-Wl,-no-relax"]

diff --git a/dev-lang/ghc/files/ghc-8.10.4-sphinx-quote.patch b/dev-lang/ghc/files/ghc-8.10.4-sphinx-quote.patch
deleted file mode 100644
index e9517dbea06e..000000000000
--- a/dev-lang/ghc/files/ghc-8.10.4-sphinx-quote.patch
+++ /dev/null
@@ -1,27 +0,0 @@
-https://bugs.gentoo.org/792558
-
-From 83407ffc7acc00cc025b9f6ed063add9ab9f9bcc Mon Sep 17 00:00:00 2001
-From: Krzysztof Gogolewski <krzysztof.gogolewski@tweag.io>
-Date: Fri, 25 Sep 2020 02:52:19 +0200
-Subject: [PATCH] Various documentation fixes
-
-* Use r'' in conf.py. This fixes a Sphinx warning:
-  WARNING: Support for evaluating Python 2 syntax is deprecated and will be removed in Sphinx 4.0. Convert docs/users_guide/conf.py to Python 3 syntax.
---- a/docs/users_guide/conf.py
-+++ b/docs/users_guide/conf.py
-@@ -100,13 +100,13 @@ htmlhelp_basename = 'GHCUsersGuide'
- latex_elements = {
-     'inputenc': '',
-     'utf8extra': '',
--    'preamble': '''
-+    'preamble': r'''
- \usepackage{fontspec}
- \usepackage{makeidx}
- \setsansfont{DejaVu Sans}
- \setromanfont{DejaVu Serif}
- \setmonofont{DejaVu Sans Mono}
--\setlength{\\tymin}{45pt}
-+\setlength{\tymin}{45pt}
- ''',
- }
- 

diff --git a/dev-lang/ghc/files/ghc-8.4.2-allow-cross-bootstrap.patch b/dev-lang/ghc/files/ghc-8.4.2-allow-cross-bootstrap.patch
deleted file mode 100644
index 071d4970a25b..000000000000
--- a/dev-lang/ghc/files/ghc-8.4.2-allow-cross-bootstrap.patch
+++ /dev/null
@@ -1,23 +0,0 @@
-Allow using cross-compilers to bootstrap GHC.
-
-In my case I'm using "cross"-compiler from
-x86_64-unknown-linux to x86_64-HEAD-linux.
-
-Those targets have the same ABI and can boot one another.
-diff --git a/configure.ac b/configure.ac
-index a8b8681a36..791367e8bf 100644
---- a/configure.ac
-+++ b/configure.ac
-@@ -228,11 +228,11 @@ FPTOOLS_SET_PLATFORM_VARS
- if test "$BuildPlatform" != "$bootstrap_target"
- then
-     echo "This GHC (${WithGhc}) does not generate code for the build platform"
-     echo "   GHC target platform    : $bootstrap_target"
-     echo "   Desired build platform : $BuildPlatform"
--    exit 1
-+    #exit 1
- fi
- 
- # Testing if we shall enable shared libs support on Solaris.
- # Anything older than SunOS 5.11 aka Solaris 11 (Express) is broken.
- 

diff --git a/dev-lang/ghc/files/ghc-8.6.5-numa.patch b/dev-lang/ghc/files/ghc-8.6.5-numa.patch
deleted file mode 100644
index 61c6cfdbfb13..000000000000
--- a/dev-lang/ghc/files/ghc-8.6.5-numa.patch
+++ /dev/null
@@ -1,22 +0,0 @@
-Disable automagic NUMA linking.
-
-Reported-by: Sergey Alirzaev
-Bug: https://github.com/gentoo-haskell/gentoo-haskell/issues/955
---- a/configure.ac
-+++ b/configure.ac
-@@ -1264,10 +1264,14 @@ dnl ** Have libnuma?
- dnl --------------------------------------------------------------
- HaveLibNuma=0
- AC_CHECK_HEADERS([numa.h numaif.h])
--
- if test "$ac_cv_header_numa_h$ac_cv_header_numaif_h" = "yesyes" ; then
-     AC_CHECK_LIB(numa, numa_available,HaveLibNuma=1)
- fi
-+AC_ARG_ENABLE(numa,
-+    [AC_HELP_STRING([--enable-numa],
-+        [Enable NUMA thread balancing support in the runtime system via numactl's libnuma [default=auto]])])
-+AS_IF([test "x$enable_numa" = "xno"], [HaveLibNuma=0])
-+
- AC_DEFINE_UNQUOTED([HAVE_LIBNUMA], [$HaveLibNuma], [Define to 1 if you have libnuma])
- if test $HaveLibNuma = "1" ; then
-   AC_SUBST([CabalHaveLibNuma],[True])

diff --git a/dev-lang/ghc/files/ghc-8.8.4-autoconf-2.71.patch b/dev-lang/ghc/files/ghc-8.8.4-autoconf-2.71.patch
deleted file mode 100644
index 5de8c6806b79..000000000000
--- a/dev-lang/ghc/files/ghc-8.8.4-autoconf-2.71.patch
+++ /dev/null
@@ -1,22 +0,0 @@
-https://bugs.gentoo.org/829162
-https://gitlab.haskell.org/ghc/ghc/-/issues/19655
-https://gitlab.haskell.org/ghc/ghc/-/commit/ad2ef3a13f1eb000eab8e3d64592373b91a52806
-
-From: Moritz Angermann <moritz.angermann@gmail.com>
-Date: Wed, 17 Feb 2021 21:13:07 +0800
-Subject: [PATCH] [configure] Fix _AC_PROG_CC_99
-
-_AC_PROG_CC_99 isn't available anymore in recent autoconf versions.
-This broke on aarch64-darwin.
---- a/aclocal.m4
-+++ b/aclocal.m4
-@@ -659,7 +659,7 @@ AC_DEFUN([FP_SET_CFLAGS_C99],
-     CPPFLAGS="$$3"
-     unset ac_cv_prog_cc_c99
-     dnl perform detection
--    _AC_PROG_CC_C99
-+    AC_PROG_CC_C99
-     fp_cc_c99="$ac_cv_prog_cc_c99"
-     case "x$ac_cv_prog_cc_c99" in
-       x)   ;; # noop
-GitLab

diff --git a/dev-lang/ghc/ghc-8.10.4-r1.ebuild b/dev-lang/ghc/ghc-8.10.4-r1.ebuild
deleted file mode 100644
index 3ceeddccb9e8..000000000000
--- a/dev-lang/ghc/ghc-8.10.4-r1.ebuild
+++ /dev/null
@@ -1,812 +0,0 @@
-# Copyright 1999-2022 Gentoo Authors
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI=7
-
-# to make make a crosscompiler use crossdev and symlink ghc tree into
-# cross overlay. result would look like 'cross-sparc-unknown-linux-gnu/ghc'
-export CBUILD=${CBUILD:-${CHOST}}
-export CTARGET=${CTARGET:-${CHOST}}
-if [[ ${CTARGET} = ${CHOST} ]] ; then
-	if [[ ${CATEGORY/cross-} != ${CATEGORY} ]] ; then
-		export CTARGET=${CATEGORY/cross-}
-	fi
-fi
-
-PYTHON_COMPAT=( python3_{7..9} )
-inherit python-any-r1
-inherit autotools bash-completion-r1 eutils flag-o-matic ghc-package
-inherit multilib multiprocessing pax-utils toolchain-funcs prefix
-inherit check-reqs
-DESCRIPTION="The Glasgow Haskell Compiler"
-HOMEPAGE="https://www.haskell.org/ghc/"
-
-# we don't have any binaries yet
-arch_binaries=""
-
-BIN_PV=${PV}
-# sorted!
-#arch_binaries="$arch_binaries alpha? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-alpha.tbz2 )"
-#arch_binaries="$arch_binaries arm? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-armv7a-hardfloat-linux-gnueabi.tbz2 )"
-#arch_binaries="$arch_binaries arm64? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-aarch64-unknown-linux-gnu.tbz2 )"
-arch_binaries="$arch_binaries amd64? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-x86_64-pc-linux-gnu.tbz2 )"
-#arch_binaries="$arch_binaries ia64?  ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-ia64-fixed-fiw.tbz2 )"
-#arch_binaries="$arch_binaries ppc? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-ppc.tbz2 )"
-#arch_binaries="$arch_binaries ppc64? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-ppc64.tbz2 )"
-#arch_binaries="$arch_binaries ppc64? ( !big-endian? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-powerpc64le-unknown-linux-gnu.tbz2 ) )"
-#arch_binaries="$arch_binaries sparc? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-sparc.tbz2 )"
-arch_binaries="$arch_binaries x86? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-i686-pc-linux-gnu.tbz2 )"
-
-# 0 - yet
-yet_binary() {
-	case "${ARCH}" in
-		#alpha) return 0 ;;
-		#arm64) return 0 ;;
-		#arm) return 0 ;;
-		amd64) return 0 ;;
-		#ia64) return 0 ;;
-		#ppc) return 0 ;;
-		#ppc64)
-		#	use big-endian && return 0
-		#	return 0
-		#	;;
-		#sparc) return 0 ;;
-		x86) return 0 ;;
-		*) return 1 ;;
-	esac
-}
-
-GHC_PV=${PV}
-#GHC_PV=8.10.0.20200123 # uncomment only for -alpha, -beta, -rc ebuilds
-GHC_P=${PN}-${GHC_PV} # using ${P} is almost never correct
-
-SRC_URI="!binary? (
-	https://downloads.haskell.org/ghc/${PV/_/-}/${GHC_P}-src.tar.xz
-	test? ( https://downloads.haskell.org/ghc/${PV/_/-}/${GHC_P}-testsuite.tar.xz )
-)"
-S="${WORKDIR}"/${GHC_P}
-
-[[ -n $arch_binaries ]] && SRC_URI+=" !ghcbootstrap? ( $arch_binaries )"
-
-BUMP_LIBRARIES=(
-	# "hackage-name          hackage-version"
-)
-
-LICENSE="BSD"
-SLOT="0/${PV}"
-KEYWORDS="~amd64 ~x86"
-IUSE="big-endian doc elfutils ghcbootstrap ghcmakebinary +gmp numa profile test"
-IUSE+=" binary"
-RESTRICT="!test? ( test )"
-
-RDEPEND="
-	>=dev-lang/perl-5.6.1
-	dev-libs/gmp:0=
-	sys-libs/ncurses:=[unicode(+)]
-	elfutils? ( dev-libs/elfutils )
-	!ghcmakebinary? ( dev-libs/libffi:= )
-	numa? ( sys-process/numactl )
-"
-
-# This set of dependencies is needed to run
-# prebuilt ghc. We specifically avoid ncurses
-# dependency with:
-#    utils/ghc-pkg_HC_OPTS += -DBOOTSTRAPPING
-PREBUILT_BINARY_DEPENDS="
-	!prefix? ( elibc_glibc? ( >=sys-libs/glibc-2.17 ) )
-"
-# This set of dependencies is needed to install
-# ghc[binary] in system. terminfo package is linked
-# against ncurses.
-PREBUILT_BINARY_RDEPENDS="${PREBUILT_BINARY_DEPENDS}
-	sys-libs/ncurses:0/6
-"
-
-RDEPEND+="binary? ( ${PREBUILT_BINARY_RDEPENDS} )"
-
-DEPEND="${RDEPEND}"
-BDEPEND="
-	virtual/pkgconfig
-	doc? ( app-text/docbook-xml-dtd:4.2
-		app-text/docbook-xml-dtd:4.5
-		app-text/docbook-xsl-stylesheets
-		dev-python/sphinx
-		>=dev-libs/libxslt-1.1.2 )
-	!ghcbootstrap? ( ${PREBUILT_BINARY_DEPENDS} )
-	test? ( ${PYTHON_DEPS} )
-"
-
-needs_python() {
-	# test driver is written in python
-	use test && return 0
-	return 1
-}
-
-# we build binaries without profiling support
-REQUIRED_USE="
-	?? ( ghcbootstrap binary )
-	?? ( profile binary )
-"
-
-# haskell libraries built with cabal in configure mode, #515354
-QA_CONFIGURE_OPTIONS+=" --with-compiler --with-gcc"
-
-is_crosscompile() {
-	[[ ${CHOST} != ${CTARGET} ]]
-}
-
-is_native() {
-	[[ ${CHOST} == ${CBUILD} ]] && [[ ${CHOST} == ${CTARGET} ]]
-}
-
-if ! is_crosscompile; then
-	PDEPEND="!ghcbootstrap? ( >=app-admin/haskell-updater-1.2 )"
-fi
-
-# returns tool prefix for crosscompiler.
-# Example:
-#  CTARGET=armv7a-unknown-linux-gnueabi
-#  CHOST=x86_64-pc-linux-gnu
-#    "armv7a-unknown-linux-gnueabi-"
-#  CTARGET=${CHOST}
-#    ""
-# Used in tools and library prefix:
-#    "${ED}"/usr/bin/$(cross)haddock
-#    "${ED}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d"
-
-cross() {
-	if is_crosscompile; then
-		echo "${CTARGET}-"
-	else
-		echo ""
-	fi
-}
-
-append-ghc-cflags() {
-	local persistent compile assemble link
-	local flag ghcflag
-
-	for flag in $*; do
-		case ${flag} in
-			persistent)	persistent="yes";;
-			compile)	compile="yes";;
-			assemble)	assemble="yes";;
-			link)		link="yes";;
-			*)
-				[[ ${compile}  ]] && ghcflag="-optc${flag}"  CFLAGS+=" ${flag}" && GHC_FLAGS+=" ${ghcflag}" &&
-					[[ ${persistent} ]] && GHC_PERSISTENT_FLAGS+=" ${ghcflag}"
-				[[ ${assemble} ]] && ghcflag="-opta${flag}"  CFLAGS+=" ${flag}" && GHC_FLAGS+=" ${ghcflag}" &&
-					[[ ${persistent} ]] && GHC_PERSISTENT_FLAGS+=" ${ghcflag}"
-				[[ ${link}     ]] && ghcflag="-optl${flag}" LDFLAGS+=" ${flag}" && GHC_FLAGS+=" ${ghcflag}" &&
-					[[ ${persistent} ]] && GHC_PERSISTENT_FLAGS+=" ${ghcflag}"
-				;;
-		esac
-	done
-}
-
-# $1 - lib name (under libraries/)
-# $2 - lib version
-# example: bump_lib "transformers" "0.4.2.0"
-bump_lib() {
-	local pn=$1 pv=$2
-	local p=${pn}-${pv}
-	local f
-
-	einfo "Bumping ${pn} up to ${pv}"
-
-	for f in ghc.mk GNUmakefile; do
-		mv libraries/"${pn}"/$f "${WORKDIR}"/"${p}"/$f || die
-	done
-	mv libraries/"${pn}" "${WORKDIR}"/"${pn}".old || die
-	mv "${WORKDIR}"/"${p}" libraries/"${pn}" || die
-}
-
-update_SRC_URI() {
-	local p pn pv
-	for p in "${BUMP_LIBRARIES[@]}"; do
-		set -- $p
-		pn=$1 pv=$2
-
-		SRC_URI+=" https://hackage.haskell.org/package/${pn}-${pv}/${pn}-${pv}.tar.gz"
-	done
-}
-
-update_SRC_URI
-
-bump_libs() {
-	local p pn pv
-	for p in "${BUMP_LIBRARIES[@]}"; do
-		set -- $p
-		pn=$1 pv=$2
-
-		bump_lib "${pn}" "${pv}"
-	done
-}
-
-ghc_setup_cflags() {
-	# TODO: plumb CFLAGS and BUILD_CFLAGS to respective CONF_CC_OPTS_STAGE<N>
-	if ! is_native; then
-		export CFLAGS=${GHC_CFLAGS-"-O2 -pipe"}
-		export LDFLAGS=${GHC_LDFLAGS-"-Wl,-O1"}
-		einfo "Crosscompiling mode:"
-		einfo "   CHOST:   ${CHOST}"
-		einfo "   CTARGET: ${CTARGET}"
-		einfo "   CFLAGS:  ${CFLAGS}"
-		einfo "   LDFLAGS: ${LDFLAGS}"
-		einfo "   prefix: $(cross)"
-		return
-	fi
-	# We need to be very careful with the CFLAGS we ask ghc to pass through to
-	# gcc. There are plenty of flags which will make gcc produce output that
-	# breaks ghc in various ways. The main ones we want to pass through are
-	# -mcpu / -march flags. These are important for arches like alpha & sparc.
-	# We also use these CFLAGS for building the C parts of ghc, ie the rts.
-	strip-flags
-	strip-unsupported-flags
-
-	# Cmm can't parse line numbers #482086
-	replace-flags -ggdb[3-9] -ggdb2
-
-	GHC_FLAGS=""
-	GHC_PERSISTENT_FLAGS=""
-	for flag in ${CFLAGS}; do
-		case ${flag} in
-
-			# Ignore extra optimisation (ghc passes -O to gcc anyway)
-			# -O2 and above break on too many systems
-			-O*) ;;
-
-			# Arch and ABI flags are what we're really after
-			-m*) append-ghc-cflags compile assemble ${flag};;
-
-			# Sometimes it's handy to see backtrace of RTS
-			# to get an idea what happens there
-			-g*) append-ghc-cflags compile ${flag};;
-
-			# Ignore all other flags, including all -f* flags
-		esac
-	done
-
-	for flag in ${LDFLAGS}; do
-		append-ghc-cflags link ${flag}
-	done
-
-	# GHC uses ${CBUILD}-gcc, ${CHOST}-gcc and ${CTARGET}-gcc at a single build.
-	# Skip any gentoo-specific tweaks for cross-case to avoid passing unsupported
-	# options to gcc.
-	if is_native; then
-		# prevent from failing to build unregisterised ghc:
-		# https://www.mail-archive.com/debian-bugs-dist@lists.debian.org/msg171602.html
-		use ppc64 && append-ghc-cflags persistent compile -mminimal-toc
-	fi
-}
-
-# substitutes string $1 to $2 in files $3 $4 ...
-relocate_path() {
-	local from=$1
-	local   to=$2
-	shift 2
-	local file=
-	for file in "$@"
-	do
-		sed -i -e "s|$from|$to|g" \
-			"$file" || die "path relocation failed for '$file'"
-	done
-}
-
-# changes hardcoded ghc paths and updates package index
-# $1 - new absolute root path
-relocate_ghc() {
-	local to=$1 ghc_v=${BIN_PV}
-
-	# libdir for prebuilt binary and for current system may mismatch
-	# It does for prefix installation for example: bug #476998
-	local bin_ghc_prefix=${WORKDIR}/usr
-	local bin_libpath=$(echo "${bin_ghc_prefix}"/lib*)
-	local bin_libdir=${bin_libpath#${bin_ghc_prefix}/}
-
-	# backup original script to use it later after relocation
-	local gp_back="${T}/ghc-pkg-${ghc_v}-orig"
-	cp "${WORKDIR}/usr/bin/ghc-pkg-${ghc_v}" "$gp_back" || die "unable to backup ghc-pkg wrapper"
-
-	if [[ ${bin_libdir} != $(get_libdir) ]]; then
-		einfo "Relocating '${bin_libdir}' to '$(get_libdir)' (bug #476998)"
-		# moving the dir itself is not strictly needed
-		# but then USE=binary would result in installing
-		# in '${bin_libdir}'
-		mv "${bin_ghc_prefix}/${bin_libdir}" "${bin_ghc_prefix}/$(get_libdir)" || die
-
-		relocate_path "/usr/${bin_libdir}" "/usr/$(get_libdir)" \
-			"${WORKDIR}/usr/bin/ghc-${ghc_v}" \
-			"${WORKDIR}/usr/bin/ghci-${ghc_v}" \
-			"${WORKDIR}/usr/bin/ghc-pkg-${ghc_v}" \
-			"${WORKDIR}/usr/bin/hsc2hs" \
-			"${WORKDIR}/usr/bin/runghc-${ghc_v}" \
-			"$gp_back" \
-			"${WORKDIR}/usr/$(get_libdir)/${PN}-${ghc_v}/package.conf.d/"*
-	fi
-
-	# Relocate from /usr to ${EPREFIX}/usr
-	relocate_path "/usr" "${to}/usr" \
-		"${WORKDIR}/usr/bin/ghc-${ghc_v}" \
-		"${WORKDIR}/usr/bin/ghci-${ghc_v}" \
-		"${WORKDIR}/usr/bin/ghc-pkg-${ghc_v}" \
-		"${WORKDIR}/usr/bin/haddock-ghc-${ghc_v}" \
-		"${WORKDIR}/usr/bin/hp2ps" \
-		"${WORKDIR}/usr/bin/hpc" \
-		"${WORKDIR}/usr/bin/hsc2hs" \
-		"${WORKDIR}/usr/bin/runghc-${ghc_v}" \
-		"${WORKDIR}/usr/$(get_libdir)/${PN}-${ghc_v}/package.conf.d/"*
-
-	# this one we will use to regenerate cache
-	# so it should point to current tree location
-	relocate_path "/usr" "${WORKDIR}/usr" "$gp_back"
-
-	if use prefix; then
-		hprefixify "${bin_libpath}"/${PN}*/settings
-	fi
-
-	# regenerate the binary package cache
-	"$gp_back" recache || die "failed to update cache after relocation"
-	rm "$gp_back"
-}
-
-ghc-check-reqs() {
-	# These are pessimistic values (slightly bigger than worst-case)
-	# Worst case is UNREG USE=profile ia64. See bug #611866 for some
-	# numbers on various arches.
-	CHECKREQS_DISK_BUILD=8G
-	CHECKREQS_DISK_USR=2G
-	# USE=binary roughly takes
-	use binary && CHECKREQS_DISK_BUILD=4G
-
-	"$@"
-}
-
-pkg_pretend() {
-	ghc-check-reqs check-reqs_pkg_pretend
-}
-
-pkg_setup() {
-	ghc-check-reqs check-reqs_pkg_setup
-
-	# quiet portage about prebuilt binaries
-	use binary && QA_PREBUILT="*"
-
-	[[ ${MERGE_TYPE} == binary ]] && return
-
-	if use ghcbootstrap; then
-		ewarn "You requested ghc bootstrapping, this is usually only used"
-		ewarn "by Gentoo developers to make binary .tbz2 packages."
-
-		[[ -z $(type -P ghc) ]] && \
-			die "Could not find a ghc to bootstrap with."
-	else
-		if ! yet_binary; then
-			eerror "Please try emerging with USE=ghcbootstrap and report build"
-			eerror "sucess or failure to the haskell team (haskell@gentoo.org)"
-			die "No binary available for '${ARCH}' arch yet, USE=ghcbootstrap"
-		fi
-	fi
-
-	if needs_python; then
-		python-any-r1_pkg_setup
-	fi
-}
-
-src_unpack() {
-	# Create the ${S} dir if we're using the binary version
-	use binary && mkdir "${S}"
-
-	# the Solaris and Darwin binaries from ghc (maeder) need to be
-	# unpacked separately, so prevent them from being unpacked
-	local ONLYA=${A}
-	case ${CHOST} in
-		*-darwin* | *-solaris*)  ONLYA=${GHC_P}-src.tar.xz  ;;
-	esac
-	unpack ${ONLYA}
-}
-
-src_prepare() {
-	ghc_setup_cflags
-
-	if ! use ghcbootstrap && [[ ${CHOST} != *-darwin* && ${CHOST} != *-solaris* ]]; then
-		# Modify the wrapper script from the binary tarball to use GHC_PERSISTENT_FLAGS.
-		# See bug #313635.
-		sed -i -e "s|\"\$topdir\"|\"\$topdir\" ${GHC_PERSISTENT_FLAGS}|" \
-			"${WORKDIR}/usr/bin/ghc-${BIN_PV}"
-
-		# allow hardened users use vanilla binary to bootstrap ghc
-		# ghci uses mmap with rwx protection at it implements dynamic
-		# linking on it's own (bug #299709)
-		pax-mark -m "${WORKDIR}/usr/$(get_libdir)/${PN}-${BIN_PV}/bin/ghc"
-	fi
-
-	if use binary; then
-		if use prefix; then
-			relocate_ghc "${EPREFIX}"
-		fi
-
-		# Move unpacked files to the expected place
-		mv "${WORKDIR}/usr" "${S}"
-		eapply_user
-	else
-		if ! use ghcbootstrap; then
-			case ${CHOST} in
-				*-darwin* | *-solaris*)
-				# UPDATE ME for ghc-7
-				mkdir "${WORKDIR}"/ghc-bin-installer || die
-				pushd "${WORKDIR}"/ghc-bin-installer > /dev/null || die
-				use sparc-solaris && unpack ghc-6.10.4-sparc-sun-solaris2.tar.bz2
-				use x86-solaris && unpack ghc-7.0.3-i386-unknown-solaris2.tar.bz2
-				use x86-macos && unpack ghc-7.4.1-i386-apple-darwin.tar.bz2
-				use x64-macos && unpack ghc-7.4.1-x86_64-apple-darwin.tar.bz2
-				popd > /dev/null
-
-				pushd "${WORKDIR}"/ghc-bin-installer/ghc-[67].?*.? > /dev/null || die
-				# fix the binaries so they run, on Solaris we need an
-				# LD_LIBRARY_PATH which has our prefix libdirs, on
-				# Darwin we need to replace the frameworks with our libs
-				# from the prefix fix before installation, because some
-				# of the tools are actually used during configure/make
-				if [[ ${CHOST} == *-solaris* ]] ; then
-					export LD_LIBRARY_PATH="${EPREFIX}/$(get_libdir):${EPREFIX}/usr/$(get_libdir):${LD_LIBRARY_PATH}"
-				elif [[ ${CHOST} == *-darwin* ]] ; then
-					local readline_framework=GNUreadline.framework/GNUreadline
-					local gmp_framework=/opt/local/lib/libgmp.10.dylib
-					local ncurses_file=/opt/local/lib/libncurses.5.dylib
-					for binary in $(scanmacho -BRE MH_EXECUTE -F '%F' .) ; do
-						install_name_tool -change \
-							${readline_framework} \
-							"${EPREFIX}"/lib/libreadline.dylib \
-							${binary} || die
-						install_name_tool -change \
-							${gmp_framework} \
-							"${EPREFIX}"/usr/lib/libgmp.dylib \
-							${binary} || die
-						install_name_tool -change \
-							${ncurses_file} \
-							"${EPREFIX}"/usr/lib/libncurses.dylib \
-							${binary} || die
-					done
-					# we don't do frameworks!
-					sed -i \
-						-e 's/\(frameworks = \)\["GMP"\]/\1[]/g' \
-						-e 's/\(extraLibraries = \)\["m"\]/\1["m","gmp"]/g' \
-						rts/package.conf.in || die
-				fi
-
-				# it is autoconf, but we really don't want to give it too
-				# many arguments, in fact we do the make in-place anyway
-				./configure --prefix="${WORKDIR}"/usr || die
-				make install || die
-				popd > /dev/null
-				;;
-				*)
-				relocate_ghc "${WORKDIR}"
-				;;
-			esac
-		fi
-
-		sed -i -e "s|\"\$topdir\"|\"\$topdir\" ${GHC_PERSISTENT_FLAGS}|" \
-			"${S}/ghc/ghc.wrapper"
-
-		cd "${S}" # otherwise eapply will break
-
-		eapply "${FILESDIR}"/${PN}-7.0.4-CHOST-prefix.patch
-		eapply "${FILESDIR}"/${PN}-8.2.1-darwin.patch
-		eapply "${FILESDIR}"/${PN}-7.8.3-prim-lm.patch
-		eapply "${FILESDIR}"/${PN}-8.8.1-revert-CPP.patch
-		eapply "${FILESDIR}"/${PN}-8.10.1-allow-cross-bootstrap.patch
-		eapply "${FILESDIR}"/${PN}-8.10.3-C99-typo-ac270.patch
-		eapply "${FILESDIR}"/${PN}-8.10.4-sphinx-quote.patch
-
-		# a bunch of crosscompiler patches
-		# needs newer version:
-		#eapply "${FILESDIR}"/${PN}-8.2.1_rc1-hp2ps-cross.patch
-
-		# mingw32 target
-		pushd "${S}/libraries/Win32"
-			eapply "${FILESDIR}"/${PN}-8.2.1_rc1-win32-cross-2-hack.patch # bad workaround
-		popd
-
-		bump_libs
-
-		eapply_user
-		# as we have changed the build system
-		eautoreconf
-	fi
-}
-
-src_configure() {
-	if ! use binary; then
-		# initialize build.mk
-		echo '# Gentoo changes' > mk/build.mk
-
-		# Put docs into the right place, ie /usr/share/doc/ghc-${GHC_PV}
-		echo "docdir = ${EPREFIX}/usr/share/doc/$(cross)${PF}" >> mk/build.mk
-		echo "htmldir = ${EPREFIX}/usr/share/doc/$(cross)${PF}" >> mk/build.mk
-
-		# We also need to use the GHC_FLAGS flags when building ghc itself
-		echo "SRC_HC_OPTS+=${HCFLAGS} ${GHC_FLAGS}" >> mk/build.mk
-		echo "SRC_CC_OPTS+=${CFLAGS}" >> mk/build.mk
-		echo "SRC_LD_OPTS+=${LDFLAGS}" >> mk/build.mk
-		# Speed up initial Cabal bootstrap
-		echo "utils/ghc-cabal_dist_EXTRA_HC_OPTS+=$(ghc-make-args)" >> mk/build.mk
-
-		# We can't depend on haddock except when bootstrapping when we
-		# must build docs and include them into the binary .tbz2 package
-		# app-text/dblatex is not in portage, can not build PDF or PS
-		echo "BUILD_SPHINX_PDF  = NO"  >> mk/build.mk
-		echo "BUILD_SPHINX_HTML = $(usex doc YES NO)" >> mk/build.mk
-		echo "BUILD_MAN = $(usex doc YES NO)" >> mk/build.mk
-
-		# this controls presence on 'xhtml' and 'haddock' in final install
-		echo "HADDOCK_DOCS       = YES" >> mk/build.mk
-
-		# not used outside of ghc's test
-		if [[ -n ${GHC_BUILD_DPH} ]]; then
-				echo "BUILD_DPH = YES" >> mk/build.mk
-			else
-				echo "BUILD_DPH = NO" >> mk/build.mk
-		fi
-
-		# Any non-native build has to skip as it needs
-		# target haddock binary to be runnabine.
-		if ! is_native; then
-			# disable docs generation as it requires running stage2
-			echo "HADDOCK_DOCS=NO" >> mk/build.mk
-			echo "BUILD_SPHINX_HTML=NO" >> mk/build.mk
-			echo "BUILD_SPHINX_PDF=NO" >> mk/build.mk
-		fi
-
-		if is_crosscompile; then
-			# Install ghc-stage1 crosscompiler instead of
-			# ghc-stage2 cross-built compiler.
-			echo "Stage1Only=YES" >> mk/build.mk
-		fi
-
-		# allows overriding build flavours for libraries:
-		# v   - vanilla (static libs)
-		# p   - profiled
-		# dyn - shared libraries
-		# example: GHC_LIBRARY_WAYS="v dyn"
-		if [[ -n ${GHC_LIBRARY_WAYS} ]]; then
-			echo "GhcLibWays=${GHC_LIBRARY_WAYS}" >> mk/build.mk
-		fi
-		echo "BUILD_PROF_LIBS = $(usex profile YES NO)" >> mk/build.mk
-
-		# Get ghc from the unpacked binary .tbz2
-		# except when bootstrapping we just pick ghc up off the path
-		if ! use ghcbootstrap; then
-			export PATH="${WORKDIR}/usr/bin:${PATH}"
-		fi
-
-		echo "INTEGER_LIBRARY = $(usex gmp integer-gmp integer-simple)" >> mk/build.mk
-
-		# don't strip anything. Very useful when stage2 SIGSEGVs on you
-		echo "STRIP_CMD = :" >> mk/build.mk
-
-		local econf_args=()
-
-		# GHC embeds toolchain it was built by and uses it later.
-		# Don't allow things like ccache or versioned binary slip.
-		# We use stable thing across gcc upgrades.
-		# User can use EXTRA_ECONF=CC=... to override this default.
-		econf_args+=(
-			AR=${CTARGET}-ar
-			CC=${CTARGET}-gcc
-			# these should be inferred by GHC but ghc defaults
-			# to using bundled tools on windows.
-			Windres=${CTARGET}-windres
-			DllWrap=${CTARGET}-dllwrap
-			# we set the linker explicitly below
-			--disable-ld-override
-		)
-		case ${CTARGET} in
-			arm*)
-				# ld.bfd-2.28 does not work for ghc. Force ld.gold
-				# instead. This should be removed once gentoo gets
-				# a fix for R_ARM_COPY bug: https://sourceware.org/PR16177
-				econf_args+=(LD=${CTARGET}-ld.gold)
-			;;
-			sparc*)
-				# ld.gold-2.28 does not work for ghc. Force ld.bfd
-				# instead. This should be removed once gentoo gets
-				# a fix for missing --no-relax support bug:
-				# https://sourceware.org/ml/binutils/2017-07/msg00183.html
-				econf_args+=(LD=${CTARGET}-ld.bfd)
-			;;
-			*)
-				econf_args+=(LD=${CTARGET}-ld)
-		esac
-
-		if [[ ${CBUILD} != ${CHOST} ]]; then
-			# GHC bug: ghc claims not to support cross-building.
-			# It does, but does not distinct --host= value
-			# for stage1 and stage2 compiler.
-			econf_args+=(--host=${CBUILD})
-		fi
-
-		if use ghcmakebinary; then
-			# When building booting libary we are trying to
-			# bundle or restrict most of external depends
-			# with unstable ABI:
-			#  - embed libffi (default GHC behaviour)
-			#  - disable ncurses support for ghci (via haskeline)
-			#    https://bugs.gentoo.org/557478
-			#  - disable ncurses support for ghc-pkg
-			echo "libraries/haskeline_CONFIGURE_OPTS += --flag=-terminfo" >> mk/build.mk
-			echo "utils/ghc-pkg_HC_OPTS += -DBOOTSTRAPPING" >> mk/build.mk
-		elif is_native; then
-			# using ${GTARGET}'s libffi is not supported yet:
-			# GHC embeds full path for ffi includes without /usr/${CTARGET} account.
-			econf_args+=(--with-system-libffi)
-			econf_args+=(--with-ffi-includes=$($(tc-getPKG_CONFIG) libffi --cflags-only-I | sed -e 's@^-I@@'))
-		fi
-
-		einfo "Final mk/build.mk:"
-		cat mk/build.mk || die
-
-		econf ${econf_args[@]} \
-			--enable-bootstrap-with-devel-snapshot \
-			$(use_enable elfutils dwarf-unwind) \
-			$(use_enable numa)
-
-		if [[ ${PV} == *9999* ]]; then
-			GHC_PV="$(grep 'S\[\"PACKAGE_VERSION\"\]' config.status | sed -e 's@^.*=\"\(.*\)\"@\1@')"
-			GHC_P=${PN}-${GHC_PV}
-		fi
-	fi # ! use binary
-}
-
-src_compile() {
-	if ! use binary; then
-		# Stage1Only crosscompiler does not build stage2
-		if ! is_crosscompile; then
-			# 1. build/pax-mark compiler binary first
-			emake ghc/stage2/build/tmp/ghc-stage2
-			# 2. pax-mark (bug #516430)
-			pax-mark -m ghc/stage2/build/tmp/ghc-stage2
-			# 2. build/pax-mark haddock using ghc-stage2
-			if is_native; then
-				# non-native build does not build haddock
-				# due to HADDOCK_DOCS=NO, but it could.
-				emake utils/haddock/dist/build/tmp/haddock
-				pax-mark -m utils/haddock/dist/build/tmp/haddock
-			fi
-		fi
-		# 3. and then all the rest
-		emake all
-	fi # ! use binary
-}
-
-src_test() {
-	# TODO: deal with:
-	#    - sandbox (pollutes environment)
-	#    - extra packages (to extend testsuite coverage)
-	# bits are taken from 'validate'
-	local make_test_target='test' # can be fulltest
-	# not 'emake' as testsuite uses '$MAKE' without jobserver available
-	make $make_test_target stage=2 THREADS=$(makeopts_jobs)
-}
-
-src_install() {
-	if use binary; then
-		use prefix && mkdir -p "${ED}"
-		mv "${S}/usr" "${ED}"
-	else
-		[[ -f VERSION ]] || emake VERSION
-
-		# -j1 due to a rare race in install script:
-		#    make --no-print-directory -f ghc.mk phase=final install
-		#    /usr/lib/portage/python3.4/ebuild-helpers/xattr/install -c -m 755 \
-		#        -d "/tmp/portage-tmpdir/portage/cross-armv7a-unknown-linux-gnueabi/ghc-9999/image/usr/lib64/armv7a-unknown-linux-gnueabi-ghc-8.3.20170404/include"
-		#    /usr/lib/portage/python3.4/ebuild-helpers/xattr/install -c -m 644  utils/hsc2hs/template-hsc.h \
-		#           "/tmp/portage-tmpdir/portage/cross-armv7a-unknown-linux-gnueabi/ghc-9999/image/usr/lib64/armv7a-unknown-linux-gnueabi-ghc-8.3.20170404"
-		#    /usr/bin/install: cannot create regular file \
-		#           '/tmp/portage-tmpdir/portage/cross-armv7a-unknown-linux-gnueabi/ghc-9999/image/usr/lib64/armv7a-unknown-linux-gnueabi-ghc-8.3.20170404': No such file or directory
-		emake -j1 install DESTDIR="${D}"
-
-		# Skip for cross-targets as they all share target location:
-		# /usr/share/doc/ghc-9999/
-		if ! is_crosscompile; then
-			dodoc "distrib/README" "LICENSE" "VERSION"
-		fi
-
-		# rename ghc-shipped files to avoid collision
-		# of external packages. Motivating example:
-		#  user had installed:
-		#      dev-lang/ghc-7.8.4-r0 (with transformers-0.3.0.0)
-		#      dev-haskell/transformers-0.4.2.0
-		#  then user tried to update to
-		#      dev-lang/ghc-7.8.4-r1 (with transformers-0.4.2.0)
-		#  this will lead to single .conf file collision.
-		local shipped_conf renamed_conf
-		local package_confdir="${ED}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d"
-		for shipped_conf in "${package_confdir}"/*.conf; do
-			# rename 'pkg-ver-id.conf' to 'pkg-ver-id-gentoo-${PF}.conf'
-			renamed_conf=${shipped_conf%.conf}-gentoo-${PF}.conf
-			mv "${shipped_conf}" "${renamed_conf}" || die
-		done
-
-		# remove link, but leave 'haddock-${GHC_P}'
-		rm -f "${ED}"/usr/bin/$(cross)haddock
-
-		if ! is_crosscompile; then
-			newbashcomp "${FILESDIR}"/ghc-bash-completion ghc-pkg
-			newbashcomp utils/completion/ghc.bash         ghc
-		fi
-	fi
-
-	# path to the package.cache
-	local package_confdir="${ED}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d"
-	PKGCACHE="${package_confdir}"/package.cache
-	# copy the package.conf.d, including timestamp, save it so we can help
-	# users that have a broken package.conf.d
-	cp -pR "${package_confdir}"{,.initial} || die "failed to backup intial package.conf.d"
-
-	# copy the package.conf, including timestamp, save it so we later can put it
-	# back before uninstalling, or when upgrading.
-	cp -p "${PKGCACHE}"{,.shipped} \
-		|| die "failed to copy package.conf.d/package.cache"
-
-	if is_crosscompile; then
-		# When we build a cross-compiler the layout is the following:
-		#     usr/lib/${CTARGET}-ghc-${VER}/ contains target libraries
-		# but
-		#     usr/lib/${CTARGET}-ghc-${VER}/bin/ directory
-		# containst host binaries (modulo bugs).
-
-		# Portage's stripping mechanism does not skip stripping
-		# foreign binaries. This frequently causes binaries to be
-		# broken.
-		#
-		# Thus below we disable stripping of target libraries and allow
-		# stripping hosts executables.
-		dostrip -x "/usr/$(get_libdir)/$(cross)${GHC_P}"
-		dostrip    "/usr/$(get_libdir)/$(cross)${GHC_P}/bin"
-	fi
-}
-
-pkg_preinst() {
-	# have we got an earlier version of ghc installed?
-	if has_version "<${CATEGORY}/${PF}"; then
-		haskell_updater_warn="1"
-	fi
-}
-
-pkg_postinst() {
-	ghc-reregister
-
-	# path to the package.cache
-	PKGCACHE="${EROOT}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d/package.cache"
-
-	# give the cache a new timestamp, it must be as recent as
-	# the package.conf.d directory.
-	touch "${PKGCACHE}"
-
-	if [[ "${haskell_updater_warn}" == "1" ]]; then
-		ewarn
-		ewarn "\e[1;31m************************************************************************\e[0m"
-		ewarn
-		ewarn "You have just upgraded from an older version of GHC."
-		ewarn "You may have to run"
-		ewarn "      'haskell-updater'"
-		ewarn "to rebuild all ghc-based Haskell libraries."
-		ewarn
-		ewarn "\e[1;31m************************************************************************\e[0m"
-		ewarn
-	fi
-}
-
-pkg_prerm() {
-	PKGCACHE="${EROOT}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d/package.cache"
-	rm -rf "${PKGCACHE}"
-
-	cp -p "${PKGCACHE}"{.shipped,}
-}
-
-pkg_postrm() {
-	ghc-package_pkg_postrm
-}

diff --git a/dev-lang/ghc/ghc-8.8.4-r1.ebuild b/dev-lang/ghc/ghc-8.8.4-r1.ebuild
deleted file mode 100644
index 7cb29d4a740c..000000000000
--- a/dev-lang/ghc/ghc-8.8.4-r1.ebuild
+++ /dev/null
@@ -1,824 +0,0 @@
-# Copyright 1999-2022 Gentoo Authors
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI=7
-
-# to make make a crosscompiler use crossdev and symlink ghc tree into
-# cross overlay. result would look like 'cross-sparc-unknown-linux-gnu/ghc'
-export CBUILD=${CBUILD:-${CHOST}}
-export CTARGET=${CTARGET:-${CHOST}}
-if [[ ${CTARGET} = ${CHOST} ]] ; then
-	if [[ ${CATEGORY/cross-} != ${CATEGORY} ]] ; then
-		export CTARGET=${CATEGORY/cross-}
-	fi
-fi
-
-PYTHON_COMPAT=( python3_{7..9} )
-inherit python-any-r1
-inherit autotools bash-completion-r1 eutils flag-o-matic ghc-package
-inherit multilib multiprocessing pax-utils toolchain-funcs prefix
-inherit check-reqs
-DESCRIPTION="The Glasgow Haskell Compiler"
-HOMEPAGE="https://www.haskell.org/ghc/"
-
-# we don't have any binaries yet
-arch_binaries=""
-
-BIN_PV=${PV}
-# sorted!
-#arch_binaries="$arch_binaries alpha? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-alpha.tbz2 )"
-#arch_binaries="$arch_binaries arm? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-armv7a-hardfloat-linux-gnueabi.tbz2 )"
-#arch_binaries="$arch_binaries arm64? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-aarch64-unknown-linux-gnu.tbz2 )"
-arch_binaries="$arch_binaries amd64? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-x86_64-pc-linux-gnu.tbz2 )"
-#arch_binaries="$arch_binaries ia64?  ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-ia64-fixed-fiw.tbz2 )"
-#arch_binaries="$arch_binaries ppc? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-ppc.tbz2 )"
-#arch_binaries="$arch_binaries ppc64? ( !big-endian? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-powerpc64le-unknown-linux-gnu.tbz2 ) )"
-#arch_binaries="$arch_binaries sparc? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-sparc.tbz2 )"
-arch_binaries="$arch_binaries x86? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-i686-pc-linux-gnu.tbz2 )"
-
-# 0 - yet
-yet_binary() {
-	case "${ARCH}" in
-		#alpha) return 0 ;;
-		#arm64) return 0 ;;
-		#arm) return 0 ;;
-		amd64) return 0 ;;
-		#ia64) return 0 ;;
-		#ppc) return 0 ;;
-		#ppc64)
-		#	use big-endian && return 1
-		#	return 0
-		#	;;
-		#sparc) return 0 ;;
-		x86) return 0 ;;
-		*) return 1 ;;
-	esac
-}
-
-GHC_PV=${PV}
-#GHC_PV=8.6.0.20180810 # uncomment only for -alpha, -beta, -rc ebuilds
-GHC_P=${PN}-${GHC_PV} # using ${P} is almost never correct
-
-SRC_URI="!binary? (
-	https://downloads.haskell.org/~ghc/${PV/_/-}/${GHC_P}-src.tar.xz
-	test? ( https://downloads.haskell.org/~ghc/${PV/_/-}/${GHC_P}-testsuite.tar.xz )
-)"
-S="${WORKDIR}"/${GHC_P}
-
-[[ -n $arch_binaries ]] && SRC_URI+=" !ghcbootstrap? ( $arch_binaries )"
-
-BUMP_LIBRARIES=(
-	# "hackage-name          hackage-version"
-)
-
-LICENSE="BSD"
-SLOT="0/${PV}"
-KEYWORDS="~amd64 ~x86"
-IUSE="big-endian doc elfutils ghcbootstrap ghcmakebinary +gmp numa profile test"
-IUSE+=" binary"
-RESTRICT="!test? ( test )"
-
-RDEPEND="
-	>=dev-lang/perl-5.6.1
-	dev-libs/gmp:0=
-	sys-libs/ncurses:=[unicode(+)]
-	elfutils? ( dev-libs/elfutils )
-	!ghcmakebinary? ( dev-libs/libffi:= )
-	numa? ( sys-process/numactl )
-"
-
-# This set of dependencies is needed to run
-# prebuilt ghc. We specifically avoid ncurses
-# dependency with:
-#    utils/ghc-pkg_HC_OPTS += -DBOOTSTRAPPING
-PREBUILT_BINARY_DEPENDS="
-	!prefix? ( elibc_glibc? ( >=sys-libs/glibc-2.17 ) )
-"
-# This set of dependencies is needed to install
-# ghc[binary] in system. terminfo package is linked
-# against ncurses.
-PREBUILT_BINARY_RDEPENDS="${PREBUILT_BINARY_DEPENDS}
-	sys-libs/ncurses:0/6
-"
-
-RDEPEND+="binary? ( ${PREBUILT_BINARY_RDEPENDS} )"
-
-DEPEND="${RDEPEND}"
-BDEPEND="
-	virtual/pkgconfig
-	doc? ( app-text/docbook-xml-dtd:4.2
-		app-text/docbook-xml-dtd:4.5
-		app-text/docbook-xsl-stylesheets
-		dev-python/sphinx
-		>=dev-libs/libxslt-1.1.2 )
-	!ghcbootstrap? ( ${PREBUILT_BINARY_DEPENDS} )
-	test? ( ${PYTHON_DEPS} )
-"
-
-needs_python() {
-	# test driver is written in python
-	use test && return 0
-	return 1
-}
-
-# we build binaries without profiling support
-REQUIRED_USE="
-	?? ( ghcbootstrap binary )
-	?? ( profile binary )
-"
-
-# haskell libraries built with cabal in configure mode, #515354
-QA_CONFIGURE_OPTIONS+=" --with-compiler --with-gcc"
-
-is_crosscompile() {
-	[[ ${CHOST} != ${CTARGET} ]]
-}
-
-is_native() {
-	[[ ${CHOST} == ${CBUILD} ]] && [[ ${CHOST} == ${CTARGET} ]]
-}
-
-if ! is_crosscompile; then
-	PDEPEND="!ghcbootstrap? ( >=app-admin/haskell-updater-1.2 )"
-fi
-
-# returns tool prefix for crosscompiler.
-# Example:
-#  CTARGET=armv7a-unknown-linux-gnueabi
-#  CHOST=x86_64-pc-linux-gnu
-#    "armv7a-unknown-linux-gnueabi-"
-#  CTARGET=${CHOST}
-#    ""
-# Used in tools and library prefix:
-#    "${ED}"/usr/bin/$(cross)haddock
-#    "${ED}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d"
-
-cross() {
-	if is_crosscompile; then
-		echo "${CTARGET}-"
-	else
-		echo ""
-	fi
-}
-
-append-ghc-cflags() {
-	local persistent compile assemble link
-	local flag ghcflag
-
-	for flag in $*; do
-		case ${flag} in
-			persistent)	persistent="yes";;
-			compile)	compile="yes";;
-			assemble)	assemble="yes";;
-			link)		link="yes";;
-			*)
-				[[ ${compile}  ]] && ghcflag="-optc${flag}"  CFLAGS+=" ${flag}" && GHC_FLAGS+=" ${ghcflag}" &&
-					[[ ${persistent} ]] && GHC_PERSISTENT_FLAGS+=" ${ghcflag}"
-				[[ ${assemble} ]] && ghcflag="-opta${flag}"  CFLAGS+=" ${flag}" && GHC_FLAGS+=" ${ghcflag}" &&
-					[[ ${persistent} ]] && GHC_PERSISTENT_FLAGS+=" ${ghcflag}"
-				[[ ${link}     ]] && ghcflag="-optl${flag}" LDFLAGS+=" ${flag}" && GHC_FLAGS+=" ${ghcflag}" &&
-					[[ ${persistent} ]] && GHC_PERSISTENT_FLAGS+=" ${ghcflag}"
-				;;
-		esac
-	done
-}
-
-# $1 - lib name (under libraries/)
-# $2 - lib version
-# example: bump_lib "transformers" "0.4.2.0"
-bump_lib() {
-	local pn=$1 pv=$2
-	local p=${pn}-${pv}
-	local f
-
-	einfo "Bumping ${pn} up to ${pv}"
-
-	for f in ghc.mk GNUmakefile; do
-		mv libraries/"${pn}"/$f "${WORKDIR}"/"${p}"/$f || die
-	done
-	mv libraries/"${pn}" "${WORKDIR}"/"${pn}".old || die
-	mv "${WORKDIR}"/"${p}" libraries/"${pn}" || die
-}
-
-update_SRC_URI() {
-	local p pn pv
-	for p in "${BUMP_LIBRARIES[@]}"; do
-		set -- $p
-		pn=$1 pv=$2
-
-		SRC_URI+=" https://hackage.haskell.org/package/${pn}-${pv}/${pn}-${pv}.tar.gz"
-	done
-}
-
-update_SRC_URI
-
-bump_libs() {
-	local p pn pv
-	for p in "${BUMP_LIBRARIES[@]}"; do
-		set -- $p
-		pn=$1 pv=$2
-
-		bump_lib "${pn}" "${pv}"
-	done
-}
-
-ghc_setup_cflags() {
-	# TODO: plumb CFLAGS and BUILD_CFLAGS to respective CONF_CC_OPTS_STAGE<N>
-	if ! is_native; then
-		export CFLAGS=${GHC_CFLAGS-"-O2 -pipe"}
-		export LDFLAGS=${GHC_LDFLAGS-"-Wl,-O1"}
-		einfo "Crosscompiling mode:"
-		einfo "   CHOST:   ${CHOST}"
-		einfo "   CTARGET: ${CTARGET}"
-		einfo "   CFLAGS:  ${CFLAGS}"
-		einfo "   LDFLAGS: ${LDFLAGS}"
-		einfo "   prefix: $(cross)"
-		return
-	fi
-	# We need to be very careful with the CFLAGS we ask ghc to pass through to
-	# gcc. There are plenty of flags which will make gcc produce output that
-	# breaks ghc in various ways. The main ones we want to pass through are
-	# -mcpu / -march flags. These are important for arches like alpha & sparc.
-	# We also use these CFLAGS for building the C parts of ghc, ie the rts.
-	strip-flags
-	strip-unsupported-flags
-
-	# Cmm can't parse line numbers #482086
-	replace-flags -ggdb[3-9] -ggdb2
-
-	GHC_FLAGS=""
-	GHC_PERSISTENT_FLAGS=""
-	for flag in ${CFLAGS}; do
-		case ${flag} in
-
-			# Ignore extra optimisation (ghc passes -O to gcc anyway)
-			# -O2 and above break on too many systems
-			-O*) ;;
-
-			# Arch and ABI flags are what we're really after
-			-m*) append-ghc-cflags compile assemble ${flag};;
-
-			# Sometimes it's handy to see backtrace of RTS
-			# to get an idea what happens there
-			-g*) append-ghc-cflags compile ${flag};;
-
-			# Ignore all other flags, including all -f* flags
-		esac
-	done
-
-	for flag in ${LDFLAGS}; do
-		append-ghc-cflags link ${flag}
-	done
-
-	# GHC uses ${CBUILD}-gcc, ${CHOST}-gcc and ${CTARGET}-gcc at a single build.
-	# Skip any gentoo-specific tweaks for cross-case to avoid passing unsupported
-	# options to gcc.
-	if is_native; then
-		# hardened-gcc needs to be disabled, because our prebuilt binaries/libraries
-		# are not built with fPIC, bug #606666
-		gcc-specs-pie && append-ghc-cflags persistent compile link -nopie
-		tc-is-gcc && ver_test $(gcc-version) -ge 6.3 && if ! use ghcbootstrap; then
-			# gcc-6.3 has support for -no-pie upstream, but spelling differs from
-			# gentoo-specific '-nopie'. We enable it in non-bootstrap to allow
-			# hardened users try '-pie' in USE=ghcbootstrap mode.
-			append-ghc-cflags compile link -no-pie
-		fi
-
-		# prevent from failing to build unregisterised ghc:
-		# https://www.mail-archive.com/debian-bugs-dist@lists.debian.org/msg171602.html
-		use ppc64 && append-ghc-cflags persistent compile -mminimal-toc
-	fi
-}
-
-# substitutes string $1 to $2 in files $3 $4 ...
-relocate_path() {
-	local from=$1
-	local   to=$2
-	shift 2
-	local file=
-	for file in "$@"
-	do
-		sed -i -e "s|$from|$to|g" \
-			"$file" || die "path relocation failed for '$file'"
-	done
-}
-
-# changes hardcoded ghc paths and updates package index
-# $1 - new absolute root path
-relocate_ghc() {
-	local to=$1 ghc_v=${BIN_PV}
-
-	# libdir for prebuilt binary and for current system may mismatch
-	# It does for prefix installation for example: bug #476998
-	local bin_ghc_prefix=${WORKDIR}/usr
-	local bin_libpath=$(echo "${bin_ghc_prefix}"/lib*)
-	local bin_libdir=${bin_libpath#${bin_ghc_prefix}/}
-
-	# backup original script to use it later after relocation
-	local gp_back="${T}/ghc-pkg-${ghc_v}-orig"
-	cp "${WORKDIR}/usr/bin/ghc-pkg-${ghc_v}" "$gp_back" || die "unable to backup ghc-pkg wrapper"
-
-	if [[ ${bin_libdir} != $(get_libdir) ]]; then
-		einfo "Relocating '${bin_libdir}' to '$(get_libdir)' (bug #476998)"
-		# moving the dir itself is not strictly needed
-		# but then USE=binary would result in installing
-		# in '${bin_libdir}'
-		mv "${bin_ghc_prefix}/${bin_libdir}" "${bin_ghc_prefix}/$(get_libdir)" || die
-
-		relocate_path "/usr/${bin_libdir}" "/usr/$(get_libdir)" \
-			"${WORKDIR}/usr/bin/ghc-${ghc_v}" \
-			"${WORKDIR}/usr/bin/ghci-${ghc_v}" \
-			"${WORKDIR}/usr/bin/ghc-pkg-${ghc_v}" \
-			"${WORKDIR}/usr/bin/hsc2hs" \
-			"${WORKDIR}/usr/bin/runghc-${ghc_v}" \
-			"$gp_back" \
-			"${WORKDIR}/usr/$(get_libdir)/${PN}-${ghc_v}/package.conf.d/"*
-	fi
-
-	# Relocate from /usr to ${EPREFIX}/usr
-	relocate_path "/usr" "${to}/usr" \
-		"${WORKDIR}/usr/bin/ghc-${ghc_v}" \
-		"${WORKDIR}/usr/bin/ghci-${ghc_v}" \
-		"${WORKDIR}/usr/bin/ghc-pkg-${ghc_v}" \
-		"${WORKDIR}/usr/bin/haddock-ghc-${ghc_v}" \
-		"${WORKDIR}/usr/bin/hp2ps" \
-		"${WORKDIR}/usr/bin/hpc" \
-		"${WORKDIR}/usr/bin/hsc2hs" \
-		"${WORKDIR}/usr/bin/runghc-${ghc_v}" \
-		"${WORKDIR}/usr/$(get_libdir)/${PN}-${ghc_v}/package.conf.d/"*
-
-	# this one we will use to regenerate cache
-	# so it should point to current tree location
-	relocate_path "/usr" "${WORKDIR}/usr" "$gp_back"
-
-	if use prefix; then
-		hprefixify "${bin_libpath}"/${PN}*/settings
-	fi
-
-	# regenerate the binary package cache
-	"$gp_back" recache || die "failed to update cache after relocation"
-	rm "$gp_back"
-}
-
-ghc-check-reqs() {
-	# These are pessimistic values (slightly bigger than worst-case)
-	# Worst case is UNREG USE=profile ia64. See bug #611866 for some
-	# numbers on various arches.
-	CHECKREQS_DISK_BUILD=8G
-	CHECKREQS_DISK_USR=2G
-	# USE=binary roughly takes
-	use binary && CHECKREQS_DISK_BUILD=4G
-
-	"$@"
-}
-
-pkg_pretend() {
-	ghc-check-reqs check-reqs_pkg_pretend
-}
-
-pkg_setup() {
-	ghc-check-reqs check-reqs_pkg_setup
-
-	# quiet portage about prebuilt binaries
-	use binary && QA_PREBUILT="*"
-
-	[[ ${MERGE_TYPE} == binary ]] && return
-
-	if use ghcbootstrap; then
-		ewarn "You requested ghc bootstrapping, this is usually only used"
-		ewarn "by Gentoo developers to make binary .tbz2 packages."
-
-		[[ -z $(type -P ghc) ]] && \
-			die "Could not find a ghc to bootstrap with."
-	else
-		if ! yet_binary; then
-			eerror "Please try emerging with USE=ghcbootstrap and report build"
-			eerror "sucess or failure to the haskell team (haskell@gentoo.org)"
-			die "No binary available for '${ARCH}' arch yet, USE=ghcbootstrap"
-		fi
-	fi
-
-	if needs_python; then
-		python-any-r1_pkg_setup
-	fi
-}
-
-src_unpack() {
-	# Create the ${S} dir if we're using the binary version
-	use binary && mkdir "${S}"
-
-	# the Solaris and Darwin binaries from ghc (maeder) need to be
-	# unpacked separately, so prevent them from being unpacked
-	local ONLYA=${A}
-	case ${CHOST} in
-		*-darwin* | *-solaris*)  ONLYA=${GHC_P}-src.tar.xz  ;;
-	esac
-	unpack ${ONLYA}
-}
-
-src_prepare() {
-	ghc_setup_cflags
-
-	if ! use ghcbootstrap && [[ ${CHOST} != *-darwin* && ${CHOST} != *-solaris* ]]; then
-		# Modify the wrapper script from the binary tarball to use GHC_PERSISTENT_FLAGS.
-		# See bug #313635.
-		sed -i -e "s|\"\$topdir\"|\"\$topdir\" ${GHC_PERSISTENT_FLAGS}|" \
-			"${WORKDIR}/usr/bin/ghc-${BIN_PV}"
-
-		# allow hardened users use vanilla binary to bootstrap ghc
-		# ghci uses mmap with rwx protection at it implements dynamic
-		# linking on it's own (bug #299709)
-		pax-mark -m "${WORKDIR}/usr/$(get_libdir)/${PN}-${BIN_PV}/bin/ghc"
-	fi
-
-	if use binary; then
-		if use prefix; then
-			relocate_ghc "${EPREFIX}"
-		fi
-
-		# Move unpacked files to the expected place
-		mv "${WORKDIR}/usr" "${S}"
-		eapply_user
-	else
-		if ! use ghcbootstrap; then
-			case ${CHOST} in
-				*-darwin* | *-solaris*)
-				# UPDATE ME for ghc-7
-				mkdir "${WORKDIR}"/ghc-bin-installer || die
-				pushd "${WORKDIR}"/ghc-bin-installer > /dev/null || die
-				use sparc-solaris && unpack ghc-6.10.4-sparc-sun-solaris2.tar.bz2
-				use x86-solaris && unpack ghc-7.0.3-i386-unknown-solaris2.tar.bz2
-				use x86-macos && unpack ghc-7.4.1-i386-apple-darwin.tar.bz2
-				use x64-macos && unpack ghc-7.4.1-x86_64-apple-darwin.tar.bz2
-				popd > /dev/null
-
-				pushd "${WORKDIR}"/ghc-bin-installer/ghc-[67].?*.? > /dev/null || die
-				# fix the binaries so they run, on Solaris we need an
-				# LD_LIBRARY_PATH which has our prefix libdirs, on
-				# Darwin we need to replace the frameworks with our libs
-				# from the prefix fix before installation, because some
-				# of the tools are actually used during configure/make
-				if [[ ${CHOST} == *-solaris* ]] ; then
-					export LD_LIBRARY_PATH="${EPREFIX}/$(get_libdir):${EPREFIX}/usr/$(get_libdir):${LD_LIBRARY_PATH}"
-				elif [[ ${CHOST} == *-darwin* ]] ; then
-					local readline_framework=GNUreadline.framework/GNUreadline
-					local gmp_framework=/opt/local/lib/libgmp.10.dylib
-					local ncurses_file=/opt/local/lib/libncurses.5.dylib
-					for binary in $(scanmacho -BRE MH_EXECUTE -F '%F' .) ; do
-						install_name_tool -change \
-							${readline_framework} \
-							"${EPREFIX}"/lib/libreadline.dylib \
-							${binary} || die
-						install_name_tool -change \
-							${gmp_framework} \
-							"${EPREFIX}"/usr/lib/libgmp.dylib \
-							${binary} || die
-						install_name_tool -change \
-							${ncurses_file} \
-							"${EPREFIX}"/usr/lib/libncurses.dylib \
-							${binary} || die
-					done
-					# we don't do frameworks!
-					sed -i \
-						-e 's/\(frameworks = \)\["GMP"\]/\1[]/g' \
-						-e 's/\(extraLibraries = \)\["m"\]/\1["m","gmp"]/g' \
-						rts/package.conf.in || die
-				fi
-
-				# it is autoconf, but we really don't want to give it too
-				# many arguments, in fact we do the make in-place anyway
-				./configure --prefix="${WORKDIR}"/usr || die
-				make install || die
-				popd > /dev/null
-				;;
-				*)
-				relocate_ghc "${WORKDIR}"
-				;;
-			esac
-		fi
-
-		sed -i -e "s|\"\$topdir\"|\"\$topdir\" ${GHC_PERSISTENT_FLAGS}|" \
-			"${S}/ghc/ghc.wrapper"
-
-		cd "${S}" # otherwise eapply will break
-
-		eapply "${FILESDIR}"/${PN}-7.0.4-CHOST-prefix.patch
-		eapply "${FILESDIR}"/${PN}-8.2.1-darwin.patch
-		eapply "${FILESDIR}"/${PN}-7.8.3-prim-lm.patch
-		eapply "${FILESDIR}"/${PN}-8.0.2-no-relax-everywhere.patch
-		eapply "${FILESDIR}"/${PN}-8.4.2-allow-cross-bootstrap.patch
-		eapply "${FILESDIR}"/${P}-autoconf-2.71.patch
-		# fixed in 8.8.4. See https://gitlab.haskell.org/ghc/ghc/-/blob/ghc-8.8.4-release/configure.ac#L1273
-		# eapply "${FILESDIR}"/${PN}-8.6.5-numa.patch
-		# rumors say this is fixed properly in 8.8.3. Let's check!
-		#eapply "${FILESDIR}"/${PN}-8.8.1-revert-CPP.patch
-
-		# a bunch of crosscompiler patches
-		# needs newer version:
-		#eapply "${FILESDIR}"/${PN}-8.2.1_rc1-hp2ps-cross.patch
-
-		# mingw32 target
-		pushd "${S}/libraries/Win32"
-			eapply "${FILESDIR}"/${PN}-8.2.1_rc1-win32-cross-2-hack.patch # bad workaround
-		popd
-
-		bump_libs
-
-		eapply_user
-		# as we have changed the build system
-		eautoreconf
-	fi
-}
-
-src_configure() {
-	if ! use binary; then
-		# initialize build.mk
-		echo '# Gentoo changes' > mk/build.mk
-
-		# Put docs into the right place, ie /usr/share/doc/ghc-${GHC_PV}
-		echo "docdir = ${EPREFIX}/usr/share/doc/$(cross)${PF}" >> mk/build.mk
-		echo "htmldir = ${EPREFIX}/usr/share/doc/$(cross)${PF}" >> mk/build.mk
-
-		# We also need to use the GHC_FLAGS flags when building ghc itself
-		echo "SRC_HC_OPTS+=${HCFLAGS} ${GHC_FLAGS}" >> mk/build.mk
-		echo "SRC_CC_OPTS+=${CFLAGS}" >> mk/build.mk
-		echo "SRC_LD_OPTS+=${LDFLAGS}" >> mk/build.mk
-		# Speed up initial Cabal bootstrap
-		echo "utils/ghc-cabal_dist_EXTRA_HC_OPTS+=$(ghc-make-args)" >> mk/build.mk
-
-		# We can't depend on haddock except when bootstrapping when we
-		# must build docs and include them into the binary .tbz2 package
-		# app-text/dblatex is not in portage, can not build PDF or PS
-		echo "BUILD_SPHINX_PDF  = NO"  >> mk/build.mk
-		echo "BUILD_SPHINX_HTML = $(usex doc YES NO)" >> mk/build.mk
-		echo "BUILD_MAN = $(usex doc YES NO)" >> mk/build.mk
-
-		# this controls presence on 'xhtml' and 'haddock' in final install
-		echo "HADDOCK_DOCS       = YES" >> mk/build.mk
-
-		# not used outside of ghc's test
-		if [[ -n ${GHC_BUILD_DPH} ]]; then
-				echo "BUILD_DPH = YES" >> mk/build.mk
-			else
-				echo "BUILD_DPH = NO" >> mk/build.mk
-		fi
-
-		# Any non-native build has to skip as it needs
-		# target haddock binary to be runnabine.
-		if ! is_native; then
-			# disable docs generation as it requires running stage2
-			echo "HADDOCK_DOCS=NO" >> mk/build.mk
-			echo "BUILD_SPHINX_HTML=NO" >> mk/build.mk
-			echo "BUILD_SPHINX_PDF=NO" >> mk/build.mk
-		fi
-
-		if is_crosscompile; then
-			# Install ghc-stage1 crosscompiler instead of
-			# ghc-stage2 cross-built compiler.
-			echo "Stage1Only=YES" >> mk/build.mk
-		fi
-
-		# allows overriding build flavours for libraries:
-		# v   - vanilla (static libs)
-		# p   - profiled
-		# dyn - shared libraries
-		# example: GHC_LIBRARY_WAYS="v dyn"
-		if [[ -n ${GHC_LIBRARY_WAYS} ]]; then
-			echo "GhcLibWays=${GHC_LIBRARY_WAYS}" >> mk/build.mk
-		fi
-		echo "BUILD_PROF_LIBS = $(usex profile YES NO)" >> mk/build.mk
-
-		# Get ghc from the unpacked binary .tbz2
-		# except when bootstrapping we just pick ghc up off the path
-		if ! use ghcbootstrap; then
-			export PATH="${WORKDIR}/usr/bin:${PATH}"
-		fi
-
-		echo "INTEGER_LIBRARY = $(usex gmp integer-gmp integer-simple)" >> mk/build.mk
-
-		# don't strip anything. Very useful when stage2 SIGSEGVs on you
-		echo "STRIP_CMD = :" >> mk/build.mk
-
-		local econf_args=()
-
-		# GHC embeds toolchain it was built by and uses it later.
-		# Don't allow things like ccache or versioned binary slip.
-		# We use stable thing across gcc upgrades.
-		# User can use EXTRA_ECONF=CC=... to override this default.
-		econf_args+=(
-			AR=${CTARGET}-ar
-			CC=${CTARGET}-gcc
-			# these should be inferred by GHC but ghc defaults
-			# to using bundled tools on windows.
-			Windres=${CTARGET}-windres
-			DllWrap=${CTARGET}-dllwrap
-			# we set the linker explicitly below
-			--disable-ld-override
-		)
-		case ${CTARGET} in
-			arm*)
-				# ld.bfd-2.28 does not work for ghc. Force ld.gold
-				# instead. This should be removed once gentoo gets
-				# a fix for R_ARM_COPY bug: https://sourceware.org/PR16177
-				econf_args+=(LD=${CTARGET}-ld.gold)
-			;;
-			sparc*)
-				# ld.gold-2.28 does not work for ghc. Force ld.bfd
-				# instead. This should be removed once gentoo gets
-				# a fix for missing --no-relax support bug:
-				# https://sourceware.org/ml/binutils/2017-07/msg00183.html
-				econf_args+=(LD=${CTARGET}-ld.bfd)
-			;;
-			*)
-				econf_args+=(LD=${CTARGET}-ld)
-		esac
-
-		if [[ ${CBUILD} != ${CHOST} ]]; then
-			# GHC bug: ghc claims not to support cross-building.
-			# It does, but does not distinct --host= value
-			# for stage1 and stage2 compiler.
-			econf_args+=(--host=${CBUILD})
-		fi
-
-		if use ghcmakebinary; then
-			# When building booting libary we are trying to
-			# bundle or restrict most of external depends
-			# with unstable ABI:
-			#  - embed libffi (default GHC behaviour)
-			#  - disable ncurses support for ghci (via haskeline)
-			#    https://bugs.gentoo.org/557478
-			#  - disable ncurses support for ghc-pkg
-			echo "libraries/haskeline_CONFIGURE_OPTS += --flag=-terminfo" >> mk/build.mk
-			echo "utils/ghc-pkg_HC_OPTS += -DBOOTSTRAPPING" >> mk/build.mk
-		elif is_native; then
-			# using ${GTARGET}'s libffi is not supported yet:
-			# GHC embeds full path for ffi includes without /usr/${CTARGET} account.
-			econf_args+=(--with-system-libffi)
-			econf_args+=(--with-ffi-includes=$($(tc-getPKG_CONFIG) libffi --cflags-only-I | sed -e 's@^-I@@'))
-		fi
-
-		einfo "Final mk/build.mk:"
-		cat mk/build.mk || die
-
-		econf ${econf_args[@]} \
-			--enable-bootstrap-with-devel-snapshot \
-			$(use elfutils && echo --enable-dwarf-unwind) \
-			$(use_enable numa)
-
-		if [[ ${PV} == *9999* ]]; then
-			GHC_PV="$(grep 'S\[\"PACKAGE_VERSION\"\]' config.status | sed -e 's@^.*=\"\(.*\)\"@\1@')"
-			GHC_P=${PN}-${GHC_PV}
-		fi
-	fi # ! use binary
-}
-
-src_compile() {
-	if ! use binary; then
-		# Stage1Only crosscompiler does not build stage2
-		if ! is_crosscompile; then
-			# 1. build/pax-mark compiler binary first
-			emake ghc/stage2/build/tmp/ghc-stage2
-			# 2. pax-mark (bug #516430)
-			pax-mark -m ghc/stage2/build/tmp/ghc-stage2
-			# 2. build/pax-mark haddock using ghc-stage2
-			if is_native; then
-				# non-native build does not build haddock
-				# due to HADDOCK_DOCS=NO, but it could.
-				emake utils/haddock/dist/build/tmp/haddock
-				pax-mark -m utils/haddock/dist/build/tmp/haddock
-			fi
-		fi
-		# 3. and then all the rest
-		emake all
-	fi # ! use binary
-}
-
-src_test() {
-	# TODO: deal with:
-	#    - sandbox (pollutes environment)
-	#    - extra packages (to extend testsuite coverage)
-	# bits are taken from 'validate'
-	local make_test_target='test' # can be fulltest
-	# not 'emake' as testsuite uses '$MAKE' without jobserver available
-	make $make_test_target stage=2 THREADS=$(makeopts_jobs)
-}
-
-src_install() {
-	if use binary; then
-		use prefix && mkdir -p "${ED}"
-		mv "${S}/usr" "${ED}"
-	else
-		[[ -f VERSION ]] || emake VERSION
-
-		# -j1 due to a rare race in install script:
-		#    make --no-print-directory -f ghc.mk phase=final install
-		#    /usr/lib/portage/python3.4/ebuild-helpers/xattr/install -c -m 755 \
-		#        -d "/tmp/portage-tmpdir/portage/cross-armv7a-unknown-linux-gnueabi/ghc-9999/image/usr/lib64/armv7a-unknown-linux-gnueabi-ghc-8.3.20170404/include"
-		#    /usr/lib/portage/python3.4/ebuild-helpers/xattr/install -c -m 644  utils/hsc2hs/template-hsc.h \
-		#           "/tmp/portage-tmpdir/portage/cross-armv7a-unknown-linux-gnueabi/ghc-9999/image/usr/lib64/armv7a-unknown-linux-gnueabi-ghc-8.3.20170404"
-		#    /usr/bin/install: cannot create regular file \
-		#           '/tmp/portage-tmpdir/portage/cross-armv7a-unknown-linux-gnueabi/ghc-9999/image/usr/lib64/armv7a-unknown-linux-gnueabi-ghc-8.3.20170404': No such file or directory
-		emake -j1 install DESTDIR="${D}"
-
-		# Skip for cross-targets as they all share target location:
-		# /usr/share/doc/ghc-9999/
-		if ! is_crosscompile; then
-			dodoc "distrib/README" "ANNOUNCE" "LICENSE" "VERSION"
-		fi
-
-		# rename ghc-shipped files to avoid collision
-		# of external packages. Motivating example:
-		#  user had installed:
-		#      dev-lang/ghc-7.8.4-r0 (with transformers-0.3.0.0)
-		#      dev-haskell/transformers-0.4.2.0
-		#  then user tried to update to
-		#      dev-lang/ghc-7.8.4-r1 (with transformers-0.4.2.0)
-		#  this will lead to single .conf file collision.
-		local shipped_conf renamed_conf
-		local package_confdir="${ED}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d"
-		for shipped_conf in "${package_confdir}"/*.conf; do
-			# rename 'pkg-ver-id.conf' to 'pkg-ver-id-gentoo-${PF}.conf'
-			renamed_conf=${shipped_conf%.conf}-gentoo-${PF}.conf
-			mv "${shipped_conf}" "${renamed_conf}" || die
-		done
-
-		# remove link, but leave 'haddock-${GHC_P}'
-		rm -f "${ED}"/usr/bin/$(cross)haddock
-
-		if ! is_crosscompile; then
-			newbashcomp "${FILESDIR}"/ghc-bash-completion ghc-pkg
-			newbashcomp utils/completion/ghc.bash         ghc
-		fi
-	fi
-
-	# path to the package.cache
-	local package_confdir="${ED}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d"
-	PKGCACHE="${package_confdir}"/package.cache
-	# copy the package.conf.d, including timestamp, save it so we can help
-	# users that have a broken package.conf.d
-	cp -pR "${package_confdir}"{,.initial} || die "failed to backup intial package.conf.d"
-
-	# copy the package.conf, including timestamp, save it so we later can put it
-	# back before uninstalling, or when upgrading.
-	cp -p "${PKGCACHE}"{,.shipped} \
-		|| die "failed to copy package.conf.d/package.cache"
-
-	if is_crosscompile; then
-		# When we build a cross-compiler the layout is the following:
-		#     usr/lib/${CTARGET}-ghc-${VER}/ contains target libraries
-		# but
-		#     usr/lib/${CTARGET}-ghc-${VER}/bin/ directory
-		# containst host binaries (modulo bugs).
-
-		# Portage's stripping mechanism does not skip stripping
-		# foreign binaries. This frequently causes binaries to be
-		# broken.
-		#
-		# Thus below we disable stripping of target libraries and allow
-		# stripping hosts executables.
-		dostrip -x "/usr/$(get_libdir)/$(cross)${GHC_P}"
-		dostrip    "/usr/$(get_libdir)/$(cross)${GHC_P}/bin"
-	fi
-}
-
-pkg_preinst() {
-	# have we got an earlier version of ghc installed?
-	if has_version "<${CATEGORY}/${PF}"; then
-		haskell_updater_warn="1"
-	fi
-}
-
-pkg_postinst() {
-	ghc-reregister
-
-	# path to the package.cache
-	PKGCACHE="${EROOT}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d/package.cache"
-
-	# give the cache a new timestamp, it must be as recent as
-	# the package.conf.d directory.
-	touch "${PKGCACHE}"
-
-	if [[ "${haskell_updater_warn}" == "1" ]]; then
-		ewarn
-		ewarn "\e[1;31m************************************************************************\e[0m"
-		ewarn
-		ewarn "You have just upgraded from an older version of GHC."
-		ewarn "You may have to run"
-		ewarn "      'haskell-updater'"
-		ewarn "to rebuild all ghc-based Haskell libraries."
-		ewarn
-		ewarn "\e[1;31m************************************************************************\e[0m"
-		ewarn
-	fi
-}
-
-pkg_prerm() {
-	PKGCACHE="${EROOT}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d/package.cache"
-	rm -rf "${PKGCACHE}"
-
-	cp -p "${PKGCACHE}"{.shipped,}
-}
-
-pkg_postrm() {
-	ghc-package_pkg_postrm
-}


^ permalink raw reply related	[flat|nested] 15+ messages in thread
* [gentoo-commits] repo/gentoo:master commit in: dev-lang/ghc/, dev-lang/ghc/files/
@ 2022-07-04  0:33 Sam James
  0 siblings, 0 replies; 15+ messages in thread
From: Sam James @ 2022-07-04  0:33 UTC (permalink / raw
  To: gentoo-commits

commit:     9f39f305a5e3ace79efb86f41638070f9c97fae5
Author:     Jack Todaro <solpeth <AT> posteo <DOT> org>
AuthorDate: Tue Feb  1 09:42:46 2022 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Mon Jul  4 00:32:53 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=9f39f305

dev-lang/ghc: add 9.0.2 (no keywords)

Package-Manager: Portage-3.0.30, Repoman-3.0.3
Signed-off-by: Jack Todaro <solpeth <AT> posteo.org>
Closes: https://github.com/gentoo/gentoo/pull/24042
Signed-off-by: Sam James <sam <AT> gentoo.org>

 dev-lang/ghc/Manifest                              |   4 +
 dev-lang/ghc/files/ghc-9.0.2-CHOST-prefix.patch    |  17 +
 dev-lang/ghc/files/ghc-9.0.2-darwin.patch          |  31 +
 .../ghc/files/ghc-9.0.2-fix-tests-python310.patch  |  33 +
 dev-lang/ghc/files/ghc-9.0.2-modorigin.patch       |  24 +
 .../ghc/files/ghc-9.0.2-verbose-modunusable.patch  |  12 +
 dev-lang/ghc/ghc-9.0.2.ebuild                      | 824 +++++++++++++++++++++
 7 files changed, 945 insertions(+)

diff --git a/dev-lang/ghc/Manifest b/dev-lang/ghc/Manifest
index 0c3307d5e446..fde4b8f1e0c6 100644
--- a/dev-lang/ghc/Manifest
+++ b/dev-lang/ghc/Manifest
@@ -8,6 +8,8 @@ DIST ghc-8.8.4-src.tar.xz 19395252 BLAKE2B 6fa898b9552398a724f0452f5cc88ba073264
 DIST ghc-8.8.4-testsuite.tar.xz 1965820 BLAKE2B 3b715700561788b8abdc986961d533b91399461d57a1686ededb4ccc36881503cdc3fc126b9a7b204a728c24b9a9ca97320142348644367aca9b47c87a5b3b51 SHA512 79d8fb0ba8de0fb48c938bd54c8c3278f1895d8ce5c700ce8cf6b3fc550073bb757208e85d4f9818400ebecca96f51d9248b8bbdac9eb2995671756164d08c16
 DIST ghc-9.0.1-src.tar.xz 20782336 BLAKE2B 53eaf903081d705d641459fbc1e6fa7387a6039f9cd466b4708bda86e81252a84d80878d6eb956ec2e1e5b721a313e68eeb796f8345244ca62f536a7a3f0c6df SHA512 bee7950a5118be8d8cefe0db5070139a5a93ca21c5bc6f8bf453429831f0c44f5e0fb5ee569865d6b8b92749044ee4123be06920928ac7a1ec9cffa9404a3e53
 DIST ghc-9.0.1-testsuite.tar.xz 2322432 BLAKE2B 350df763c607dd89ba58ad6e856d815556159a9f088dc0b069de48ae87c1e874a45fad51159e65a3c9a9beed68602eeb2a2728dbce86277bd287455f46f6c53a SHA512 13fbe0f0ab5e2426820d0fb37f0a75e1198ef2a660398508806e8ef094fd23647ca3d386815a2118168d12253d8df3273043678dbb37cf3924c689dd0fd1932e
+DIST ghc-9.0.2-src.tar.xz 27270396 BLAKE2B 0a73d910d3ef11161f895849025fe37ce231932f7cde441fdf620cf8c51678060a804467879eb0ee5c0a30413604c56e28e2aa1cde01e45c620b76987d9c0c0e SHA512 32994c7d2b8f47bae604cd825bfcf9c788d79ce26d1d5f58bd73a7093e11ae6c3c17b31dc0c9e454dbf67ca169b942f92213c388d615768cae86055bf6094dee
+DIST ghc-9.0.2-testsuite.tar.xz 2403564 BLAKE2B 0e7f6fefb9c972f94073aca8b15147913ffa8d3cd3ff7fc63ef7e20b4efd8b443cf21f12e1ab0f5044790f6d8af6cf7788bda85a21b2f356ddface86eb896670 SHA512 b2375500ae837d74af8085d099899b5a7a589c59bdcc033ca0bd6e00f33c4f8d90b481e0c7c3de113e607fcfafdfe8edde4713e6d242b2d4ee87df2eb960c9c7
 DIST ghc-bin-8.10.4-i686-pc-linux-gnu.tbz2 123831294 BLAKE2B 1ca4c1b5c34c948011049a73d409c741db89658d10e311cffbe464c631c3733278fc7dede6ad27474832295ded2c26fd4d6419c760505255e29f7cb232a670a4 SHA512 1f87cf63651f7c0e5f7f55d1f4d7d7c48b0a911cc6673a899d4b92190d765b359f9c7d73c329969c1b76f1af102b7e2c18a80382c81d5dade9ac7dd57de4ef65
 DIST ghc-bin-8.10.4-x86_64-pc-linux-gnu.tbz2 122558873 BLAKE2B 9f07c7bdc3beccfa629d28b2524ccd2f4688a5c0036a45408f5ace2d530a2a0e42f95b3cda5037ebb365317999e1ae776c6f9d21692867abfe85e33f2892b1be SHA512 68bd70f94961547746a696aa2839e156c95858fda0c7ec5b2ecf802070724ab7102b0aa86bcbf93432170d521cce4af10f46b851b470e5dc49dfa5b07380f46d
 DIST ghc-bin-8.10.5-i686-pc-linux-gnu.tbz2 124356781 BLAKE2B 53c5d259a19f11db83d69f7a2f39090d623b07caf1859eb8bf0385183586f538d8eb3eadb06f56f4b7160fa82043eb0f7b8df1632d55af562b8b1cb21c08b4c3 SHA512 58676b4eaeef9e05f69b7c821e115f3a678487b0de696e702ff6378f7d8f23fafda997b0c19d52a730c22bf8012a99c01783d16d00e356fe12532156d5965fc6
@@ -18,3 +20,5 @@ DIST ghc-bin-8.8.4-i686-pc-linux-gnu.tbz2 120336081 BLAKE2B 55dfbb90d5e55c2af5e9
 DIST ghc-bin-8.8.4-x86_64-pc-linux-gnu.tbz2 118897883 BLAKE2B a180b2dd1a3bc222044ece809ad700aee29d0c3e75b57ee9af3ca33c9c0f59dbf36f68202f746d99f80915cb717a9c41fc12db507f1cb469981732703a06b9cc SHA512 9d4be02dbd9704c93ef18feb92ea30bd5d590df31f288bf1b364818424c5019ca9ada26eec88418199f90ae8f4459d0a9352104e3f3186bbdc241891eb1b66c4
 DIST ghc-bin-9.0.1-i686-pc-linux-gnu.tbz2 122955511 BLAKE2B b870f46cc78fcc1d715aafe7108951582cfd12495b4e9d804d4b66562c66a6a2b2d9513031aedc8f3630a0cdbb3257943304b05732301a084f89487452f2f2d9 SHA512 aafd4233c40f93b71e6ac1acc8a75e30d49b826e4bce6d9832836966fd5f6c4898963bd4c2f34577f4199c1d9a3f537ac1e7d87eab11e9fb5e849573580ed3fb
 DIST ghc-bin-9.0.1-x86_64-pc-linux-gnu.tbz2 121542968 BLAKE2B 837870e68138f8d97dc8b2aae90090cf02416628602ca4ba4417ac92b49155f10028b05ac465665b8872b32372a5cee075616983f2eacdebb0188bd2ce6a93d2 SHA512 0e8c6d2e6f32fac95588f7323a4e02dddfc9ec2476a82b97bf5a106d3810f7e638fda7124c53b5bbc563fce70f4436553c282d8ea2f1f5fdf4fcccfb15a2b079
+DIST ghc-bin-9.0.2-i686-pc-linux-gnu.tbz2 123509908 BLAKE2B 45614984803a7bfa266f99d4adb4b5f2ab7b9e5e89c6ecd501296fc99a1d96e798ccb9c832f8dcb15fff9725beb918a7b63e62ff13f59b6506a2ef17930c45d2 SHA512 e0b7f4474c16f0763a2f787027fbdfeb3125b48c987fa1196bc189fefad9f0bfa2806da62af46d61ca911f5275b578076e2b326acf39e0894a8daa9deda0843a
+DIST ghc-bin-9.0.2-x86_64-pc-linux-gnu.tbz2 121536759 BLAKE2B 4433e2d266f065d2b2944b711d622ec26288a2187ac03562257a671744b44da35110ce16ac6d76f7062a563488885326be073e0ff03c7e48250051c3b4763d96 SHA512 2de29a9ddbfd0fac797cdd628f3657ff38e6a153151849508bba75d36f84394ed77750435ff5cc1bdfcd30ef2b6e009bde965bd0a83e0496b5027239642f4b6c

diff --git a/dev-lang/ghc/files/ghc-9.0.2-CHOST-prefix.patch b/dev-lang/ghc/files/ghc-9.0.2-CHOST-prefix.patch
new file mode 100644
index 000000000000..204eb3ef7dcd
--- /dev/null
+++ b/dev-lang/ghc/files/ghc-9.0.2-CHOST-prefix.patch
@@ -0,0 +1,17 @@
+Strip versioning components from *HOST for Darwin and Solaris
+
+--- a/m4/fptools.m4
++++ b/m4/fptools.m4
+@@ -1358,6 +1358,12 @@
+   freebsd*)
+     $2="freebsd"
+     ;;
++  darwin*)
++    $2="darwin"
++	;;
++  solaris2.*)
++    $2="solaris2"
++	;;
+   *)
+     echo "Unknown OS $1"
+     exit 1

diff --git a/dev-lang/ghc/files/ghc-9.0.2-darwin.patch b/dev-lang/ghc/files/ghc-9.0.2-darwin.patch
new file mode 100644
index 000000000000..c3d8109e6ccc
--- /dev/null
+++ b/dev-lang/ghc/files/ghc-9.0.2-darwin.patch
@@ -0,0 +1,31 @@
+From d39a3409acd3c40fb018ec1c114f15d3ecef6ef9 Mon Sep 17 00:00:00 2001
+From: Sergei Trofimovich <slyfox@gentoo.org>
+Date: Thu, 1 Jun 2017 22:30:05 +0100
+Subject: [PATCH] aclocal.m4: add support for versioned darwin triplets
+
+The change adds support for 'darwin*' OS:
+    $ ./configure --target=aarch64-apple-darwin14
+
+Reported-by: jp_rider
+Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
+---
+ aclocal.m4 | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/aclocal.m4 b/aclocal.m4
+index 7ad9c36453..437974a0c7 100644
+--- a/m4/fptools.m4
++++ b/m4/fptools.m4
+@@ -1906,6 +1906,9 @@ AC_DEFUN([GHC_CONVERT_OS],[
+       aix*) # e.g. powerpc-ibm-aix7.1.3.0
+         $3="aix"
+         ;;
++      darwin*) # e.g. aarch64-apple-darwin14
++        $3="darwin"
++        ;;
+       freebsd*) # like i686-gentoo-freebsd7
+                 #      i686-gentoo-freebsd8
+                 #      i686-gentoo-freebsd8.2
+-- 
+2.14.1
+

diff --git a/dev-lang/ghc/files/ghc-9.0.2-fix-tests-python310.patch b/dev-lang/ghc/files/ghc-9.0.2-fix-tests-python310.patch
new file mode 100644
index 000000000000..c59cfcbfc4a2
--- /dev/null
+++ b/dev-lang/ghc/files/ghc-9.0.2-fix-tests-python310.patch
@@ -0,0 +1,33 @@
+From 81a8f7a7daeb87db53d598ced4b303f8f320442f Mon Sep 17 00:00:00 2001
+From: Zubin Duggal <zubin.duggal@gmail.com>
+Date: Wed, 12 Jan 2022 23:01:40 +0530
+Subject: [PATCH] testsuite: Fix import on python 3.10
+
+---
+ testsuite/driver/testlib.py | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/testsuite/driver/testlib.py b/testsuite/driver/testlib.py
+index fb2a7010f59..6b6462f527b 100644
+--- a/testsuite/driver/testlib.py
++++ b/testsuite/driver/testlib.py
+@@ -16,6 +16,7 @@ import sys
+ from math import ceil, trunc, floor, log
+ from pathlib import Path, PurePath
+ import collections
++import collections.abc
+ import subprocess
+ 
+ from testglobals import config, ghc_env, default_testopts, brokens, t, \
+@@ -907,7 +908,7 @@ def join_normalisers(*a):
+         Taken from http://stackoverflow.com/a/2158532/946226
+         """
+         for el in l:
+-            if (isinstance(el, collections.Iterable)
++            if (isinstance(el, collections.abc.Iterable)
+                 and not isinstance(el, (bytes, str))):
+                 for sub in flatten(el):
+                     yield sub
+-- 
+GitLab
+

diff --git a/dev-lang/ghc/files/ghc-9.0.2-modorigin.patch b/dev-lang/ghc/files/ghc-9.0.2-modorigin.patch
new file mode 100644
index 000000000000..3c7053778e98
--- /dev/null
+++ b/dev-lang/ghc/files/ghc-9.0.2-modorigin.patch
@@ -0,0 +1,24 @@
+diff --git a/compiler/GHC/Unit/State.hs b/compiler/GHC/Unit/State.hs
+index cefa5e5058bf68e68aaafadad0c7874189bf8225..92b38443c8378eb69db19a40d23abca47d6acee8 100644
+--- a/compiler/GHC/Unit/State.hs
++++ b/compiler/GHC/Unit/State.hs
+@@ -224,14 +224,16 @@ fromFlag :: ModuleOrigin
+ fromFlag = ModOrigin Nothing [] [] True
+ 
+ instance Semigroup ModuleOrigin where
+-    ModOrigin e res rhs f <> ModOrigin e' res' rhs' f' =
++    x@(ModOrigin e res rhs f) <> y@(ModOrigin e' res' rhs' f') =
+         ModOrigin (g e e') (res ++ res') (rhs ++ rhs') (f || f')
+       where g (Just b) (Just b')
+                 | b == b'   = Just b
+-                | otherwise = panic "ModOrigin: package both exposed/hidden"
++                | otherwise = pprPanic "ModOrigin: package both exposed/hidden" $
++                    text "x: " <> ppr x $$ text "y: " <> ppr y
+             g Nothing x = x
+             g x Nothing = x
+-    _x <> _y = panic "ModOrigin: hidden module redefined"
++    x <> y = pprPanic "ModOrigin: hidden module redefined" $
++                 text "x: " <> ppr x $$ text "y: " <> ppr y
+ 
+ instance Monoid ModuleOrigin where
+     mempty = ModOrigin Nothing [] [] False

diff --git a/dev-lang/ghc/files/ghc-9.0.2-verbose-modunusable.patch b/dev-lang/ghc/files/ghc-9.0.2-verbose-modunusable.patch
new file mode 100644
index 000000000000..13d12efdc0ec
--- /dev/null
+++ b/dev-lang/ghc/files/ghc-9.0.2-verbose-modunusable.patch
@@ -0,0 +1,12 @@
+diff -urN ghc-9.0.2/compiler/GHC/Unit/State.hs ghc-9.0.2-r1/compiler/GHC/Unit/State.hs
+--- ghc-9.0.2/compiler/GHC/Unit/State.hs	2021-10-19 05:20:00.000000000 -0600
++++ ghc-9.0.2-r1/compiler/GHC/Unit/State.hs	2022-02-17 01:04:05.117930250 -0700
+@@ -194,7 +194,7 @@
+ 
+ instance Outputable ModuleOrigin where
+     ppr ModHidden = text "hidden module"
+-    ppr (ModUnusable _) = text "unusable module"
++    ppr (ModUnusable reason) = text "unusable module" $$ ppr reason
+     ppr (ModOrigin e res rhs f) = sep (punctuate comma (
+         (case e of
+             Nothing -> []

diff --git a/dev-lang/ghc/ghc-9.0.2.ebuild b/dev-lang/ghc/ghc-9.0.2.ebuild
new file mode 100644
index 000000000000..b39fe464ab9a
--- /dev/null
+++ b/dev-lang/ghc/ghc-9.0.2.ebuild
@@ -0,0 +1,824 @@
+# Copyright 1999-2022 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+# to make make a crosscompiler use crossdev and symlink ghc tree into
+# cross overlay. result would look like 'cross-sparc-unknown-linux-gnu/ghc'
+export CBUILD=${CBUILD:-${CHOST}}
+export CTARGET=${CTARGET:-${CHOST}}
+if [[ ${CTARGET} = ${CHOST} ]] ; then
+	if [[ ${CATEGORY/cross-} != ${CATEGORY} ]] ; then
+		export CTARGET=${CATEGORY/cross-}
+	fi
+fi
+
+PYTHON_COMPAT=( python3_{8..10} )
+inherit python-any-r1
+inherit autotools bash-completion-r1 eutils flag-o-matic ghc-package
+inherit multilib multiprocessing pax-utils toolchain-funcs prefix
+inherit check-reqs
+DESCRIPTION="The Glasgow Haskell Compiler"
+HOMEPAGE="https://www.haskell.org/ghc/"
+
+# we don't have any binaries yet
+arch_binaries=""
+
+BIN_PV=${PV}
+# sorted!
+#arch_binaries="$arch_binaries alpha? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-alpha.tbz2 )"
+#arch_binaries="$arch_binaries arm? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-armv7a-hardfloat-linux-gnueabi.tbz2 )"
+#arch_binaries="$arch_binaries arm64? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-aarch64-unknown-linux-gnu.tbz2 )"
+arch_binaries="$arch_binaries amd64? ( https://eidetic.codes/ghc-bin-${PV}-x86_64-pc-linux-gnu.tbz2 )"
+#arch_binaries="$arch_binaries ia64?  ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-ia64-fixed-fiw.tbz2 )"
+#arch_binaries="$arch_binaries ppc? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-ppc.tbz2 )"
+#arch_binaries="$arch_binaries ppc64? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-ppc64.tbz2 )"
+#arch_binaries="$arch_binaries ppc64? ( !big-endian? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-powerpc64le-unknown-linux-gnu.tbz2 ) )"
+#arch_binaries="$arch_binaries sparc? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-sparc.tbz2 )"
+arch_binaries="$arch_binaries x86? ( https://eidetic.codes/ghc-bin-${PV}-i686-pc-linux-gnu.tbz2 )"
+
+# various ports:
+#arch_binaries="$arch_binaries x86-fbsd? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-x86-fbsd.tbz2 )"
+
+# 0 - yet
+yet_binary() {
+	case "${ARCH}" in
+		#alpha) return 0 ;;
+		#arm64) return 0 ;;
+		#arm) return 0 ;;
+		amd64) return 0 ;;
+		#ia64) return 0 ;;
+		#ppc) return 0 ;;
+		#ppc64)
+		#	use big-endian && return 0
+		#	return 0
+		#	;;
+		#sparc) return 0 ;;
+		x86) return 0 ;;
+		*) return 1 ;;
+	esac
+}
+
+GHC_PV=${PV}
+#GHC_PV=8.10.0.20200123 # uncomment only for -alpha, -beta, -rc ebuilds
+GHC_P=${PN}-${GHC_PV} # using ${P} is almost never correct
+
+SRC_URI="!binary? (
+	https://downloads.haskell.org/ghc/${PV/_/-}/${GHC_P}-src.tar.xz
+	test? ( https://downloads.haskell.org/ghc/${PV/_/-}/${GHC_P}-testsuite.tar.xz )
+)"
+S="${WORKDIR}"/${GHC_P}
+
+[[ -n $arch_binaries ]] && SRC_URI+=" !ghcbootstrap? ( $arch_binaries )"
+
+BUMP_LIBRARIES=(
+	# "hackage-name          hackage-version"
+)
+
+LICENSE="BSD"
+SLOT="0/${PV}"
+KEYWORDS=""
+IUSE="big-endian +doc elfutils ghcbootstrap ghcmakebinary +gmp numa profile test"
+IUSE+=" binary"
+RESTRICT="!test? ( test )"
+
+RDEPEND="
+	>=dev-lang/perl-5.6.1
+	dev-libs/gmp:0=
+	sys-libs/ncurses:=[unicode(+)]
+	elfutils? ( dev-libs/elfutils )
+	!ghcmakebinary? ( dev-libs/libffi:= )
+	numa? ( sys-process/numactl )
+"
+
+# This set of dependencies is needed to run
+# prebuilt ghc. We specifically avoid ncurses
+# dependency with:
+#    utils/ghc-pkg_HC_OPTS += -DBOOTSTRAPPING
+PREBUILT_BINARY_DEPENDS="
+	!prefix? ( elibc_glibc? ( >=sys-libs/glibc-2.17 ) )
+"
+# This set of dependencies is needed to install
+# ghc[binary] in system. terminfo package is linked
+# against ncurses.
+PREBUILT_BINARY_RDEPENDS="${PREBUILT_BINARY_DEPENDS}
+	sys-libs/ncurses:0/6
+"
+
+RDEPEND+="binary? ( ${PREBUILT_BINARY_RDEPENDS} )"
+
+DEPEND="${RDEPEND}"
+BDEPEND="
+	virtual/pkgconfig
+	doc? ( app-text/docbook-xml-dtd:4.2
+		app-text/docbook-xml-dtd:4.5
+		app-text/docbook-xsl-stylesheets
+		dev-python/sphinx
+		>=dev-libs/libxslt-1.1.2 )
+	!ghcbootstrap? ( ${PREBUILT_BINARY_DEPENDS} )
+	test? ( ${PYTHON_DEPS} )
+"
+
+needs_python() {
+	# test driver is written in python
+	use test && return 0
+	return 1
+}
+
+# we build binaries without profiling support
+REQUIRED_USE="
+	?? ( ghcbootstrap binary )
+	?? ( profile binary )
+"
+
+# haskell libraries built with cabal in configure mode, #515354
+QA_CONFIGURE_OPTIONS+=" --with-compiler --with-gcc"
+
+is_crosscompile() {
+	[[ ${CHOST} != ${CTARGET} ]]
+}
+
+is_native() {
+	[[ ${CHOST} == ${CBUILD} ]] && [[ ${CHOST} == ${CTARGET} ]]
+}
+
+if ! is_crosscompile; then
+	PDEPEND="!ghcbootstrap? ( >=app-admin/haskell-updater-1.2 )"
+fi
+
+# returns tool prefix for crosscompiler.
+# Example:
+#  CTARGET=armv7a-unknown-linux-gnueabi
+#  CHOST=x86_64-pc-linux-gnu
+#    "armv7a-unknown-linux-gnueabi-"
+#  CTARGET=${CHOST}
+#    ""
+# Used in tools and library prefix:
+#    "${ED}"/usr/bin/$(cross)haddock
+#    "${ED}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d"
+
+cross() {
+	if is_crosscompile; then
+		echo "${CTARGET}-"
+	else
+		echo ""
+	fi
+}
+
+append-ghc-cflags() {
+	local persistent compile assemble link
+	local flag ghcflag
+
+	for flag in $*; do
+		case ${flag} in
+			persistent)	persistent="yes";;
+			compile)	compile="yes";;
+			assemble)	assemble="yes";;
+			link)		link="yes";;
+			*)
+				[[ ${compile}  ]] && ghcflag="-optc${flag}"  CFLAGS+=" ${flag}" && GHC_FLAGS+=" ${ghcflag}" &&
+					[[ ${persistent} ]] && GHC_PERSISTENT_FLAGS+=" ${ghcflag}"
+				[[ ${assemble} ]] && ghcflag="-opta${flag}"  CFLAGS+=" ${flag}" && GHC_FLAGS+=" ${ghcflag}" &&
+					[[ ${persistent} ]] && GHC_PERSISTENT_FLAGS+=" ${ghcflag}"
+				[[ ${link}     ]] && ghcflag="-optl${flag}" LDFLAGS+=" ${flag}" && GHC_FLAGS+=" ${ghcflag}" &&
+					[[ ${persistent} ]] && GHC_PERSISTENT_FLAGS+=" ${ghcflag}"
+				;;
+		esac
+	done
+}
+
+# $1 - lib name (under libraries/)
+# $2 - lib version
+# example: bump_lib "transformers" "0.4.2.0"
+bump_lib() {
+	local pn=$1 pv=$2
+	local p=${pn}-${pv}
+	local f
+
+	einfo "Bumping ${pn} up to ${pv}"
+
+	for f in ghc.mk GNUmakefile; do
+		mv libraries/"${pn}"/$f "${WORKDIR}"/"${p}"/$f || die
+	done
+	mv libraries/"${pn}" "${WORKDIR}"/"${pn}".old || die
+	mv "${WORKDIR}"/"${p}" libraries/"${pn}" || die
+}
+
+update_SRC_URI() {
+	local p pn pv
+	for p in "${BUMP_LIBRARIES[@]}"; do
+		set -- $p
+		pn=$1 pv=$2
+
+		SRC_URI+=" https://hackage.haskell.org/package/${pn}-${pv}/${pn}-${pv}.tar.gz"
+	done
+}
+
+update_SRC_URI
+
+bump_libs() {
+	local p pn pv
+	for p in "${BUMP_LIBRARIES[@]}"; do
+		set -- $p
+		pn=$1 pv=$2
+
+		bump_lib "${pn}" "${pv}"
+	done
+}
+
+ghc_setup_cflags() {
+	# TODO: plumb CFLAGS and BUILD_CFLAGS to respective CONF_CC_OPTS_STAGE<N>
+	if ! is_native; then
+		export CFLAGS=${GHC_CFLAGS-"-O2 -pipe"}
+		export LDFLAGS=${GHC_LDFLAGS-"-Wl,-O1"}
+		einfo "Crosscompiling mode:"
+		einfo "   CHOST:   ${CHOST}"
+		einfo "   CTARGET: ${CTARGET}"
+		einfo "   CFLAGS:  ${CFLAGS}"
+		einfo "   LDFLAGS: ${LDFLAGS}"
+		einfo "   prefix: $(cross)"
+		return
+	fi
+	# We need to be very careful with the CFLAGS we ask ghc to pass through to
+	# gcc. There are plenty of flags which will make gcc produce output that
+	# breaks ghc in various ways. The main ones we want to pass through are
+	# -mcpu / -march flags. These are important for arches like alpha & sparc.
+	# We also use these CFLAGS for building the C parts of ghc, ie the rts.
+	strip-flags
+	strip-unsupported-flags
+
+	# Cmm can't parse line numbers #482086
+	replace-flags -ggdb[3-9] -ggdb2
+
+	GHC_FLAGS=""
+	GHC_PERSISTENT_FLAGS=""
+	for flag in ${CFLAGS}; do
+		case ${flag} in
+
+			# Ignore extra optimisation (ghc passes -O to gcc anyway)
+			# -O2 and above break on too many systems
+			-O*) ;;
+
+			# Arch and ABI flags are what we're really after
+			-m*) append-ghc-cflags compile assemble ${flag};;
+
+			# Sometimes it's handy to see backtrace of RTS
+			# to get an idea what happens there
+			-g*) append-ghc-cflags compile ${flag};;
+
+			# Ignore all other flags, including all -f* flags
+		esac
+	done
+
+	for flag in ${LDFLAGS}; do
+		append-ghc-cflags link ${flag}
+	done
+
+	# GHC uses ${CBUILD}-gcc, ${CHOST}-gcc and ${CTARGET}-gcc at a single build.
+	# Skip any gentoo-specific tweaks for cross-case to avoid passing unsupported
+	# options to gcc.
+	if is_native; then
+		# prevent from failing to build unregisterised ghc:
+		# https://www.mail-archive.com/debian-bugs-dist@lists.debian.org/msg171602.html
+		use ppc64 && append-ghc-cflags persistent compile -mminimal-toc
+	fi
+}
+
+# substitutes string $1 to $2 in files $3 $4 ...
+relocate_path() {
+	local from=$1
+	local   to=$2
+	shift 2
+	local file=
+	for file in "$@"
+	do
+		sed -i -e "s|$from|$to|g" \
+			"$file" || die "path relocation failed for '$file'"
+	done
+}
+
+# changes hardcoded ghc paths and updates package index
+# $1 - new absolute root path
+relocate_ghc() {
+	local to=$1 ghc_v=${BIN_PV}
+
+	# libdir for prebuilt binary and for current system may mismatch
+	# It does for prefix installation for example: bug #476998
+	local bin_ghc_prefix=${WORKDIR}/usr
+	local bin_libpath=$(echo "${bin_ghc_prefix}"/lib*)
+	local bin_libdir=${bin_libpath#${bin_ghc_prefix}/}
+
+	# backup original script to use it later after relocation
+	local gp_back="${T}/ghc-pkg-${ghc_v}-orig"
+	cp "${WORKDIR}/usr/bin/ghc-pkg-${ghc_v}" "$gp_back" || die "unable to backup ghc-pkg wrapper"
+
+	if [[ ${bin_libdir} != $(get_libdir) ]]; then
+		einfo "Relocating '${bin_libdir}' to '$(get_libdir)' (bug #476998)"
+		# moving the dir itself is not strictly needed
+		# but then USE=binary would result in installing
+		# in '${bin_libdir}'
+		mv "${bin_ghc_prefix}/${bin_libdir}" "${bin_ghc_prefix}/$(get_libdir)" || die
+
+		relocate_path "/usr/${bin_libdir}" "/usr/$(get_libdir)" \
+			"${WORKDIR}/usr/bin/ghc-${ghc_v}" \
+			"${WORKDIR}/usr/bin/ghci-${ghc_v}" \
+			"${WORKDIR}/usr/bin/ghc-pkg-${ghc_v}" \
+			"${WORKDIR}/usr/bin/hsc2hs" \
+			"${WORKDIR}/usr/bin/runghc-${ghc_v}" \
+			"$gp_back" \
+			"${WORKDIR}/usr/$(get_libdir)/${PN}-${ghc_v}/package.conf.d/"*
+	fi
+
+	# Relocate from /usr to ${EPREFIX}/usr
+	relocate_path "/usr" "${to}/usr" \
+		"${WORKDIR}/usr/bin/ghc-${ghc_v}" \
+		"${WORKDIR}/usr/bin/ghci-${ghc_v}" \
+		"${WORKDIR}/usr/bin/ghc-pkg-${ghc_v}" \
+		"${WORKDIR}/usr/bin/haddock-ghc-${ghc_v}" \
+		"${WORKDIR}/usr/bin/hp2ps" \
+		"${WORKDIR}/usr/bin/hpc" \
+		"${WORKDIR}/usr/bin/hsc2hs" \
+		"${WORKDIR}/usr/bin/runghc-${ghc_v}" \
+		"${WORKDIR}/usr/$(get_libdir)/${PN}-${ghc_v}/package.conf.d/"*
+
+	# this one we will use to regenerate cache
+	# so it should point to current tree location
+	relocate_path "/usr" "${WORKDIR}/usr" "$gp_back"
+
+	if use prefix; then
+		hprefixify "${bin_libpath}"/${PN}*/settings
+	fi
+
+	# regenerate the binary package cache
+	"$gp_back" recache || die "failed to update cache after relocation"
+	rm "$gp_back"
+}
+
+ghc-check-reqs() {
+	# These are pessimistic values (slightly bigger than worst-case)
+	# Worst case is UNREG USE=profile ia64. See bug #611866 for some
+	# numbers on various arches.
+	CHECKREQS_DISK_BUILD=8G
+	CHECKREQS_DISK_USR=2G
+	# USE=binary roughly takes
+	use binary && CHECKREQS_DISK_BUILD=4G
+
+	"$@"
+}
+
+pkg_pretend() {
+	ghc-check-reqs check-reqs_pkg_pretend
+}
+
+pkg_setup() {
+	ghc-check-reqs check-reqs_pkg_setup
+
+	# quiet portage about prebuilt binaries
+	use binary && QA_PREBUILT="*"
+
+	[[ ${MERGE_TYPE} == binary ]] && return
+
+	if use ghcbootstrap; then
+		ewarn "You requested ghc bootstrapping, this is usually only used"
+		ewarn "by Gentoo developers to make binary .tbz2 packages."
+
+		[[ -z $(type -P ghc) ]] && \
+			die "Could not find a ghc to bootstrap with."
+	else
+		if ! yet_binary; then
+			eerror "Please try emerging with USE=ghcbootstrap and report build"
+			eerror "sucess or failure to the haskell team (haskell@gentoo.org)"
+			die "No binary available for '${ARCH}' arch yet, USE=ghcbootstrap"
+		fi
+	fi
+
+	if needs_python; then
+		python-any-r1_pkg_setup
+	fi
+}
+
+src_unpack() {
+	# Create the ${S} dir if we're using the binary version
+	use binary && mkdir "${S}"
+
+	# the Solaris and Darwin binaries from ghc (maeder) need to be
+	# unpacked separately, so prevent them from being unpacked
+	local ONLYA=${A}
+	case ${CHOST} in
+		*-darwin* | *-solaris*)  ONLYA=${GHC_P}-src.tar.xz  ;;
+	esac
+	unpack ${ONLYA}
+}
+
+src_prepare() {
+	ghc_setup_cflags
+
+	if ! use ghcbootstrap && [[ ${CHOST} != *-darwin* && ${CHOST} != *-solaris* ]]; then
+		# Modify the wrapper script from the binary tarball to use GHC_PERSISTENT_FLAGS.
+		# See bug #313635.
+		sed -i -e "s|\"\$topdir\"|\"\$topdir\" ${GHC_PERSISTENT_FLAGS}|" \
+			"${WORKDIR}/usr/bin/ghc-${BIN_PV}"
+
+		# allow hardened users use vanilla binary to bootstrap ghc
+		# ghci uses mmap with rwx protection at it implements dynamic
+		# linking on it's own (bug #299709)
+		pax-mark -m "${WORKDIR}/usr/$(get_libdir)/${PN}-${BIN_PV}/bin/ghc"
+	fi
+
+	if use binary; then
+		if use prefix; then
+			relocate_ghc "${EPREFIX}"
+		fi
+
+		# Move unpacked files to the expected place
+		mv "${WORKDIR}/usr" "${S}"
+		eapply_user
+	else
+		if ! use ghcbootstrap; then
+			case ${CHOST} in
+				*-darwin* | *-solaris*)
+				# UPDATE ME for ghc-7
+				mkdir "${WORKDIR}"/ghc-bin-installer || die
+				pushd "${WORKDIR}"/ghc-bin-installer > /dev/null || die
+				use sparc-solaris && unpack ghc-6.10.4-sparc-sun-solaris2.tar.bz2
+				use x86-solaris && unpack ghc-7.0.3-i386-unknown-solaris2.tar.bz2
+				use x86-macos && unpack ghc-7.4.1-i386-apple-darwin.tar.bz2
+				use x64-macos && unpack ghc-7.4.1-x86_64-apple-darwin.tar.bz2
+				popd > /dev/null
+
+				pushd "${WORKDIR}"/ghc-bin-installer/ghc-[67].?*.? > /dev/null || die
+				# fix the binaries so they run, on Solaris we need an
+				# LD_LIBRARY_PATH which has our prefix libdirs, on
+				# Darwin we need to replace the frameworks with our libs
+				# from the prefix fix before installation, because some
+				# of the tools are actually used during configure/make
+				if [[ ${CHOST} == *-solaris* ]] ; then
+					export LD_LIBRARY_PATH="${EPREFIX}/$(get_libdir):${EPREFIX}/usr/$(get_libdir):${LD_LIBRARY_PATH}"
+				elif [[ ${CHOST} == *-darwin* ]] ; then
+					local readline_framework=GNUreadline.framework/GNUreadline
+					local gmp_framework=/opt/local/lib/libgmp.10.dylib
+					local ncurses_file=/opt/local/lib/libncurses.5.dylib
+					for binary in $(scanmacho -BRE MH_EXECUTE -F '%F' .) ; do
+						install_name_tool -change \
+							${readline_framework} \
+							"${EPREFIX}"/lib/libreadline.dylib \
+							${binary} || die
+						install_name_tool -change \
+							${gmp_framework} \
+							"${EPREFIX}"/usr/lib/libgmp.dylib \
+							${binary} || die
+						install_name_tool -change \
+							${ncurses_file} \
+							"${EPREFIX}"/usr/lib/libncurses.dylib \
+							${binary} || die
+					done
+					# we don't do frameworks!
+					sed -i \
+						-e 's/\(frameworks = \)\["GMP"\]/\1[]/g' \
+						-e 's/\(extraLibraries = \)\["m"\]/\1["m","gmp"]/g' \
+						rts/package.conf.in || die
+				fi
+
+				# it is autoconf, but we really don't want to give it too
+				# many arguments, in fact we do the make in-place anyway
+				./configure --prefix="${WORKDIR}"/usr || die
+				make install || die
+				popd > /dev/null
+				;;
+				*)
+				relocate_ghc "${WORKDIR}"
+				;;
+			esac
+		fi
+
+		sed -i -e "s|\"\$topdir\"|\"\$topdir\" ${GHC_PERSISTENT_FLAGS}|" \
+			"${S}/ghc/ghc.wrapper"
+
+		cd "${S}" # otherwise eapply will break
+
+		eapply "${FILESDIR}"/${PN}-9.0.2-CHOST-prefix.patch
+		eapply "${FILESDIR}"/${PN}-9.0.2-darwin.patch
+
+		# Below patch should not be needed by ghc-9.2
+		eapply "${FILESDIR}"/${PN}-9.0.2-modorigin.patch
+
+		# ModUnusable pretty-printing should include the reason
+		eapply "${FILESDIR}/${PN}-9.0.2-verbose-modunusable.patch"
+
+		# Needed for testing with python-3.10
+		use test && eapply "${FILESDIR}/${PN}-9.0.2-fix-tests-python310.patch"
+
+		#needs a port?
+		#eapply "${FILESDIR}"/${PN}-8.8.1-revert-CPP.patch
+		eapply "${FILESDIR}"/${PN}-8.10.1-allow-cross-bootstrap.patch
+		#eapply "${FILESDIR}"/${PN}-8.10.3-C99-typo-ac270.patch
+
+		# a bunch of crosscompiler patches
+		# needs newer version:
+		#eapply "${FILESDIR}"/${PN}-8.2.1_rc1-hp2ps-cross.patch
+
+		# mingw32 target
+		pushd "${S}/libraries/Win32"
+			eapply "${FILESDIR}"/${PN}-8.2.1_rc1-win32-cross-2-hack.patch # bad workaround
+		popd
+
+		bump_libs
+
+		eapply_user
+		# as we have changed the build system
+		eautoreconf
+	fi
+}
+
+src_configure() {
+	if ! use binary; then
+		# initialize build.mk
+		echo '# Gentoo changes' > mk/build.mk
+
+		# Put docs into the right place, ie /usr/share/doc/ghc-${GHC_PV}
+		echo "docdir = ${EPREFIX}/usr/share/doc/$(cross)${PF}" >> mk/build.mk
+		echo "htmldir = ${EPREFIX}/usr/share/doc/$(cross)${PF}" >> mk/build.mk
+
+		# We also need to use the GHC_FLAGS flags when building ghc itself
+		echo "SRC_HC_OPTS+=${HCFLAGS} ${GHC_FLAGS}" >> mk/build.mk
+		echo "SRC_CC_OPTS+=${CFLAGS}" >> mk/build.mk
+		echo "SRC_LD_OPTS+=${LDFLAGS}" >> mk/build.mk
+		# Speed up initial Cabal bootstrap
+		echo "utils/ghc-cabal_dist_EXTRA_HC_OPTS+=$(ghc-make-args)" >> mk/build.mk
+
+		# We can't depend on haddock except when bootstrapping when we
+		# must build docs and include them into the binary .tbz2 package
+		# app-text/dblatex is not in portage, can not build PDF or PS
+		echo "BUILD_SPHINX_PDF  = NO"  >> mk/build.mk
+		echo "BUILD_SPHINX_HTML = $(usex doc YES NO)" >> mk/build.mk
+		echo "BUILD_MAN = $(usex doc YES NO)" >> mk/build.mk
+
+		# this controls presence on 'xhtml' and 'haddock' in final install
+		echo "HADDOCK_DOCS       = YES" >> mk/build.mk
+
+		# not used outside of ghc's test
+		if [[ -n ${GHC_BUILD_DPH} ]]; then
+				echo "BUILD_DPH = YES" >> mk/build.mk
+			else
+				echo "BUILD_DPH = NO" >> mk/build.mk
+		fi
+
+		# Any non-native build has to skip as it needs
+		# target haddock binary to be runnabine.
+		if ! is_native; then
+			# disable docs generation as it requires running stage2
+			echo "HADDOCK_DOCS=NO" >> mk/build.mk
+			echo "BUILD_SPHINX_HTML=NO" >> mk/build.mk
+			echo "BUILD_SPHINX_PDF=NO" >> mk/build.mk
+		fi
+
+		if is_crosscompile; then
+			# Install ghc-stage1 crosscompiler instead of
+			# ghc-stage2 cross-built compiler.
+			echo "Stage1Only=YES" >> mk/build.mk
+		fi
+
+		# allows overriding build flavours for libraries:
+		# v   - vanilla (static libs)
+		# p   - profiled
+		# dyn - shared libraries
+		# example: GHC_LIBRARY_WAYS="v dyn"
+		if [[ -n ${GHC_LIBRARY_WAYS} ]]; then
+			echo "GhcLibWays=${GHC_LIBRARY_WAYS}" >> mk/build.mk
+		fi
+		echo "BUILD_PROF_LIBS = $(usex profile YES NO)" >> mk/build.mk
+
+		# Get ghc from the unpacked binary .tbz2
+		# except when bootstrapping we just pick ghc up off the path
+		if ! use ghcbootstrap; then
+			export PATH="${WORKDIR}/usr/bin:${PATH}"
+		fi
+
+		echo "BIGNUM_BACKEND = $(usex gmp gmp native)" >> mk/build.mk
+
+		# don't strip anything. Very useful when stage2 SIGSEGVs on you
+		echo "STRIP_CMD = :" >> mk/build.mk
+
+		local econf_args=()
+
+		# GHC embeds toolchain it was built by and uses it later.
+		# Don't allow things like ccache or versioned binary slip.
+		# We use stable thing across gcc upgrades.
+		# User can use EXTRA_ECONF=CC=... to override this default.
+		econf_args+=(
+			AR=${CTARGET}-ar
+			CC=${CTARGET}-gcc
+			# these should be inferred by GHC but ghc defaults
+			# to using bundled tools on windows.
+			Windres=${CTARGET}-windres
+			DllWrap=${CTARGET}-dllwrap
+			# we set the linker explicitly below
+			--disable-ld-override
+		)
+		case ${CTARGET} in
+			arm*)
+				# ld.bfd-2.28 does not work for ghc. Force ld.gold
+				# instead. This should be removed once gentoo gets
+				# a fix for R_ARM_COPY bug: https://sourceware.org/PR16177
+				econf_args+=(LD=${CTARGET}-ld.gold)
+			;;
+			sparc*)
+				# ld.gold-2.28 does not work for ghc. Force ld.bfd
+				# instead. This should be removed once gentoo gets
+				# a fix for missing --no-relax support bug:
+				# https://sourceware.org/ml/binutils/2017-07/msg00183.html
+				econf_args+=(LD=${CTARGET}-ld.bfd)
+			;;
+			*)
+				econf_args+=(LD=${CTARGET}-ld)
+		esac
+
+		if [[ ${CBUILD} != ${CHOST} ]]; then
+			# GHC bug: ghc claims not to support cross-building.
+			# It does, but does not distinct --host= value
+			# for stage1 and stage2 compiler.
+			econf_args+=(--host=${CBUILD})
+		fi
+
+		if use ghcmakebinary; then
+			# When building booting libary we are trying to
+			# bundle or restrict most of external depends
+			# with unstable ABI:
+			#  - embed libffi (default GHC behaviour)
+			#  - disable ncurses support for ghci (via haskeline)
+			#    https://bugs.gentoo.org/557478
+			#  - disable ncurses support for ghc-pkg
+			echo "libraries/haskeline_CONFIGURE_OPTS += --flag=-terminfo" >> mk/build.mk
+			echo "utils/ghc-pkg_HC_OPTS += -DBOOTSTRAPPING" >> mk/build.mk
+		elif is_native; then
+			# using ${GTARGET}'s libffi is not supported yet:
+			# GHC embeds full path for ffi includes without /usr/${CTARGET} account.
+			econf_args+=(--with-system-libffi)
+			econf_args+=(--with-ffi-includes=$($(tc-getPKG_CONFIG) libffi --cflags-only-I | sed -e 's@^-I@@'))
+		fi
+
+		einfo "Final mk/build.mk:"
+		cat mk/build.mk || die
+
+		econf ${econf_args[@]} \
+			--enable-bootstrap-with-devel-snapshot \
+			$(use_enable elfutils dwarf-unwind) \
+			$(use_enable numa)
+
+		if [[ ${PV} == *9999* ]]; then
+			GHC_PV="$(grep 'S\[\"PACKAGE_VERSION\"\]' config.status | sed -e 's@^.*=\"\(.*\)\"@\1@')"
+			GHC_P=${PN}-${GHC_PV}
+		fi
+	fi # ! use binary
+}
+
+src_compile() {
+	if ! use binary; then
+		# Stage1Only crosscompiler does not build stage2
+		if ! is_crosscompile; then
+			# 1. build/pax-mark compiler binary first
+			emake ghc/stage2/build/tmp/ghc-stage2
+			# 2. pax-mark (bug #516430)
+			pax-mark -m ghc/stage2/build/tmp/ghc-stage2
+			# 2. build/pax-mark haddock using ghc-stage2
+			if is_native; then
+				# non-native build does not build haddock
+				# due to HADDOCK_DOCS=NO, but it could.
+				emake utils/haddock/dist/build/tmp/haddock
+				pax-mark -m utils/haddock/dist/build/tmp/haddock
+			fi
+		fi
+		# 3. and then all the rest
+		emake all
+	fi # ! use binary
+}
+
+src_test() {
+	# TODO: deal with:
+	#    - sandbox (pollutes environment)
+	#    - extra packages (to extend testsuite coverage)
+	# bits are taken from 'validate'
+	local make_test_target='test' # can be fulltest
+	# not 'emake' as testsuite uses '$MAKE' without jobserver available
+	make $make_test_target stage=2 THREADS=$(makeopts_jobs)
+}
+
+src_install() {
+	if use binary; then
+		use prefix && mkdir -p "${ED}"
+		mv "${S}/usr" "${ED}"
+	else
+		[[ -f VERSION ]] || emake VERSION
+
+		# -j1 due to a rare race in install script:
+		#    make --no-print-directory -f ghc.mk phase=final install
+		#    /usr/lib/portage/python3.4/ebuild-helpers/xattr/install -c -m 755 \
+		#        -d "/tmp/portage-tmpdir/portage/cross-armv7a-unknown-linux-gnueabi/ghc-9999/image/usr/lib64/armv7a-unknown-linux-gnueabi-ghc-8.3.20170404/include"
+		#    /usr/lib/portage/python3.4/ebuild-helpers/xattr/install -c -m 644  utils/hsc2hs/template-hsc.h \
+		#           "/tmp/portage-tmpdir/portage/cross-armv7a-unknown-linux-gnueabi/ghc-9999/image/usr/lib64/armv7a-unknown-linux-gnueabi-ghc-8.3.20170404"
+		#    /usr/bin/install: cannot create regular file \
+		#           '/tmp/portage-tmpdir/portage/cross-armv7a-unknown-linux-gnueabi/ghc-9999/image/usr/lib64/armv7a-unknown-linux-gnueabi-ghc-8.3.20170404': No such file or directory
+		emake -j1 install DESTDIR="${D}"
+
+		# Skip for cross-targets as they all share target location:
+		# /usr/share/doc/ghc-9999/
+		if ! is_crosscompile; then
+			dodoc "distrib/README" "LICENSE" "VERSION"
+		fi
+
+		# rename ghc-shipped files to avoid collision
+		# of external packages. Motivating example:
+		#  user had installed:
+		#      dev-lang/ghc-7.8.4-r0 (with transformers-0.3.0.0)
+		#      dev-haskell/transformers-0.4.2.0
+		#  then user tried to update to
+		#      dev-lang/ghc-7.8.4-r1 (with transformers-0.4.2.0)
+		#  this will lead to single .conf file collision.
+		local shipped_conf renamed_conf
+		local package_confdir="${ED}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d"
+		for shipped_conf in "${package_confdir}"/*.conf; do
+			# rename 'pkg-ver-id.conf' to 'pkg-ver-id-gentoo-${PF}.conf'
+			renamed_conf=${shipped_conf%.conf}-gentoo-${PF}.conf
+			mv "${shipped_conf}" "${renamed_conf}" || die
+		done
+
+		# remove link, but leave 'haddock-${GHC_P}'
+		rm -f "${ED}"/usr/bin/$(cross)haddock
+
+		if ! is_crosscompile; then
+			newbashcomp "${FILESDIR}"/ghc-bash-completion ghc-pkg
+			newbashcomp utils/completion/ghc.bash         ghc
+		fi
+	fi
+
+	# path to the package.cache
+	local package_confdir="${ED}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d"
+	PKGCACHE="${package_confdir}"/package.cache
+	# copy the package.conf.d, including timestamp, save it so we can help
+	# users that have a broken package.conf.d
+	cp -pR "${package_confdir}"{,.initial} || die "failed to backup intial package.conf.d"
+
+	# copy the package.conf, including timestamp, save it so we later can put it
+	# back before uninstalling, or when upgrading.
+	cp -p "${PKGCACHE}"{,.shipped} \
+		|| die "failed to copy package.conf.d/package.cache"
+
+	if is_crosscompile; then
+		# When we build a cross-compiler the layout is the following:
+		#     usr/lib/${CTARGET}-ghc-${VER}/ contains target libraries
+		# but
+		#     usr/lib/${CTARGET}-ghc-${VER}/bin/ directory
+		# containst host binaries (modulo bugs).
+
+		# Portage's stripping mechanism does not skip stripping
+		# foreign binaries. This frequently causes binaries to be
+		# broken.
+		#
+		# Thus below we disable stripping of target libraries and allow
+		# stripping hosts executables.
+		dostrip -x "/usr/$(get_libdir)/$(cross)${GHC_P}"
+		dostrip    "/usr/$(get_libdir)/$(cross)${GHC_P}/bin"
+	fi
+}
+
+pkg_preinst() {
+	# have we got an earlier version of ghc installed?
+	if has_version "<${CATEGORY}/${PF}"; then
+		haskell_updater_warn="1"
+	fi
+}
+
+pkg_postinst() {
+	ghc-reregister
+
+	# path to the package.cache
+	PKGCACHE="${EROOT}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d/package.cache"
+
+	# give the cache a new timestamp, it must be as recent as
+	# the package.conf.d directory.
+	touch "${PKGCACHE}"
+
+	if [[ "${haskell_updater_warn}" == "1" ]]; then
+		ewarn
+		ewarn "\e[1;31m************************************************************************\e[0m"
+		ewarn
+		ewarn "You have just upgraded from an older version of GHC."
+		ewarn "You may have to run"
+		ewarn "      'haskell-updater'"
+		ewarn "to rebuild all ghc-based Haskell libraries."
+		ewarn
+		ewarn "\e[1;31m************************************************************************\e[0m"
+		ewarn
+	fi
+}
+
+pkg_prerm() {
+	PKGCACHE="${EROOT}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d/package.cache"
+	rm -rf "${PKGCACHE}"
+
+	cp -p "${PKGCACHE}"{.shipped,}
+}
+
+pkg_postrm() {
+	ghc-package_pkg_postrm
+}


^ permalink raw reply related	[flat|nested] 15+ messages in thread
* [gentoo-commits] repo/gentoo:master commit in: dev-lang/ghc/, dev-lang/ghc/files/
@ 2021-12-14 11:46 Sam James
  0 siblings, 0 replies; 15+ messages in thread
From: Sam James @ 2021-12-14 11:46 UTC (permalink / raw
  To: gentoo-commits

commit:     1896d50ddab8495c4fb1f116799c0fbf6b22a817
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Tue Dec 14 11:45:48 2021 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Tue Dec 14 11:45:48 2021 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=1896d50d

dev-lang/ghc: fix build with autoconf 2.71

Closes: https://bugs.gentoo.org/829162
Signed-off-by: Sam James <sam <AT> gentoo.org>

 dev-lang/ghc/files/ghc-8.8.4-autoconf-2.71.patch | 22 ++++++++++++++++++++++
 dev-lang/ghc/ghc-8.8.4-r1.ebuild                 |  1 +
 2 files changed, 23 insertions(+)

diff --git a/dev-lang/ghc/files/ghc-8.8.4-autoconf-2.71.patch b/dev-lang/ghc/files/ghc-8.8.4-autoconf-2.71.patch
new file mode 100644
index 000000000000..5de8c6806b79
--- /dev/null
+++ b/dev-lang/ghc/files/ghc-8.8.4-autoconf-2.71.patch
@@ -0,0 +1,22 @@
+https://bugs.gentoo.org/829162
+https://gitlab.haskell.org/ghc/ghc/-/issues/19655
+https://gitlab.haskell.org/ghc/ghc/-/commit/ad2ef3a13f1eb000eab8e3d64592373b91a52806
+
+From: Moritz Angermann <moritz.angermann@gmail.com>
+Date: Wed, 17 Feb 2021 21:13:07 +0800
+Subject: [PATCH] [configure] Fix _AC_PROG_CC_99
+
+_AC_PROG_CC_99 isn't available anymore in recent autoconf versions.
+This broke on aarch64-darwin.
+--- a/aclocal.m4
++++ b/aclocal.m4
+@@ -659,7 +659,7 @@ AC_DEFUN([FP_SET_CFLAGS_C99],
+     CPPFLAGS="$$3"
+     unset ac_cv_prog_cc_c99
+     dnl perform detection
+-    _AC_PROG_CC_C99
++    AC_PROG_CC_C99
+     fp_cc_c99="$ac_cv_prog_cc_c99"
+     case "x$ac_cv_prog_cc_c99" in
+       x)   ;; # noop
+GitLab

diff --git a/dev-lang/ghc/ghc-8.8.4-r1.ebuild b/dev-lang/ghc/ghc-8.8.4-r1.ebuild
index 6254a54371ae..5803cfac6333 100644
--- a/dev-lang/ghc/ghc-8.8.4-r1.ebuild
+++ b/dev-lang/ghc/ghc-8.8.4-r1.ebuild
@@ -510,6 +510,7 @@ src_prepare() {
 		eapply "${FILESDIR}"/${PN}-7.8.3-prim-lm.patch
 		eapply "${FILESDIR}"/${PN}-8.0.2-no-relax-everywhere.patch
 		eapply "${FILESDIR}"/${PN}-8.4.2-allow-cross-bootstrap.patch
+		eapply "${FILESDIR}"/${P}-autoconf-2.71.patch
 		# fixed in 8.8.4. See https://gitlab.haskell.org/ghc/ghc/-/blob/ghc-8.8.4-release/configure.ac#L1273
 		# eapply "${FILESDIR}"/${PN}-8.6.5-numa.patch
 		# rumors say this is fixed properly in 8.8.3. Let's check!


^ permalink raw reply related	[flat|nested] 15+ messages in thread
* [gentoo-commits] repo/gentoo:master commit in: dev-lang/ghc/, dev-lang/ghc/files/
@ 2021-08-27  8:23 Mark Wright
  0 siblings, 0 replies; 15+ messages in thread
From: Mark Wright @ 2021-08-27  8:23 UTC (permalink / raw
  To: gentoo-commits

commit:     c3e9bd6f88b4d24a55bd8959f5248732077e376b
Author:     Jack Todaro <solpeth <AT> posteo <DOT> org>
AuthorDate: Tue Aug 24 07:17:23 2021 +0000
Commit:     Mark Wright <gienah <AT> gentoo <DOT> org>
CommitDate: Fri Aug 27 08:22:31 2021 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=c3e9bd6f

dev-lang/ghc: sync 8.10.6 from ::haskell (no keywords)

Package-Manager: Portage-3.0.22, Repoman-3.0.3
Signed-off-by: Jack Todaro <solpeth <AT> posteo.org>
Signed-off-by: Mark Wright <gienah <AT> gentoo.org>

 dev-lang/ghc/Manifest                              |   4 +
 .../ghc-8.10.5-modorigin-verbose-conflict.patch    |  20 +
 dev-lang/ghc/ghc-8.10.6.ebuild                     | 814 +++++++++++++++++++++
 3 files changed, 838 insertions(+)

diff --git a/dev-lang/ghc/Manifest b/dev-lang/ghc/Manifest
index d072a4397b6..0c3307d5e44 100644
--- a/dev-lang/ghc/Manifest
+++ b/dev-lang/ghc/Manifest
@@ -2,6 +2,8 @@ DIST ghc-8.10.4-src.tar.xz 19818108 BLAKE2B 069dd8436c373ccf73c20d8b577243792ffd
 DIST ghc-8.10.4-testsuite.tar.xz 2236932 BLAKE2B 17d0520ad5c6daa0cc60530279ae7e617e4d79328b9f436abbe75e72f0803d9a997fb9e1ae61425326b070f45794a488d8507957fec9a6ed49eea86d30a1e579 SHA512 1bf129c8d872e3ceff7c19929605adc5d68daab9ded9aa2e5109b0de162089631472c66f04993adf8481291f8128bf804fe64a9d344c81e257f1b962ba5e382c
 DIST ghc-8.10.5-src.tar.xz 19920148 BLAKE2B bd3b702fdac4d1c94366bb233a665c2f5677b795d9041c61cc13d813aa43738d5270c3604731f964393035cef90768d4c6e0e401aa35fec6dab61465782f41dc SHA512 b5f39be0accd5c1cecf1cc326ba3142f561d2ac93e9abf366fe46307d7c0712aac244836e659e1a4d9d0fb98299ea96edc8e8a06f3a81b528b14914b94057ffe
 DIST ghc-8.10.5-testsuite.tar.xz 2270504 BLAKE2B 076afc4565c7ba52814547b09313c44bfc3875fc0b05d1af1d3fa702cec9b6b219d86fd56d26a3df07aaa00b37eeb87c58b509162a231bf4e03a07bcc57e9550 SHA512 adae7ff8005c73fc5ded42035c51b1ad6c476beed54de7ba336437a67e81a75d7af8c1be3817516e877b1b2ff0e771fe667d07b93d3a73de8df26a06ed42f334
+DIST ghc-8.10.6-src.tar.xz 19932832 BLAKE2B f5d0c43aa5df87648e32beeb5ed6866b231cbce4f344fb03110db826b36bbac435f5e89d9ffeef3f87c15e830fdee6b95150b7bdcd06906575bfcd9c83797dff SHA512 6314eb9744d47d803b30b621bd12bf6179dad5cc578ec267b3a65b89e9c9b431bdb4913936f040c7ca4fcc71a676a43e78b5f6173d123a844e7f29004405b8b6
+DIST ghc-8.10.6-testsuite.tar.xz 2265044 BLAKE2B 72a1e955acecc92a720ee2747d96cacf56f2968c9deabb254c882a969c154baa0fdb639a857844ec91a4e47ee553dd13b58c3b790202e7e73500095c1ec85ee9 SHA512 f74d743bd8f889c2941be8fd5348e92abcaf75bce48140f7f9cc0c6ce33ba24a8479bef48631ffe2a10397c0ecf166b3bddb6ca8ee905859c029175de5d43f2a
 DIST ghc-8.8.4-src.tar.xz 19395252 BLAKE2B 6fa898b9552398a724f0452f5cc88ba073264a5645288c73507258959efec40ce5a56a0eaafdabe58f15c5a9210b2c9da5954411dff5c81c52e061569d6a350a SHA512 efd23bd819f7429486696a3a929a040471db7ea8a2d1f1d832e4cf0825b9e1e0c5e6ecad0ab8376f58b74e9c28c1d2f773bd126596d6d853c9e57d57e5ceb090
 DIST ghc-8.8.4-testsuite.tar.xz 1965820 BLAKE2B 3b715700561788b8abdc986961d533b91399461d57a1686ededb4ccc36881503cdc3fc126b9a7b204a728c24b9a9ca97320142348644367aca9b47c87a5b3b51 SHA512 79d8fb0ba8de0fb48c938bd54c8c3278f1895d8ce5c700ce8cf6b3fc550073bb757208e85d4f9818400ebecca96f51d9248b8bbdac9eb2995671756164d08c16
 DIST ghc-9.0.1-src.tar.xz 20782336 BLAKE2B 53eaf903081d705d641459fbc1e6fa7387a6039f9cd466b4708bda86e81252a84d80878d6eb956ec2e1e5b721a313e68eeb796f8345244ca62f536a7a3f0c6df SHA512 bee7950a5118be8d8cefe0db5070139a5a93ca21c5bc6f8bf453429831f0c44f5e0fb5ee569865d6b8b92749044ee4123be06920928ac7a1ec9cffa9404a3e53
@@ -10,6 +12,8 @@ DIST ghc-bin-8.10.4-i686-pc-linux-gnu.tbz2 123831294 BLAKE2B 1ca4c1b5c34c9480110
 DIST ghc-bin-8.10.4-x86_64-pc-linux-gnu.tbz2 122558873 BLAKE2B 9f07c7bdc3beccfa629d28b2524ccd2f4688a5c0036a45408f5ace2d530a2a0e42f95b3cda5037ebb365317999e1ae776c6f9d21692867abfe85e33f2892b1be SHA512 68bd70f94961547746a696aa2839e156c95858fda0c7ec5b2ecf802070724ab7102b0aa86bcbf93432170d521cce4af10f46b851b470e5dc49dfa5b07380f46d
 DIST ghc-bin-8.10.5-i686-pc-linux-gnu.tbz2 124356781 BLAKE2B 53c5d259a19f11db83d69f7a2f39090d623b07caf1859eb8bf0385183586f538d8eb3eadb06f56f4b7160fa82043eb0f7b8df1632d55af562b8b1cb21c08b4c3 SHA512 58676b4eaeef9e05f69b7c821e115f3a678487b0de696e702ff6378f7d8f23fafda997b0c19d52a730c22bf8012a99c01783d16d00e356fe12532156d5965fc6
 DIST ghc-bin-8.10.5-x86_64-pc-linux-gnu.tbz2 123186918 BLAKE2B 5049514a7c2c58e7f5c929cfb9e818cdc20280f4fc002350cf0cc19f410eb4d4be4d0b46db88205633fde73151e322f3cabd050a9c07e05ccae168c7e6be8be9 SHA512 3a8ef5f0c259ad86adc6a7a5718db419fb0e38a5d1e0bdcc8676e44d1a0130a4b25658ab23572e4e860307b024409da021e08b038fac64a773437c23519b1d0a
+DIST ghc-bin-8.10.6-i686-pc-linux-gnu.tbz2 124324289 BLAKE2B afb34984872b35fdedbdedeb8756cc7c33e5b943dba57dd86910b076d483bb643265d0ab0027784dec5dc489eabd65b5ab17474f25fb2ce657925aa0efaa9033 SHA512 4be13e6dba298d12a4d49ae4633eec83cfaaaf22b5f8cfca5f5952aa294ae52fb3601490beed3bda5a7f7b6a5bd81e0ecc9fc39e8df836cc8fd377a0d0b783a0
+DIST ghc-bin-8.10.6-x86_64-pc-linux-gnu.tbz2 122871118 BLAKE2B 527b36abf60390c91f91bc650ee25484d39d377739da87b5b6fd1a752705c1f3bc0ce0c68644657c9a7c1fc9a3b858b9dd7d84b25eab1a89125fccb6eb1f6250 SHA512 42b7fae339e82a6078fae8920efea8d0992e4774ea66b100e22dd9df168be57d8bce52558b8501c3c567c40776389d94bde3f17d26d63535140ce26ac16c27e1
 DIST ghc-bin-8.8.4-i686-pc-linux-gnu.tbz2 120336081 BLAKE2B 55dfbb90d5e55c2af5e93c69249828a85cd9171c164b80dfdaf86512972b2c6854c8e4f07426af4ab52a5fb1a85d96a58c2cf003fb02372c55428001cfaea491 SHA512 ad3b83344349976d3253934195b2dc6299648391572b13735943c5ea2239c031c19b0cafd86c16cfb0c061e73bc72e9248f9c1731494a9a15fbe188f02913c12
 DIST ghc-bin-8.8.4-x86_64-pc-linux-gnu.tbz2 118897883 BLAKE2B a180b2dd1a3bc222044ece809ad700aee29d0c3e75b57ee9af3ca33c9c0f59dbf36f68202f746d99f80915cb717a9c41fc12db507f1cb469981732703a06b9cc SHA512 9d4be02dbd9704c93ef18feb92ea30bd5d590df31f288bf1b364818424c5019ca9ada26eec88418199f90ae8f4459d0a9352104e3f3186bbdc241891eb1b66c4
 DIST ghc-bin-9.0.1-i686-pc-linux-gnu.tbz2 122955511 BLAKE2B b870f46cc78fcc1d715aafe7108951582cfd12495b4e9d804d4b66562c66a6a2b2d9513031aedc8f3630a0cdbb3257943304b05732301a084f89487452f2f2d9 SHA512 aafd4233c40f93b71e6ac1acc8a75e30d49b826e4bce6d9832836966fd5f6c4898963bd4c2f34577f4199c1d9a3f537ac1e7d87eab11e9fb5e849573580ed3fb

diff --git a/dev-lang/ghc/files/ghc-8.10.5-modorigin-verbose-conflict.patch b/dev-lang/ghc/files/ghc-8.10.5-modorigin-verbose-conflict.patch
new file mode 100644
index 00000000000..a34c0c9059f
--- /dev/null
+++ b/dev-lang/ghc/files/ghc-8.10.5-modorigin-verbose-conflict.patch
@@ -0,0 +1,20 @@
+--- a/compiler/main/Packages.hs
++++ b/compiler/main/Packages.hs
+@@ -219,12 +219,14 @@ fromFlag = ModOrigin Nothing [] [] True
+ instance Semigroup ModuleOrigin where
+     ModOrigin e res rhs f <> ModOrigin e' res' rhs' f' =
+         ModOrigin (g e e') (res ++ res') (rhs ++ rhs') (f || f')
+-      where g (Just b) (Just b')
++      where g x@(Just b) y@(Just b')
+                 | b == b'   = Just b
+-                | otherwise = panic "ModOrigin: package both exposed/hidden"
++                | otherwise = pprPanic "ModOrigin: package both exposed/hidden" $
++                                text "x: " <> ppr x $$ text "y: " <> ppr y
+             g Nothing x = x
+             g x Nothing = x
+-    _x <> _y = panic "ModOrigin: hidden module redefined"
++    x <> y = pprPanic "ModOrigin: hidden module redefined" $
++               text "x: " <> ppr x $$ text "y: " <> ppr y
+ 
+ instance Monoid ModuleOrigin where
+     mempty = ModOrigin Nothing [] [] False

diff --git a/dev-lang/ghc/ghc-8.10.6.ebuild b/dev-lang/ghc/ghc-8.10.6.ebuild
new file mode 100644
index 00000000000..4276efffd61
--- /dev/null
+++ b/dev-lang/ghc/ghc-8.10.6.ebuild
@@ -0,0 +1,814 @@
+# Copyright 1999-2021 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+# to make make a crosscompiler use crossdev and symlink ghc tree into
+# cross overlay. result would look like 'cross-sparc-unknown-linux-gnu/ghc'
+export CBUILD=${CBUILD:-${CHOST}}
+export CTARGET=${CTARGET:-${CHOST}}
+if [[ ${CTARGET} = ${CHOST} ]] ; then
+	if [[ ${CATEGORY/cross-} != ${CATEGORY} ]] ; then
+		export CTARGET=${CATEGORY/cross-}
+	fi
+fi
+
+PYTHON_COMPAT=( python3_{7..9} )
+inherit python-any-r1
+inherit autotools bash-completion-r1 eutils flag-o-matic ghc-package
+inherit multilib multiprocessing pax-utils toolchain-funcs prefix
+inherit check-reqs
+DESCRIPTION="The Glasgow Haskell Compiler"
+HOMEPAGE="https://www.haskell.org/ghc/"
+
+# we don't have any binaries yet
+arch_binaries=""
+
+BIN_PV=${PV}
+# sorted!
+#arch_binaries="$arch_binaries alpha? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-alpha.tbz2 )"
+#arch_binaries="$arch_binaries arm? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-armv7a-hardfloat-linux-gnueabi.tbz2 )"
+#arch_binaries="$arch_binaries arm64? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-aarch64-unknown-linux-gnu.tbz2 )"
+arch_binaries="$arch_binaries amd64? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-x86_64-pc-linux-gnu.tbz2 )"
+#arch_binaries="$arch_binaries ia64?  ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-ia64-fixed-fiw.tbz2 )"
+#arch_binaries="$arch_binaries ppc? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-ppc.tbz2 )"
+#arch_binaries="$arch_binaries ppc64? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-ppc64.tbz2 )"
+#arch_binaries="$arch_binaries ppc64? ( !big-endian? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-powerpc64le-unknown-linux-gnu.tbz2 ) )"
+#arch_binaries="$arch_binaries sparc? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-sparc.tbz2 )"
+arch_binaries="$arch_binaries x86? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-i686-pc-linux-gnu.tbz2 )"
+
+# various ports:
+#arch_binaries="$arch_binaries x86-fbsd? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-x86-fbsd.tbz2 )"
+
+# 0 - yet
+yet_binary() {
+	case "${ARCH}" in
+		#alpha) return 0 ;;
+		#arm64) return 0 ;;
+		#arm) return 0 ;;
+		amd64) return 0 ;;
+		#ia64) return 0 ;;
+		#ppc) return 0 ;;
+		#ppc64)
+		#	use big-endian && return 0
+		#	return 0
+		#	;;
+		#sparc) return 0 ;;
+		x86) return 0 ;;
+		*) return 1 ;;
+	esac
+}
+
+GHC_PV=${PV}
+#GHC_PV=8.10.0.20200123 # uncomment only for -alpha, -beta, -rc ebuilds
+GHC_P=${PN}-${GHC_PV} # using ${P} is almost never correct
+
+SRC_URI="!binary? (
+	https://downloads.haskell.org/ghc/${PV/_/-}/${GHC_P}-src.tar.xz
+	test? ( https://downloads.haskell.org/ghc/${PV/_/-}/${GHC_P}-testsuite.tar.xz )
+)"
+S="${WORKDIR}"/${GHC_P}
+
+[[ -n $arch_binaries ]] && SRC_URI+=" !ghcbootstrap? ( $arch_binaries )"
+
+BUMP_LIBRARIES=(
+	# "hackage-name          hackage-version"
+)
+
+LICENSE="BSD"
+SLOT="0/${PV}"
+#KEYWORDS="~amd64 ~x86"
+IUSE="big-endian +doc elfutils ghcbootstrap ghcmakebinary +gmp numa profile test"
+IUSE+=" binary"
+RESTRICT="!test? ( test )"
+
+RDEPEND="
+	>=dev-lang/perl-5.6.1
+	dev-libs/gmp:0=
+	sys-libs/ncurses:=[unicode(+)]
+	elfutils? ( dev-libs/elfutils )
+	!ghcmakebinary? ( dev-libs/libffi:= )
+	numa? ( sys-process/numactl )
+"
+
+# This set of dependencies is needed to run
+# prebuilt ghc. We specifically avoid ncurses
+# dependency with:
+#    utils/ghc-pkg_HC_OPTS += -DBOOTSTRAPPING
+PREBUILT_BINARY_DEPENDS="
+	!prefix? ( elibc_glibc? ( >=sys-libs/glibc-2.17 ) )
+"
+# This set of dependencies is needed to install
+# ghc[binary] in system. terminfo package is linked
+# against ncurses.
+PREBUILT_BINARY_RDEPENDS="${PREBUILT_BINARY_DEPENDS}
+	sys-libs/ncurses:0/6
+"
+
+RDEPEND+="binary? ( ${PREBUILT_BINARY_RDEPENDS} )"
+
+DEPEND="${RDEPEND}"
+BDEPEND="
+	virtual/pkgconfig
+	doc? ( app-text/docbook-xml-dtd:4.2
+		app-text/docbook-xml-dtd:4.5
+		app-text/docbook-xsl-stylesheets
+		dev-python/sphinx
+		>=dev-libs/libxslt-1.1.2 )
+	!ghcbootstrap? ( ${PREBUILT_BINARY_DEPENDS} )
+	test? ( ${PYTHON_DEPS} )
+"
+
+needs_python() {
+	# test driver is written in python
+	use test && return 0
+	return 1
+}
+
+# we build binaries without profiling support
+REQUIRED_USE="
+	?? ( ghcbootstrap binary )
+	?? ( profile binary )
+"
+
+# haskell libraries built with cabal in configure mode, #515354
+QA_CONFIGURE_OPTIONS+=" --with-compiler --with-gcc"
+
+is_crosscompile() {
+	[[ ${CHOST} != ${CTARGET} ]]
+}
+
+is_native() {
+	[[ ${CHOST} == ${CBUILD} ]] && [[ ${CHOST} == ${CTARGET} ]]
+}
+
+if ! is_crosscompile; then
+	PDEPEND="!ghcbootstrap? ( >=app-admin/haskell-updater-1.2 )"
+fi
+
+# returns tool prefix for crosscompiler.
+# Example:
+#  CTARGET=armv7a-unknown-linux-gnueabi
+#  CHOST=x86_64-pc-linux-gnu
+#    "armv7a-unknown-linux-gnueabi-"
+#  CTARGET=${CHOST}
+#    ""
+# Used in tools and library prefix:
+#    "${ED}"/usr/bin/$(cross)haddock
+#    "${ED}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d"
+
+cross() {
+	if is_crosscompile; then
+		echo "${CTARGET}-"
+	else
+		echo ""
+	fi
+}
+
+append-ghc-cflags() {
+	local persistent compile assemble link
+	local flag ghcflag
+
+	for flag in $*; do
+		case ${flag} in
+			persistent)	persistent="yes";;
+			compile)	compile="yes";;
+			assemble)	assemble="yes";;
+			link)		link="yes";;
+			*)
+				[[ ${compile}  ]] && ghcflag="-optc${flag}"  CFLAGS+=" ${flag}" && GHC_FLAGS+=" ${ghcflag}" &&
+					[[ ${persistent} ]] && GHC_PERSISTENT_FLAGS+=" ${ghcflag}"
+				[[ ${assemble} ]] && ghcflag="-opta${flag}"  CFLAGS+=" ${flag}" && GHC_FLAGS+=" ${ghcflag}" &&
+					[[ ${persistent} ]] && GHC_PERSISTENT_FLAGS+=" ${ghcflag}"
+				[[ ${link}     ]] && ghcflag="-optl${flag}" LDFLAGS+=" ${flag}" && GHC_FLAGS+=" ${ghcflag}" &&
+					[[ ${persistent} ]] && GHC_PERSISTENT_FLAGS+=" ${ghcflag}"
+				;;
+		esac
+	done
+}
+
+# $1 - lib name (under libraries/)
+# $2 - lib version
+# example: bump_lib "transformers" "0.4.2.0"
+bump_lib() {
+	local pn=$1 pv=$2
+	local p=${pn}-${pv}
+	local f
+
+	einfo "Bumping ${pn} up to ${pv}"
+
+	for f in ghc.mk GNUmakefile; do
+		mv libraries/"${pn}"/$f "${WORKDIR}"/"${p}"/$f || die
+	done
+	mv libraries/"${pn}" "${WORKDIR}"/"${pn}".old || die
+	mv "${WORKDIR}"/"${p}" libraries/"${pn}" || die
+}
+
+update_SRC_URI() {
+	local p pn pv
+	for p in "${BUMP_LIBRARIES[@]}"; do
+		set -- $p
+		pn=$1 pv=$2
+
+		SRC_URI+=" https://hackage.haskell.org/package/${pn}-${pv}/${pn}-${pv}.tar.gz"
+	done
+}
+
+update_SRC_URI
+
+bump_libs() {
+	local p pn pv
+	for p in "${BUMP_LIBRARIES[@]}"; do
+		set -- $p
+		pn=$1 pv=$2
+
+		bump_lib "${pn}" "${pv}"
+	done
+}
+
+ghc_setup_cflags() {
+	# TODO: plumb CFLAGS and BUILD_CFLAGS to respective CONF_CC_OPTS_STAGE<N>
+	if ! is_native; then
+		export CFLAGS=${GHC_CFLAGS-"-O2 -pipe"}
+		export LDFLAGS=${GHC_LDFLAGS-"-Wl,-O1"}
+		einfo "Crosscompiling mode:"
+		einfo "   CHOST:   ${CHOST}"
+		einfo "   CTARGET: ${CTARGET}"
+		einfo "   CFLAGS:  ${CFLAGS}"
+		einfo "   LDFLAGS: ${LDFLAGS}"
+		einfo "   prefix: $(cross)"
+		return
+	fi
+	# We need to be very careful with the CFLAGS we ask ghc to pass through to
+	# gcc. There are plenty of flags which will make gcc produce output that
+	# breaks ghc in various ways. The main ones we want to pass through are
+	# -mcpu / -march flags. These are important for arches like alpha & sparc.
+	# We also use these CFLAGS for building the C parts of ghc, ie the rts.
+	strip-flags
+	strip-unsupported-flags
+
+	# Cmm can't parse line numbers #482086
+	replace-flags -ggdb[3-9] -ggdb2
+
+	GHC_FLAGS=""
+	GHC_PERSISTENT_FLAGS=""
+	for flag in ${CFLAGS}; do
+		case ${flag} in
+
+			# Ignore extra optimisation (ghc passes -O to gcc anyway)
+			# -O2 and above break on too many systems
+			-O*) ;;
+
+			# Arch and ABI flags are what we're really after
+			-m*) append-ghc-cflags compile assemble ${flag};;
+
+			# Sometimes it's handy to see backtrace of RTS
+			# to get an idea what happens there
+			-g*) append-ghc-cflags compile ${flag};;
+
+			# Ignore all other flags, including all -f* flags
+		esac
+	done
+
+	for flag in ${LDFLAGS}; do
+		append-ghc-cflags link ${flag}
+	done
+
+	# GHC uses ${CBUILD}-gcc, ${CHOST}-gcc and ${CTARGET}-gcc at a single build.
+	# Skip any gentoo-specific tweaks for cross-case to avoid passing unsupported
+	# options to gcc.
+	if is_native; then
+		# prevent from failing to build unregisterised ghc:
+		# https://www.mail-archive.com/debian-bugs-dist@lists.debian.org/msg171602.html
+		use ppc64 && append-ghc-cflags persistent compile -mminimal-toc
+	fi
+}
+
+# substitutes string $1 to $2 in files $3 $4 ...
+relocate_path() {
+	local from=$1
+	local   to=$2
+	shift 2
+	local file=
+	for file in "$@"
+	do
+		sed -i -e "s|$from|$to|g" \
+			"$file" || die "path relocation failed for '$file'"
+	done
+}
+
+# changes hardcoded ghc paths and updates package index
+# $1 - new absolute root path
+relocate_ghc() {
+	local to=$1 ghc_v=${BIN_PV}
+
+	# libdir for prebuilt binary and for current system may mismatch
+	# It does for prefix installation for example: bug #476998
+	local bin_ghc_prefix=${WORKDIR}/usr
+	local bin_libpath=$(echo "${bin_ghc_prefix}"/lib*)
+	local bin_libdir=${bin_libpath#${bin_ghc_prefix}/}
+
+	# backup original script to use it later after relocation
+	local gp_back="${T}/ghc-pkg-${ghc_v}-orig"
+	cp "${WORKDIR}/usr/bin/ghc-pkg-${ghc_v}" "$gp_back" || die "unable to backup ghc-pkg wrapper"
+
+	if [[ ${bin_libdir} != $(get_libdir) ]]; then
+		einfo "Relocating '${bin_libdir}' to '$(get_libdir)' (bug #476998)"
+		# moving the dir itself is not strictly needed
+		# but then USE=binary would result in installing
+		# in '${bin_libdir}'
+		mv "${bin_ghc_prefix}/${bin_libdir}" "${bin_ghc_prefix}/$(get_libdir)" || die
+
+		relocate_path "/usr/${bin_libdir}" "/usr/$(get_libdir)" \
+			"${WORKDIR}/usr/bin/ghc-${ghc_v}" \
+			"${WORKDIR}/usr/bin/ghci-${ghc_v}" \
+			"${WORKDIR}/usr/bin/ghc-pkg-${ghc_v}" \
+			"${WORKDIR}/usr/bin/hsc2hs" \
+			"${WORKDIR}/usr/bin/runghc-${ghc_v}" \
+			"$gp_back" \
+			"${WORKDIR}/usr/$(get_libdir)/${PN}-${ghc_v}/package.conf.d/"*
+	fi
+
+	# Relocate from /usr to ${EPREFIX}/usr
+	relocate_path "/usr" "${to}/usr" \
+		"${WORKDIR}/usr/bin/ghc-${ghc_v}" \
+		"${WORKDIR}/usr/bin/ghci-${ghc_v}" \
+		"${WORKDIR}/usr/bin/ghc-pkg-${ghc_v}" \
+		"${WORKDIR}/usr/bin/haddock-ghc-${ghc_v}" \
+		"${WORKDIR}/usr/bin/hp2ps" \
+		"${WORKDIR}/usr/bin/hpc" \
+		"${WORKDIR}/usr/bin/hsc2hs" \
+		"${WORKDIR}/usr/bin/runghc-${ghc_v}" \
+		"${WORKDIR}/usr/$(get_libdir)/${PN}-${ghc_v}/package.conf.d/"*
+
+	# this one we will use to regenerate cache
+	# so it should point to current tree location
+	relocate_path "/usr" "${WORKDIR}/usr" "$gp_back"
+
+	if use prefix; then
+		hprefixify "${bin_libpath}"/${PN}*/settings
+	fi
+
+	# regenerate the binary package cache
+	"$gp_back" recache || die "failed to update cache after relocation"
+	rm "$gp_back"
+}
+
+ghc-check-reqs() {
+	# These are pessimistic values (slightly bigger than worst-case)
+	# Worst case is UNREG USE=profile ia64. See bug #611866 for some
+	# numbers on various arches.
+	CHECKREQS_DISK_BUILD=8G
+	CHECKREQS_DISK_USR=2G
+	# USE=binary roughly takes
+	use binary && CHECKREQS_DISK_BUILD=4G
+
+	"$@"
+}
+
+pkg_pretend() {
+	ghc-check-reqs check-reqs_pkg_pretend
+}
+
+pkg_setup() {
+	ghc-check-reqs check-reqs_pkg_setup
+
+	# quiet portage about prebuilt binaries
+	use binary && QA_PREBUILT="*"
+
+	[[ ${MERGE_TYPE} == binary ]] && return
+
+	if use ghcbootstrap; then
+		ewarn "You requested ghc bootstrapping, this is usually only used"
+		ewarn "by Gentoo developers to make binary .tbz2 packages."
+
+		[[ -z $(type -P ghc) ]] && \
+			die "Could not find a ghc to bootstrap with."
+	else
+		if ! yet_binary; then
+			eerror "Please try emerging with USE=ghcbootstrap and report build"
+			eerror "sucess or failure to the haskell team (haskell@gentoo.org)"
+			die "No binary available for '${ARCH}' arch yet, USE=ghcbootstrap"
+		fi
+	fi
+
+	if needs_python; then
+		python-any-r1_pkg_setup
+	fi
+}
+
+src_unpack() {
+	# Create the ${S} dir if we're using the binary version
+	use binary && mkdir "${S}"
+
+	# the Solaris and Darwin binaries from ghc (maeder) need to be
+	# unpacked separately, so prevent them from being unpacked
+	local ONLYA=${A}
+	case ${CHOST} in
+		*-darwin* | *-solaris*)  ONLYA=${GHC_P}-src.tar.xz  ;;
+	esac
+	unpack ${ONLYA}
+}
+
+src_prepare() {
+	ghc_setup_cflags
+
+	if ! use ghcbootstrap && [[ ${CHOST} != *-darwin* && ${CHOST} != *-solaris* ]]; then
+		# Modify the wrapper script from the binary tarball to use GHC_PERSISTENT_FLAGS.
+		# See bug #313635.
+		sed -i -e "s|\"\$topdir\"|\"\$topdir\" ${GHC_PERSISTENT_FLAGS}|" \
+			"${WORKDIR}/usr/bin/ghc-${BIN_PV}"
+
+		# allow hardened users use vanilla binary to bootstrap ghc
+		# ghci uses mmap with rwx protection at it implements dynamic
+		# linking on it's own (bug #299709)
+		pax-mark -m "${WORKDIR}/usr/$(get_libdir)/${PN}-${BIN_PV}/bin/ghc"
+	fi
+
+	if use binary; then
+		if use prefix; then
+			relocate_ghc "${EPREFIX}"
+		fi
+
+		# Move unpacked files to the expected place
+		mv "${WORKDIR}/usr" "${S}"
+		eapply_user
+	else
+		if ! use ghcbootstrap; then
+			case ${CHOST} in
+				*-darwin* | *-solaris*)
+				# UPDATE ME for ghc-7
+				mkdir "${WORKDIR}"/ghc-bin-installer || die
+				pushd "${WORKDIR}"/ghc-bin-installer > /dev/null || die
+				use sparc-solaris && unpack ghc-6.10.4-sparc-sun-solaris2.tar.bz2
+				use x86-solaris && unpack ghc-7.0.3-i386-unknown-solaris2.tar.bz2
+				use x86-macos && unpack ghc-7.4.1-i386-apple-darwin.tar.bz2
+				use x64-macos && unpack ghc-7.4.1-x86_64-apple-darwin.tar.bz2
+				popd > /dev/null
+
+				pushd "${WORKDIR}"/ghc-bin-installer/ghc-[67].?*.? > /dev/null || die
+				# fix the binaries so they run, on Solaris we need an
+				# LD_LIBRARY_PATH which has our prefix libdirs, on
+				# Darwin we need to replace the frameworks with our libs
+				# from the prefix fix before installation, because some
+				# of the tools are actually used during configure/make
+				if [[ ${CHOST} == *-solaris* ]] ; then
+					export LD_LIBRARY_PATH="${EPREFIX}/$(get_libdir):${EPREFIX}/usr/$(get_libdir):${LD_LIBRARY_PATH}"
+				elif [[ ${CHOST} == *-darwin* ]] ; then
+					local readline_framework=GNUreadline.framework/GNUreadline
+					local gmp_framework=/opt/local/lib/libgmp.10.dylib
+					local ncurses_file=/opt/local/lib/libncurses.5.dylib
+					for binary in $(scanmacho -BRE MH_EXECUTE -F '%F' .) ; do
+						install_name_tool -change \
+							${readline_framework} \
+							"${EPREFIX}"/lib/libreadline.dylib \
+							${binary} || die
+						install_name_tool -change \
+							${gmp_framework} \
+							"${EPREFIX}"/usr/lib/libgmp.dylib \
+							${binary} || die
+						install_name_tool -change \
+							${ncurses_file} \
+							"${EPREFIX}"/usr/lib/libncurses.dylib \
+							${binary} || die
+					done
+					# we don't do frameworks!
+					sed -i \
+						-e 's/\(frameworks = \)\["GMP"\]/\1[]/g' \
+						-e 's/\(extraLibraries = \)\["m"\]/\1["m","gmp"]/g' \
+						rts/package.conf.in || die
+				fi
+
+				# it is autoconf, but we really don't want to give it too
+				# many arguments, in fact we do the make in-place anyway
+				./configure --prefix="${WORKDIR}"/usr || die
+				make install || die
+				popd > /dev/null
+				;;
+				*)
+				relocate_ghc "${WORKDIR}"
+				;;
+			esac
+		fi
+
+		sed -i -e "s|\"\$topdir\"|\"\$topdir\" ${GHC_PERSISTENT_FLAGS}|" \
+			"${S}/ghc/ghc.wrapper"
+
+		cd "${S}" # otherwise eapply will break
+
+		eapply "${FILESDIR}"/${PN}-7.0.4-CHOST-prefix.patch
+		eapply "${FILESDIR}"/${PN}-8.2.1-darwin.patch
+		eapply "${FILESDIR}"/${PN}-7.8.3-prim-lm.patch
+		eapply "${FILESDIR}"/${PN}-8.8.1-revert-CPP.patch
+		eapply "${FILESDIR}"/${PN}-8.10.1-allow-cross-bootstrap.patch
+		eapply "${FILESDIR}"/${PN}-8.10.5-modorigin-verbose-conflict.patch
+
+		# a bunch of crosscompiler patches
+		# needs newer version:
+		#eapply "${FILESDIR}"/${PN}-8.2.1_rc1-hp2ps-cross.patch
+
+		# mingw32 target
+		pushd "${S}/libraries/Win32"
+			eapply "${FILESDIR}"/${PN}-8.2.1_rc1-win32-cross-2-hack.patch # bad workaround
+		popd
+
+		bump_libs
+
+		eapply_user
+		# as we have changed the build system
+		eautoreconf
+	fi
+}
+
+src_configure() {
+	if ! use binary; then
+		# initialize build.mk
+		echo '# Gentoo changes' > mk/build.mk
+
+		# Put docs into the right place, ie /usr/share/doc/ghc-${GHC_PV}
+		echo "docdir = ${EPREFIX}/usr/share/doc/$(cross)${PF}" >> mk/build.mk
+		echo "htmldir = ${EPREFIX}/usr/share/doc/$(cross)${PF}" >> mk/build.mk
+
+		# We also need to use the GHC_FLAGS flags when building ghc itself
+		echo "SRC_HC_OPTS+=${HCFLAGS} ${GHC_FLAGS}" >> mk/build.mk
+		echo "SRC_CC_OPTS+=${CFLAGS}" >> mk/build.mk
+		echo "SRC_LD_OPTS+=${LDFLAGS}" >> mk/build.mk
+		# Speed up initial Cabal bootstrap
+		echo "utils/ghc-cabal_dist_EXTRA_HC_OPTS+=$(ghc-make-args)" >> mk/build.mk
+
+		# We can't depend on haddock except when bootstrapping when we
+		# must build docs and include them into the binary .tbz2 package
+		# app-text/dblatex is not in portage, can not build PDF or PS
+		echo "BUILD_SPHINX_PDF  = NO"  >> mk/build.mk
+		echo "BUILD_SPHINX_HTML = $(usex doc YES NO)" >> mk/build.mk
+		echo "BUILD_MAN = $(usex doc YES NO)" >> mk/build.mk
+
+		# this controls presence on 'xhtml' and 'haddock' in final install
+		echo "HADDOCK_DOCS       = YES" >> mk/build.mk
+
+		# not used outside of ghc's test
+		if [[ -n ${GHC_BUILD_DPH} ]]; then
+				echo "BUILD_DPH = YES" >> mk/build.mk
+			else
+				echo "BUILD_DPH = NO" >> mk/build.mk
+		fi
+
+		# Any non-native build has to skip as it needs
+		# target haddock binary to be runnabine.
+		if ! is_native; then
+			# disable docs generation as it requires running stage2
+			echo "HADDOCK_DOCS=NO" >> mk/build.mk
+			echo "BUILD_SPHINX_HTML=NO" >> mk/build.mk
+			echo "BUILD_SPHINX_PDF=NO" >> mk/build.mk
+		fi
+
+		if is_crosscompile; then
+			# Install ghc-stage1 crosscompiler instead of
+			# ghc-stage2 cross-built compiler.
+			echo "Stage1Only=YES" >> mk/build.mk
+		fi
+
+		# allows overriding build flavours for libraries:
+		# v   - vanilla (static libs)
+		# p   - profiled
+		# dyn - shared libraries
+		# example: GHC_LIBRARY_WAYS="v dyn"
+		if [[ -n ${GHC_LIBRARY_WAYS} ]]; then
+			echo "GhcLibWays=${GHC_LIBRARY_WAYS}" >> mk/build.mk
+		fi
+		echo "BUILD_PROF_LIBS = $(usex profile YES NO)" >> mk/build.mk
+
+		# Get ghc from the unpacked binary .tbz2
+		# except when bootstrapping we just pick ghc up off the path
+		if ! use ghcbootstrap; then
+			export PATH="${WORKDIR}/usr/bin:${PATH}"
+		fi
+
+		echo "INTEGER_LIBRARY = $(usex gmp integer-gmp integer-simple)" >> mk/build.mk
+
+		# don't strip anything. Very useful when stage2 SIGSEGVs on you
+		echo "STRIP_CMD = :" >> mk/build.mk
+
+		local econf_args=()
+
+		# GHC embeds toolchain it was built by and uses it later.
+		# Don't allow things like ccache or versioned binary slip.
+		# We use stable thing across gcc upgrades.
+		# User can use EXTRA_ECONF=CC=... to override this default.
+		econf_args+=(
+			AR=${CTARGET}-ar
+			CC=${CTARGET}-gcc
+			# these should be inferred by GHC but ghc defaults
+			# to using bundled tools on windows.
+			Windres=${CTARGET}-windres
+			DllWrap=${CTARGET}-dllwrap
+			# we set the linker explicitly below
+			--disable-ld-override
+		)
+		case ${CTARGET} in
+			arm*)
+				# ld.bfd-2.28 does not work for ghc. Force ld.gold
+				# instead. This should be removed once gentoo gets
+				# a fix for R_ARM_COPY bug: https://sourceware.org/PR16177
+				econf_args+=(LD=${CTARGET}-ld.gold)
+			;;
+			sparc*)
+				# ld.gold-2.28 does not work for ghc. Force ld.bfd
+				# instead. This should be removed once gentoo gets
+				# a fix for missing --no-relax support bug:
+				# https://sourceware.org/ml/binutils/2017-07/msg00183.html
+				econf_args+=(LD=${CTARGET}-ld.bfd)
+			;;
+			*)
+				econf_args+=(LD=${CTARGET}-ld)
+		esac
+
+		if [[ ${CBUILD} != ${CHOST} ]]; then
+			# GHC bug: ghc claims not to support cross-building.
+			# It does, but does not distinct --host= value
+			# for stage1 and stage2 compiler.
+			econf_args+=(--host=${CBUILD})
+		fi
+
+		if use ghcmakebinary; then
+			# When building booting libary we are trying to
+			# bundle or restrict most of external depends
+			# with unstable ABI:
+			#  - embed libffi (default GHC behaviour)
+			#  - disable ncurses support for ghci (via haskeline)
+			#    https://bugs.gentoo.org/557478
+			#  - disable ncurses support for ghc-pkg
+			echo "libraries/haskeline_CONFIGURE_OPTS += --flag=-terminfo" >> mk/build.mk
+			echo "utils/ghc-pkg_HC_OPTS += -DBOOTSTRAPPING" >> mk/build.mk
+		elif is_native; then
+			# using ${GTARGET}'s libffi is not supported yet:
+			# GHC embeds full path for ffi includes without /usr/${CTARGET} account.
+			econf_args+=(--with-system-libffi)
+			econf_args+=(--with-ffi-includes=$($(tc-getPKG_CONFIG) libffi --cflags-only-I | sed -e 's@^-I@@'))
+		fi
+
+		einfo "Final mk/build.mk:"
+		cat mk/build.mk || die
+
+		econf ${econf_args[@]} \
+			--enable-bootstrap-with-devel-snapshot \
+			$(use_enable elfutils dwarf-unwind) \
+			$(use_enable numa)
+
+		if [[ ${PV} == *9999* ]]; then
+			GHC_PV="$(grep 'S\[\"PACKAGE_VERSION\"\]' config.status | sed -e 's@^.*=\"\(.*\)\"@\1@')"
+			GHC_P=${PN}-${GHC_PV}
+		fi
+	fi # ! use binary
+}
+
+src_compile() {
+	if ! use binary; then
+		# Stage1Only crosscompiler does not build stage2
+		if ! is_crosscompile; then
+			# 1. build/pax-mark compiler binary first
+			emake ghc/stage2/build/tmp/ghc-stage2
+			# 2. pax-mark (bug #516430)
+			pax-mark -m ghc/stage2/build/tmp/ghc-stage2
+			# 2. build/pax-mark haddock using ghc-stage2
+			if is_native; then
+				# non-native build does not build haddock
+				# due to HADDOCK_DOCS=NO, but it could.
+				emake utils/haddock/dist/build/tmp/haddock
+				pax-mark -m utils/haddock/dist/build/tmp/haddock
+			fi
+		fi
+		# 3. and then all the rest
+		emake all
+	fi # ! use binary
+}
+
+src_test() {
+	# TODO: deal with:
+	#    - sandbox (pollutes environment)
+	#    - extra packages (to extend testsuite coverage)
+	# bits are taken from 'validate'
+	local make_test_target='test' # can be fulltest
+	# not 'emake' as testsuite uses '$MAKE' without jobserver available
+	make $make_test_target stage=2 THREADS=$(makeopts_jobs)
+}
+
+src_install() {
+	if use binary; then
+		use prefix && mkdir -p "${ED}"
+		mv "${S}/usr" "${ED}"
+	else
+		[[ -f VERSION ]] || emake VERSION
+
+		# -j1 due to a rare race in install script:
+		#    make --no-print-directory -f ghc.mk phase=final install
+		#    /usr/lib/portage/python3.4/ebuild-helpers/xattr/install -c -m 755 \
+		#        -d "/tmp/portage-tmpdir/portage/cross-armv7a-unknown-linux-gnueabi/ghc-9999/image/usr/lib64/armv7a-unknown-linux-gnueabi-ghc-8.3.20170404/include"
+		#    /usr/lib/portage/python3.4/ebuild-helpers/xattr/install -c -m 644  utils/hsc2hs/template-hsc.h \
+		#           "/tmp/portage-tmpdir/portage/cross-armv7a-unknown-linux-gnueabi/ghc-9999/image/usr/lib64/armv7a-unknown-linux-gnueabi-ghc-8.3.20170404"
+		#    /usr/bin/install: cannot create regular file \
+		#           '/tmp/portage-tmpdir/portage/cross-armv7a-unknown-linux-gnueabi/ghc-9999/image/usr/lib64/armv7a-unknown-linux-gnueabi-ghc-8.3.20170404': No such file or directory
+		emake -j1 install DESTDIR="${D}"
+
+		# Skip for cross-targets as they all share target location:
+		# /usr/share/doc/ghc-9999/
+		if ! is_crosscompile; then
+			dodoc "distrib/README" "LICENSE" "VERSION"
+		fi
+
+		# rename ghc-shipped files to avoid collision
+		# of external packages. Motivating example:
+		#  user had installed:
+		#      dev-lang/ghc-7.8.4-r0 (with transformers-0.3.0.0)
+		#      dev-haskell/transformers-0.4.2.0
+		#  then user tried to update to
+		#      dev-lang/ghc-7.8.4-r1 (with transformers-0.4.2.0)
+		#  this will lead to single .conf file collision.
+		local shipped_conf renamed_conf
+		local package_confdir="${ED}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d"
+		for shipped_conf in "${package_confdir}"/*.conf; do
+			# rename 'pkg-ver-id.conf' to 'pkg-ver-id-gentoo-${PF}.conf'
+			renamed_conf=${shipped_conf%.conf}-gentoo-${PF}.conf
+			mv "${shipped_conf}" "${renamed_conf}" || die
+		done
+
+		# remove link, but leave 'haddock-${GHC_P}'
+		rm -f "${ED}"/usr/bin/$(cross)haddock
+
+		if ! is_crosscompile; then
+			newbashcomp "${FILESDIR}"/ghc-bash-completion ghc-pkg
+			newbashcomp utils/completion/ghc.bash         ghc
+		fi
+	fi
+
+	# path to the package.cache
+	local package_confdir="${ED}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d"
+	PKGCACHE="${package_confdir}"/package.cache
+	# copy the package.conf.d, including timestamp, save it so we can help
+	# users that have a broken package.conf.d
+	cp -pR "${package_confdir}"{,.initial} || die "failed to backup intial package.conf.d"
+
+	# copy the package.conf, including timestamp, save it so we later can put it
+	# back before uninstalling, or when upgrading.
+	cp -p "${PKGCACHE}"{,.shipped} \
+		|| die "failed to copy package.conf.d/package.cache"
+
+	if is_crosscompile; then
+		# When we build a cross-compiler the layout is the following:
+		#     usr/lib/${CTARGET}-ghc-${VER}/ contains target libraries
+		# but
+		#     usr/lib/${CTARGET}-ghc-${VER}/bin/ directory
+		# containst host binaries (modulo bugs).
+
+		# Portage's stripping mechanism does not skip stripping
+		# foreign binaries. This frequently causes binaries to be
+		# broken.
+		#
+		# Thus below we disable stripping of target libraries and allow
+		# stripping hosts executables.
+		dostrip -x "/usr/$(get_libdir)/$(cross)${GHC_P}"
+		dostrip    "/usr/$(get_libdir)/$(cross)${GHC_P}/bin"
+	fi
+}
+
+pkg_preinst() {
+	# have we got an earlier version of ghc installed?
+	if has_version "<${CATEGORY}/${PF}"; then
+		haskell_updater_warn="1"
+	fi
+}
+
+pkg_postinst() {
+	ghc-reregister
+
+	# path to the package.cache
+	PKGCACHE="${EROOT}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d/package.cache"
+
+	# give the cache a new timestamp, it must be as recent as
+	# the package.conf.d directory.
+	touch "${PKGCACHE}"
+
+	if [[ "${haskell_updater_warn}" == "1" ]]; then
+		ewarn
+		ewarn "\e[1;31m************************************************************************\e[0m"
+		ewarn
+		ewarn "You have just upgraded from an older version of GHC."
+		ewarn "You may have to run"
+		ewarn "      'haskell-updater'"
+		ewarn "to rebuild all ghc-based Haskell libraries."
+		ewarn
+		ewarn "\e[1;31m************************************************************************\e[0m"
+		ewarn
+	fi
+}
+
+pkg_prerm() {
+	PKGCACHE="${EROOT}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d/package.cache"
+	rm -rf "${PKGCACHE}"
+
+	cp -p "${PKGCACHE}"{.shipped,}
+}
+
+pkg_postrm() {
+	ghc-package_pkg_postrm
+}


^ permalink raw reply related	[flat|nested] 15+ messages in thread
* [gentoo-commits] repo/gentoo:master commit in: dev-lang/ghc/, dev-lang/ghc/files/
@ 2020-12-18  8:52 Sergei Trofimovich
  0 siblings, 0 replies; 15+ messages in thread
From: Sergei Trofimovich @ 2020-12-18  8:52 UTC (permalink / raw
  To: gentoo-commits

commit:     3e0a550ed6aada6c28da02f9582209c4f789d819
Author:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
AuthorDate: Fri Dec 18 08:52:22 2020 +0000
Commit:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
CommitDate: Fri Dec 18 08:52:32 2020 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=3e0a550e

dev-lang/ghc: bump up to 8.10.2

Package-Manager: Portage-3.0.12, Repoman-3.0.2
Signed-off-by: Sergei Trofimovich <slyfox <AT> gentoo.org>

 dev-lang/ghc/Manifest                              |   3 +
 ...ert-linker-rtsSymbols_more_linker_symbols.patch | 296 ++++++++
 dev-lang/ghc/ghc-8.10.2.ebuild                     | 798 +++++++++++++++++++++
 3 files changed, 1097 insertions(+)

diff --git a/dev-lang/ghc/Manifest b/dev-lang/ghc/Manifest
index 0f7b4fe5d55..ba190adce3d 100644
--- a/dev-lang/ghc/Manifest
+++ b/dev-lang/ghc/Manifest
@@ -5,6 +5,8 @@ DIST ghc-7.8.4-src.tar.bz2 10600755 BLAKE2B 6cf27f663178513b25032b648cf36b016e01
 DIST ghc-8.0.2-src.tar.xz 10687760 BLAKE2B 3b2a487c115680342ce308ff1a42d2b6fa6fb1f31e2670b27a305b4d44160056611b77273c9d47f2e37a1ef01b1aba59c36e76b65c83142a5f09812bf3b1ea02 SHA512 58ea3853cd93b556ecdc4abd0be079b2621171b8491f59004ea4e036a4cba4470aaafe6591b942e0a50a64bdc47540e01fe6900212a1ef7087850112d9bfc5ef
 DIST ghc-8.10.1-src.tar.xz 19781652 BLAKE2B 61ff73d3a895cfa0c836e25a684d7a31cf099dcc33d1f308eaf56aa4b2a75b8f38cf963197c11dad9d027270845af20e00a7d81e5417b0fb8b4a98ddbadd53d8 SHA512 e6bb5c326f8354f0892324586c164c6e04168215d8bfeccb594173a838a535e37bac38db6fbdb01fb37150099c12842c53be5e912dfb6a6feeae3c75d4ae24d0
 DIST ghc-8.10.1-testsuite.tar.xz 2091988 BLAKE2B 88796f0fb6ea2bdd749161c84ec88768f3bf87063d2224a083db24f69282e615227626fe3c7b41d4abec10883e22042abed6a231582bab4ea530feffd683ed0b SHA512 35147f98301c5bfb6c939e108de48b2a1133adc1028aaa720ce49d60faa06a4b486a9eded658295e3f203731b4dd53475b57e8213491c45b05959430030be269
+DIST ghc-8.10.2-src.tar.xz 21880680 BLAKE2B 0c1b67c1576cfd1067d11838301f96041cabf66b94cfd546cfe6bef57babe940fc3814918ff9327e59fe73a8e230fa1d62d7816d7c6cae274dd8c53de6e81736 SHA512 6c3f1311feab3665419a301b17fcb09d303ec822f8eb8c4021edfacff00d9b52e71895bed0e58f11d8f7970415bd8c6f95ffde1294afe795e15607199b20cefc
+DIST ghc-8.10.2-testsuite.tar.xz 2101788 BLAKE2B 0d4528223471dfd68cadcda47931d53508c9eafa415716ca5990ea519eb89bfa2bdd444280057be33467382dd3d178887262d54ef633aa8ce88ea91eb9d58ece SHA512 043faaf2f0dc34a868c481b284b94afd78aa1ec1a4056d1f3c97ca3f7dadb3e9cff0517a4cfb378fe5187389db7c9027763bf066328e7dcfd264b737f6d09e41
 DIST ghc-8.2.1-src.tar.xz 10736016 BLAKE2B 60993cfc9569e83b0c383591ef30a7280e0138fbb7bd696ad62d87e68dcbccf31c0b8ba211b6647922b8595c7aec2c783648f12c67da53e0766b71c7d7c923fc SHA512 d9aa2aa7f9414db8f4e51d6c275694b46df515e68331a1a2b6018256333a2c63ebd877b75ee90407ecce5be672ec9afc6bebd62aadbf8ae06b94f1760d1736be
 DIST ghc-8.2.2-src.tar.xz 10753272 BLAKE2B 6fd792390d3df20f84836466705c3f3c931ba2d594dcbe2b808ea0ae284460000b443df8aae74903eabf05ff9064d68a303086cf888ea68222eb1c60959c8f21 SHA512 6549416f470b599973d409fa45f59c25b07e6a94798cef1a19ad432547dc225338cf4dbc4a4793114b4a417798a3b59b122b92b020251074405c5302b7ffe799
 DIST ghc-8.4.1-src.tar.xz 11301528 BLAKE2B 6dcf467d04cace856b68315c85b80f19b517dcbc8ae6e2a08c60afa141c9e0261e012738452c9ca208f9fc40c48bd1a0817e5e0fe9f4737383cd7b44ca65c8d9 SHA512 f8ae11f498bf2911fb92635534c6906c96f1fbe5072c7b7447bd3f69e408026b674564515af02a8aaddc57ee6905ce78d10005b12478a39c220580aaec13a9f7
@@ -45,6 +47,7 @@ DIST ghc-bin-8.0.2-ppc64.tbz2 117432068 BLAKE2B cae202f0d6e825127d543996b2fe7ae0
 DIST ghc-bin-8.0.2-x86_64-pc-linux-gnu.tbz2 130852973 BLAKE2B 24d2032bbfc664d924800c1a317334e2342c8ec1e529178f9d1bb99bb4772a9cc100603bf70111b8cfafa715c1cccc643f115c77cf6adcdfb17d1f1735ee6682 SHA512 c36e0e2600fc7c284562a323d396a03062cb6e8fa63c353e672be61e76d2ec5c7698485e3a370a57cf512db9e5ba6a68338fff2ab404d9fe67b1a468ed72638f
 DIST ghc-bin-8.10.1-i686-pc-linux-gnu.tbz2 123398571 BLAKE2B 3650f9dbaaa5af684abad589953bcef5b1684a91a4cc2695d0ef735536057bb031231fe3d73dd74bc38a199f0890ef91764b551e5e158c120affc0d7bc3175b7 SHA512 52cc172de08ef30d6e89384e86eda1b8bbdef2bbff526041eb47d85d77b70ab49314ac7f33f18b40864c16fa546256f1b4c7964e65aa5d3cfbb7f9cbec505dc9
 DIST ghc-bin-8.10.1-x86_64-pc-linux-gnu.tbz2 122227601 BLAKE2B 84340866c70044eb1444a70b0cbed6814808037b697db28f567d2b14bb791cbe7d9bf2a327cc47ae85ce3c4970ba039854b4a6df44eb85cdc18040c5a4d15f4f SHA512 81df9de95aec47d60ad8d699756ad323eb525c3a16536fac8c6717e1754272061bd8d7d70cd38f5c509a2fc323305333e4f898c9b6dc27645521bb29ee218bdb
+DIST ghc-bin-8.10.2-x86_64-pc-linux-gnu.tbz2 122818630 BLAKE2B 030a68e2aca0eb0a273e0d48a3e180d92b219b2d1826d1d58fa133d0a6cae1316b3ccceadb55a4fa5870f87c3df85df2998e7611b93dbc1fea592437748b2daf SHA512 23bf47ee45fae54a843de9e6991b67fccb79c14ad8d08eff9f38a68a3530496c8ce4bc8cae8a731bb690ddd6cd0bf36d6d5bf37eb68ddae8ce646a0bf3916d8f
 DIST ghc-bin-8.2.1-i686-pc-linux-gnu.tbz2 96157437 BLAKE2B 2b9608845db8cea78db07209fa054b3b05085d5c3ac07cbe3de02a93c87fb0cff12b1820f08757221c59c8a0a9e7a5563c44266b181525d916825e5cf5bac34c SHA512 e891e76557fa61853e28829b8bedc4a6abb92954f90cc1ebcf22a13cc137556bbe9262e7398b7e1aedbabeb997916b008bf1561a52f16a569f3d58ea9404f41e
 DIST ghc-bin-8.2.1-x86_64-pc-linux-gnu.tbz2 97490496 BLAKE2B 3666ea70cb8b3645db071040d2069fe244042c11954b34e5d92aaa90132d2316c0ee8c176cd4e674772bea3b99df150404f62bd8745c046cdaf102ecf0a0fa54 SHA512 52630a185d0eab56bce0469a612a54109895bfee041ec362ced59a9b35ba3b9c185e86bc7dbf0a5939081d3626baa19fbb3306e36d1857530248a7b9bfc100bb
 DIST ghc-bin-8.2.2-i686-pc-linux-gnu.tbz2 96638908 BLAKE2B b470f838e77330969f162196b0f1035fa764f5d123687fbf67c14323280bfe55216af0e16f8b79c62f290905d96abc8bfafee650f8d27c81608853e78329b2c9 SHA512 15b1525890477539878385efc15ce5f1cf2f126cc785c42923be958cabe3298cebe73526a2370cf4c630124160a7ca0f0f9062aebbf035dce807a0374eaddd14

diff --git a/dev-lang/ghc/files/ghc-8.10.2-revert-linker-rtsSymbols_more_linker_symbols.patch b/dev-lang/ghc/files/ghc-8.10.2-revert-linker-rtsSymbols_more_linker_symbols.patch
new file mode 100644
index 00000000000..eb30d9d9dd4
--- /dev/null
+++ b/dev-lang/ghc/files/ghc-8.10.2-revert-linker-rtsSymbols_more_linker_symbols.patch
@@ -0,0 +1,296 @@
+From fac083e7ac8a37b61a4082bbbca2848e52fd1bb2 Mon Sep 17 00:00:00 2001
+From: Ben Gamari <ben@smart-cactus.org>
+Date: Sun, 9 Aug 2020 09:15:16 -0400
+Subject: [PATCH] Revert "[linker/rtsSymbols] More linker symbols"
+
+This reverts commit aa2e5863699306920513b216f337de09e29b5bb8.
+---
+ rts/RtsSymbols.c | 224 ++++-------------------------------------------
+ 1 file changed, 17 insertions(+), 207 deletions(-)
+
+diff --git a/rts/RtsSymbols.c b/rts/RtsSymbols.c
+index d10a6900db..b2f90a892d 100644
+--- a/rts/RtsSymbols.c
++++ b/rts/RtsSymbols.c
+@@ -58,6 +58,7 @@
+       SymI_HasProto(signal_handlers)            \
+       SymI_HasProto(stg_sig_install)            \
+       SymI_HasProto(rtsTimerSignal)             \
++      SymI_HasProto(atexit)                     \
+       SymI_NeedsDataProto(nocldstop)
+ #endif
+ 
+@@ -976,213 +977,29 @@
+       RTS_USER_SIGNALS_SYMBOLS                                          \
+       RTS_INTCHAR_SYMBOLS
+ 
++
+ // 64-bit support functions in libgcc.a
+-// See https://gcc.gnu.org/onlinedocs/gccint/Libgcc.html#Libgcc
+-#define RTS_LIBGCC_SYMBOLS_32                          \
+-      SymI_NeedsProto(__fixunsdfdi)                    \
+-      /* 4 The GCC low-level runtime library         */\
+-      /* 4.1.1 Arithmetic functions                  */\
+-      /* SymI_NeedsProto(__ashlsi3) */\
+-      SymI_NeedsProto(__ashldi3) \
+-      /* SymI_NeedsProto(__ashlti3) */\
+-      /* These functions return the result of shifting a left by b bits. */\
+-      /* SymI_NeedsProto(__ashrsi3) */\
+-      SymI_NeedsProto(__ashrdi3) \
+-      /* SymI_NeedsProto(__ashrti3) */\
+-      /* These functions return the result of arithmetically shifting a right by b bits. */\
+-      /* SymI_NeedsProto(__divsi3) */\
+-      SymI_NeedsProto(__divdi3) \
+-      /* SymI_NeedsProto(__divti3) */\
+-      /* These functions return the quotient of the signed division of a and b. */\
+-      /* SymI_NeedsProto(__lshrsi3) */ \
+-      SymI_NeedsProto(__lshrdi3) \
+-      /* SymI_NeedsProto(__lshrti3) */ \
+-      /* These functions return the result of logically shifting a right by b bits. */\
+-      /* SymI_NeedsProto(__modsi3) */ \
+-      SymI_NeedsProto(__moddi3) \
+-      /* SymI_NeedsProto(__modti3) */ \
+-      /* These functions return the remainder of the signed division of a and b. */\
+-      /* SymI_NeedsProto(__mulsi3) */ \
+-      SymI_NeedsProto(__muldi3) \
+-      /* SymI_NeedsProto(__multi3) */ \
+-      /* These functions return the product of a and b. */\
+-      SymI_NeedsProto(__negdi2) \
+-      /* SymI_NeedsProto(__negti2) */ \
+-      /* These functions return the negation of a. */\
+-      /* SymI_NeedsProto(__udivsi3) */ \
+-      SymI_NeedsProto(__udivdi3) \
+-      /* SymI_NeedsProto(__udivti3) */ \
+-      /* These functions return the quotient of the unsigned division of a and b. */\
+-      SymI_NeedsProto(__udivmoddi4) \
+-      /* SymI_NeedsProto(__udivmodti4) */ \
+-      /* These functions calculate both the quotient and remainder of the unsigned division of a and b. The return value is the quotient, and the remainder is placed in variable pointed to by c. */\
+-      /* SymI_NeedsProto(__umodsi3) */ \
+-      SymI_NeedsProto(__umoddi3) \
+-      /* SymI_NeedsProto(__umodti3) */ \
+-      /* These functions return the remainder of the unsigned division of a and b. */\
+-      /* 4.1.2 Comparison functions */\
+-      /* The following functions implement integral comparisons. These functions implement a low-level compare, upon which the higher level comparison operators (such as less than and greater than or equal to) can be constructed. The returned values lie in the range zero to two, to allow the high-level operators to be implemented by testing the returned result using either signed or unsigned comparison. */\
+-      SymI_NeedsProto(__cmpdi2) \
+-      /* SymI_NeedsProto(__cmpti2) */ \
+-      /* These functions perform a signed comparison of a and b. If a is less than b, they return 0; if a is greater than b, they return 2; and if a and b are equal they return 1. */\
+-      SymI_NeedsProto(__ucmpdi2) \
+-      /* SymI_NeedsProto(__ucmpti2) */ \
+-      /* These functions perform an unsigned comparison of a and b. If a is less than b, they return 0; if a is greater than b, they return 2; and if a and b are equal they return 1. */\
+-      /* 4.1.3 Trapping arithmetic functions */\
+-      /* The following functions implement trapping arithmetic. These functions call the libc function abort upon signed arithmetic overflow. */\
+-      SymI_NeedsProto(__absvsi2) \
+-      SymI_NeedsProto(__absvdi2) \
+-      /* These functions return the absolute value of a. */\
+-      /* SymI_NeedsProto(__addvsi3) */ \
+-      SymI_NeedsProto(__addvdi3) \
+-      /* These functions return the sum of a and b; that is a + b. */\
+-      /* SymI_NeedsProto(__mulvsi3) */ \
+-      SymI_NeedsProto(__mulvdi3) \
+-      /* The functions return the product of a and b; that is a * b. */\
+-      SymI_NeedsProto(__negvsi2) \
+-      SymI_NeedsProto(__negvdi2) \
+-      /* These functions return the negation of a; that is -a. */\
+-      /* SymI_NeedsProto(__subvsi3) */ \
+-      SymI_NeedsProto(__subvdi3) \
+-      /* These functions return the difference between b and a; that is a - b. */\
+-      /* 4.1.4 Bit operations */\
+-      SymI_NeedsProto(__clzsi2) \
+-      SymI_NeedsProto(__clzdi2) \
+-      /* SymI_NeedsProto(__clzti2) */ \
+-      /* These functions return the number of leading 0-bits in a, starting at the most significant bit position. If a is zero, the result is undefined. */\
+-      SymI_NeedsProto(__ctzsi2) \
+-      SymI_NeedsProto(__ctzdi2) \
+-      /* SymI_NeedsProto(__ctzti2) */ \
+-      /* These functions return the number of trailing 0-bits in a, starting at the least significant bit position. If a is zero, the result is undefined. */\
+-      SymI_NeedsProto(__ffsdi2) \
+-      /* SymI_NeedsProto(__ffsti2) */ \
+-      /* These functions return the index of the least significant 1-bit in a, or the value zero if a is zero. The least significant bit is index one. */\
+-      SymI_NeedsProto(__paritysi2) \
+-      SymI_NeedsProto(__paritydi2) \
+-      /* SymI_NeedsProto(__parityti2) */\
+-      /* These functions return the value zero if the number of bits set in a is even, and the value one otherwise. */\
+-      SymI_NeedsProto(__popcountsi2) \
+-      SymI_NeedsProto(__popcountdi2) \
+-      /* SymI_NeedsProto(__popcountti2) */ \
+-      /* These functions return the number of bits set in a. */\
+-      SymI_NeedsProto(__bswapsi2) \
+-      SymI_NeedsProto(__bswapdi2)
+-#define RTS_LIBGCC_SYMBOLS_aarch32                     \
+-      /* armv6l                                      */\
+-      /* TODO: should check for __ARM_EABI__         */\
+-      SymI_NeedsProto(__aeabi_d2f) \
+-      SymI_NeedsProto(__aeabi_d2iz) \
+-      SymI_NeedsProto(__aeabi_d2lz) \
+-      SymI_NeedsProto(__aeabi_d2uiz) \
+-      SymI_NeedsProto(__aeabi_d2ulz) \
+-      SymI_NeedsProto(__aeabi_dadd) \
+-      SymI_NeedsProto(__aeabi_dcmpeq) \
+-      SymI_NeedsProto(__aeabi_dcmpge) \
+-      SymI_NeedsProto(__aeabi_dcmpgt) \
+-      SymI_NeedsProto(__aeabi_dcmple) \
+-      SymI_NeedsProto(__aeabi_dcmplt) \
+-      SymI_NeedsProto(__aeabi_dcmpun) \
+-      SymI_NeedsProto(__aeabi_ddiv) \
+-      SymI_NeedsProto(__aeabi_dmul) \
+-      SymI_NeedsProto(__aeabi_dneg) \
+-      SymI_NeedsProto(__aeabi_dsub) \
+-      SymI_NeedsProto(__aeabi_f2d) \
+-      SymI_NeedsProto(__aeabi_f2iz) \
+-      SymI_NeedsProto(__aeabi_f2lz) \
+-      SymI_NeedsProto(__aeabi_f2uiz) \
+-      SymI_NeedsProto(__aeabi_f2ulz) \
+-      SymI_NeedsProto(__aeabi_fadd) \
+-      SymI_NeedsProto(__aeabi_fcmpeq) \
+-      SymI_NeedsProto(__aeabi_fcmpge) \
+-      SymI_NeedsProto(__aeabi_fcmpgt) \
+-      SymI_NeedsProto(__aeabi_fcmple) \
+-      SymI_NeedsProto(__aeabi_fcmplt) \
+-      SymI_NeedsProto(__aeabi_fcmpun) \
+-      SymI_NeedsProto(__aeabi_fdiv) \
+-      SymI_NeedsProto(__aeabi_fmul) \
+-      SymI_NeedsProto(__aeabi_fneg) \
+-      SymI_NeedsProto(__aeabi_fsub) \
+-      SymI_NeedsProto(__aeabi_i2d) \
+-      SymI_NeedsProto(__aeabi_i2f) \
+-      SymI_NeedsProto(__aeabi_idiv) \
+-      SymI_NeedsProto(__aeabi_idivmod) \
+-      SymI_NeedsProto(__aeabi_l2d) \
+-      SymI_NeedsProto(__aeabi_l2f) \
+-      SymI_NeedsProto(__aeabi_lasr) \
+-      SymI_NeedsProto(__aeabi_lcmp) \
+-      SymI_NeedsProto(__aeabi_ldivmod) \
+-      SymI_NeedsProto(__aeabi_llsl) \
+-      SymI_NeedsProto(__aeabi_llsr) \
+-      SymI_NeedsProto(__aeabi_lmul) \
+-      SymI_NeedsProto(__aeabi_ui2d) \
+-      SymI_NeedsProto(__aeabi_ui2f) \
+-      SymI_NeedsProto(__aeabi_uidiv) \
+-      SymI_NeedsProto(__aeabi_uidivmod) \
+-      SymI_NeedsProto(__aeabi_ul2d) \
+-      SymI_NeedsProto(__aeabi_ul2f) \
+-      SymI_NeedsProto(__aeabi_ulcmp) \
+-      SymI_NeedsProto(__aeabi_uldivmod)
+-#define RTS_LIBGCC_SYMBOLS_64                          \
++#if defined(__GNUC__) && SIZEOF_VOID_P <= 4 && !defined(_ABIN32)
++#define RTS_LIBGCC_SYMBOLS                             \
++      SymI_NeedsProto(__divdi3)                        \
++      SymI_NeedsProto(__udivdi3)                       \
++      SymI_NeedsProto(__moddi3)                        \
++      SymI_NeedsProto(__umoddi3)                       \
++      SymI_NeedsProto(__muldi3)                        \
++      SymI_NeedsProto(__ashldi3)                       \
++      SymI_NeedsProto(__ashrdi3)                       \
++      SymI_NeedsProto(__lshrdi3)                       \
++      SymI_NeedsProto(__fixunsdfdi)
++#elif defined(__GNUC__) && SIZEOF_VOID_P == 8
++#define RTS_LIBGCC_SYMBOLS                             \
+       SymI_NeedsProto(__udivti3)                       \
+       SymI_NeedsProto(__umodti3)
+-
+-/* for aarch64                                        */
+-#define RTS_LIBGCC_SYMBOLS_aarch64                     \
+-      SymI_NeedsProto(__netf2)                         \
+-      SymI_NeedsProto(__addtf3)                        \
+-      SymI_NeedsProto(__subtf3)                        \
+-      SymI_NeedsProto(__multf3)                        \
+-      SymI_NeedsProto(__extenddftf2)                   \
+-      SymI_NeedsProto(__fixtfsi)                       \
+-      SymI_NeedsProto(__fixunstfsi)                    \
+-      SymI_NeedsProto(__floatsitf)                     \
+-      SymI_NeedsProto(__floatunsitf)
+-
+-#if defined(__GNUC__) && SIZEOF_VOID_P <= 4 && defined(arm_HOST_OS)
+-#define RTS_LIBGCC_SYMBOLS RTS_LIBGCC_SYMBOLS_32 RTS_LIBGCC_SYMBOLS_aarch32
+-#elif defined(__GNUC__) && SIZEOF_VOID_P <= 4 && !defined(_ABIN32)
+-#define RTS_LIBGCC_SYMBOLS RTS_LIBGCC_SYMBOLS_32
+-#elif defined(__GNUC__) && SIZEOF_VOID_P == 8 && defined(aarch64_HOST_OS)
+-#define RTS_LIBGCC_SYMBOLS RTS_LIBGCC_SYMBOLS_64 RTS_LIBGCC_SYMBOLS_aarch64
+-#elif defined(__GNUC__) && SIZEOF_VOID_P == 8
+-#define RTS_LIBGCC_SYMBOLS RTS_LIBGCC_SYMBOLS_64
+ #else
+ #define RTS_LIBGCC_SYMBOLS
+ #endif
+ 
+-#if !defined(mingw32_HOST_OS) && !defined(DYNAMIC) && (defined(_FORTIFY_SOURCE) || defined(__SSP__))
+-#define RTS_SSP_SYMBOLS                                \
+-      SymI_NeedsProto(__stack_chk_guard)               \
+-      SymI_NeedsProto(__stack_chk_fail)
+-#else
+-#define RTS_SSP_SYMBOLS
+-#endif
+-#if !defined(DYNAMIC) && defined(linux_HOST_OS)
+-// we need these for static musl builds. However when
+-// linking shared objects (DLLs) this will fail, hence
+-// we do not include them when building with -DDYNAMIC
+-#define RTS_LINKER_SYMBOLS                             \
+-      SymI_NeedsProto(__fini_array_start)              \
+-      SymI_NeedsProto(__fini_array_end)
+-#else
+-#define RTS_LINKER_SYMBOLS
+-#endif
+-
+-#if defined(darwin_HOST_OS) && defined(powerpc_HOST_ARCH)
+-      // Symbols that don't have a leading underscore
+-      // on Mac OS X. They have to receive special treatment,
+-      // see machoInitSymbolsWithoutUnderscore()
+-#define RTS_MACHO_NOUNDERLINE_SYMBOLS                   \
+-      SymI_NeedsProto(saveFP)                           \
+-      SymI_NeedsProto(restFP)
+-#endif
+-
+ /* entirely bogus claims about types of these symbols */
+-/* to prevent a bit of define expansion, SymI_NeedsProto is a variadic
+- * macro.  And we'll concat vvv with the __VA_ARGS__. This prevents
+- * vvv from getting macro expanded.
+- */
+-#define SymI_NeedsProto(vvv,...) extern void vvv ## __VA_ARGS__ (void);
++#define SymI_NeedsProto(vvv)  extern void vvv(void);
+ #define SymI_NeedsDataProto(vvv)  extern StgWord vvv[];
+ #if defined(COMPILING_WINDOWS_DLL)
+ #define SymE_HasProto(vvv)    SymE_HasProto(vvv);
+@@ -1209,8 +1026,6 @@ RTS_DARWIN_ONLY_SYMBOLS
+ RTS_OPENBSD_ONLY_SYMBOLS
+ RTS_LIBGCC_SYMBOLS
+ RTS_LIBFFI_SYMBOLS
+-RTS_SSP_SYMBOLS
+-RTS_LINKER_SYMBOLS
+ #undef SymI_NeedsProto
+ #undef SymI_NeedsDataProto
+ #undef SymI_HasProto
+@@ -1230,7 +1045,7 @@ RTS_LINKER_SYMBOLS
+ #define SymE_HasDataProto(vvv) \
+                     SymE_HasProto(vvv)
+ 
+-#define SymI_NeedsProto(vvv,...) SymI_HasProto(vvv ## __VA_ARGS__)
++#define SymI_NeedsProto(vvv) SymI_HasProto(vvv)
+ #define SymI_NeedsDataProto(vvv) SymI_HasDataProto(vvv)
+ #define SymE_NeedsProto(vvv) SymE_HasProto(vvv)
+ #define SymE_NeedsDataProto(vvv) SymE_HasDataProto(vvv)
+@@ -1251,8 +1066,6 @@ RTS_LINKER_SYMBOLS
+ #define SymI_HasProto_deprecated(vvv)   \
+    { #vvv, (void*)0xBAADF00D, true },
+ 
+-void *RTS_DYNAMIC = NULL;
+-
+ RtsSymbolVal rtsSyms[] = {
+       RTS_SYMBOLS
+       RTS_RET_SYMBOLS
+@@ -1264,14 +1077,11 @@ RtsSymbolVal rtsSyms[] = {
+       RTS_LIBGCC_SYMBOLS
+       RTS_LIBFFI_SYMBOLS
+       SymI_HasDataProto(nonmoving_write_barrier_enabled)
+-      RTS_SSP_SYMBOLS
+-      RTS_LINKER_SYMBOLS
+ #if defined(darwin_HOST_OS) && defined(i386_HOST_ARCH)
+       // dyld stub code contains references to this,
+       // but it should never be called because we treat
+       // lazy pointers as nonlazy.
+       { "dyld_stub_binding_helper", (void*)0xDEADBEEF, false },
+ #endif
+-      { "_DYNAMIC", (void*)(&RTS_DYNAMIC), false },
+       { 0, 0, false } /* sentinel */
+ };
+-- 
+2.25.4
+

diff --git a/dev-lang/ghc/ghc-8.10.2.ebuild b/dev-lang/ghc/ghc-8.10.2.ebuild
new file mode 100644
index 00000000000..567a3225311
--- /dev/null
+++ b/dev-lang/ghc/ghc-8.10.2.ebuild
@@ -0,0 +1,798 @@
+# Copyright 1999-2020 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+# to make make a crosscompiler use crossdev and symlink ghc tree into
+# cross overlay. result would look like 'cross-sparc-unknown-linux-gnu/ghc'
+export CBUILD=${CBUILD:-${CHOST}}
+export CTARGET=${CTARGET:-${CHOST}}
+if [[ ${CTARGET} = ${CHOST} ]] ; then
+	if [[ ${CATEGORY/cross-} != ${CATEGORY} ]] ; then
+		export CTARGET=${CATEGORY/cross-}
+	fi
+fi
+
+inherit autotools bash-completion-r1 eutils flag-o-matic ghc-package
+inherit multilib multiprocessing pax-utils toolchain-funcs prefix
+inherit check-reqs
+DESCRIPTION="The Glasgow Haskell Compiler"
+HOMEPAGE="https://www.haskell.org/ghc/"
+
+# we don't have any binaries yet
+arch_binaries=""
+
+BIN_PV=${PV}
+# sorted!
+#arch_binaries="$arch_binaries alpha? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-alpha.tbz2 )"
+#arch_binaries="$arch_binaries arm? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-armv7a-hardfloat-linux-gnueabi.tbz2 )"
+#arch_binaries="$arch_binaries arm64? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-aarch64-unknown-linux-gnu.tbz2 )"
+arch_binaries="$arch_binaries amd64? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-x86_64-pc-linux-gnu.tbz2 )"
+#arch_binaries="$arch_binaries ia64?  ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-ia64-fixed-fiw.tbz2 )"
+#arch_binaries="$arch_binaries ppc? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-ppc.tbz2 )"
+#arch_binaries="$arch_binaries ppc64? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-ppc64.tbz2 )"
+#arch_binaries="$arch_binaries ppc64? ( !big-endian? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-powerpc64le-unknown-linux-gnu.tbz2 ) )"
+#arch_binaries="$arch_binaries sparc? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-sparc.tbz2 )"
+#arch_binaries="$arch_binaries x86? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-i686-pc-linux-gnu.tbz2 )"
+
+# various ports:
+#arch_binaries="$arch_binaries x86-fbsd? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-x86-fbsd.tbz2 )"
+
+# 0 - yet
+yet_binary() {
+	case "${ARCH}" in
+		#alpha) return 0 ;;
+		#arm64) return 0 ;;
+		#arm) return 0 ;;
+		amd64) return 0 ;;
+		#ia64) return 0 ;;
+		#ppc) return 0 ;;
+		#ppc64)
+		#	use big-endian && return 0
+		#	return 0
+		#	;;
+		#sparc) return 0 ;;
+		#x86) return 0 ;;
+		*) return 1 ;;
+	esac
+}
+
+GHC_PV=${PV}
+#GHC_PV=8.10.0.20200123 # uncomment only for -alpha, -beta, -rc ebuilds
+GHC_P=${PN}-${GHC_PV} # using ${P} is almost never correct
+
+SRC_URI="!binary? (
+	https://downloads.haskell.org/ghc/${PV/_/-}/${GHC_P}-src.tar.xz
+	test? ( https://downloads.haskell.org/ghc/${PV/_/-}/${GHC_P}-testsuite.tar.xz )
+)"
+S="${WORKDIR}"/${GHC_P}
+
+[[ -n $arch_binaries ]] && SRC_URI+=" !ghcbootstrap? ( $arch_binaries )"
+
+BUMP_LIBRARIES=(
+	# "hackage-name          hackage-version"
+)
+
+LICENSE="BSD"
+SLOT="0/${PV}"
+KEYWORDS=""
+IUSE="big-endian doc elfutils ghcbootstrap ghcmakebinary +gmp numa profile test"
+IUSE+=" binary"
+RESTRICT="!test? ( test )"
+
+RDEPEND="
+	>=dev-lang/perl-5.6.1
+	dev-libs/gmp:0=
+	sys-libs/ncurses:0=[unicode]
+	elfutils? ( dev-libs/elfutils )
+	!ghcmakebinary? ( dev-libs/libffi:= )
+	numa? ( sys-process/numactl )
+"
+
+# This set of dependencies is needed to run
+# prebuilt ghc. We specifically avoid ncurses
+# dependency with:
+#    utils/ghc-pkg_HC_OPTS += -DBOOTSTRAPPING
+PREBUILT_BINARY_DEPENDS="
+	!prefix? ( elibc_glibc? ( >=sys-libs/glibc-2.17 ) )
+"
+# This set of dependencies is needed to install
+# ghc[binary] in system. terminfo package is linked
+# against ncurses.
+PREBUILT_BINARY_RDEPENDS="${PREBUILT_BINARY_DEPENDS}
+	sys-libs/ncurses:0/6
+"
+
+RDEPEND+="binary? ( ${PREBUILT_BINARY_RDEPENDS} )"
+
+DEPEND="${RDEPEND}
+	doc? ( app-text/docbook-xml-dtd:4.2
+		app-text/docbook-xml-dtd:4.5
+		app-text/docbook-xsl-stylesheets
+		dev-python/sphinx
+		>=dev-libs/libxslt-1.1.2 )
+	!ghcbootstrap? ( ${PREBUILT_BINARY_DEPENDS} )"
+
+# we build binaries without profiling support
+REQUIRED_USE="
+	?? ( ghcbootstrap binary )
+	?? ( profile binary )
+"
+
+# haskell libraries built with cabal in configure mode, #515354
+QA_CONFIGURE_OPTIONS+=" --with-compiler --with-gcc"
+
+is_crosscompile() {
+	[[ ${CHOST} != ${CTARGET} ]]
+}
+
+is_native() {
+	[[ ${CHOST} == ${CBUILD} ]] && [[ ${CHOST} == ${CTARGET} ]]
+}
+
+if ! is_crosscompile; then
+	PDEPEND="!ghcbootstrap? ( >=app-admin/haskell-updater-1.2 )"
+fi
+
+# returns tool prefix for crosscompiler.
+# Example:
+#  CTARGET=armv7a-unknown-linux-gnueabi
+#  CHOST=x86_64-pc-linux-gnu
+#    "armv7a-unknown-linux-gnueabi-"
+#  CTARGET=${CHOST}
+#    ""
+# Used in tools and library prefix:
+#    "${ED}"/usr/bin/$(cross)haddock
+#    "${ED}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d"
+
+cross() {
+	if is_crosscompile; then
+		echo "${CTARGET}-"
+	else
+		echo ""
+	fi
+}
+
+append-ghc-cflags() {
+	local persistent compile assemble link
+	local flag ghcflag
+
+	for flag in $*; do
+		case ${flag} in
+			persistent)	persistent="yes";;
+			compile)	compile="yes";;
+			assemble)	assemble="yes";;
+			link)		link="yes";;
+			*)
+				[[ ${compile}  ]] && ghcflag="-optc${flag}"  CFLAGS+=" ${flag}" && GHC_FLAGS+=" ${ghcflag}" &&
+					[[ ${persistent} ]] && GHC_PERSISTENT_FLAGS+=" ${ghcflag}"
+				[[ ${assemble} ]] && ghcflag="-opta${flag}"  CFLAGS+=" ${flag}" && GHC_FLAGS+=" ${ghcflag}" &&
+					[[ ${persistent} ]] && GHC_PERSISTENT_FLAGS+=" ${ghcflag}"
+				[[ ${link}     ]] && ghcflag="-optl${flag}" LDFLAGS+=" ${flag}" && GHC_FLAGS+=" ${ghcflag}" &&
+					[[ ${persistent} ]] && GHC_PERSISTENT_FLAGS+=" ${ghcflag}"
+				;;
+		esac
+	done
+}
+
+# $1 - lib name (under libraries/)
+# $2 - lib version
+# example: bump_lib "transformers" "0.4.2.0"
+bump_lib() {
+	local pn=$1 pv=$2
+	local p=${pn}-${pv}
+	local f
+
+	einfo "Bumping ${pn} up to ${pv}"
+
+	for f in ghc.mk GNUmakefile; do
+		mv libraries/"${pn}"/$f "${WORKDIR}"/"${p}"/$f || die
+	done
+	mv libraries/"${pn}" "${WORKDIR}"/"${pn}".old || die
+	mv "${WORKDIR}"/"${p}" libraries/"${pn}" || die
+}
+
+update_SRC_URI() {
+	local p pn pv
+	for p in "${BUMP_LIBRARIES[@]}"; do
+		set -- $p
+		pn=$1 pv=$2
+
+		SRC_URI+=" https://hackage.haskell.org/package/${pn}-${pv}/${pn}-${pv}.tar.gz"
+	done
+}
+
+update_SRC_URI
+
+bump_libs() {
+	local p pn pv
+	for p in "${BUMP_LIBRARIES[@]}"; do
+		set -- $p
+		pn=$1 pv=$2
+
+		bump_lib "${pn}" "${pv}"
+	done
+}
+
+ghc_setup_cflags() {
+	# TODO: plumb CFLAGS and BUILD_CFLAGS to respective CONF_CC_OPTS_STAGE<N>
+	if ! is_native; then
+		export CFLAGS=${GHC_CFLAGS-"-O2 -pipe"}
+		export LDFLAGS=${GHC_LDFLAGS-"-Wl,-O1"}
+		einfo "Crosscompiling mode:"
+		einfo "   CHOST:   ${CHOST}"
+		einfo "   CTARGET: ${CTARGET}"
+		einfo "   CFLAGS:  ${CFLAGS}"
+		einfo "   LDFLAGS: ${LDFLAGS}"
+		einfo "   prefix: $(cross)"
+		return
+	fi
+	# We need to be very careful with the CFLAGS we ask ghc to pass through to
+	# gcc. There are plenty of flags which will make gcc produce output that
+	# breaks ghc in various ways. The main ones we want to pass through are
+	# -mcpu / -march flags. These are important for arches like alpha & sparc.
+	# We also use these CFLAGS for building the C parts of ghc, ie the rts.
+	strip-flags
+	strip-unsupported-flags
+
+	# Cmm can't parse line numbers #482086
+	replace-flags -ggdb[3-9] -ggdb2
+
+	GHC_FLAGS=""
+	GHC_PERSISTENT_FLAGS=""
+	for flag in ${CFLAGS}; do
+		case ${flag} in
+
+			# Ignore extra optimisation (ghc passes -O to gcc anyway)
+			# -O2 and above break on too many systems
+			-O*) ;;
+
+			# Arch and ABI flags are what we're really after
+			-m*) append-ghc-cflags compile assemble ${flag};;
+
+			# Sometimes it's handy to see backtrace of RTS
+			# to get an idea what happens there
+			-g*) append-ghc-cflags compile ${flag};;
+
+			# Ignore all other flags, including all -f* flags
+		esac
+	done
+
+	for flag in ${LDFLAGS}; do
+		append-ghc-cflags link ${flag}
+	done
+
+	# GHC uses ${CBUILD}-gcc, ${CHOST}-gcc and ${CTARGET}-gcc at a single build.
+	# Skip any gentoo-specific tweaks for cross-case to avoid passing unsupported
+	# options to gcc.
+	if is_native; then
+		# prevent from failing to build unregisterised ghc:
+		# https://www.mail-archive.com/debian-bugs-dist@lists.debian.org/msg171602.html
+		use ppc64 && append-ghc-cflags persistent compile -mminimal-toc
+	fi
+}
+
+# substitutes string $1 to $2 in files $3 $4 ...
+relocate_path() {
+	local from=$1
+	local   to=$2
+	shift 2
+	local file=
+	for file in "$@"
+	do
+		sed -i -e "s|$from|$to|g" \
+			"$file" || die "path relocation failed for '$file'"
+	done
+}
+
+# changes hardcoded ghc paths and updates package index
+# $1 - new absolute root path
+relocate_ghc() {
+	local to=$1 ghc_v=${BIN_PV}
+
+	# libdir for prebuilt binary and for current system may mismatch
+	# It does for prefix installation for example: bug #476998
+	local bin_ghc_prefix=${WORKDIR}/usr
+	local bin_libpath=$(echo "${bin_ghc_prefix}"/lib*)
+	local bin_libdir=${bin_libpath#${bin_ghc_prefix}/}
+
+	# backup original script to use it later after relocation
+	local gp_back="${T}/ghc-pkg-${ghc_v}-orig"
+	cp "${WORKDIR}/usr/bin/ghc-pkg-${ghc_v}" "$gp_back" || die "unable to backup ghc-pkg wrapper"
+
+	if [[ ${bin_libdir} != $(get_libdir) ]]; then
+		einfo "Relocating '${bin_libdir}' to '$(get_libdir)' (bug #476998)"
+		# moving the dir itself is not strictly needed
+		# but then USE=binary would result in installing
+		# in '${bin_libdir}'
+		mv "${bin_ghc_prefix}/${bin_libdir}" "${bin_ghc_prefix}/$(get_libdir)" || die
+
+		relocate_path "/usr/${bin_libdir}" "/usr/$(get_libdir)" \
+			"${WORKDIR}/usr/bin/ghc-${ghc_v}" \
+			"${WORKDIR}/usr/bin/ghci-${ghc_v}" \
+			"${WORKDIR}/usr/bin/ghc-pkg-${ghc_v}" \
+			"${WORKDIR}/usr/bin/hsc2hs" \
+			"${WORKDIR}/usr/bin/runghc-${ghc_v}" \
+			"$gp_back" \
+			"${WORKDIR}/usr/$(get_libdir)/${PN}-${ghc_v}/package.conf.d/"*
+	fi
+
+	# Relocate from /usr to ${EPREFIX}/usr
+	relocate_path "/usr" "${to}/usr" \
+		"${WORKDIR}/usr/bin/ghc-${ghc_v}" \
+		"${WORKDIR}/usr/bin/ghci-${ghc_v}" \
+		"${WORKDIR}/usr/bin/ghc-pkg-${ghc_v}" \
+		"${WORKDIR}/usr/bin/haddock-ghc-${ghc_v}" \
+		"${WORKDIR}/usr/bin/hp2ps" \
+		"${WORKDIR}/usr/bin/hpc" \
+		"${WORKDIR}/usr/bin/hsc2hs" \
+		"${WORKDIR}/usr/bin/runghc-${ghc_v}" \
+		"${WORKDIR}/usr/$(get_libdir)/${PN}-${ghc_v}/package.conf.d/"*
+
+	# this one we will use to regenerate cache
+	# so it should point to current tree location
+	relocate_path "/usr" "${WORKDIR}/usr" "$gp_back"
+
+	if use prefix; then
+		hprefixify "${bin_libpath}"/${PN}*/settings
+	fi
+
+	# regenerate the binary package cache
+	"$gp_back" recache || die "failed to update cache after relocation"
+	rm "$gp_back"
+}
+
+ghc-check-reqs() {
+	# These are pessimistic values (slightly bigger than worst-case)
+	# Worst case is UNREG USE=profile ia64. See bug #611866 for some
+	# numbers on various arches.
+	CHECKREQS_DISK_BUILD=8G
+	CHECKREQS_DISK_USR=2G
+	# USE=binary roughly takes
+	use binary && CHECKREQS_DISK_BUILD=4G
+
+	"$@"
+}
+
+pkg_pretend() {
+	ghc-check-reqs check-reqs_pkg_pretend
+}
+
+pkg_setup() {
+	ghc-check-reqs check-reqs_pkg_setup
+
+	# quiet portage about prebuilt binaries
+	use binary && QA_PREBUILT="*"
+
+	[[ ${MERGE_TYPE} == binary ]] && return
+
+	if use ghcbootstrap; then
+		ewarn "You requested ghc bootstrapping, this is usually only used"
+		ewarn "by Gentoo developers to make binary .tbz2 packages."
+
+		[[ -z $(type -P ghc) ]] && \
+			die "Could not find a ghc to bootstrap with."
+	else
+		if ! yet_binary; then
+			eerror "Please try emerging with USE=ghcbootstrap and report build"
+			eerror "sucess or failure to the haskell team (haskell@gentoo.org)"
+			die "No binary available for '${ARCH}' arch yet, USE=ghcbootstrap"
+		fi
+	fi
+}
+
+src_unpack() {
+	# Create the ${S} dir if we're using the binary version
+	use binary && mkdir "${S}"
+
+	# the Solaris and Darwin binaries from ghc (maeder) need to be
+	# unpacked separately, so prevent them from being unpacked
+	local ONLYA=${A}
+	case ${CHOST} in
+		*-darwin* | *-solaris*)  ONLYA=${GHC_P}-src.tar.xz  ;;
+	esac
+	unpack ${ONLYA}
+}
+
+src_prepare() {
+	ghc_setup_cflags
+
+	if ! use ghcbootstrap && [[ ${CHOST} != *-darwin* && ${CHOST} != *-solaris* ]]; then
+		# Modify the wrapper script from the binary tarball to use GHC_PERSISTENT_FLAGS.
+		# See bug #313635.
+		sed -i -e "s|\"\$topdir\"|\"\$topdir\" ${GHC_PERSISTENT_FLAGS}|" \
+			"${WORKDIR}/usr/bin/ghc-${BIN_PV}"
+
+		# allow hardened users use vanilla binary to bootstrap ghc
+		# ghci uses mmap with rwx protection at it implements dynamic
+		# linking on it's own (bug #299709)
+		pax-mark -m "${WORKDIR}/usr/$(get_libdir)/${PN}-${BIN_PV}/bin/ghc"
+	fi
+
+	if use binary; then
+		if use prefix; then
+			relocate_ghc "${EPREFIX}"
+		fi
+
+		# Move unpacked files to the expected place
+		mv "${WORKDIR}/usr" "${S}"
+		eapply_user
+	else
+		if ! use ghcbootstrap; then
+			case ${CHOST} in
+				*-darwin* | *-solaris*)
+				# UPDATE ME for ghc-7
+				mkdir "${WORKDIR}"/ghc-bin-installer || die
+				pushd "${WORKDIR}"/ghc-bin-installer > /dev/null || die
+				use sparc-solaris && unpack ghc-6.10.4-sparc-sun-solaris2.tar.bz2
+				use x86-solaris && unpack ghc-7.0.3-i386-unknown-solaris2.tar.bz2
+				use x86-macos && unpack ghc-7.4.1-i386-apple-darwin.tar.bz2
+				use x64-macos && unpack ghc-7.4.1-x86_64-apple-darwin.tar.bz2
+				popd > /dev/null
+
+				pushd "${WORKDIR}"/ghc-bin-installer/ghc-[67].?*.? > /dev/null || die
+				# fix the binaries so they run, on Solaris we need an
+				# LD_LIBRARY_PATH which has our prefix libdirs, on
+				# Darwin we need to replace the frameworks with our libs
+				# from the prefix fix before installation, because some
+				# of the tools are actually used during configure/make
+				if [[ ${CHOST} == *-solaris* ]] ; then
+					export LD_LIBRARY_PATH="${EPREFIX}/$(get_libdir):${EPREFIX}/usr/$(get_libdir):${LD_LIBRARY_PATH}"
+				elif [[ ${CHOST} == *-darwin* ]] ; then
+					local readline_framework=GNUreadline.framework/GNUreadline
+					local gmp_framework=/opt/local/lib/libgmp.10.dylib
+					local ncurses_file=/opt/local/lib/libncurses.5.dylib
+					for binary in $(scanmacho -BRE MH_EXECUTE -F '%F' .) ; do
+						install_name_tool -change \
+							${readline_framework} \
+							"${EPREFIX}"/lib/libreadline.dylib \
+							${binary} || die
+						install_name_tool -change \
+							${gmp_framework} \
+							"${EPREFIX}"/usr/lib/libgmp.dylib \
+							${binary} || die
+						install_name_tool -change \
+							${ncurses_file} \
+							"${EPREFIX}"/usr/lib/libncurses.dylib \
+							${binary} || die
+					done
+					# we don't do frameworks!
+					sed -i \
+						-e 's/\(frameworks = \)\["GMP"\]/\1[]/g' \
+						-e 's/\(extraLibraries = \)\["m"\]/\1["m","gmp"]/g' \
+						rts/package.conf.in || die
+				fi
+
+				# it is autoconf, but we really don't want to give it too
+				# many arguments, in fact we do the make in-place anyway
+				./configure --prefix="${WORKDIR}"/usr || die
+				make install || die
+				popd > /dev/null
+				;;
+				*)
+				relocate_ghc "${WORKDIR}"
+				;;
+			esac
+		fi
+
+		sed -i -e "s|\"\$topdir\"|\"\$topdir\" ${GHC_PERSISTENT_FLAGS}|" \
+			"${S}/ghc/ghc.wrapper"
+
+		cd "${S}" # otherwise eapply will break
+
+		eapply "${FILESDIR}"/${PN}-7.0.4-CHOST-prefix.patch
+		eapply "${FILESDIR}"/${PN}-8.2.1-darwin.patch
+		eapply "${FILESDIR}"/${PN}-7.8.3-prim-lm.patch
+		eapply "${FILESDIR}"/${PN}-8.8.1-revert-CPP.patch
+		eapply "${FILESDIR}"/${PN}-8.10.1-allow-cross-bootstrap.patch
+		eapply "${FILESDIR}"/${PN}-8.10.2-revert-linker-rtsSymbols_more_linker_symbols.patch
+
+		# a bunch of crosscompiler patches
+		# needs newer version:
+		#eapply "${FILESDIR}"/${PN}-8.2.1_rc1-hp2ps-cross.patch
+
+		# mingw32 target
+		pushd "${S}/libraries/Win32"
+			eapply "${FILESDIR}"/${PN}-8.2.1_rc1-win32-cross-2-hack.patch # bad workaround
+		popd
+
+		bump_libs
+
+		eapply_user
+		# as we have changed the build system
+		eautoreconf
+	fi
+}
+
+src_configure() {
+	if ! use binary; then
+		# initialize build.mk
+		echo '# Gentoo changes' > mk/build.mk
+
+		# Put docs into the right place, ie /usr/share/doc/ghc-${GHC_PV}
+		echo "docdir = ${EPREFIX}/usr/share/doc/$(cross)${P}" >> mk/build.mk
+		echo "htmldir = ${EPREFIX}/usr/share/doc/$(cross)${P}" >> mk/build.mk
+
+		# We also need to use the GHC_FLAGS flags when building ghc itself
+		echo "SRC_HC_OPTS+=${HCFLAGS} ${GHC_FLAGS}" >> mk/build.mk
+		echo "SRC_CC_OPTS+=${CFLAGS}" >> mk/build.mk
+		echo "SRC_LD_OPTS+=${LDFLAGS}" >> mk/build.mk
+		# Speed up initial Cabal bootstrap
+		echo "utils/ghc-cabal_dist_EXTRA_HC_OPTS+=$(ghc-make-args)" >> mk/build.mk
+
+		# We can't depend on haddock except when bootstrapping when we
+		# must build docs and include them into the binary .tbz2 package
+		# app-text/dblatex is not in portage, can not build PDF or PS
+		echo "BUILD_SPHINX_PDF  = NO"  >> mk/build.mk
+		echo "BUILD_SPHINX_HTML = $(usex doc YES NO)" >> mk/build.mk
+		echo "BUILD_MAN = $(usex doc YES NO)" >> mk/build.mk
+
+		# this controls presence on 'xhtml' and 'haddock' in final install
+		echo "HADDOCK_DOCS       = YES" >> mk/build.mk
+
+		# not used outside of ghc's test
+		if [[ -n ${GHC_BUILD_DPH} ]]; then
+				echo "BUILD_DPH = YES" >> mk/build.mk
+			else
+				echo "BUILD_DPH = NO" >> mk/build.mk
+		fi
+
+		# Any non-native build has to skip as it needs
+		# target haddock binary to be runnabine.
+		if ! is_native; then
+			# disable docs generation as it requires running stage2
+			echo "HADDOCK_DOCS=NO" >> mk/build.mk
+			echo "BUILD_SPHINX_HTML=NO" >> mk/build.mk
+			echo "BUILD_SPHINX_PDF=NO" >> mk/build.mk
+		fi
+
+		if is_crosscompile; then
+			# Install ghc-stage1 crosscompiler instead of
+			# ghc-stage2 cross-built compiler.
+			echo "Stage1Only=YES" >> mk/build.mk
+		fi
+
+		# allows overriding build flavours for libraries:
+		# v   - vanilla (static libs)
+		# p   - profiled
+		# dyn - shared libraries
+		# example: GHC_LIBRARY_WAYS="v dyn"
+		if [[ -n ${GHC_LIBRARY_WAYS} ]]; then
+			echo "GhcLibWays=${GHC_LIBRARY_WAYS}" >> mk/build.mk
+		fi
+		echo "BUILD_PROF_LIBS = $(usex profile YES NO)" >> mk/build.mk
+
+		# Get ghc from the unpacked binary .tbz2
+		# except when bootstrapping we just pick ghc up off the path
+		if ! use ghcbootstrap; then
+			export PATH="${WORKDIR}/usr/bin:${PATH}"
+		fi
+
+		echo "INTEGER_LIBRARY = $(usex gmp integer-gmp integer-simple)" >> mk/build.mk
+
+		# don't strip anything. Very useful when stage2 SIGSEGVs on you
+		echo "STRIP_CMD = :" >> mk/build.mk
+
+		local econf_args=()
+
+		# GHC embeds toolchain it was built by and uses it later.
+		# Don't allow things like ccache or versioned binary slip.
+		# We use stable thing across gcc upgrades.
+		# User can use EXTRA_ECONF=CC=... to override this default.
+		econf_args+=(
+			AR=${CTARGET}-ar
+			CC=${CTARGET}-gcc
+			# these should be inferred by GHC but ghc defaults
+			# to using bundled tools on windows.
+			Windres=${CTARGET}-windres
+			DllWrap=${CTARGET}-dllwrap
+			# we set the linker explicitly below
+			--disable-ld-override
+		)
+		case ${CTARGET} in
+			arm*)
+				# ld.bfd-2.28 does not work for ghc. Force ld.gold
+				# instead. This should be removed once gentoo gets
+				# a fix for R_ARM_COPY bug: https://sourceware.org/PR16177
+				econf_args+=(LD=${CTARGET}-ld.gold)
+			;;
+			sparc*)
+				# ld.gold-2.28 does not work for ghc. Force ld.bfd
+				# instead. This should be removed once gentoo gets
+				# a fix for missing --no-relax support bug:
+				# https://sourceware.org/ml/binutils/2017-07/msg00183.html
+				econf_args+=(LD=${CTARGET}-ld.bfd)
+			;;
+			*)
+				econf_args+=(LD=${CTARGET}-ld)
+		esac
+
+		if [[ ${CBUILD} != ${CHOST} ]]; then
+			# GHC bug: ghc claims not to support cross-building.
+			# It does, but does not distinct --host= value
+			# for stage1 and stage2 compiler.
+			econf_args+=(--host=${CBUILD})
+		fi
+
+		if use ghcmakebinary; then
+			# When building booting libary we are trying to
+			# bundle or restrict most of external depends
+			# with unstable ABI:
+			#  - embed libffi (default GHC behaviour)
+			#  - disable ncurses support for ghci (via haskeline)
+			#    https://bugs.gentoo.org/557478
+			#  - disable ncurses support for ghc-pkg
+			echo "libraries/haskeline_CONFIGURE_OPTS += --flag=-terminfo" >> mk/build.mk
+			echo "utils/ghc-pkg_HC_OPTS += -DBOOTSTRAPPING" >> mk/build.mk
+		elif is_native; then
+			# using ${GTARGET}'s libffi is not supported yet:
+			# GHC embeds full path for ffi includes without /usr/${CTARGET} account.
+			econf_args+=(--with-system-libffi)
+			econf_args+=(--with-ffi-includes=$($(tc-getPKG_CONFIG) libffi --cflags-only-I | sed -e 's@^-I@@'))
+		fi
+
+		einfo "Final mk/build.mk:"
+		cat mk/build.mk || die
+
+		econf ${econf_args[@]} \
+			--enable-bootstrap-with-devel-snapshot \
+			$(use_enable elfutils dwarf-unwind) \
+			$(use_enable numa)
+
+		if [[ ${PV} == *9999* ]]; then
+			GHC_PV="$(grep 'S\[\"PACKAGE_VERSION\"\]' config.status | sed -e 's@^.*=\"\(.*\)\"@\1@')"
+			GHC_P=${PN}-${GHC_PV}
+		fi
+	fi # ! use binary
+}
+
+src_compile() {
+	if ! use binary; then
+		# Stage1Only crosscompiler does not build stage2
+		if ! is_crosscompile; then
+			# 1. build/pax-mark compiler binary first
+			emake ghc/stage2/build/tmp/ghc-stage2
+			# 2. pax-mark (bug #516430)
+			pax-mark -m ghc/stage2/build/tmp/ghc-stage2
+			# 2. build/pax-mark haddock using ghc-stage2
+			if is_native; then
+				# non-native build does not build haddock
+				# due to HADDOCK_DOCS=NO, but it could.
+				emake utils/haddock/dist/build/tmp/haddock
+				pax-mark -m utils/haddock/dist/build/tmp/haddock
+			fi
+		fi
+		# 3. and then all the rest
+		emake all
+	fi # ! use binary
+}
+
+src_test() {
+	# TODO: deal with:
+	#    - sandbox (pollutes environment)
+	#    - extra packages (to extend testsuite coverage)
+	# bits are taken from 'validate'
+	local make_test_target='test' # can be fulltest
+	# not 'emake' as testsuite uses '$MAKE' without jobserver available
+	make $make_test_target stage=2 THREADS=$(makeopts_jobs)
+}
+
+src_install() {
+	if use binary; then
+		use prefix && mkdir -p "${ED}"
+		mv "${S}/usr" "${ED}"
+	else
+		[[ -f VERSION ]] || emake VERSION
+
+		# -j1 due to a rare race in install script:
+		#    make --no-print-directory -f ghc.mk phase=final install
+		#    /usr/lib/portage/python3.4/ebuild-helpers/xattr/install -c -m 755 \
+		#        -d "/tmp/portage-tmpdir/portage/cross-armv7a-unknown-linux-gnueabi/ghc-9999/image/usr/lib64/armv7a-unknown-linux-gnueabi-ghc-8.3.20170404/include"
+		#    /usr/lib/portage/python3.4/ebuild-helpers/xattr/install -c -m 644  utils/hsc2hs/template-hsc.h \
+		#           "/tmp/portage-tmpdir/portage/cross-armv7a-unknown-linux-gnueabi/ghc-9999/image/usr/lib64/armv7a-unknown-linux-gnueabi-ghc-8.3.20170404"
+		#    /usr/bin/install: cannot create regular file \
+		#           '/tmp/portage-tmpdir/portage/cross-armv7a-unknown-linux-gnueabi/ghc-9999/image/usr/lib64/armv7a-unknown-linux-gnueabi-ghc-8.3.20170404': No such file or directory
+		emake -j1 install DESTDIR="${D}"
+
+		# Skip for cross-targets as they all share target location:
+		# /usr/share/doc/ghc-9999/
+		if ! is_crosscompile; then
+			dodoc "distrib/README" "LICENSE" "VERSION"
+		fi
+
+		# rename ghc-shipped files to avoid collision
+		# of external packages. Motivating example:
+		#  user had installed:
+		#      dev-lang/ghc-7.8.4-r0 (with transformers-0.3.0.0)
+		#      dev-haskell/transformers-0.4.2.0
+		#  then user tried to update to
+		#      dev-lang/ghc-7.8.4-r1 (with transformers-0.4.2.0)
+		#  this will lead to single .conf file collision.
+		local shipped_conf renamed_conf
+		local package_confdir="${ED}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d"
+		for shipped_conf in "${package_confdir}"/*.conf; do
+			# rename 'pkg-ver-id.conf' to 'pkg-ver-id-gentoo-${PF}.conf'
+			renamed_conf=${shipped_conf%.conf}-gentoo-${PF}.conf
+			mv "${shipped_conf}" "${renamed_conf}" || die
+		done
+
+		# remove link, but leave 'haddock-${GHC_P}'
+		rm -f "${ED}"/usr/bin/$(cross)haddock
+
+		if ! is_crosscompile; then
+			newbashcomp "${FILESDIR}"/ghc-bash-completion ghc-pkg
+			newbashcomp utils/completion/ghc.bash         ghc
+		fi
+	fi
+
+	# path to the package.cache
+	local package_confdir="${ED}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d"
+	PKGCACHE="${package_confdir}"/package.cache
+	# copy the package.conf.d, including timestamp, save it so we can help
+	# users that have a broken package.conf.d
+	cp -pR "${package_confdir}"{,.initial} || die "failed to backup intial package.conf.d"
+
+	# copy the package.conf, including timestamp, save it so we later can put it
+	# back before uninstalling, or when upgrading.
+	cp -p "${PKGCACHE}"{,.shipped} \
+		|| die "failed to copy package.conf.d/package.cache"
+
+	if is_crosscompile; then
+		# When we build a cross-compiler the layout is the following:
+		#     usr/lib/${CTARGET}-ghc-${VER}/ contains target libraries
+		# but
+		#     usr/lib/${CTARGET}-ghc-${VER}/bin/ directory
+		# containst host binaries (modulo bugs).
+
+		# Portage's stripping mechanism does not skip stripping
+		# foreign binaries. This frequently causes binaries to be
+		# broken.
+		#
+		# Thus below we disable stripping of target libraries and allow
+		# stripping hosts executables.
+		dostrip -x "/usr/$(get_libdir)/$(cross)${GHC_P}"
+		dostrip    "/usr/$(get_libdir)/$(cross)${GHC_P}/bin"
+	fi
+}
+
+pkg_preinst() {
+	# have we got an earlier version of ghc installed?
+	if has_version "<${CATEGORY}/${PF}"; then
+		haskell_updater_warn="1"
+	fi
+}
+
+pkg_postinst() {
+	ghc-reregister
+
+	# path to the package.cache
+	PKGCACHE="${EROOT}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d/package.cache"
+
+	# give the cache a new timestamp, it must be as recent as
+	# the package.conf.d directory.
+	touch "${PKGCACHE}"
+
+	if [[ "${haskell_updater_warn}" == "1" ]]; then
+		ewarn
+		ewarn "\e[1;31m************************************************************************\e[0m"
+		ewarn
+		ewarn "You have just upgraded from an older version of GHC."
+		ewarn "You may have to run"
+		ewarn "      'haskell-updater'"
+		ewarn "to rebuild all ghc-based Haskell libraries."
+		ewarn
+		ewarn "\e[1;31m************************************************************************\e[0m"
+		ewarn
+	fi
+}
+
+pkg_prerm() {
+	PKGCACHE="${EROOT}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d/package.cache"
+	rm -rf "${PKGCACHE}"
+
+	cp -p "${PKGCACHE}"{.shipped,}
+}
+
+pkg_postrm() {
+	ghc-package_pkg_postrm
+}


^ permalink raw reply related	[flat|nested] 15+ messages in thread
* [gentoo-commits] repo/gentoo:master commit in: dev-lang/ghc/, dev-lang/ghc/files/
@ 2020-03-24 23:34 Sergei Trofimovich
  0 siblings, 0 replies; 15+ messages in thread
From: Sergei Trofimovich @ 2020-03-24 23:34 UTC (permalink / raw
  To: gentoo-commits

commit:     2f8caac4a356bdcab968b08105ae966fb514b3ef
Author:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
AuthorDate: Tue Mar 24 23:34:28 2020 +0000
Commit:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
CommitDate: Tue Mar 24 23:34:48 2020 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=2f8caac4

dev-lang/ghc: bump up to 8.10.1

Package-Manager: Portage-2.3.95, Repoman-2.3.21
Signed-off-by: Sergei Trofimovich <slyfox <AT> gentoo.org>

 dev-lang/ghc/Manifest                              |   2 +
 .../files/ghc-8.10.1-allow-cross-bootstrap.patch   |  17 +
 .../ghc/files/ghc-8.10.1-no-relax-everywhere.patch |  19 +
 dev-lang/ghc/ghc-8.10.1.ebuild                     | 794 +++++++++++++++++++++
 4 files changed, 832 insertions(+)

diff --git a/dev-lang/ghc/Manifest b/dev-lang/ghc/Manifest
index bd2437f9012..31b52d5da13 100644
--- a/dev-lang/ghc/Manifest
+++ b/dev-lang/ghc/Manifest
@@ -3,6 +3,8 @@ DIST ghc-7.10.3-src.tar.bz2 13281867 BLAKE2B 51b0a94cc63269926fd5d04c0fb0871266c
 DIST ghc-7.8.4-ia64-CLOSUREs-regenerated.patch.gz 13268 BLAKE2B 35af21163e3a46ee340e29eb88daf617eeb094f02da7fdcb80e947c1d26234232b12d9eb2c38c02c3207c047573521fef3ac5e7b87609e66f0c57072fef1038e SHA512 a655713e06324b56f0041edf70837487e296d28e6f3ee35fe116b9938765aaf3469d25e92645e0940655ed3607dff27d3826fe0f995c84e81b51bfc956816e7d
 DIST ghc-7.8.4-src.tar.bz2 10600755 BLAKE2B 6cf27f663178513b25032b648cf36b016e01361966725dbfc219079961e8eb9b1ab3531427c7012dc599e8e102dc87ed6dd43b31e7bd4e231e2d989936eb2c66 SHA512 079a53891d8ebd8d9b88da96170e60981608a619f8282e4b7948f35244e99bd87277649ac7fcebc227a61a4d21960db8d5e5b9e92f2c69c82d8d68d7fd0a41d3
 DIST ghc-8.0.2-src.tar.xz 10687760 BLAKE2B 3b2a487c115680342ce308ff1a42d2b6fa6fb1f31e2670b27a305b4d44160056611b77273c9d47f2e37a1ef01b1aba59c36e76b65c83142a5f09812bf3b1ea02 SHA512 58ea3853cd93b556ecdc4abd0be079b2621171b8491f59004ea4e036a4cba4470aaafe6591b942e0a50a64bdc47540e01fe6900212a1ef7087850112d9bfc5ef
+DIST ghc-8.10.1-src.tar.xz 19781652 BLAKE2B 61ff73d3a895cfa0c836e25a684d7a31cf099dcc33d1f308eaf56aa4b2a75b8f38cf963197c11dad9d027270845af20e00a7d81e5417b0fb8b4a98ddbadd53d8 SHA512 e6bb5c326f8354f0892324586c164c6e04168215d8bfeccb594173a838a535e37bac38db6fbdb01fb37150099c12842c53be5e912dfb6a6feeae3c75d4ae24d0
+DIST ghc-8.10.1-testsuite.tar.xz 2091988 BLAKE2B 88796f0fb6ea2bdd749161c84ec88768f3bf87063d2224a083db24f69282e615227626fe3c7b41d4abec10883e22042abed6a231582bab4ea530feffd683ed0b SHA512 35147f98301c5bfb6c939e108de48b2a1133adc1028aaa720ce49d60faa06a4b486a9eded658295e3f203731b4dd53475b57e8213491c45b05959430030be269
 DIST ghc-8.2.1-src.tar.xz 10736016 BLAKE2B 60993cfc9569e83b0c383591ef30a7280e0138fbb7bd696ad62d87e68dcbccf31c0b8ba211b6647922b8595c7aec2c783648f12c67da53e0766b71c7d7c923fc SHA512 d9aa2aa7f9414db8f4e51d6c275694b46df515e68331a1a2b6018256333a2c63ebd877b75ee90407ecce5be672ec9afc6bebd62aadbf8ae06b94f1760d1736be
 DIST ghc-8.2.2-src.tar.xz 10753272 BLAKE2B 6fd792390d3df20f84836466705c3f3c931ba2d594dcbe2b808ea0ae284460000b443df8aae74903eabf05ff9064d68a303086cf888ea68222eb1c60959c8f21 SHA512 6549416f470b599973d409fa45f59c25b07e6a94798cef1a19ad432547dc225338cf4dbc4a4793114b4a417798a3b59b122b92b020251074405c5302b7ffe799
 DIST ghc-8.4.1-src.tar.xz 11301528 BLAKE2B 6dcf467d04cace856b68315c85b80f19b517dcbc8ae6e2a08c60afa141c9e0261e012738452c9ca208f9fc40c48bd1a0817e5e0fe9f4737383cd7b44ca65c8d9 SHA512 f8ae11f498bf2911fb92635534c6906c96f1fbe5072c7b7447bd3f69e408026b674564515af02a8aaddc57ee6905ce78d10005b12478a39c220580aaec13a9f7

diff --git a/dev-lang/ghc/files/ghc-8.10.1-allow-cross-bootstrap.patch b/dev-lang/ghc/files/ghc-8.10.1-allow-cross-bootstrap.patch
new file mode 100644
index 00000000000..7495cc8bff8
--- /dev/null
+++ b/dev-lang/ghc/files/ghc-8.10.1-allow-cross-bootstrap.patch
@@ -0,0 +1,17 @@
+Allow using cross-compilers to bootstrap GHC.
+
+In my case I'm using "cross"-compiler from
+x86_64-unknown-linux to x86_64-HEAD-linux.
+
+Those targets have the same ABI and can boot one another.
+--- a/configure.ac
++++ b/configure.ac
+@@ -219,7 +219,7 @@ then
+     echo "This GHC (${WithGhc}) does not generate code for the build platform"
+     echo "   GHC target platform    : $bootstrap_target"
+     echo "   Desired build platform : $BuildPlatform"
+-    exit 1
++    #exit 1
+ fi
+ 
+ # Testing if we shall enable shared libs support on Solaris.

diff --git a/dev-lang/ghc/files/ghc-8.10.1-no-relax-everywhere.patch b/dev-lang/ghc/files/ghc-8.10.1-no-relax-everywhere.patch
new file mode 100644
index 00000000000..19c8b4bccc4
--- /dev/null
+++ b/dev-lang/ghc/files/ghc-8.10.1-no-relax-everywhere.patch
@@ -0,0 +1,19 @@
+https://github.com/gentoo-haskell/gentoo-haskell/issues/704
+
+Allow users to specify -W,--relax externally and pass
+-Wl,-no-relax unconditonally on all arches.
+
+Reported-by: wmyrda
+--- a/compiler/main/DriverPipeline.hs
++++ b/compiler/main/DriverPipeline.hs
+@@ -2144,9 +2144,7 @@ joinObjectFiles dflags o_files output_fn = do
+                         -- gcc on sparc sets -Wl,--relax implicitly, but
+                         -- -r and --relax are incompatible for ld, so
+                         -- disable --relax explicitly.
+-                     ++ (if platformArch (targetPlatform dflags)
+-                                `elem` [ArchSPARC, ArchSPARC64]
+-                         && ldIsGnuLd
++                     ++ (if ldIsGnuLd
+                             then [SysTools.Option "-Wl,-no-relax"]
+                             else [])
+                         -- See Note [Produce big objects on Windows]

diff --git a/dev-lang/ghc/ghc-8.10.1.ebuild b/dev-lang/ghc/ghc-8.10.1.ebuild
new file mode 100644
index 00000000000..c1bb998ba2c
--- /dev/null
+++ b/dev-lang/ghc/ghc-8.10.1.ebuild
@@ -0,0 +1,794 @@
+# Copyright 1999-2020 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+# to make make a crosscompiler use crossdev and symlink ghc tree into
+# cross overlay. result would look like 'cross-sparc-unknown-linux-gnu/ghc'
+export CBUILD=${CBUILD:-${CHOST}}
+export CTARGET=${CTARGET:-${CHOST}}
+if [[ ${CTARGET} = ${CHOST} ]] ; then
+	if [[ ${CATEGORY/cross-} != ${CATEGORY} ]] ; then
+		export CTARGET=${CATEGORY/cross-}
+	fi
+fi
+
+inherit autotools bash-completion-r1 eutils flag-o-matic ghc-package
+inherit multilib multiprocessing pax-utils toolchain-funcs prefix
+inherit check-reqs
+DESCRIPTION="The Glasgow Haskell Compiler"
+HOMEPAGE="https://www.haskell.org/ghc/"
+
+# we don't have any binaries yet
+arch_binaries=""
+
+BIN_PV=${PV}
+# sorted!
+#arch_binaries="$arch_binaries alpha? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-alpha.tbz2 )"
+#arch_binaries="$arch_binaries arm? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-armv7a-hardfloat-linux-gnueabi.tbz2 )"
+#arch_binaries="$arch_binaries arm64? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-aarch64-unknown-linux-gnu.tbz2 )"
+#arch_binaries="$arch_binaries amd64? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-x86_64-pc-linux-gnu.tbz2 )"
+#arch_binaries="$arch_binaries ia64?  ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-ia64-fixed-fiw.tbz2 )"
+#arch_binaries="$arch_binaries ppc? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-ppc.tbz2 )"
+#arch_binaries="$arch_binaries ppc64? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-ppc64.tbz2 )"
+#arch_binaries="$arch_binaries ppc64? ( !big-endian? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-powerpc64le-unknown-linux-gnu.tbz2 ) )"
+#arch_binaries="$arch_binaries sparc? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-sparc.tbz2 )"
+#arch_binaries="$arch_binaries x86? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-i686-pc-linux-gnu.tbz2 )"
+
+# various ports:
+#arch_binaries="$arch_binaries x86-fbsd? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-x86-fbsd.tbz2 )"
+
+# 0 - yet
+yet_binary() {
+	case "${ARCH}" in
+		#alpha) return 0 ;;
+		#arm64) return 0 ;;
+		#arm) return 0 ;;
+		#amd64) return 0 ;;
+		#ia64) return 0 ;;
+		#ppc) return 0 ;;
+		#ppc64)
+		#	use big-endian && return 0
+		#	return 0
+		#	;;
+		#sparc) return 0 ;;
+		#x86) return 0 ;;
+		*) return 1 ;;
+	esac
+}
+
+GHC_PV=${PV}
+#GHC_PV=8.10.0.20200123 # uncomment only for -alpha, -beta, -rc ebuilds
+GHC_P=${PN}-${GHC_PV} # using ${P} is almost never correct
+
+SRC_URI="!binary? (
+	https://downloads.haskell.org/ghc/${PV/_/-}/${GHC_P}-src.tar.xz
+	test? ( https://downloads.haskell.org/ghc/${PV/_/-}/${GHC_P}-testsuite.tar.xz )
+)"
+S="${WORKDIR}"/${GHC_P}
+
+[[ -n $arch_binaries ]] && SRC_URI+=" !ghcbootstrap? ( $arch_binaries )"
+
+BUMP_LIBRARIES=(
+	# "hackage-name          hackage-version"
+)
+
+LICENSE="BSD"
+SLOT="0/${PV}"
+KEYWORDS=""
+IUSE="big-endian doc elfutils ghcbootstrap ghcmakebinary +gmp numa profile test"
+IUSE+=" binary"
+RESTRICT="!test? ( test )"
+
+RDEPEND="
+	>=dev-lang/perl-5.6.1
+	dev-libs/gmp:0=
+	sys-libs/ncurses:0=[unicode]
+	elfutils? ( dev-libs/elfutils )
+	!ghcmakebinary? ( virtual/libffi:= )
+	numa? ( sys-process/numactl )
+"
+
+# This set of dependencies is needed to run
+# prebuilt ghc. We specifically avoid ncurses
+# dependency with:
+#    utils/ghc-pkg_HC_OPTS += -DBOOTSTRAPPING
+PREBUILT_BINARY_DEPENDS="
+	!prefix? ( elibc_glibc? ( >=sys-libs/glibc-2.17 ) )
+"
+# This set of dependencies is needed to install
+# ghc[binary] in system. terminfo package is linked
+# against ncurses.
+PREBUILT_BINARY_RDEPENDS="${PREBUILT_BINARY_DEPENDS}
+	sys-libs/ncurses:0/6
+"
+
+RDEPEND+="binary? ( ${PREBUILT_BINARY_RDEPENDS} )"
+
+DEPEND="${RDEPEND}
+	doc? ( app-text/docbook-xml-dtd:4.2
+		app-text/docbook-xml-dtd:4.5
+		app-text/docbook-xsl-stylesheets
+		dev-python/sphinx
+		>=dev-libs/libxslt-1.1.2 )
+	!ghcbootstrap? ( ${PREBUILT_BINARY_DEPENDS} )"
+
+REQUIRED_USE="?? ( ghcbootstrap binary )"
+
+# haskell libraries built with cabal in configure mode, #515354
+QA_CONFIGURE_OPTIONS+=" --with-compiler --with-gcc"
+
+is_crosscompile() {
+	[[ ${CHOST} != ${CTARGET} ]]
+}
+
+is_native() {
+	[[ ${CHOST} == ${CBUILD} ]] && [[ ${CHOST} == ${CTARGET} ]]
+}
+
+if ! is_crosscompile; then
+	PDEPEND="!ghcbootstrap? ( >=app-admin/haskell-updater-1.2 )"
+fi
+
+# returns tool prefix for crosscompiler.
+# Example:
+#  CTARGET=armv7a-unknown-linux-gnueabi
+#  CHOST=x86_64-pc-linux-gnu
+#    "armv7a-unknown-linux-gnueabi-"
+#  CTARGET=${CHOST}
+#    ""
+# Used in tools and library prefix:
+#    "${ED}"/usr/bin/$(cross)haddock
+#    "${ED}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d"
+
+cross() {
+	if is_crosscompile; then
+		echo "${CTARGET}-"
+	else
+		echo ""
+	fi
+}
+
+append-ghc-cflags() {
+	local persistent compile assemble link
+	local flag ghcflag
+
+	for flag in $*; do
+		case ${flag} in
+			persistent)	persistent="yes";;
+			compile)	compile="yes";;
+			assemble)	assemble="yes";;
+			link)		link="yes";;
+			*)
+				[[ ${compile}  ]] && ghcflag="-optc${flag}"  CFLAGS+=" ${flag}" && GHC_FLAGS+=" ${ghcflag}" &&
+					[[ ${persistent} ]] && GHC_PERSISTENT_FLAGS+=" ${ghcflag}"
+				[[ ${assemble} ]] && ghcflag="-opta${flag}"  CFLAGS+=" ${flag}" && GHC_FLAGS+=" ${ghcflag}" &&
+					[[ ${persistent} ]] && GHC_PERSISTENT_FLAGS+=" ${ghcflag}"
+				[[ ${link}     ]] && ghcflag="-optl${flag}" LDFLAGS+=" ${flag}" && GHC_FLAGS+=" ${ghcflag}" &&
+					[[ ${persistent} ]] && GHC_PERSISTENT_FLAGS+=" ${ghcflag}"
+				;;
+		esac
+	done
+}
+
+# $1 - lib name (under libraries/)
+# $2 - lib version
+# example: bump_lib "transformers" "0.4.2.0"
+bump_lib() {
+	local pn=$1 pv=$2
+	local p=${pn}-${pv}
+	local f
+
+	einfo "Bumping ${pn} up to ${pv}"
+
+	for f in ghc.mk GNUmakefile; do
+		mv libraries/"${pn}"/$f "${WORKDIR}"/"${p}"/$f || die
+	done
+	mv libraries/"${pn}" "${WORKDIR}"/"${pn}".old || die
+	mv "${WORKDIR}"/"${p}" libraries/"${pn}" || die
+}
+
+update_SRC_URI() {
+	local p pn pv
+	for p in "${BUMP_LIBRARIES[@]}"; do
+		set -- $p
+		pn=$1 pv=$2
+
+		SRC_URI+=" https://hackage.haskell.org/package/${pn}-${pv}/${pn}-${pv}.tar.gz"
+	done
+}
+
+update_SRC_URI
+
+bump_libs() {
+	local p pn pv
+	for p in "${BUMP_LIBRARIES[@]}"; do
+		set -- $p
+		pn=$1 pv=$2
+
+		bump_lib "${pn}" "${pv}"
+	done
+}
+
+ghc_setup_cflags() {
+	# TODO: plumb CFLAGS and BUILD_CFLAGS to respective CONF_CC_OPTS_STAGE<N>
+	if ! is_native; then
+		export CFLAGS=${GHC_CFLAGS-"-O2 -pipe"}
+		export LDFLAGS=${GHC_LDFLAGS-"-Wl,-O1"}
+		einfo "Crosscompiling mode:"
+		einfo "   CHOST:   ${CHOST}"
+		einfo "   CTARGET: ${CTARGET}"
+		einfo "   CFLAGS:  ${CFLAGS}"
+		einfo "   LDFLAGS: ${LDFLAGS}"
+		einfo "   prefix: $(cross)"
+		return
+	fi
+	# We need to be very careful with the CFLAGS we ask ghc to pass through to
+	# gcc. There are plenty of flags which will make gcc produce output that
+	# breaks ghc in various ways. The main ones we want to pass through are
+	# -mcpu / -march flags. These are important for arches like alpha & sparc.
+	# We also use these CFLAGS for building the C parts of ghc, ie the rts.
+	strip-flags
+	strip-unsupported-flags
+
+	# Cmm can't parse line numbers #482086
+	replace-flags -ggdb[3-9] -ggdb2
+
+	GHC_FLAGS=""
+	GHC_PERSISTENT_FLAGS=""
+	for flag in ${CFLAGS}; do
+		case ${flag} in
+
+			# Ignore extra optimisation (ghc passes -O to gcc anyway)
+			# -O2 and above break on too many systems
+			-O*) ;;
+
+			# Arch and ABI flags are what we're really after
+			-m*) append-ghc-cflags compile assemble ${flag};;
+
+			# Sometimes it's handy to see backtrace of RTS
+			# to get an idea what happens there
+			-g*) append-ghc-cflags compile ${flag};;
+
+			# Ignore all other flags, including all -f* flags
+		esac
+	done
+
+	for flag in ${LDFLAGS}; do
+		append-ghc-cflags link ${flag}
+	done
+
+	# GHC uses ${CBUILD}-gcc, ${CHOST}-gcc and ${CTARGET}-gcc at a single build.
+	# Skip any gentoo-specific tweaks for cross-case to avoid passing unsupported
+	# options to gcc.
+	if is_native; then
+		# prevent from failing to build unregisterised ghc:
+		# https://www.mail-archive.com/debian-bugs-dist@lists.debian.org/msg171602.html
+		use ppc64 && append-ghc-cflags persistent compile -mminimal-toc
+	fi
+}
+
+# substitutes string $1 to $2 in files $3 $4 ...
+relocate_path() {
+	local from=$1
+	local   to=$2
+	shift 2
+	local file=
+	for file in "$@"
+	do
+		sed -i -e "s|$from|$to|g" \
+			"$file" || die "path relocation failed for '$file'"
+	done
+}
+
+# changes hardcoded ghc paths and updates package index
+# $1 - new absolute root path
+relocate_ghc() {
+	local to=$1 ghc_v=${BIN_PV}
+
+	# libdir for prebuilt binary and for current system may mismatch
+	# It does for prefix installation for example: bug #476998
+	local bin_ghc_prefix=${WORKDIR}/usr
+	local bin_libpath=$(echo "${bin_ghc_prefix}"/lib*)
+	local bin_libdir=${bin_libpath#${bin_ghc_prefix}/}
+
+	# backup original script to use it later after relocation
+	local gp_back="${T}/ghc-pkg-${ghc_v}-orig"
+	cp "${WORKDIR}/usr/bin/ghc-pkg-${ghc_v}" "$gp_back" || die "unable to backup ghc-pkg wrapper"
+
+	if [[ ${bin_libdir} != $(get_libdir) ]]; then
+		einfo "Relocating '${bin_libdir}' to '$(get_libdir)' (bug #476998)"
+		# moving the dir itself is not strictly needed
+		# but then USE=binary would result in installing
+		# in '${bin_libdir}'
+		mv "${bin_ghc_prefix}/${bin_libdir}" "${bin_ghc_prefix}/$(get_libdir)" || die
+
+		relocate_path "/usr/${bin_libdir}" "/usr/$(get_libdir)" \
+			"${WORKDIR}/usr/bin/ghc-${ghc_v}" \
+			"${WORKDIR}/usr/bin/ghci-${ghc_v}" \
+			"${WORKDIR}/usr/bin/ghc-pkg-${ghc_v}" \
+			"${WORKDIR}/usr/bin/hsc2hs" \
+			"${WORKDIR}/usr/bin/runghc-${ghc_v}" \
+			"$gp_back" \
+			"${WORKDIR}/usr/$(get_libdir)/${PN}-${ghc_v}/package.conf.d/"*
+	fi
+
+	# Relocate from /usr to ${EPREFIX}/usr
+	relocate_path "/usr" "${to}/usr" \
+		"${WORKDIR}/usr/bin/ghc-${ghc_v}" \
+		"${WORKDIR}/usr/bin/ghci-${ghc_v}" \
+		"${WORKDIR}/usr/bin/ghc-pkg-${ghc_v}" \
+		"${WORKDIR}/usr/bin/haddock-ghc-${ghc_v}" \
+		"${WORKDIR}/usr/bin/hp2ps" \
+		"${WORKDIR}/usr/bin/hpc" \
+		"${WORKDIR}/usr/bin/hsc2hs" \
+		"${WORKDIR}/usr/bin/runghc-${ghc_v}" \
+		"${WORKDIR}/usr/$(get_libdir)/${PN}-${ghc_v}/package.conf.d/"*
+
+	# this one we will use to regenerate cache
+	# so it should point to current tree location
+	relocate_path "/usr" "${WORKDIR}/usr" "$gp_back"
+
+	if use prefix; then
+		hprefixify "${bin_libpath}"/${PN}*/settings
+	fi
+
+	# regenerate the binary package cache
+	"$gp_back" recache || die "failed to update cache after relocation"
+	rm "$gp_back"
+}
+
+ghc-check-reqs() {
+	# These are pessimistic values (slightly bigger than worst-case)
+	# Worst case is UNREG USE=profile ia64. See bug #611866 for some
+	# numbers on various arches.
+	CHECKREQS_DISK_BUILD=8G
+	CHECKREQS_DISK_USR=2G
+	# USE=binary roughly takes
+	use binary && CHECKREQS_DISK_BUILD=4G
+
+	"$@"
+}
+
+pkg_pretend() {
+	ghc-check-reqs check-reqs_pkg_pretend
+}
+
+pkg_setup() {
+	ghc-check-reqs check-reqs_pkg_setup
+
+	# quiet portage about prebuilt binaries
+	use binary && QA_PREBUILT="*"
+
+	[[ ${MERGE_TYPE} == binary ]] && return
+
+	if use ghcbootstrap; then
+		ewarn "You requested ghc bootstrapping, this is usually only used"
+		ewarn "by Gentoo developers to make binary .tbz2 packages."
+
+		[[ -z $(type -P ghc) ]] && \
+			die "Could not find a ghc to bootstrap with."
+	else
+		if ! yet_binary; then
+			eerror "Please try emerging with USE=ghcbootstrap and report build"
+			eerror "sucess or failure to the haskell team (haskell@gentoo.org)"
+			die "No binary available for '${ARCH}' arch yet, USE=ghcbootstrap"
+		fi
+	fi
+}
+
+src_unpack() {
+	# Create the ${S} dir if we're using the binary version
+	use binary && mkdir "${S}"
+
+	# the Solaris and Darwin binaries from ghc (maeder) need to be
+	# unpacked separately, so prevent them from being unpacked
+	local ONLYA=${A}
+	case ${CHOST} in
+		*-darwin* | *-solaris*)  ONLYA=${GHC_P}-src.tar.xz  ;;
+	esac
+	unpack ${ONLYA}
+}
+
+src_prepare() {
+	ghc_setup_cflags
+
+	if ! use ghcbootstrap && [[ ${CHOST} != *-darwin* && ${CHOST} != *-solaris* ]]; then
+		# Modify the wrapper script from the binary tarball to use GHC_PERSISTENT_FLAGS.
+		# See bug #313635.
+		sed -i -e "s|\"\$topdir\"|\"\$topdir\" ${GHC_PERSISTENT_FLAGS}|" \
+			"${WORKDIR}/usr/bin/ghc-${BIN_PV}"
+
+		# allow hardened users use vanilla binary to bootstrap ghc
+		# ghci uses mmap with rwx protection at it implements dynamic
+		# linking on it's own (bug #299709)
+		pax-mark -m "${WORKDIR}/usr/$(get_libdir)/${PN}-${BIN_PV}/bin/ghc"
+	fi
+
+	if use binary; then
+		if use prefix; then
+			relocate_ghc "${EPREFIX}"
+		fi
+
+		# Move unpacked files to the expected place
+		mv "${WORKDIR}/usr" "${S}"
+		eapply_user
+	else
+		if ! use ghcbootstrap; then
+			case ${CHOST} in
+				*-darwin* | *-solaris*)
+				# UPDATE ME for ghc-7
+				mkdir "${WORKDIR}"/ghc-bin-installer || die
+				pushd "${WORKDIR}"/ghc-bin-installer > /dev/null || die
+				use sparc-solaris && unpack ghc-6.10.4-sparc-sun-solaris2.tar.bz2
+				use x86-solaris && unpack ghc-7.0.3-i386-unknown-solaris2.tar.bz2
+				use x86-macos && unpack ghc-7.4.1-i386-apple-darwin.tar.bz2
+				use x64-macos && unpack ghc-7.4.1-x86_64-apple-darwin.tar.bz2
+				popd > /dev/null
+
+				pushd "${WORKDIR}"/ghc-bin-installer/ghc-[67].?*.? > /dev/null || die
+				# fix the binaries so they run, on Solaris we need an
+				# LD_LIBRARY_PATH which has our prefix libdirs, on
+				# Darwin we need to replace the frameworks with our libs
+				# from the prefix fix before installation, because some
+				# of the tools are actually used during configure/make
+				if [[ ${CHOST} == *-solaris* ]] ; then
+					export LD_LIBRARY_PATH="${EPREFIX}/$(get_libdir):${EPREFIX}/usr/$(get_libdir):${LD_LIBRARY_PATH}"
+				elif [[ ${CHOST} == *-darwin* ]] ; then
+					local readline_framework=GNUreadline.framework/GNUreadline
+					local gmp_framework=/opt/local/lib/libgmp.10.dylib
+					local ncurses_file=/opt/local/lib/libncurses.5.dylib
+					for binary in $(scanmacho -BRE MH_EXECUTE -F '%F' .) ; do
+						install_name_tool -change \
+							${readline_framework} \
+							"${EPREFIX}"/lib/libreadline.dylib \
+							${binary} || die
+						install_name_tool -change \
+							${gmp_framework} \
+							"${EPREFIX}"/usr/lib/libgmp.dylib \
+							${binary} || die
+						install_name_tool -change \
+							${ncurses_file} \
+							"${EPREFIX}"/usr/lib/libncurses.dylib \
+							${binary} || die
+					done
+					# we don't do frameworks!
+					sed -i \
+						-e 's/\(frameworks = \)\["GMP"\]/\1[]/g' \
+						-e 's/\(extraLibraries = \)\["m"\]/\1["m","gmp"]/g' \
+						rts/package.conf.in || die
+				fi
+
+				# it is autoconf, but we really don't want to give it too
+				# many arguments, in fact we do the make in-place anyway
+				./configure --prefix="${WORKDIR}"/usr || die
+				make install || die
+				popd > /dev/null
+				;;
+				*)
+				relocate_ghc "${WORKDIR}"
+				;;
+			esac
+		fi
+
+		sed -i -e "s|\"\$topdir\"|\"\$topdir\" ${GHC_PERSISTENT_FLAGS}|" \
+			"${S}/ghc/ghc.wrapper"
+
+		cd "${S}" # otherwise eapply will break
+
+		eapply "${FILESDIR}"/${PN}-7.0.4-CHOST-prefix.patch
+		eapply "${FILESDIR}"/${PN}-8.2.1-darwin.patch
+		eapply "${FILESDIR}"/${PN}-7.8.3-prim-lm.patch
+		eapply "${FILESDIR}"/${PN}-8.8.1-revert-CPP.patch
+		eapply "${FILESDIR}"/${PN}-8.10.1-no-relax-everywhere.patch
+		eapply "${FILESDIR}"/${PN}-8.10.1-allow-cross-bootstrap.patch
+
+		# a bunch of crosscompiler patches
+		# needs newer version:
+		#eapply "${FILESDIR}"/${PN}-8.2.1_rc1-hp2ps-cross.patch
+
+		# mingw32 target
+		pushd "${S}/libraries/Win32"
+			eapply "${FILESDIR}"/${PN}-8.2.1_rc1-win32-cross-2-hack.patch # bad workaround
+		popd
+
+		bump_libs
+
+		eapply_user
+		# as we have changed the build system
+		eautoreconf
+	fi
+}
+
+src_configure() {
+	if ! use binary; then
+		# initialize build.mk
+		echo '# Gentoo changes' > mk/build.mk
+
+		# Put docs into the right place, ie /usr/share/doc/ghc-${GHC_PV}
+		echo "docdir = ${EPREFIX}/usr/share/doc/$(cross)${P}" >> mk/build.mk
+		echo "htmldir = ${EPREFIX}/usr/share/doc/$(cross)${P}" >> mk/build.mk
+
+		# We also need to use the GHC_FLAGS flags when building ghc itself
+		echo "SRC_HC_OPTS+=${HCFLAGS} ${GHC_FLAGS}" >> mk/build.mk
+		echo "SRC_CC_OPTS+=${CFLAGS}" >> mk/build.mk
+		echo "SRC_LD_OPTS+=${LDFLAGS}" >> mk/build.mk
+		# Speed up initial Cabal bootstrap
+		echo "utils/ghc-cabal_dist_EXTRA_HC_OPTS+=$(ghc-make-args)" >> mk/build.mk
+
+		# We can't depend on haddock except when bootstrapping when we
+		# must build docs and include them into the binary .tbz2 package
+		# app-text/dblatex is not in portage, can not build PDF or PS
+		echo "BUILD_SPHINX_PDF  = NO"  >> mk/build.mk
+		echo "BUILD_SPHINX_HTML = $(usex doc YES NO)" >> mk/build.mk
+		echo "BUILD_MAN = $(usex doc YES NO)" >> mk/build.mk
+
+		# this controls presence on 'xhtml' and 'haddock' in final install
+		echo "HADDOCK_DOCS       = YES" >> mk/build.mk
+
+		# not used outside of ghc's test
+		if [[ -n ${GHC_BUILD_DPH} ]]; then
+				echo "BUILD_DPH = YES" >> mk/build.mk
+			else
+				echo "BUILD_DPH = NO" >> mk/build.mk
+		fi
+
+		# Any non-native build has to skip as it needs
+		# target haddock binary to be runnabine.
+		if ! is_native; then
+			# disable docs generation as it requires running stage2
+			echo "HADDOCK_DOCS=NO" >> mk/build.mk
+			echo "BUILD_SPHINX_HTML=NO" >> mk/build.mk
+			echo "BUILD_SPHINX_PDF=NO" >> mk/build.mk
+		fi
+
+		if is_crosscompile; then
+			# Install ghc-stage1 crosscompiler instead of
+			# ghc-stage2 cross-built compiler.
+			echo "Stage1Only=YES" >> mk/build.mk
+		fi
+
+		# allows overriding build flavours for libraries:
+		# v   - vanilla (static libs)
+		# p   - profiled
+		# dyn - shared libraries
+		# example: GHC_LIBRARY_WAYS="v dyn"
+		if [[ -n ${GHC_LIBRARY_WAYS} ]]; then
+			echo "GhcLibWays=${GHC_LIBRARY_WAYS}" >> mk/build.mk
+		fi
+		echo "BUILD_PROF_LIBS = $(usex profile YES NO)" >> mk/build.mk
+
+		# Get ghc from the unpacked binary .tbz2
+		# except when bootstrapping we just pick ghc up off the path
+		if ! use ghcbootstrap; then
+			export PATH="${WORKDIR}/usr/bin:${PATH}"
+		fi
+
+		echo "INTEGER_LIBRARY = $(usex gmp integer-gmp integer-simple)" >> mk/build.mk
+
+		# don't strip anything. Very useful when stage2 SIGSEGVs on you
+		echo "STRIP_CMD = :" >> mk/build.mk
+
+		local econf_args=()
+
+		# GHC embeds toolchain it was built by and uses it later.
+		# Don't allow things like ccache or versioned binary slip.
+		# We use stable thing across gcc upgrades.
+		# User can use EXTRA_ECONF=CC=... to override this default.
+		econf_args+=(
+			AR=${CTARGET}-ar
+			CC=${CTARGET}-gcc
+			# these should be inferred by GHC but ghc defaults
+			# to using bundled tools on windows.
+			Windres=${CTARGET}-windres
+			DllWrap=${CTARGET}-dllwrap
+			# we set the linker explicitly below
+			--disable-ld-override
+		)
+		case ${CTARGET} in
+			arm*)
+				# ld.bfd-2.28 does not work for ghc. Force ld.gold
+				# instead. This should be removed once gentoo gets
+				# a fix for R_ARM_COPY bug: https://sourceware.org/PR16177
+				econf_args+=(LD=${CTARGET}-ld.gold)
+			;;
+			sparc*)
+				# ld.gold-2.28 does not work for ghc. Force ld.bfd
+				# instead. This should be removed once gentoo gets
+				# a fix for missing --no-relax support bug:
+				# https://sourceware.org/ml/binutils/2017-07/msg00183.html
+				econf_args+=(LD=${CTARGET}-ld.bfd)
+			;;
+			*)
+				econf_args+=(LD=${CTARGET}-ld)
+		esac
+
+		if [[ ${CBUILD} != ${CHOST} ]]; then
+			# GHC bug: ghc claims not to support cross-building.
+			# It does, but does not distinct --host= value
+			# for stage1 and stage2 compiler.
+			econf_args+=(--host=${CBUILD})
+		fi
+
+		if use ghcmakebinary; then
+			# When building booting libary we are trying to
+			# bundle or restrict most of external depends
+			# with unstable ABI:
+			#  - embed libffi (default GHC behaviour)
+			#  - disable ncurses support for ghci (via haskeline)
+			#    https://bugs.gentoo.org/557478
+			#  - disable ncurses support for ghc-pkg
+			echo "libraries/haskeline_CONFIGURE_OPTS += --flag=-terminfo" >> mk/build.mk
+			echo "utils/ghc-pkg_HC_OPTS += -DBOOTSTRAPPING" >> mk/build.mk
+		elif is_native; then
+			# using ${GTARGET}'s libffi is not supported yet:
+			# GHC embeds full path for ffi includes without /usr/${CTARGET} account.
+			econf_args+=(--with-system-libffi)
+			econf_args+=(--with-ffi-includes=$(pkg-config libffi --cflags-only-I | sed -e 's@^-I@@'))
+		fi
+
+		einfo "Final mk/build.mk:"
+		cat mk/build.mk || die
+
+		econf ${econf_args[@]} \
+			--enable-bootstrap-with-devel-snapshot \
+			$(use_enable elfutils dwarf-unwind) \
+			$(use_enable numa)
+
+		if [[ ${PV} == *9999* ]]; then
+			GHC_PV="$(grep 'S\[\"PACKAGE_VERSION\"\]' config.status | sed -e 's@^.*=\"\(.*\)\"@\1@')"
+			GHC_P=${PN}-${GHC_PV}
+		fi
+	fi # ! use binary
+}
+
+src_compile() {
+	if ! use binary; then
+		# Stage1Only crosscompiler does not build stage2
+		if ! is_crosscompile; then
+			# 1. build/pax-mark compiler binary first
+			emake ghc/stage2/build/tmp/ghc-stage2
+			# 2. pax-mark (bug #516430)
+			pax-mark -m ghc/stage2/build/tmp/ghc-stage2
+			# 2. build/pax-mark haddock using ghc-stage2
+			if is_native; then
+				# non-native build does not build haddock
+				# due to HADDOCK_DOCS=NO, but it could.
+				emake utils/haddock/dist/build/tmp/haddock
+				pax-mark -m utils/haddock/dist/build/tmp/haddock
+			fi
+		fi
+		# 3. and then all the rest
+		emake all
+	fi # ! use binary
+}
+
+src_test() {
+	# TODO: deal with:
+	#    - sandbox (pollutes environment)
+	#    - extra packages (to extend testsuite coverage)
+	# bits are taken from 'validate'
+	local make_test_target='test' # can be fulltest
+	# not 'emake' as testsuite uses '$MAKE' without jobserver available
+	make $make_test_target stage=2 THREADS=$(makeopts_jobs)
+}
+
+src_install() {
+	if use binary; then
+		use prefix && mkdir -p "${ED}"
+		mv "${S}/usr" "${ED}"
+	else
+		[[ -f VERSION ]] || emake VERSION
+
+		# -j1 due to a rare race in install script:
+		#    make --no-print-directory -f ghc.mk phase=final install
+		#    /usr/lib/portage/python3.4/ebuild-helpers/xattr/install -c -m 755 \
+		#        -d "/tmp/portage-tmpdir/portage/cross-armv7a-unknown-linux-gnueabi/ghc-9999/image/usr/lib64/armv7a-unknown-linux-gnueabi-ghc-8.3.20170404/include"
+		#    /usr/lib/portage/python3.4/ebuild-helpers/xattr/install -c -m 644  utils/hsc2hs/template-hsc.h \
+		#           "/tmp/portage-tmpdir/portage/cross-armv7a-unknown-linux-gnueabi/ghc-9999/image/usr/lib64/armv7a-unknown-linux-gnueabi-ghc-8.3.20170404"
+		#    /usr/bin/install: cannot create regular file \
+		#           '/tmp/portage-tmpdir/portage/cross-armv7a-unknown-linux-gnueabi/ghc-9999/image/usr/lib64/armv7a-unknown-linux-gnueabi-ghc-8.3.20170404': No such file or directory
+		emake -j1 install DESTDIR="${D}"
+
+		# Skip for cross-targets as they all share target location:
+		# /usr/share/doc/ghc-9999/
+		if ! is_crosscompile; then
+			dodoc "distrib/README" "LICENSE" "VERSION"
+		fi
+
+		# rename ghc-shipped files to avoid collision
+		# of external packages. Motivating example:
+		#  user had installed:
+		#      dev-lang/ghc-7.8.4-r0 (with transformers-0.3.0.0)
+		#      dev-haskell/transformers-0.4.2.0
+		#  then user tried to update to
+		#      dev-lang/ghc-7.8.4-r1 (with transformers-0.4.2.0)
+		#  this will lead to single .conf file collision.
+		local shipped_conf renamed_conf
+		local package_confdir="${ED}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d"
+		for shipped_conf in "${package_confdir}"/*.conf; do
+			# rename 'pkg-ver-id.conf' to 'pkg-ver-id-gentoo-${PF}.conf'
+			renamed_conf=${shipped_conf%.conf}-gentoo-${PF}.conf
+			mv "${shipped_conf}" "${renamed_conf}" || die
+		done
+
+		# remove link, but leave 'haddock-${GHC_P}'
+		rm -f "${ED}"/usr/bin/$(cross)haddock
+
+		if ! is_crosscompile; then
+			newbashcomp "${FILESDIR}"/ghc-bash-completion ghc-pkg
+			newbashcomp utils/completion/ghc.bash         ghc
+		fi
+	fi
+
+	# path to the package.cache
+	local package_confdir="${ED}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d"
+	PKGCACHE="${package_confdir}"/package.cache
+	# copy the package.conf.d, including timestamp, save it so we can help
+	# users that have a broken package.conf.d
+	cp -pR "${package_confdir}"{,.initial} || die "failed to backup intial package.conf.d"
+
+	# copy the package.conf, including timestamp, save it so we later can put it
+	# back before uninstalling, or when upgrading.
+	cp -p "${PKGCACHE}"{,.shipped} \
+		|| die "failed to copy package.conf.d/package.cache"
+
+	if is_crosscompile; then
+		# When we build a cross-compiler the layout is the following:
+		#     usr/lib/${CTARGET}-ghc-${VER}/ contains target libraries
+		# but
+		#     usr/lib/${CTARGET}-ghc-${VER}/bin/ directory
+		# containst host binaries (modulo bugs).
+
+		# Portage's stripping mechanism does not skip stripping
+		# foreign binaries. This frequently causes binaries to be
+		# broken.
+		#
+		# Thus below we disable stripping of target libraries and allow
+		# stripping hosts executables.
+		dostrip -x "/usr/$(get_libdir)/$(cross)${GHC_P}"
+		dostrip    "/usr/$(get_libdir)/$(cross)${GHC_P}/bin"
+	fi
+}
+
+pkg_preinst() {
+	# have we got an earlier version of ghc installed?
+	if has_version "<${CATEGORY}/${PF}"; then
+		haskell_updater_warn="1"
+	fi
+}
+
+pkg_postinst() {
+	ghc-reregister
+
+	# path to the package.cache
+	PKGCACHE="${EROOT}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d/package.cache"
+
+	# give the cache a new timestamp, it must be as recent as
+	# the package.conf.d directory.
+	touch "${PKGCACHE}"
+
+	if [[ "${haskell_updater_warn}" == "1" ]]; then
+		ewarn
+		ewarn "\e[1;31m************************************************************************\e[0m"
+		ewarn
+		ewarn "You have just upgraded from an older version of GHC."
+		ewarn "You may have to run"
+		ewarn "      'haskell-updater'"
+		ewarn "to rebuild all ghc-based Haskell libraries."
+		ewarn
+		ewarn "\e[1;31m************************************************************************\e[0m"
+		ewarn
+	fi
+}
+
+pkg_prerm() {
+	PKGCACHE="${EROOT}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d/package.cache"
+	rm -rf "${PKGCACHE}"
+
+	cp -p "${PKGCACHE}"{.shipped,}
+}
+
+pkg_postrm() {
+	ghc-package_pkg_postrm
+}


^ permalink raw reply related	[flat|nested] 15+ messages in thread
* [gentoo-commits] repo/gentoo:master commit in: dev-lang/ghc/, dev-lang/ghc/files/
@ 2019-10-04  6:46 Sergei Trofimovich
  0 siblings, 0 replies; 15+ messages in thread
From: Sergei Trofimovich @ 2019-10-04  6:46 UTC (permalink / raw
  To: gentoo-commits

commit:     8ff3b28cba24e45c81ec63a95695c0b41640da4e
Author:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
AuthorDate: Fri Oct  4 06:46:34 2019 +0000
Commit:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
CommitDate: Fri Oct  4 06:46:45 2019 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=8ff3b28c

dev-lang/ghc: bump up to 8.8.1. no KEYWORDS yet

Package-Manager: Portage-2.3.76, Repoman-2.3.17
Signed-off-by: Sergei Trofimovich <slyfox <AT> gentoo.org>

 dev-lang/ghc/Manifest                         |   4 +
 dev-lang/ghc/files/ghc-8.6.5-numa.patch       |  22 +
 dev-lang/ghc/files/ghc-8.8.1-no-alex.patch    |  33 ++
 dev-lang/ghc/files/ghc-8.8.1-revert-CPP.patch |  52 ++
 dev-lang/ghc/ghc-8.8.1.ebuild                 | 801 ++++++++++++++++++++++++++
 dev-lang/ghc/metadata.xml                     |   3 +
 6 files changed, 915 insertions(+)

diff --git a/dev-lang/ghc/Manifest b/dev-lang/ghc/Manifest
index b0480697f5f..bfde022be70 100644
--- a/dev-lang/ghc/Manifest
+++ b/dev-lang/ghc/Manifest
@@ -12,6 +12,8 @@ DIST ghc-8.6.4-src.tar.xz 19029904 BLAKE2B 80676923866417cbf674c3cfadc2ecf9a673e
 DIST ghc-8.6.4-testsuite.tar.xz 1906656 BLAKE2B b0e55b415c885479c3573fe86436338971e685edc95e106043f36e92e1ee6a7e86add9e86a35c8bd685916f18a7bcf08d4a7b845da41dd855132b131ccbc4a37 SHA512 b1bbe1759ec528914cbfa6b3789c596e46b6266568972b9f5d1cf13e31b7206400b65536e7acea698161e46b8ca11285b3282ebd9336d23b68d34feb4f0bf314
 DIST ghc-8.6.5-src.tar.xz 19092168 BLAKE2B 2ac0926b186c43fd179170a0690492129e9ffb6651608875db7167113becf324dcf99a82f56e578c67051f813007c0ffa32ca5b12588f0d370330c8274a2d74d SHA512 c08a7480200cb99e1ffbe4ce7669f552b1054054966f7e7efcbc5f98af8032e1249fa391c4fc4c7d62cc8e0be5d17fa05845177f3cea3dbcf86e6c92d40fc0f9
 DIST ghc-8.6.5-testsuite.tar.xz 1910060 BLAKE2B 71136207e3eccb4ec6756661ffa64c0a82475704c071cd8f060855a9f40d7d1fc4be2da7ff265df38fb918b8ee2ce21a54ee4b224aacaa3026ad1ddb1e1e4ab2 SHA512 980f3934bb18876cc80b80a0eb64a9ca1dfaa7f4d8b0761f5d733a6583053e38b231445388b992b26ec1ad5f569b6385dbe60f96381794f5577964979c253e16
+DIST ghc-8.8.1-src.tar.xz 28634672 BLAKE2B 3a012db5d9798efddf806542a88cd9fef1d0972f7f025d377c247961cf8d8071fcf390aa130ac11f1a5556fb572499b9288a8698c49bbd594f0bb5fec4130a2f SHA512 7268b012c3a6c34e7eac05c7d6959de6005651d33e870860bbfe589295502e8794a76580130b8f4da2f88032b68116dbbdbc4c1e900e0c862aaa9891fa788bef
+DIST ghc-8.8.1-testsuite.tar.xz 1959220 BLAKE2B 8606a6439f7d5b4c837b2325c4ef5705dbcea17c4b59daf7aafd0de68e55179bb2c03ce7a4f376398b185b6dbfb361d18592756558461ee43722d2142370d815 SHA512 e13b651c60deb86522efbfe8aa42679cc81a413475f70580d9ef28dbb711617c523951441a30fb46f3be9418c4c0bb4dbc522b04aaa51313afd2d39027696c30
 DIST ghc-bin-7.10.3-alpha.tbz2 183558856 BLAKE2B 2bb02aafa49c6a91bec016e8bec2d07257d602e53c9df55792ec6fbbf8e2e46de1d5f3f72c0ccf74d6bd7f7987f53412063ccb02ae85455fce11fa928cbf5291 SHA512 08709fe9b4036ab41715c9a637a2a160104e3ab9e0ed9efaaf73428e3cfe19619e50c42b72c60bbbd27be2b9c2ea68f63d72c1a27d4519756e7c0d909f724230
 DIST ghc-bin-7.10.3-amd64.tbz2 112040431 BLAKE2B 3e59b70ca309a1cd704266c54a7983f9a58362bf700ced89c5649c780c664c650ec091e14026a7b84e339d2ebff39eba1772eebcd9fb4b99b9c99d179453d5cc SHA512 e1554b3944edbe8e16537de5a29132dc6a22d780d9a700cdc9b76387b94191164398d6f2242bf8199527802572e2bb02545569d4f0930a0ee0dbfdeb25978558
 DIST ghc-bin-7.10.3-ia64.tbz2 238680956 BLAKE2B 08593718d376051edfb0c86131e54dafc5c15056757fbeef90c653a7d217e49ff34ffaf7cd4083144c9277e73a290b822a0f889aaf806341375708e4b92654b2 SHA512 3694011aec8a6dc37889418b318993cb82f9b46a5175dd837713f396c8f59a19a920e0b0669fe3b4ec37d5bd8837c115264c0a8fc97c5a4ce06a3bdd52fcfce5
@@ -47,5 +49,7 @@ DIST ghc-bin-8.6.4-i686-pc-linux-gnu.tbz2 121639881 BLAKE2B 51d223b654ff23bbdd59
 DIST ghc-bin-8.6.4-x86_64-pc-linux-gnu.tbz2 121695747 BLAKE2B 39c745f5f9946bbae622e09bbdabdde4d62eec472fe14e693f37cba6b93ff66e4e56f66df8f0f073686339d252dce71f79f4c2aaef620c3dffbc26a67b1119c3 SHA512 c60bac50e7879bda1d6dcc7c1f12fdac915b18c3ebbfcfad575b2b01fcb57a487496ce7935f7ee4ae934162209ab66370fbcc8a4f021628e5f9a2aa7ef95e119
 DIST ghc-bin-8.6.5-i686-pc-linux-gnu.tbz2 121938050 BLAKE2B 17b6d15af21390e28a025505da76d39a2f8656f74c88a81fc75e7c8e799e54171c0d964d8a977c01576603a781c139b5363ea79eeaa2252622913d2a08a79f0e SHA512 9eb33b4670ee15f53c988885a119f3ef7be896ddcb318019628cdd04e21ec0c61876e08466d9d10d6cb1e16d89cd318e0ba42f0f0ae512f48590fe87483739cd
 DIST ghc-bin-8.6.5-x86_64-pc-linux-gnu.tbz2 121728723 BLAKE2B 6620b2a116b5696dd2d776350a43251c093e117338a4407ae8c41ae27763a4614d7e761b2684b90aa9317dafe7cb67481a6bc141c812d335d5231724ae3db2a7 SHA512 69681eab137f6713339f8912d0d92f6af865630053bcd7a32cb8a31e01628e969951db976533196794fe39e0e57f0fcd8778d9fc9fed4f4231e965b9a603dd8e
+DIST ghc-bin-8.8.1-i686-pc-linux-gnu.tbz2 120789855 BLAKE2B 386f37696d956078fad5cad50cbf5b9d9d7765615a1d9cc91a376fb5394648afe8ca956e24ef210f2ff0e51f339b63b16a50f6dc35f30babf019aa57de50b27b SHA512 193c29889693befba863d3c5a26d38d8182bb7e1932b61115dc0a21b6582f818b05db144a9fae5aee06af2044ea59f884825cf1081b62a1c67feb3041d184d3a
+DIST ghc-bin-8.8.1-x86_64-pc-linux-gnu.tbz2 119317594 BLAKE2B 98f0fb262ac485dcfd6a8a67304912ffad2bf2634111fcc3b60346697a836867006bbacaab1e1be0cd5be34b4595d12bec13af644c451c10f7e3843ebaf5922f SHA512 e6acb11755db18fd86a346de642b8579a6b48b303c19795949757f5e351ad3b8892906e989dc57a7fd4471d0efe30fc8175df5bac741d7faecfe42a855a67980
 DIST hoopl-3.10.2.0.tar.gz 241940 BLAKE2B 0ed7bf80486767c81415f99da8780a525401c388dea0b3f380bbecceae9cc7f66d8b5d0d7b31f8cb41796309b7a93adb113485efd14882f8af321989ce900a9b SHA512 083baa8a5eb53247aff8d5b9b2144e0f63adb9400934297bbd80bfcec607dd90a34def4301045a60472ef10b0fb90ab84692fc08f786e7f806c28afdab1ef66a
 DIST transformers-0.4.3.0.tar.gz 28632 BLAKE2B 92cabcb654bb11854a3bffbb1262f5cd62eda1aff447157086a61ebc451ebf2fddec53b6a2cc058174f24f0f0e32df671d3717e30a542c8dc90cb87e327d990c SHA512 c3ec0893ebba4fbd6087c3202e919552c4a9bff3350b5c0589e7ebb18751a515d98b8cac15b0a3252906ea72b5a0eb09b7fe88c8da88b09d6ce4fbf0f50b2780

diff --git a/dev-lang/ghc/files/ghc-8.6.5-numa.patch b/dev-lang/ghc/files/ghc-8.6.5-numa.patch
new file mode 100644
index 00000000000..61c6cfdbfb1
--- /dev/null
+++ b/dev-lang/ghc/files/ghc-8.6.5-numa.patch
@@ -0,0 +1,22 @@
+Disable automagic NUMA linking.
+
+Reported-by: Sergey Alirzaev
+Bug: https://github.com/gentoo-haskell/gentoo-haskell/issues/955
+--- a/configure.ac
++++ b/configure.ac
+@@ -1264,10 +1264,14 @@ dnl ** Have libnuma?
+ dnl --------------------------------------------------------------
+ HaveLibNuma=0
+ AC_CHECK_HEADERS([numa.h numaif.h])
+-
+ if test "$ac_cv_header_numa_h$ac_cv_header_numaif_h" = "yesyes" ; then
+     AC_CHECK_LIB(numa, numa_available,HaveLibNuma=1)
+ fi
++AC_ARG_ENABLE(numa,
++    [AC_HELP_STRING([--enable-numa],
++        [Enable NUMA thread balancing support in the runtime system via numactl's libnuma [default=auto]])])
++AS_IF([test "x$enable_numa" = "xno"], [HaveLibNuma=0])
++
+ AC_DEFINE_UNQUOTED([HAVE_LIBNUMA], [$HaveLibNuma], [Define to 1 if you have libnuma])
+ if test $HaveLibNuma = "1" ; then
+   AC_SUBST([CabalHaveLibNuma],[True])

diff --git a/dev-lang/ghc/files/ghc-8.8.1-no-alex.patch b/dev-lang/ghc/files/ghc-8.8.1-no-alex.patch
new file mode 100644
index 00000000000..39b6eeedd56
--- /dev/null
+++ b/dev-lang/ghc/files/ghc-8.8.1-no-alex.patch
@@ -0,0 +1,33 @@
+https://github.com/gentoo-haskell/gentoo-haskell/issues/959
+
+From 144abba394c6a23eb877fbde727111a5e75b9d47 Mon Sep 17 00:00:00 2001
+From: Ben Gamari <ben@smart-cactus.org>
+Date: Wed, 18 Sep 2019 23:50:20 -0400
+Subject: [PATCH] configure: Don't depend upon alex in source dist build
+
+This fixes #16860 by verifying that the generated sources don't already
+exist before asserting that the `alex` executable was found. This
+replicates the logic already used for `happy` in the case of `alex`.
+---
+ aclocal.m4 | 7 +++++--
+ 1 file changed, 5 insertions(+), 2 deletions(-)
+
+--- a/aclocal.m4
++++ b/aclocal.m4
+@@ -984,8 +984,11 @@ else
+ fi;
+ changequote([, ])dnl
+ ])
+-FP_COMPARE_VERSIONS([$fptools_cv_alex_version],[-lt],[3.1.7],
+-  [AC_MSG_ERROR([Alex version 3.1.7 or later is required to compile GHC.])])[]
++if test ! -f compiler/parser/Lexer.hs
++then
++    FP_COMPARE_VERSIONS([$fptools_cv_alex_version],[-lt],[3.1.7],
++      [AC_MSG_ERROR([Alex version 3.1.7 or later is required to compile GHC.])])[]
++fi
+ AlexVersion=$fptools_cv_alex_version;
+ AC_SUBST(AlexVersion)
+ ])
+-- 
+2.23.0
+

diff --git a/dev-lang/ghc/files/ghc-8.8.1-revert-CPP.patch b/dev-lang/ghc/files/ghc-8.8.1-revert-CPP.patch
new file mode 100644
index 00000000000..8535cf09ef3
--- /dev/null
+++ b/dev-lang/ghc/files/ghc-8.8.1-revert-CPP.patch
@@ -0,0 +1,52 @@
+Don't pass CPP options. Otherwise ghc-8.8.1 can't build itself.
+Eventually ghc will fix it's headers at propagate defines.
+
+https://gitlab.haskell.org/ghc/ghc/commit/cfd3e0f1cfd16c8f35cae139d2a871a32eb4d2e1
+https://gitlab.haskell.org/ghc/ghc/issues/17146
+
+--- a/compiler/main/DriverPipeline.hs
++++ b/compiler/main/DriverPipeline.hs
+@@ -1190,6 +1190,9 @@ runPhase (RealPhase Cmm) input_fn dflags
+ -----------------------------------------------------------------------------
+ -- Cc phase
+ 
++-- we don't support preprocessing .c files (with -E) now.  Doing so introduces
++-- way too many hacks, and I can't say I've ever used it anyway.
++
+ runPhase (RealPhase cc_phase) input_fn dflags
+    | any (cc_phase `eqPhase`) [Cc, Ccxx, HCc, Cobjc, Cobjcxx]
+    = do
+@@ -1211,16 +1214,6 @@ runPhase (RealPhase cc_phase) input_fn dflags
+               (includePathsQuote cmdline_include_paths)
+         let include_paths = include_paths_quote ++ include_paths_global
+ 
+-        -- pass -D or -optP to preprocessor when compiling foreign C files
+-        -- (#16737). Doing it in this way is simpler and also enable the C
+-        -- compiler to performs preprocessing and parsing in a single pass,
+-        -- but it may introduce inconsistency if a different pgm_P is specified.
+-        let more_preprocessor_opts = concat
+-              [ ["-Xpreprocessor", i]
+-              | not hcc
+-              , i <- getOpts dflags opt_P
+-              ]
+-
+         let gcc_extra_viac_flags = extraGccViaCFlags dflags
+         let pic_c_flags = picCCOpts dflags
+ 
+@@ -1230,7 +1223,7 @@ runPhase (RealPhase cc_phase) input_fn dflags
+         -- hc code doesn't not #include any header files anyway, so these
+         -- options aren't necessary.
+         pkg_extra_cc_opts <- liftIO $
+-          if hcc
++          if cc_phase `eqPhase` HCc
+              then return []
+              else getPackageExtraCcOpts dflags pkgs
+ 
+@@ -1312,7 +1305,6 @@ runPhase (RealPhase cc_phase) input_fn dflags
+                        ++ [ "-include", ghcVersionH ]
+                        ++ framework_paths
+                        ++ include_paths
+-                       ++ more_preprocessor_opts
+                        ++ pkg_extra_cc_opts
+                        ))
+ 

diff --git a/dev-lang/ghc/ghc-8.8.1.ebuild b/dev-lang/ghc/ghc-8.8.1.ebuild
new file mode 100644
index 00000000000..107850a9f4a
--- /dev/null
+++ b/dev-lang/ghc/ghc-8.8.1.ebuild
@@ -0,0 +1,801 @@
+# Copyright 1999-2019 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+# to make make a crosscompiler use crossdev and symlink ghc tree into
+# cross overlay. result would look like 'cross-sparc-unknown-linux-gnu/ghc'
+export CBUILD=${CBUILD:-${CHOST}}
+export CTARGET=${CTARGET:-${CHOST}}
+if [[ ${CTARGET} = ${CHOST} ]] ; then
+	if [[ ${CATEGORY/cross-} != ${CATEGORY} ]] ; then
+		export CTARGET=${CATEGORY/cross-}
+	fi
+fi
+
+inherit autotools bash-completion-r1 eutils flag-o-matic ghc-package
+inherit multilib multiprocessing pax-utils toolchain-funcs prefix
+inherit check-reqs
+DESCRIPTION="The Glasgow Haskell Compiler"
+HOMEPAGE="http://www.haskell.org/ghc/"
+
+# we don't have any binaries yet
+arch_binaries=""
+
+BIN_PV=${PV}
+# sorted!
+#arch_binaries="$arch_binaries alpha? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-alpha.tbz2 )"
+#arch_binaries="$arch_binaries arm? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-armv7a-hardfloat-linux-gnueabi.tbz2 )"
+#arch_binaries="$arch_binaries arm64? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-aarch64-unknown-linux-gnu.tbz2 )"
+arch_binaries="$arch_binaries amd64? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-x86_64-pc-linux-gnu.tbz2 )"
+#arch_binaries="$arch_binaries ia64?  ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-ia64-fixed-fiw.tbz2 )"
+#arch_binaries="$arch_binaries ppc? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-ppc.tbz2 )"
+#arch_binaries="$arch_binaries ppc64? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-ppc64.tbz2 )"
+#arch_binaries="$arch_binaries sparc? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-sparc.tbz2 )"
+arch_binaries="$arch_binaries x86? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-i686-pc-linux-gnu.tbz2 )"
+
+# various ports:
+#arch_binaries="$arch_binaries x86-fbsd? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-x86-fbsd.tbz2 )"
+
+# 0 - yet
+yet_binary() {
+	case "${ARCH}" in
+		#alpha) return 0 ;;
+		#arm64) return 0 ;;
+		#arm) return 0 ;;
+		amd64) return 0 ;;
+		#ia64) return 0 ;;
+		#ppc) return 0 ;;
+		#ppc64) return 0 ;;
+		#sparc) return 0 ;;
+		x86) return 0 ;;
+		*) return 1 ;;
+	esac
+}
+
+GHC_PV=${PV}
+#GHC_PV=8.6.0.20180810 # uncomment only for -alpha, -beta, -rc ebuilds
+GHC_P=${PN}-${GHC_PV} # using ${P} is almost never correct
+
+SRC_URI="!binary? (
+	http://downloads.haskell.org/~ghc/${PV/_/-}/${GHC_P}-src.tar.xz
+	test? ( http://downloads.haskell.org/~ghc/${PV/_/-}/${GHC_P}-testsuite.tar.xz )
+)"
+S="${WORKDIR}"/${GHC_P}
+
+[[ -n $arch_binaries ]] && SRC_URI+=" !ghcbootstrap? ( $arch_binaries )"
+
+BUMP_LIBRARIES=(
+	# "hackage-name          hackage-version"
+)
+
+LICENSE="BSD"
+SLOT="0/${PV}"
+KEYWORDS=""
+IUSE="doc elfutils ghcbootstrap ghcmakebinary +gmp numa profile test"
+IUSE+=" binary"
+
+RDEPEND="
+	>=dev-lang/perl-5.6.1
+	dev-libs/gmp:0=
+	sys-libs/ncurses:0=[unicode]
+	elfutils? ( dev-libs/elfutils )
+	!ghcmakebinary? ( virtual/libffi:= )
+	numa? ( sys-process/numactl )
+"
+
+# This set of dependencies is needed to run
+# prebuilt ghc. We specifically avoid ncurses
+# dependency with:
+#    utils/ghc-pkg_HC_OPTS += -DBOOTSTRAPPING
+PREBUILT_BINARY_DEPENDS="
+	!prefix? ( elibc_glibc? ( >=sys-libs/glibc-2.17 ) )
+"
+# This set of dependencies is needed to install
+# ghc[binary] in system. terminfo package is linked
+# against ncurses.
+PREBUILT_BINARY_RDEPENDS="${PREBUILT_BINARY_DEPENDS}
+	sys-libs/ncurses:0/6
+"
+
+RDEPEND+="binary? ( ${PREBUILT_BINARY_RDEPENDS} )"
+
+DEPEND="${RDEPEND}
+	doc? ( app-text/docbook-xml-dtd:4.2
+		app-text/docbook-xml-dtd:4.5
+		app-text/docbook-xsl-stylesheets
+		dev-python/sphinx
+		>=dev-libs/libxslt-1.1.2 )
+	!ghcbootstrap? ( ${PREBUILT_BINARY_DEPENDS} )"
+
+REQUIRED_USE="?? ( ghcbootstrap binary )"
+
+# haskell libraries built with cabal in configure mode, #515354
+QA_CONFIGURE_OPTIONS+=" --with-compiler --with-gcc"
+
+is_crosscompile() {
+	[[ ${CHOST} != ${CTARGET} ]]
+}
+
+is_native() {
+	[[ ${CHOST} == ${CBUILD} ]] && [[ ${CHOST} == ${CTARGET} ]]
+}
+
+if ! is_crosscompile; then
+	PDEPEND="!ghcbootstrap? ( >=app-admin/haskell-updater-1.2 )"
+fi
+
+# returns tool prefix for crosscompiler.
+# Example:
+#  CTARGET=armv7a-unknown-linux-gnueabi
+#  CHOST=x86_64-pc-linux-gnu
+#    "armv7a-unknown-linux-gnueabi-"
+#  CTARGET=${CHOST}
+#    ""
+# Used in tools and library prefix:
+#    "${ED}"/usr/bin/$(cross)haddock
+#    "${ED}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d"
+
+cross() {
+	if is_crosscompile; then
+		echo "${CTARGET}-"
+	else
+		echo ""
+	fi
+}
+
+append-ghc-cflags() {
+	local persistent compile assemble link
+	local flag ghcflag
+
+	for flag in $*; do
+		case ${flag} in
+			persistent)	persistent="yes";;
+			compile)	compile="yes";;
+			assemble)	assemble="yes";;
+			link)		link="yes";;
+			*)
+				[[ ${compile}  ]] && ghcflag="-optc${flag}"  CFLAGS+=" ${flag}" && GHC_FLAGS+=" ${ghcflag}" &&
+					[[ ${persistent} ]] && GHC_PERSISTENT_FLAGS+=" ${ghcflag}"
+				[[ ${assemble} ]] && ghcflag="-opta${flag}"  CFLAGS+=" ${flag}" && GHC_FLAGS+=" ${ghcflag}" &&
+					[[ ${persistent} ]] && GHC_PERSISTENT_FLAGS+=" ${ghcflag}"
+				[[ ${link}     ]] && ghcflag="-optl${flag}" LDFLAGS+=" ${flag}" && GHC_FLAGS+=" ${ghcflag}" &&
+					[[ ${persistent} ]] && GHC_PERSISTENT_FLAGS+=" ${ghcflag}"
+				;;
+		esac
+	done
+}
+
+# $1 - lib name (under libraries/)
+# $2 - lib version
+# example: bump_lib "transformers" "0.4.2.0"
+bump_lib() {
+	local pn=$1 pv=$2
+	local p=${pn}-${pv}
+	local f
+
+	einfo "Bumping ${pn} up to ${pv}"
+
+	for f in ghc.mk GNUmakefile; do
+		mv libraries/"${pn}"/$f "${WORKDIR}"/"${p}"/$f || die
+	done
+	mv libraries/"${pn}" "${WORKDIR}"/"${pn}".old || die
+	mv "${WORKDIR}"/"${p}" libraries/"${pn}" || die
+}
+
+update_SRC_URI() {
+	local p pn pv
+	for p in "${BUMP_LIBRARIES[@]}"; do
+		set -- $p
+		pn=$1 pv=$2
+
+		SRC_URI+=" mirror://hackage/package/${pn}/${pn}-${pv}.tar.gz"
+	done
+}
+
+update_SRC_URI
+
+bump_libs() {
+	local p pn pv
+	for p in "${BUMP_LIBRARIES[@]}"; do
+		set -- $p
+		pn=$1 pv=$2
+
+		bump_lib "${pn}" "${pv}"
+	done
+}
+
+ghc_setup_cflags() {
+	# TODO: plumb CFLAGS and BUILD_CFLAGS to respective CONF_CC_OPTS_STAGE<N>
+	if ! is_native; then
+		export CFLAGS=${GHC_CFLAGS-"-O2 -pipe"}
+		export LDFLAGS=${GHC_LDFLAGS-"-Wl,-O1"}
+		einfo "Crosscompiling mode:"
+		einfo "   CHOST:   ${CHOST}"
+		einfo "   CTARGET: ${CTARGET}"
+		einfo "   CFLAGS:  ${CFLAGS}"
+		einfo "   LDFLAGS: ${LDFLAGS}"
+		einfo "   prefix: $(cross)"
+		return
+	fi
+	# We need to be very careful with the CFLAGS we ask ghc to pass through to
+	# gcc. There are plenty of flags which will make gcc produce output that
+	# breaks ghc in various ways. The main ones we want to pass through are
+	# -mcpu / -march flags. These are important for arches like alpha & sparc.
+	# We also use these CFLAGS for building the C parts of ghc, ie the rts.
+	strip-flags
+	strip-unsupported-flags
+
+	# Cmm can't parse line numbers #482086
+	replace-flags -ggdb[3-9] -ggdb2
+
+	GHC_FLAGS=""
+	GHC_PERSISTENT_FLAGS=""
+	for flag in ${CFLAGS}; do
+		case ${flag} in
+
+			# Ignore extra optimisation (ghc passes -O to gcc anyway)
+			# -O2 and above break on too many systems
+			-O*) ;;
+
+			# Arch and ABI flags are what we're really after
+			-m*) append-ghc-cflags compile assemble ${flag};;
+
+			# Sometimes it's handy to see backtrace of RTS
+			# to get an idea what happens there
+			-g*) append-ghc-cflags compile ${flag};;
+
+			# Ignore all other flags, including all -f* flags
+		esac
+	done
+
+	for flag in ${LDFLAGS}; do
+		append-ghc-cflags link ${flag}
+	done
+
+	# GHC uses ${CBUILD}-gcc, ${CHOST}-gcc and ${CTARGET}-gcc at a single build.
+	# Skip any gentoo-specific tweaks for cross-case to avoid passing unsupported
+	# options to gcc.
+	if is_native; then
+		# hardened-gcc needs to be disabled, because our prebuilt binaries/libraries
+		# are not built with fPIC, bug #606666
+		gcc-specs-pie && append-ghc-cflags persistent compile link -nopie
+		tc-is-gcc && ver_test $(gcc-version) -ge 6.3 && if ! use ghcbootstrap; then
+			# gcc-6.3 has support for -no-pie upstream, but spelling differs from
+			# gentoo-specific '-nopie'. We enable it in non-bootstrap to allow
+			# hardened users try '-pie' in USE=ghcbootstrap mode.
+			append-ghc-cflags compile link -no-pie
+		fi
+
+		# prevent from failing to build unregisterised ghc:
+		# http://www.mail-archive.com/debian-bugs-dist@lists.debian.org/msg171602.html
+		use ppc64 && append-ghc-cflags persistent compile -mminimal-toc
+	fi
+}
+
+# substitutes string $1 to $2 in files $3 $4 ...
+relocate_path() {
+	local from=$1
+	local   to=$2
+	shift 2
+	local file=
+	for file in "$@"
+	do
+		sed -i -e "s|$from|$to|g" \
+			"$file" || die "path relocation failed for '$file'"
+	done
+}
+
+# changes hardcoded ghc paths and updates package index
+# $1 - new absolute root path
+relocate_ghc() {
+	local to=$1 ghc_v=${BIN_PV}
+
+	# libdir for prebuilt binary and for current system may mismatch
+	# It does for prefix installation for example: bug #476998
+	local bin_ghc_prefix=${WORKDIR}/usr
+	local bin_libpath=$(echo "${bin_ghc_prefix}"/lib*)
+	local bin_libdir=${bin_libpath#${bin_ghc_prefix}/}
+
+	# backup original script to use it later after relocation
+	local gp_back="${T}/ghc-pkg-${ghc_v}-orig"
+	cp "${WORKDIR}/usr/bin/ghc-pkg-${ghc_v}" "$gp_back" || die "unable to backup ghc-pkg wrapper"
+
+	if [[ ${bin_libdir} != $(get_libdir) ]]; then
+		einfo "Relocating '${bin_libdir}' to '$(get_libdir)' (bug #476998)"
+		# moving the dir itself is not strictly needed
+		# but then USE=binary would result in installing
+		# in '${bin_libdir}'
+		mv "${bin_ghc_prefix}/${bin_libdir}" "${bin_ghc_prefix}/$(get_libdir)" || die
+
+		relocate_path "/usr/${bin_libdir}" "/usr/$(get_libdir)" \
+			"${WORKDIR}/usr/bin/ghc-${ghc_v}" \
+			"${WORKDIR}/usr/bin/ghci-${ghc_v}" \
+			"${WORKDIR}/usr/bin/ghc-pkg-${ghc_v}" \
+			"${WORKDIR}/usr/bin/hsc2hs" \
+			"${WORKDIR}/usr/bin/runghc-${ghc_v}" \
+			"$gp_back" \
+			"${WORKDIR}/usr/$(get_libdir)/${PN}-${ghc_v}/package.conf.d/"*
+	fi
+
+	# Relocate from /usr to ${EPREFIX}/usr
+	relocate_path "/usr" "${to}/usr" \
+		"${WORKDIR}/usr/bin/ghc-${ghc_v}" \
+		"${WORKDIR}/usr/bin/ghci-${ghc_v}" \
+		"${WORKDIR}/usr/bin/ghc-pkg-${ghc_v}" \
+		"${WORKDIR}/usr/bin/haddock-ghc-${ghc_v}" \
+		"${WORKDIR}/usr/bin/hp2ps" \
+		"${WORKDIR}/usr/bin/hpc" \
+		"${WORKDIR}/usr/bin/hsc2hs" \
+		"${WORKDIR}/usr/bin/runghc-${ghc_v}" \
+		"${WORKDIR}/usr/$(get_libdir)/${PN}-${ghc_v}/package.conf.d/"*
+
+	# this one we will use to regenerate cache
+	# so it should point to current tree location
+	relocate_path "/usr" "${WORKDIR}/usr" "$gp_back"
+
+	if use prefix; then
+		hprefixify "${bin_libpath}"/${PN}*/settings
+	fi
+
+	# regenerate the binary package cache
+	"$gp_back" recache || die "failed to update cache after relocation"
+	rm "$gp_back"
+}
+
+ghc-check-reqs() {
+	# These are pessimistic values (slightly bigger than worst-case)
+	# Worst case is UNREG USE=profile ia64. See bug #611866 for some
+	# numbers on various arches.
+	CHECKREQS_DISK_BUILD=8G
+	CHECKREQS_DISK_USR=2G
+	# USE=binary roughly takes
+	use binary && CHECKREQS_DISK_BUILD=4G
+
+	"$@"
+}
+
+pkg_pretend() {
+	ghc-check-reqs check-reqs_pkg_pretend
+}
+
+pkg_setup() {
+	ghc-check-reqs check-reqs_pkg_setup
+
+	# quiet portage about prebuilt binaries
+	use binary && QA_PREBUILT="*"
+
+	[[ ${MERGE_TYPE} == binary ]] && return
+
+	if use ghcbootstrap; then
+		ewarn "You requested ghc bootstrapping, this is usually only used"
+		ewarn "by Gentoo developers to make binary .tbz2 packages."
+
+		[[ -z $(type -P ghc) ]] && \
+			die "Could not find a ghc to bootstrap with."
+	else
+		if ! yet_binary; then
+			eerror "Please try emerging with USE=ghcbootstrap and report build"
+			eerror "sucess or failure to the haskell team (haskell@gentoo.org)"
+			die "No binary available for '${ARCH}' arch yet, USE=ghcbootstrap"
+		fi
+	fi
+}
+
+src_unpack() {
+	# Create the ${S} dir if we're using the binary version
+	use binary && mkdir "${S}"
+
+	# the Solaris and Darwin binaries from ghc (maeder) need to be
+	# unpacked separately, so prevent them from being unpacked
+	local ONLYA=${A}
+	case ${CHOST} in
+		*-darwin* | *-solaris*)  ONLYA=${GHC_P}-src.tar.xz  ;;
+	esac
+	unpack ${ONLYA}
+}
+
+src_prepare() {
+	ghc_setup_cflags
+
+	if ! use ghcbootstrap && [[ ${CHOST} != *-darwin* && ${CHOST} != *-solaris* ]]; then
+		# Modify the wrapper script from the binary tarball to use GHC_PERSISTENT_FLAGS.
+		# See bug #313635.
+		sed -i -e "s|\"\$topdir\"|\"\$topdir\" ${GHC_PERSISTENT_FLAGS}|" \
+			"${WORKDIR}/usr/bin/ghc-${BIN_PV}"
+
+		# allow hardened users use vanilla binary to bootstrap ghc
+		# ghci uses mmap with rwx protection at it implements dynamic
+		# linking on it's own (bug #299709)
+		pax-mark -m "${WORKDIR}/usr/$(get_libdir)/${PN}-${BIN_PV}/bin/ghc"
+	fi
+
+	if use binary; then
+		if use prefix; then
+			relocate_ghc "${EPREFIX}"
+		fi
+
+		# Move unpacked files to the expected place
+		mv "${WORKDIR}/usr" "${S}"
+		eapply_user
+	else
+		if ! use ghcbootstrap; then
+			case ${CHOST} in
+				*-darwin* | *-solaris*)
+				# UPDATE ME for ghc-7
+				mkdir "${WORKDIR}"/ghc-bin-installer || die
+				pushd "${WORKDIR}"/ghc-bin-installer > /dev/null || die
+				use sparc-solaris && unpack ghc-6.10.4-sparc-sun-solaris2.tar.bz2
+				use x86-solaris && unpack ghc-7.0.3-i386-unknown-solaris2.tar.bz2
+				use x86-macos && unpack ghc-7.4.1-i386-apple-darwin.tar.bz2
+				use x64-macos && unpack ghc-7.4.1-x86_64-apple-darwin.tar.bz2
+				popd > /dev/null
+
+				pushd "${WORKDIR}"/ghc-bin-installer/ghc-[67].?*.? > /dev/null || die
+				# fix the binaries so they run, on Solaris we need an
+				# LD_LIBRARY_PATH which has our prefix libdirs, on
+				# Darwin we need to replace the frameworks with our libs
+				# from the prefix fix before installation, because some
+				# of the tools are actually used during configure/make
+				if [[ ${CHOST} == *-solaris* ]] ; then
+					export LD_LIBRARY_PATH="${EPREFIX}/$(get_libdir):${EPREFIX}/usr/$(get_libdir):${LD_LIBRARY_PATH}"
+				elif [[ ${CHOST} == *-darwin* ]] ; then
+					local readline_framework=GNUreadline.framework/GNUreadline
+					local gmp_framework=/opt/local/lib/libgmp.10.dylib
+					local ncurses_file=/opt/local/lib/libncurses.5.dylib
+					for binary in $(scanmacho -BRE MH_EXECUTE -F '%F' .) ; do
+						install_name_tool -change \
+							${readline_framework} \
+							"${EPREFIX}"/lib/libreadline.dylib \
+							${binary} || die
+						install_name_tool -change \
+							${gmp_framework} \
+							"${EPREFIX}"/usr/lib/libgmp.dylib \
+							${binary} || die
+						install_name_tool -change \
+							${ncurses_file} \
+							"${EPREFIX}"/usr/lib/libncurses.dylib \
+							${binary} || die
+					done
+					# we don't do frameworks!
+					sed -i \
+						-e 's/\(frameworks = \)\["GMP"\]/\1[]/g' \
+						-e 's/\(extraLibraries = \)\["m"\]/\1["m","gmp"]/g' \
+						rts/package.conf.in || die
+				fi
+
+				# it is autoconf, but we really don't want to give it too
+				# many arguments, in fact we do the make in-place anyway
+				./configure --prefix="${WORKDIR}"/usr || die
+				make install || die
+				popd > /dev/null
+				;;
+				*)
+				relocate_ghc "${WORKDIR}"
+				;;
+			esac
+		fi
+
+		sed -i -e "s|\"\$topdir\"|\"\$topdir\" ${GHC_PERSISTENT_FLAGS}|" \
+			"${S}/ghc/ghc.wrapper"
+
+		cd "${S}" # otherwise eapply will break
+
+		eapply "${FILESDIR}"/${PN}-7.0.4-CHOST-prefix.patch
+		eapply "${FILESDIR}"/${PN}-8.2.1-darwin.patch
+		eapply "${FILESDIR}"/${PN}-7.8.3-prim-lm.patch
+		eapply "${FILESDIR}"/${PN}-8.0.2-no-relax-everywhere.patch
+		eapply "${FILESDIR}"/${PN}-8.4.2-allow-cross-bootstrap.patch
+		eapply "${FILESDIR}"/${PN}-8.6.5-numa.patch
+		eapply "${FILESDIR}"/${PN}-8.8.1-no-alex.patch
+		eapply "${FILESDIR}"/${PN}-8.8.1-revert-CPP.patch
+
+		# a bunch of crosscompiler patches
+		# needs newer version:
+		#eapply "${FILESDIR}"/${PN}-8.2.1_rc1-hp2ps-cross.patch
+
+		# mingw32 target
+		pushd "${S}/libraries/Win32"
+			eapply "${FILESDIR}"/${PN}-8.2.1_rc1-win32-cross-2-hack.patch # bad workaround
+		popd
+
+		bump_libs
+
+		eapply_user
+		# as we have changed the build system
+		eautoreconf
+	fi
+}
+
+src_configure() {
+	if ! use binary; then
+		# initialize build.mk
+		echo '# Gentoo changes' > mk/build.mk
+
+		# Put docs into the right place, ie /usr/share/doc/ghc-${GHC_PV}
+		echo "docdir = ${EPREFIX}/usr/share/doc/$(cross)${P}" >> mk/build.mk
+		echo "htmldir = ${EPREFIX}/usr/share/doc/$(cross)${P}" >> mk/build.mk
+
+		# We also need to use the GHC_FLAGS flags when building ghc itself
+		echo "SRC_HC_OPTS+=${HCFLAGS} ${GHC_FLAGS}" >> mk/build.mk
+		echo "SRC_CC_OPTS+=${CFLAGS}" >> mk/build.mk
+		echo "SRC_LD_OPTS+=${LDFLAGS}" >> mk/build.mk
+		# Speed up initial Cabal bootstrap
+		echo "utils/ghc-cabal_dist_EXTRA_HC_OPTS+=$(ghc-make-args)" >> mk/build.mk
+
+		# We can't depend on haddock except when bootstrapping when we
+		# must build docs and include them into the binary .tbz2 package
+		# app-text/dblatex is not in portage, can not build PDF or PS
+		echo "BUILD_SPHINX_PDF  = NO"  >> mk/build.mk
+		echo "BUILD_SPHINX_HTML = $(usex doc YES NO)" >> mk/build.mk
+		echo "BUILD_MAN = $(usex doc YES NO)" >> mk/build.mk
+
+		# this controls presence on 'xhtml' and 'haddock' in final install
+		echo "HADDOCK_DOCS       = YES" >> mk/build.mk
+
+		# not used outside of ghc's test
+		if [[ -n ${GHC_BUILD_DPH} ]]; then
+				echo "BUILD_DPH = YES" >> mk/build.mk
+			else
+				echo "BUILD_DPH = NO" >> mk/build.mk
+		fi
+
+		# Any non-native build has to skip as it needs
+		# target haddock binary to be runnabine.
+		if ! is_native; then
+			# disable docs generation as it requires running stage2
+			echo "HADDOCK_DOCS=NO" >> mk/build.mk
+			echo "BUILD_SPHINX_HTML=NO" >> mk/build.mk
+			echo "BUILD_SPHINX_PDF=NO" >> mk/build.mk
+		fi
+
+		if is_crosscompile; then
+			# Install ghc-stage1 crosscompiler instead of
+			# ghc-stage2 cross-built compiler.
+			echo "Stage1Only=YES" >> mk/build.mk
+		fi
+
+		# allows overriding build flavours for libraries:
+		# v   - vanilla (static libs)
+		# p   - profiled
+		# dyn - shared libraries
+		# example: GHC_LIBRARY_WAYS="v dyn"
+		if [[ -n ${GHC_LIBRARY_WAYS} ]]; then
+			echo "GhcLibWays=${GHC_LIBRARY_WAYS}" >> mk/build.mk
+		fi
+		echo "BUILD_PROF_LIBS = $(usex profile YES NO)" >> mk/build.mk
+
+		# Get ghc from the unpacked binary .tbz2
+		# except when bootstrapping we just pick ghc up off the path
+		if ! use ghcbootstrap; then
+			export PATH="${WORKDIR}/usr/bin:${PATH}"
+		fi
+
+		echo "INTEGER_LIBRARY = $(usex gmp integer-gmp integer-simple)" >> mk/build.mk
+
+		# don't strip anything. Very useful when stage2 SIGSEGVs on you
+		echo "STRIP_CMD = :" >> mk/build.mk
+
+		local econf_args=()
+
+		# GHC embeds toolchain it was built by and uses it later.
+		# Don't allow things like ccache or versioned binary slip.
+		# We use stable thing across gcc upgrades.
+		# User can use EXTRA_ECONF=CC=... to override this default.
+		econf_args+=(
+			AR=${CTARGET}-ar
+			CC=${CTARGET}-gcc
+			# these should be inferred by GHC but ghc defaults
+			# to using bundled tools on windows.
+			Windres=${CTARGET}-windres
+			DllWrap=${CTARGET}-dllwrap
+			# we set the linker explicitly below
+			--disable-ld-override
+		)
+		case ${CTARGET} in
+			arm*)
+				# ld.bfd-2.28 does not work for ghc. Force ld.gold
+				# instead. This should be removed once gentoo gets
+				# a fix for R_ARM_COPY bug: https://sourceware.org/PR16177
+				econf_args+=(LD=${CTARGET}-ld.gold)
+			;;
+			sparc*)
+				# ld.gold-2.28 does not work for ghc. Force ld.bfd
+				# instead. This should be removed once gentoo gets
+				# a fix for missing --no-relax support bug:
+				# https://sourceware.org/ml/binutils/2017-07/msg00183.html
+				econf_args+=(LD=${CTARGET}-ld.bfd)
+			;;
+			*)
+				econf_args+=(LD=${CTARGET}-ld)
+		esac
+
+		if [[ ${CBUILD} != ${CHOST} ]]; then
+			# GHC bug: ghc claims not to support cross-building.
+			# It does, but does not distinct --host= value
+			# for stage1 and stage2 compiler.
+			econf_args+=(--host=${CBUILD})
+		fi
+
+		if use ghcmakebinary; then
+			# When building booting libary we are trying to
+			# bundle or restrict most of external depends
+			# with unstable ABI:
+			#  - embed libffi (default GHC behaviour)
+			#  - disable ncurses support for ghci (via haskeline)
+			#    https://bugs.gentoo.org/557478
+			#  - disable ncurses support for ghc-pkg
+			echo "libraries/haskeline_CONFIGURE_OPTS += --flag=-terminfo" >> mk/build.mk
+			echo "utils/ghc-pkg_HC_OPTS += -DBOOTSTRAPPING" >> mk/build.mk
+		elif is_native; then
+			# using ${GTARGET}'s libffi is not supported yet:
+			# GHC embeds full path for ffi includes without /usr/${CTARGET} account.
+			econf_args+=(--with-system-libffi)
+			econf_args+=(--with-ffi-includes=$(pkg-config libffi --cflags-only-I | sed -e 's@^-I@@'))
+		fi
+
+		einfo "Final mk/build.mk:"
+		cat mk/build.mk || die
+
+		econf ${econf_args[@]} \
+			--enable-bootstrap-with-devel-snapshot \
+			$(use elfutils && echo --enable-dwarf-unwind) \
+			$(use_enable numa)
+
+		if [[ ${PV} == *9999* ]]; then
+			GHC_PV="$(grep 'S\[\"PACKAGE_VERSION\"\]' config.status | sed -e 's@^.*=\"\(.*\)\"@\1@')"
+			GHC_P=${PN}-${GHC_PV}
+		fi
+	fi # ! use binary
+}
+
+src_compile() {
+	if ! use binary; then
+		# Stage1Only crosscompiler does not build stage2
+		if ! is_crosscompile; then
+			# 1. build/pax-mark compiler binary first
+			emake ghc/stage2/build/tmp/ghc-stage2
+			# 2. pax-mark (bug #516430)
+			pax-mark -m ghc/stage2/build/tmp/ghc-stage2
+			# 2. build/pax-mark haddock using ghc-stage2
+			if is_native; then
+				# non-native build does not build haddock
+				# due to HADDOCK_DOCS=NO, but it could.
+				emake utils/haddock/dist/build/tmp/haddock
+				pax-mark -m utils/haddock/dist/build/tmp/haddock
+			fi
+		fi
+		# 3. and then all the rest
+		emake all
+	fi # ! use binary
+}
+
+src_test() {
+	# TODO: deal with:
+	#    - sandbox (pollutes environment)
+	#    - extra packages (to extend testsuite coverage)
+	# bits are taken from 'validate'
+	local make_test_target='test' # can be fulltest
+	# not 'emake' as testsuite uses '$MAKE' without jobserver available
+	make $make_test_target stage=2 THREADS=$(makeopts_jobs)
+}
+
+src_install() {
+	if use binary; then
+		use prefix && mkdir -p "${ED}"
+		mv "${S}/usr" "${ED}"
+	else
+		[[ -f VERSION ]] || emake VERSION
+
+		# -j1 due to a rare race in install script:
+		#    make --no-print-directory -f ghc.mk phase=final install
+		#    /usr/lib/portage/python3.4/ebuild-helpers/xattr/install -c -m 755 \
+		#        -d "/tmp/portage-tmpdir/portage/cross-armv7a-unknown-linux-gnueabi/ghc-9999/image/usr/lib64/armv7a-unknown-linux-gnueabi-ghc-8.3.20170404/include"
+		#    /usr/lib/portage/python3.4/ebuild-helpers/xattr/install -c -m 644  utils/hsc2hs/template-hsc.h \
+		#           "/tmp/portage-tmpdir/portage/cross-armv7a-unknown-linux-gnueabi/ghc-9999/image/usr/lib64/armv7a-unknown-linux-gnueabi-ghc-8.3.20170404"
+		#    /usr/bin/install: cannot create regular file \
+		#           '/tmp/portage-tmpdir/portage/cross-armv7a-unknown-linux-gnueabi/ghc-9999/image/usr/lib64/armv7a-unknown-linux-gnueabi-ghc-8.3.20170404': No such file or directory
+		emake -j1 install DESTDIR="${D}"
+
+		# Skip for cross-targets as they all share target location:
+		# /usr/share/doc/ghc-9999/
+		if ! is_crosscompile; then
+			dodoc "distrib/README" "ANNOUNCE" "LICENSE" "VERSION"
+		fi
+
+		# rename ghc-shipped files to avoid collision
+		# of external packages. Motivating example:
+		#  user had installed:
+		#      dev-lang/ghc-7.8.4-r0 (with transformers-0.3.0.0)
+		#      dev-haskell/transformers-0.4.2.0
+		#  then user tried to update to
+		#      dev-lang/ghc-7.8.4-r1 (with transformers-0.4.2.0)
+		#  this will lead to single .conf file collision.
+		local shipped_conf renamed_conf
+		local package_confdir="${ED}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d"
+		for shipped_conf in "${package_confdir}"/*.conf; do
+			# rename 'pkg-ver-id.conf' to 'pkg-ver-id-gentoo-${PF}.conf'
+			renamed_conf=${shipped_conf%.conf}-gentoo-${PF}.conf
+			mv "${shipped_conf}" "${renamed_conf}" || die
+		done
+
+		# remove link, but leave 'haddock-${GHC_P}'
+		rm -f "${ED}"/usr/bin/$(cross)haddock
+
+		if ! is_crosscompile; then
+			newbashcomp "${FILESDIR}"/ghc-bash-completion ghc-pkg
+			newbashcomp utils/completion/ghc.bash         ghc
+		fi
+	fi
+
+	# path to the package.cache
+	local package_confdir="${ED}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d"
+	PKGCACHE="${package_confdir}"/package.cache
+	# copy the package.conf.d, including timestamp, save it so we can help
+	# users that have a broken package.conf.d
+	cp -pR "${package_confdir}"{,.initial} || die "failed to backup intial package.conf.d"
+
+	# copy the package.conf, including timestamp, save it so we later can put it
+	# back before uninstalling, or when upgrading.
+	cp -p "${PKGCACHE}"{,.shipped} \
+		|| die "failed to copy package.conf.d/package.cache"
+
+	if is_crosscompile; then
+		# When we build a cross-compiler the layout is the following:
+		#     usr/lib/${CTARGET}-ghc-${VER}/ contains target libraries
+		# but
+		#     usr/lib/${CTARGET}-ghc-${VER}/bin/ directory
+		# containst host binaries (modulo bugs).
+
+		# Portage's stripping mechanism does not skip stripping
+		# foreign binaries. This frequently causes binaries to be
+		# broken.
+		#
+		# Thus below we disable stripping of target libraries and allow
+		# stripping hosts executables.
+		dostrip -x "/usr/$(get_libdir)/$(cross)${GHC_P}"
+		dostrip    "/usr/$(get_libdir)/$(cross)${GHC_P}/bin"
+	fi
+}
+
+pkg_preinst() {
+	# have we got an earlier version of ghc installed?
+	if has_version "<${CATEGORY}/${PF}"; then
+		haskell_updater_warn="1"
+	fi
+}
+
+pkg_postinst() {
+	ghc-reregister
+
+	# path to the package.cache
+	PKGCACHE="${EROOT}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d/package.cache"
+
+	# give the cache a new timestamp, it must be as recent as
+	# the package.conf.d directory.
+	touch "${PKGCACHE}"
+
+	if [[ "${haskell_updater_warn}" == "1" ]]; then
+		ewarn
+		ewarn "\e[1;31m************************************************************************\e[0m"
+		ewarn
+		ewarn "You have just upgraded from an older version of GHC."
+		ewarn "You may have to run"
+		ewarn "      'haskell-updater'"
+		ewarn "to rebuild all ghc-based Haskell libraries."
+		ewarn
+		ewarn "\e[1;31m************************************************************************\e[0m"
+		ewarn
+	fi
+}
+
+pkg_prerm() {
+	PKGCACHE="${EROOT}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d/package.cache"
+	rm -rf "${PKGCACHE}"
+
+	cp -p "${PKGCACHE}"{.shipped,}
+}
+
+pkg_postrm() {
+	ghc-package_pkg_postrm
+}

diff --git a/dev-lang/ghc/metadata.xml b/dev-lang/ghc/metadata.xml
index 494e169583d..5169f69026c 100644
--- a/dev-lang/ghc/metadata.xml
+++ b/dev-lang/ghc/metadata.xml
@@ -7,7 +7,10 @@
 	</maintainer>
 	<use>
 		<flag name="binary">Install the binary version directly, rather than using it to build the source version.</flag>
+		<flag name="elfutils">Enable DWARF-based baclktraces using <pkg>dev-libs/elfutils</pkg>.</flag>
 		<flag name="ghcbootstrap">Internal: Bootstrap GHC from an existing GHC installation.</flag>
 		<flag name="ghcmakebinary">Internal: Build binary friendly for redistribution.</flag>
+		<flag name="gmp">use <pkg>dev-libs/gmp</pkg> for integer operations (works faster, but an external depend).</flag>
+		<flag name="numa">Enable NUMA thread balancing policy using <pkg>sys-process/numactl</pkg>.</flag>
 	</use>
 </pkgmetadata>


^ permalink raw reply related	[flat|nested] 15+ messages in thread
* [gentoo-commits] repo/gentoo:master commit in: dev-lang/ghc/, dev-lang/ghc/files/
@ 2018-06-09 19:09 Sergei Trofimovich
  0 siblings, 0 replies; 15+ messages in thread
From: Sergei Trofimovich @ 2018-06-09 19:09 UTC (permalink / raw
  To: gentoo-commits

commit:     456fe14669aabfe1a94367fd4c331d2644e18001
Author:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
AuthorDate: Sat Jun  9 19:04:07 2018 +0000
Commit:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
CommitDate: Sat Jun  9 19:09:16 2018 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=456fe146

dev-lang/ghc: bump up to 8.4.3, no binaries yet

Package-Manager: Portage-2.3.40, Repoman-2.3.9

 dev-lang/ghc/Manifest                              |   1 +
 .../ghc/files/ghc-8.0.2-no-relax-everywhere.patch  |  17 +
 .../files/ghc-8.4.2-allow-cross-bootstrap.patch    |  23 +
 dev-lang/ghc/ghc-8.4.3.ebuild                      | 760 +++++++++++++++++++++
 4 files changed, 801 insertions(+)

diff --git a/dev-lang/ghc/Manifest b/dev-lang/ghc/Manifest
index 0e30d62f1a7..54d2adc8a19 100644
--- a/dev-lang/ghc/Manifest
+++ b/dev-lang/ghc/Manifest
@@ -7,6 +7,7 @@ DIST ghc-8.2.1-src.tar.xz 10736016 BLAKE2B 60993cfc9569e83b0c383591ef30a7280e013
 DIST ghc-8.2.2-src.tar.xz 10753272 BLAKE2B 6fd792390d3df20f84836466705c3f3c931ba2d594dcbe2b808ea0ae284460000b443df8aae74903eabf05ff9064d68a303086cf888ea68222eb1c60959c8f21 SHA512 6549416f470b599973d409fa45f59c25b07e6a94798cef1a19ad432547dc225338cf4dbc4a4793114b4a417798a3b59b122b92b020251074405c5302b7ffe799
 DIST ghc-8.4.1-src.tar.xz 11301528 BLAKE2B 6dcf467d04cace856b68315c85b80f19b517dcbc8ae6e2a08c60afa141c9e0261e012738452c9ca208f9fc40c48bd1a0817e5e0fe9f4737383cd7b44ca65c8d9 SHA512 f8ae11f498bf2911fb92635534c6906c96f1fbe5072c7b7447bd3f69e408026b674564515af02a8aaddc57ee6905ce78d10005b12478a39c220580aaec13a9f7
 DIST ghc-8.4.2-src.tar.xz 11313140 BLAKE2B d6fe90f3c68b137c6029bf08918a51ff43c210ba0485aca8d77541cd455f6f9c94287cd011ecd710a8e5a14a27e8a27c04c517417c5748966afd63a5ba6ed19e SHA512 aeb17c986c597762381d9887679eb0eec194c2938a92b5a33e66b4c80002ead02d672b4aa968e1061ab5652b74e46a3c9f9e3d58d5be4a0ae47aa8aed288cf1f
+DIST ghc-8.4.3-src.tar.xz 11315068 BLAKE2B cfb858051aff0c4fb3cdbbe96627cacc82665a6bfc4f863b0353eb3d93d358f7ed4efd7b131280763786f397aabc5c4825f60c3890649303fc97187f2b996d21 SHA512 c6cea84264f32ae888f9931f834a1d721889242f656d14262e787ec54a1793d1862ce76daacaf1006c12b8af12919501afce1dc02571373e24830e4d51803414
 DIST ghc-bin-7.10.3-alpha.tbz2 183558856 BLAKE2B 2bb02aafa49c6a91bec016e8bec2d07257d602e53c9df55792ec6fbbf8e2e46de1d5f3f72c0ccf74d6bd7f7987f53412063ccb02ae85455fce11fa928cbf5291 SHA512 08709fe9b4036ab41715c9a637a2a160104e3ab9e0ed9efaaf73428e3cfe19619e50c42b72c60bbbd27be2b9c2ea68f63d72c1a27d4519756e7c0d909f724230
 DIST ghc-bin-7.10.3-amd64.tbz2 112040431 BLAKE2B 3e59b70ca309a1cd704266c54a7983f9a58362bf700ced89c5649c780c664c650ec091e14026a7b84e339d2ebff39eba1772eebcd9fb4b99b9c99d179453d5cc SHA512 e1554b3944edbe8e16537de5a29132dc6a22d780d9a700cdc9b76387b94191164398d6f2242bf8199527802572e2bb02545569d4f0930a0ee0dbfdeb25978558
 DIST ghc-bin-7.10.3-ia64.tbz2 238680956 BLAKE2B 08593718d376051edfb0c86131e54dafc5c15056757fbeef90c653a7d217e49ff34ffaf7cd4083144c9277e73a290b822a0f889aaf806341375708e4b92654b2 SHA512 3694011aec8a6dc37889418b318993cb82f9b46a5175dd837713f396c8f59a19a920e0b0669fe3b4ec37d5bd8837c115264c0a8fc97c5a4ce06a3bdd52fcfce5

diff --git a/dev-lang/ghc/files/ghc-8.0.2-no-relax-everywhere.patch b/dev-lang/ghc/files/ghc-8.0.2-no-relax-everywhere.patch
new file mode 100644
index 00000000000..d6cff337380
--- /dev/null
+++ b/dev-lang/ghc/files/ghc-8.0.2-no-relax-everywhere.patch
@@ -0,0 +1,17 @@
+https://github.com/gentoo-haskell/gentoo-haskell/issues/704
+
+Allow users to specify -W,--relax externally and pass
+-Wl,-no-relax unconditonally on all arches.
+
+Reported-by: wmyrda
+diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs
+index acd0d61..5830517 100644
+--- a/compiler/main/DriverPipeline.hs
++++ b/compiler/main/DriverPipeline.hs
+@@ -2172,5 +2172,3 @@ joinObjectFiles dflags o_files output_fn = do
+                         -- disable --relax explicitly.
+-                     ++ (if platformArch (targetPlatform dflags)
+-                                `elem` [ArchSPARC, ArchSPARC64]
+-                         && ldIsGnuLd
++                     ++ (if ldIsGnuLd
+                             then [SysTools.Option "-Wl,-no-relax"]

diff --git a/dev-lang/ghc/files/ghc-8.4.2-allow-cross-bootstrap.patch b/dev-lang/ghc/files/ghc-8.4.2-allow-cross-bootstrap.patch
new file mode 100644
index 00000000000..071d4970a25
--- /dev/null
+++ b/dev-lang/ghc/files/ghc-8.4.2-allow-cross-bootstrap.patch
@@ -0,0 +1,23 @@
+Allow using cross-compilers to bootstrap GHC.
+
+In my case I'm using "cross"-compiler from
+x86_64-unknown-linux to x86_64-HEAD-linux.
+
+Those targets have the same ABI and can boot one another.
+diff --git a/configure.ac b/configure.ac
+index a8b8681a36..791367e8bf 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -228,11 +228,11 @@ FPTOOLS_SET_PLATFORM_VARS
+ if test "$BuildPlatform" != "$bootstrap_target"
+ then
+     echo "This GHC (${WithGhc}) does not generate code for the build platform"
+     echo "   GHC target platform    : $bootstrap_target"
+     echo "   Desired build platform : $BuildPlatform"
+-    exit 1
++    #exit 1
+ fi
+ 
+ # Testing if we shall enable shared libs support on Solaris.
+ # Anything older than SunOS 5.11 aka Solaris 11 (Express) is broken.
+ 

diff --git a/dev-lang/ghc/ghc-8.4.3.ebuild b/dev-lang/ghc/ghc-8.4.3.ebuild
new file mode 100644
index 00000000000..59e9e523932
--- /dev/null
+++ b/dev-lang/ghc/ghc-8.4.3.ebuild
@@ -0,0 +1,760 @@
+# Copyright 1999-2018 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=6
+
+# to make make a crosscompiler use crossdev and symlink ghc tree into
+# cross overlay. result would look like 'cross-sparc-unknown-linux-gnu/ghc'
+export CBUILD=${CBUILD:-${CHOST}}
+export CTARGET=${CTARGET:-${CHOST}}
+if [[ ${CTARGET} = ${CHOST} ]] ; then
+	if [[ ${CATEGORY/cross-} != ${CATEGORY} ]] ; then
+		export CTARGET=${CATEGORY/cross-}
+	fi
+fi
+
+inherit autotools bash-completion-r1 eutils flag-o-matic ghc-package
+inherit multilib pax-utils toolchain-funcs versionator prefix
+inherit check-reqs
+DESCRIPTION="The Glasgow Haskell Compiler"
+HOMEPAGE="http://www.haskell.org/ghc/"
+
+# we don't have any binaries yet
+arch_binaries=""
+
+# sorted!
+#arch_binaries="$arch_binaries alpha? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-alpha.tbz2 )"
+#arch_binaries="$arch_binaries arm? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-armv7a-hardfloat-linux-gnueabi.tbz2 )"
+#arch_binaries="$arch_binaries arm64? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-aarch64-unknown-linux-gnu.tbz2 )"
+#arch_binaries="$arch_binaries amd64? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-x86_64-pc-linux-gnu.tbz2 )"
+#arch_binaries="$arch_binaries ia64?  ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-ia64-fixed-fiw.tbz2 )"
+#arch_binaries="$arch_binaries ppc? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-ppc.tbz2 )"
+#arch_binaries="$arch_binaries ppc64? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-ppc64.tbz2 )"
+#arch_binaries="$arch_binaries sparc? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-sparc.tbz2 )"
+#arch_binaries="$arch_binaries x86? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-i686-pc-linux-gnu.tbz2 )"
+
+# various ports:
+#arch_binaries="$arch_binaries x86-fbsd? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-x86-fbsd.tbz2 )"
+
+# 0 - yet
+yet_binary() {
+	case "${ARCH}" in
+		#alpha) return 0 ;;
+		#arm64) return 0 ;;
+		#arm) return 0 ;;
+		#amd64) return 0 ;;
+		#ia64) return 0 ;;
+		#ppc) return 0 ;;
+		#ppc64) return 0 ;;
+		#sparc) return 0 ;;
+		#x86) return 0 ;;
+		*) return 1 ;;
+	esac
+}
+
+GHC_PV=${PV}
+#GHC_PV=8.4.1.20180329 # uncomment only for -alpha, -beta, -rc ebuilds
+GHC_P=${PN}-${GHC_PV} # using ${P} is almost never correct
+
+SRC_URI="!binary? ( http://downloads.haskell.org/~ghc/${PV/_/-}/${GHC_P}-src.tar.xz )"
+S="${WORKDIR}"/${GHC_P}
+
+[[ -n $arch_binaries ]] && SRC_URI+=" !ghcbootstrap? ( $arch_binaries )"
+
+BUMP_LIBRARIES=(
+	# "hackage-name          hackage-version"
+)
+
+LICENSE="BSD"
+SLOT="0/${PV}"
+#KEYWORDS="~alpha ~amd64 ~x86 ~amd64-linux ~x86-linux"
+IUSE="doc ghcbootstrap ghcmakebinary +gmp profile"
+IUSE+=" binary"
+
+RDEPEND="
+	>=dev-lang/perl-5.6.1
+	dev-libs/gmp:0=
+	sys-libs/ncurses:0=[unicode]
+	!ghcmakebinary? ( virtual/libffi:= )
+"
+
+# This set of dependencies is needed to run
+# prebuilt ghc. We specifically avoid ncurses
+# dependency with:
+#    utils/ghc-pkg_HC_OPTS += -DBOOTSTRAPPING
+PREBUILT_BINARY_DEPENDS="
+	!prefix? ( elibc_glibc? ( >=sys-libs/glibc-2.17 ) )
+"
+# This set of dependencies is needed to install
+# ghc[binary] in system. terminfo package is linked
+# against ncurses.
+PREBUILT_BINARY_RDEPENDS="${PREBUILT_BINARY_DEPENDS}
+	sys-libs/ncurses:0/6
+"
+
+RDEPEND+="binary? ( ${PREBUILT_BINARY_RDEPENDS} )"
+
+DEPEND="${RDEPEND}
+	doc? ( app-text/docbook-xml-dtd:4.2
+		app-text/docbook-xml-dtd:4.5
+		app-text/docbook-xsl-stylesheets
+		dev-python/sphinx
+		>=dev-libs/libxslt-1.1.2 )
+	!ghcbootstrap? ( ${PREBUILT_BINARY_DEPENDS} )"
+
+PDEPEND="!ghcbootstrap? ( >=app-admin/haskell-updater-1.2 )"
+
+REQUIRED_USE="?? ( ghcbootstrap binary )"
+
+# haskell libraries built with cabal in configure mode, #515354
+QA_CONFIGURE_OPTIONS+=" --with-compiler --with-gcc"
+
+is_crosscompile() {
+	[[ ${CHOST} != ${CTARGET} ]]
+}
+
+is_native() {
+	[[ ${CHOST} == ${CBUILD} ]] && [[ ${CHOST} == ${CTARGET} ]]
+}
+
+# returns tool prefix for crosscompiler.
+# Example:
+#  CTARGET=armv7a-unknown-linux-gnueabi
+#  CHOST=x86_64-pc-linux-gnu
+#    "armv7a-unknown-linux-gnueabi-"
+#  CTARGET=${CHOST}
+#    ""
+# Used in tools and library prefix:
+#    "${ED}"/usr/bin/$(cross)haddock
+#    "${ED}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d"
+
+cross() {
+	if is_crosscompile; then
+		echo "${CTARGET}-"
+	else
+		echo ""
+	fi
+}
+
+append-ghc-cflags() {
+	local persistent compile assemble link
+	local flag ghcflag
+
+	for flag in $*; do
+		case ${flag} in
+			persistent)	persistent="yes";;
+			compile)	compile="yes";;
+			assemble)	assemble="yes";;
+			link)		link="yes";;
+			*)
+				[[ ${compile}  ]] && ghcflag="-optc${flag}"  CFLAGS+=" ${flag}" && GHC_FLAGS+=" ${ghcflag}" &&
+					[[ ${persistent} ]] && GHC_PERSISTENT_FLAGS+=" ${ghcflag}"
+				[[ ${assemble} ]] && ghcflag="-opta${flag}"  CFLAGS+=" ${flag}" && GHC_FLAGS+=" ${ghcflag}" &&
+					[[ ${persistent} ]] && GHC_PERSISTENT_FLAGS+=" ${ghcflag}"
+				[[ ${link}     ]] && ghcflag="-optl${flag}" LDFLAGS+=" ${flag}" && GHC_FLAGS+=" ${ghcflag}" &&
+					[[ ${persistent} ]] && GHC_PERSISTENT_FLAGS+=" ${ghcflag}"
+				;;
+		esac
+	done
+}
+
+# $1 - lib name (under libraries/)
+# $2 - lib version
+# example: bump_lib "transformers" "0.4.2.0"
+bump_lib() {
+	local pn=$1 pv=$2
+	local p=${pn}-${pv}
+	local f
+
+	einfo "Bumping ${pn} up to ${pv}"
+
+	for f in ghc.mk GNUmakefile; do
+		mv libraries/"${pn}"/$f "${WORKDIR}"/"${p}"/$f || die
+	done
+	mv libraries/"${pn}" "${WORKDIR}"/"${pn}".old || die
+	mv "${WORKDIR}"/"${p}" libraries/"${pn}" || die
+}
+
+update_SRC_URI() {
+	local p pn pv
+	for p in "${BUMP_LIBRARIES[@]}"; do
+		set -- $p
+		pn=$1 pv=$2
+
+		SRC_URI+=" mirror://hackage/package/${pn}/${pn}-${pv}.tar.gz"
+	done
+}
+
+update_SRC_URI
+
+bump_libs() {
+	local p pn pv
+	for p in "${BUMP_LIBRARIES[@]}"; do
+		set -- $p
+		pn=$1 pv=$2
+
+		bump_lib "${pn}" "${pv}"
+	done
+}
+
+ghc_setup_cflags() {
+	# TODO: plumb CFLAGS and BUILD_CFLAGS to respective CONF_CC_OPTS_STAGE<N>
+	if ! is_native; then
+		export CFLAGS=${GHC_CFLAGS-"-O2 -pipe"}
+		export LDFLAGS=${GHC_LDFLAGS-"-Wl,-O1"}
+		einfo "Crosscompiling mode:"
+		einfo "   CHOST:   ${CHOST}"
+		einfo "   CTARGET: ${CTARGET}"
+		einfo "   CFLAGS:  ${CFLAGS}"
+		einfo "   LDFLAGS: ${LDFLAGS}"
+		einfo "   prefix: $(cross)"
+		return
+	fi
+	# We need to be very careful with the CFLAGS we ask ghc to pass through to
+	# gcc. There are plenty of flags which will make gcc produce output that
+	# breaks ghc in various ways. The main ones we want to pass through are
+	# -mcpu / -march flags. These are important for arches like alpha & sparc.
+	# We also use these CFLAGS for building the C parts of ghc, ie the rts.
+	strip-flags
+	strip-unsupported-flags
+
+	# Cmm can't parse line numbers #482086
+	replace-flags -ggdb[3-9] -ggdb2
+
+	GHC_FLAGS=""
+	GHC_PERSISTENT_FLAGS=""
+	for flag in ${CFLAGS}; do
+		case ${flag} in
+
+			# Ignore extra optimisation (ghc passes -O to gcc anyway)
+			# -O2 and above break on too many systems
+			-O*) ;;
+
+			# Arch and ABI flags are what we're really after
+			-m*) append-ghc-cflags compile assemble ${flag};;
+
+			# Sometimes it's handy to see backtrace of RTS
+			# to get an idea what happens there
+			-g*) append-ghc-cflags compile ${flag};;
+
+			# Ignore all other flags, including all -f* flags
+		esac
+	done
+
+	for flag in ${LDFLAGS}; do
+		append-ghc-cflags link ${flag}
+	done
+
+	# GHC uses ${CBUILD}-gcc, ${CHOST}-gcc and ${CTARGET}-gcc at a single build.
+	# Skip any gentoo-specific tweaks for cross-case to avoid passing unsupported
+	# options to gcc.
+	if is_native; then
+		# hardened-gcc needs to be disabled, because our prebuilt binaries/libraries
+		# are not built with fPIC, bug #606666
+		gcc-specs-pie && append-ghc-cflags persistent compile link -nopie
+		tc-is-gcc && version_is_at_least 6.3 $(gcc-version) && if ! use ghcbootstrap; then
+			# gcc-6.3 has support for -no-pie upstream, but spelling differs from
+			# gentoo-specific '-nopie'. We enable it in non-bootstrap to allow
+			# hardened users try '-pie' in USE=ghcbootstrap mode.
+			append-ghc-cflags compile link -no-pie
+		fi
+
+		# prevent from failing to build unregisterised ghc:
+		# http://www.mail-archive.com/debian-bugs-dist@lists.debian.org/msg171602.html
+		use ppc64 && append-ghc-cflags persistent compile -mminimal-toc
+	fi
+}
+
+# substitutes string $1 to $2 in files $3 $4 ...
+relocate_path() {
+	local from=$1
+	local   to=$2
+	shift 2
+	local file=
+	for file in "$@"
+	do
+		sed -i -e "s|$from|$to|g" \
+			"$file" || die "path relocation failed for '$file'"
+	done
+}
+
+# changes hardcoded ghc paths and updates package index
+# $1 - new absolute root path
+relocate_ghc() {
+	local to=$1
+
+	# libdir for prebuilt binary and for current system may mismatch
+	# It does for prefix installation for example: bug #476998
+	local bin_ghc_prefix=${WORKDIR}/usr
+	local bin_libpath=$(echo "${bin_ghc_prefix}"/lib*)
+	local bin_libdir=${bin_libpath#${bin_ghc_prefix}/}
+
+	# backup original script to use it later after relocation
+	local gp_back="${T}/ghc-pkg-${GHC_PV}-orig"
+	cp "${WORKDIR}/usr/bin/ghc-pkg-${GHC_PV}" "$gp_back" || die "unable to backup ghc-pkg wrapper"
+
+	if [[ ${bin_libdir} != $(get_libdir) ]]; then
+		einfo "Relocating '${bin_libdir}' to '$(get_libdir)' (bug #476998)"
+		# moving the dir itself is not strictly needed
+		# but then USE=binary would result in installing
+		# in '${bin_libdir}'
+		mv "${bin_ghc_prefix}/${bin_libdir}" "${bin_ghc_prefix}/$(get_libdir)" || die
+
+		relocate_path "/usr/${bin_libdir}" "/usr/$(get_libdir)" \
+			"${WORKDIR}/usr/bin/ghc-${GHC_PV}" \
+			"${WORKDIR}/usr/bin/ghci-${GHC_PV}" \
+			"${WORKDIR}/usr/bin/ghc-pkg-${GHC_PV}" \
+			"${WORKDIR}/usr/bin/hsc2hs" \
+			"${WORKDIR}/usr/bin/runghc-${GHC_PV}" \
+			"$gp_back" \
+			"${WORKDIR}/usr/$(get_libdir)/${GHC_P}/package.conf.d/"*
+	fi
+
+	# Relocate from /usr to ${EPREFIX}/usr
+	relocate_path "/usr" "${to}/usr" \
+		"${WORKDIR}/usr/bin/ghc-${GHC_PV}" \
+		"${WORKDIR}/usr/bin/ghci-${GHC_PV}" \
+		"${WORKDIR}/usr/bin/ghc-pkg-${GHC_PV}" \
+		"${WORKDIR}/usr/bin/haddock-ghc-${GHC_PV}" \
+		"${WORKDIR}/usr/bin/hp2ps" \
+		"${WORKDIR}/usr/bin/hpc" \
+		"${WORKDIR}/usr/bin/hsc2hs" \
+		"${WORKDIR}/usr/bin/runghc-${GHC_PV}" \
+		"${WORKDIR}/usr/$(get_libdir)/${GHC_P}/package.conf.d/"*
+
+	# this one we will use to regenerate cache
+	# so it should point to current tree location
+	relocate_path "/usr" "${WORKDIR}/usr" "$gp_back"
+
+	if use prefix; then
+		hprefixify "${bin_libpath}"/${PN}*/settings
+	fi
+
+	# regenerate the binary package cache
+	"$gp_back" recache || die "failed to update cache after relocation"
+	rm "$gp_back"
+}
+
+ghc-check-reqs() {
+	# These are pessimistic values (slightly bigger than worst-case)
+	# Worst case is UNREG USE=profile ia64. See bug #611866 for some
+	# numbers on various arches.
+	CHECKREQS_DISK_BUILD=8G
+	CHECKREQS_DISK_USR=2G
+	# USE=binary roughly takes
+	use binary && CHECKREQS_DISK_BUILD=4G
+
+	"$@"
+}
+
+pkg_pretend() {
+	ghc-check-reqs check-reqs_pkg_pretend
+}
+
+pkg_setup() {
+	ghc-check-reqs check-reqs_pkg_setup
+
+	# quiet portage about prebuilt binaries
+	use binary && QA_PREBUILT="*"
+
+	[[ ${MERGE_TYPE} == binary ]] && return
+
+	if use ghcbootstrap; then
+		ewarn "You requested ghc bootstrapping, this is usually only used"
+		ewarn "by Gentoo developers to make binary .tbz2 packages."
+
+		[[ -z $(type -P ghc) ]] && \
+			die "Could not find a ghc to bootstrap with."
+	else
+		if ! yet_binary; then
+			eerror "Please try emerging with USE=ghcbootstrap and report build"
+			eerror "sucess or failure to the haskell team (haskell@gentoo.org)"
+			die "No binary available for '${ARCH}' arch yet, USE=ghcbootstrap"
+		fi
+	fi
+}
+
+src_unpack() {
+	# Create the ${S} dir if we're using the binary version
+	use binary && mkdir "${S}"
+
+	# the Solaris and Darwin binaries from ghc (maeder) need to be
+	# unpacked separately, so prevent them from being unpacked
+	local ONLYA=${A}
+	case ${CHOST} in
+		*-darwin* | *-solaris*)  ONLYA=${GHC_P}-src.tar.xz  ;;
+	esac
+	unpack ${ONLYA}
+}
+
+src_prepare() {
+	ghc_setup_cflags
+
+	if ! use ghcbootstrap && [[ ${CHOST} != *-darwin* && ${CHOST} != *-solaris* ]]; then
+		# Modify the wrapper script from the binary tarball to use GHC_PERSISTENT_FLAGS.
+		# See bug #313635.
+		sed -i -e "s|\"\$topdir\"|\"\$topdir\" ${GHC_PERSISTENT_FLAGS}|" \
+			"${WORKDIR}/usr/bin/ghc-${GHC_PV}"
+
+		# allow hardened users use vanilla binary to bootstrap ghc
+		# ghci uses mmap with rwx protection at it implements dynamic
+		# linking on it's own (bug #299709)
+		pax-mark -m "${WORKDIR}/usr/$(get_libdir)/${GHC_P}/bin/ghc"
+	fi
+
+	if use binary; then
+		if use prefix; then
+			relocate_ghc "${EPREFIX}"
+		fi
+
+		# Move unpacked files to the expected place
+		mv "${WORKDIR}/usr" "${S}"
+		eapply_user
+	else
+		if ! use ghcbootstrap; then
+			case ${CHOST} in
+				*-darwin* | *-solaris*)
+				# UPDATE ME for ghc-7
+				mkdir "${WORKDIR}"/ghc-bin-installer || die
+				pushd "${WORKDIR}"/ghc-bin-installer > /dev/null || die
+				use sparc-solaris && unpack ghc-6.10.4-sparc-sun-solaris2.tar.bz2
+				use x86-solaris && unpack ghc-7.0.3-i386-unknown-solaris2.tar.bz2
+				use x86-macos && unpack ghc-7.4.1-i386-apple-darwin.tar.bz2
+				use x64-macos && unpack ghc-7.4.1-x86_64-apple-darwin.tar.bz2
+				popd > /dev/null
+
+				pushd "${WORKDIR}"/ghc-bin-installer/ghc-[67].?*.? > /dev/null || die
+				# fix the binaries so they run, on Solaris we need an
+				# LD_LIBRARY_PATH which has our prefix libdirs, on
+				# Darwin we need to replace the frameworks with our libs
+				# from the prefix fix before installation, because some
+				# of the tools are actually used during configure/make
+				if [[ ${CHOST} == *-solaris* ]] ; then
+					export LD_LIBRARY_PATH="${EPREFIX}/$(get_libdir):${EPREFIX}/usr/$(get_libdir):${LD_LIBRARY_PATH}"
+				elif [[ ${CHOST} == *-darwin* ]] ; then
+					local readline_framework=GNUreadline.framework/GNUreadline
+					local gmp_framework=/opt/local/lib/libgmp.10.dylib
+					local ncurses_file=/opt/local/lib/libncurses.5.dylib
+					for binary in $(scanmacho -BRE MH_EXECUTE -F '%F' .) ; do
+						install_name_tool -change \
+							${readline_framework} \
+							"${EPREFIX}"/lib/libreadline.dylib \
+							${binary} || die
+						install_name_tool -change \
+							${gmp_framework} \
+							"${EPREFIX}"/usr/lib/libgmp.dylib \
+							${binary} || die
+						install_name_tool -change \
+							${ncurses_file} \
+							"${EPREFIX}"/usr/lib/libncurses.dylib \
+							${binary} || die
+					done
+					# we don't do frameworks!
+					sed -i \
+						-e 's/\(frameworks = \)\["GMP"\]/\1[]/g' \
+						-e 's/\(extraLibraries = \)\["m"\]/\1["m","gmp"]/g' \
+						rts/package.conf.in || die
+				fi
+
+				# it is autoconf, but we really don't want to give it too
+				# much arguments, in fact we do the make in-place anyway
+				./configure --prefix="${WORKDIR}"/usr || die
+				make install || die
+				popd > /dev/null
+				;;
+				*)
+				relocate_ghc "${WORKDIR}"
+				;;
+			esac
+		fi
+
+		sed -i -e "s|\"\$topdir\"|\"\$topdir\" ${GHC_PERSISTENT_FLAGS}|" \
+			"${S}/ghc/ghc.wrapper"
+
+		cd "${S}" # otherwise eapply will break
+
+		eapply "${FILESDIR}"/${PN}-7.0.4-CHOST-prefix.patch
+		eapply "${FILESDIR}"/${PN}-8.2.1-darwin.patch
+		eapply "${FILESDIR}"/${PN}-7.8.3-prim-lm.patch
+		eapply "${FILESDIR}"/${PN}-8.0.2-no-relax-everywhere.patch
+		eapply "${FILESDIR}"/${PN}-8.4.2-allow-cross-bootstrap.patch
+
+		# a bunch of crosscompiler patches
+		# needs newer version:
+		#eapply "${FILESDIR}"/${PN}-8.2.1_rc1-hp2ps-cross.patch
+
+		# mingw32 target
+		pushd "${S}/libraries/Win32"
+			eapply "${FILESDIR}"/${PN}-8.2.1_rc1-win32-cross-2-hack.patch # bad workaround
+		popd
+
+		bump_libs
+
+		eapply_user
+		# as we have changed the build system
+		eautoreconf
+	fi
+}
+
+src_configure() {
+	if ! use binary; then
+		# initialize build.mk
+		echo '# Gentoo changes' > mk/build.mk
+
+		# Put docs into the right place, ie /usr/share/doc/ghc-${GHC_PV}
+		echo "docdir = ${EPREFIX}/usr/share/doc/$(cross)${P}" >> mk/build.mk
+		echo "htmldir = ${EPREFIX}/usr/share/doc/$(cross)${P}" >> mk/build.mk
+
+		# We also need to use the GHC_FLAGS flags when building ghc itself
+		echo "SRC_HC_OPTS+=${HCFLAGS} ${GHC_FLAGS}" >> mk/build.mk
+		echo "SRC_CC_OPTS+=${CFLAGS}" >> mk/build.mk
+		echo "SRC_LD_OPTS+=${LDFLAGS}" >> mk/build.mk
+		# Speed up initial Cabal bootstrap
+		echo "utils/ghc-cabal_dist_EXTRA_HC_OPTS+=$(ghc-make-args)" >> mk/build.mk
+
+		# We can't depend on haddock except when bootstrapping when we
+		# must build docs and include them into the binary .tbz2 package
+		# app-text/dblatex is not in portage, can not build PDF or PS
+		echo "BUILD_SPHINX_PDF  = NO"  >> mk/build.mk
+		echo "BUILD_SPHINX_HTML = $(usex doc YES NO)" >> mk/build.mk
+		echo "BUILD_MAN = $(usex doc YES NO)" >> mk/build.mk
+
+		# this controls presence on 'xhtml' and 'haddock' in final install
+		echo "HADDOCK_DOCS       = YES" >> mk/build.mk
+
+		# not used outside of ghc's test
+		if [[ -n ${GHC_BUILD_DPH} ]]; then
+				echo "BUILD_DPH = YES" >> mk/build.mk
+			else
+				echo "BUILD_DPH = NO" >> mk/build.mk
+		fi
+
+		# Any non-native build has to skip as it needs
+		# target haddock binary to be runnabine.
+		if ! is_native; then
+			# disable docs generation as it requires running stage2
+			echo "HADDOCK_DOCS=NO" >> mk/build.mk
+			echo "BUILD_SPHINX_HTML=NO" >> mk/build.mk
+			echo "BUILD_SPHINX_PDF=NO" >> mk/build.mk
+		fi
+
+		if is_crosscompile; then
+			# Install ghc-stage1 crosscompiler instead of
+			# ghc-stage2 cross-built compiler.
+			echo "Stage1Only=YES" >> mk/build.mk
+		fi
+
+		# allows overriding build flavours for libraries:
+		# v   - vanilla (static libs)
+		# p   - profiled
+		# dyn - shared libraries
+		# example: GHC_LIBRARY_WAYS="v dyn"
+		if [[ -n ${GHC_LIBRARY_WAYS} ]]; then
+			echo "GhcLibWays=${GHC_LIBRARY_WAYS}" >> mk/build.mk
+		fi
+		echo "BUILD_PROF_LIBS = $(usex profile YES NO)" >> mk/build.mk
+
+		# Get ghc from the unpacked binary .tbz2
+		# except when bootstrapping we just pick ghc up off the path
+		if ! use ghcbootstrap; then
+			export PATH="${WORKDIR}/usr/bin:${PATH}"
+		fi
+
+		echo "INTEGER_LIBRARY = $(usex gmp integer-gmp integer-simple)" >> mk/build.mk
+
+		# don't strip anything. Very useful when stage2 SIGSEGVs on you
+		echo "STRIP_CMD = :" >> mk/build.mk
+
+		local econf_args=()
+
+		# GHC embeds toolchain it was built by and uses it later.
+		# Don't allow things like ccache or versioned binary slip.
+		# We use stable thing across gcc upgrades.
+		# User can use EXTRA_ECONF=CC=... to override this default.
+		econf_args+=(
+			AR=${CTARGET}-ar
+			CC=${CTARGET}-gcc
+			# these should be inferred by GHC but ghc defaults
+			# to using bundled tools on windows.
+			Windres=${CTARGET}-windres
+			DllWrap=${CTARGET}-dllwrap
+			# we set the linker explicitly below
+			--disable-ld-override
+		)
+		case ${CTARGET} in
+			arm*)
+				# ld.bfd-2.28 does not work for ghc. Force ld.gold
+				# instead. This should be removed once gentoo gets
+				# a fix for R_ARM_COPY bug: https://sourceware.org/PR16177
+				econf_args+=(LD=${CTARGET}-ld.gold)
+			;;
+			sparc*)
+				# ld.gold-2.28 does not work for ghc. Force ld.bfd
+				# instead. This should be removed once gentoo gets
+				# a fix for missing --no-relax support bug:
+				# https://sourceware.org/ml/binutils/2017-07/msg00183.html
+				econf_args+=(LD=${CTARGET}-ld.bfd)
+			;;
+			*)
+				econf_args+=(LD=${CTARGET}-ld)
+		esac
+
+		if [[ ${CBUILD} != ${CHOST} ]]; then
+			# GHC bug: ghc claims not to support cross-building.
+			# It does, but does not distinct --host= value
+			# for stage1 and stage2 compiler.
+			econf_args+=(--host=${CBUILD})
+		fi
+
+		if use ghcmakebinary; then
+			# When building booting libary we are trying to
+			# bundle or restrict most of external depends
+			# with unstable ABI:
+			#  - embed libffi (default GHC behaviour)
+			#  - disable ncurses support for ghci (via haskeline)
+			#    https://bugs.gentoo.org/557478
+			#  - disable ncurses support for ghc-pkg
+			echo "libraries/haskeline_CONFIGURE_OPTS += --flag=-terminfo" >> mk/build.mk
+			echo "utils/ghc-pkg_HC_OPTS += -DBOOTSTRAPPING" >> mk/build.mk
+		elif is_native; then
+			# using ${GTARGET}'s libffi is not supported yet:
+			# GHC embeds full path for ffi includes without /usr/${CTARGET} account.
+			econf_args+=(--with-system-libffi)
+			econf_args+=(--with-ffi-includes=$(pkg-config libffi --cflags-only-I | sed -e 's@^-I@@'))
+		fi
+
+		einfo "Final mk/build.mk:"
+		cat mk/build.mk || die
+
+		econf ${econf_args[@]} --enable-bootstrap-with-devel-snapshot
+
+		if [[ ${PV} == *9999* ]]; then
+			GHC_PV="$(grep 'S\[\"PACKAGE_VERSION\"\]' config.status | sed -e 's@^.*=\"\(.*\)\"@\1@')"
+			GHC_P=${PN}-${GHC_PV}
+		fi
+	fi # ! use binary
+}
+
+src_compile() {
+	if ! use binary; then
+		# Stage1Only crosscompiler does not build stage2
+		if ! is_crosscompile; then
+			# 1. build/pax-mark compiler binary first
+			emake ghc/stage2/build/tmp/ghc-stage2
+			# 2. pax-mark (bug #516430)
+			pax-mark -m ghc/stage2/build/tmp/ghc-stage2
+			# 2. build/pax-mark haddock using ghc-stage2
+			if is_native; then
+				# non-native build does not build haddock
+				# due to HADDOCK_DOCS=NO, but it could.
+				emake utils/haddock/dist/build/tmp/haddock
+				pax-mark -m utils/haddock/dist/build/tmp/haddock
+			fi
+		fi
+		# 3. and then all the rest
+		emake all
+	fi # ! use binary
+}
+
+src_install() {
+	if use binary; then
+		use prefix && mkdir -p "${ED}"
+		mv "${S}/usr" "${ED}"
+	else
+		[[ -f VERSION ]] || emake VERSION
+
+		# -j1 due to a rare race in install script:
+		#    make --no-print-directory -f ghc.mk phase=final install
+		#    /usr/lib/portage/python3.4/ebuild-helpers/xattr/install -c -m 755 \
+		#        -d "/tmp/portage-tmpdir/portage/cross-armv7a-unknown-linux-gnueabi/ghc-9999/image/usr/lib64/armv7a-unknown-linux-gnueabi-ghc-8.3.20170404/include"
+		#    /usr/lib/portage/python3.4/ebuild-helpers/xattr/install -c -m 644  utils/hsc2hs/template-hsc.h \
+		#           "/tmp/portage-tmpdir/portage/cross-armv7a-unknown-linux-gnueabi/ghc-9999/image/usr/lib64/armv7a-unknown-linux-gnueabi-ghc-8.3.20170404"
+		#    /usr/bin/install: cannot create regular file \
+		#           '/tmp/portage-tmpdir/portage/cross-armv7a-unknown-linux-gnueabi/ghc-9999/image/usr/lib64/armv7a-unknown-linux-gnueabi-ghc-8.3.20170404': No such file or directory
+		emake -j1 install DESTDIR="${D}"
+
+		# Skip for cross-targets as they all share target location:
+		# /usr/share/doc/ghc-9999/
+		if ! is_crosscompile; then
+			dodoc "distrib/README" "ANNOUNCE" "LICENSE" "VERSION"
+		fi
+
+		# rename ghc-shipped files to avoid collision
+		# of external packages. Motivating example:
+		#  user had installed:
+		#      dev-lang/ghc-7.8.4-r0 (with transformers-0.3.0.0)
+		#      dev-haskell/transformers-0.4.2.0
+		#  then user tried to update to
+		#      dev-lang/ghc-7.8.4-r1 (with transformers-0.4.2.0)
+		#  this will lead to single .conf file collision.
+		local shipped_conf renamed_conf
+		local package_confdir="${ED}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d"
+		for shipped_conf in "${package_confdir}"/*.conf; do
+			# rename 'pkg-ver-id.conf' to 'pkg-ver-id-gentoo-${PF}.conf'
+			renamed_conf=${shipped_conf%.conf}-gentoo-${PF}.conf
+			mv "${shipped_conf}" "${renamed_conf}" || die
+		done
+
+		# remove link, but leave 'haddock-${GHC_P}'
+		rm -f "${ED}"/usr/bin/$(cross)haddock
+
+		if ! is_crosscompile; then
+			newbashcomp "${FILESDIR}"/ghc-bash-completion ghc-pkg
+			newbashcomp utils/completion/ghc.bash         ghc
+		fi
+	fi
+
+	# path to the package.cache
+	local package_confdir="${ED}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d"
+	PKGCACHE="${package_confdir}"/package.cache
+	# copy the package.conf.d, including timestamp, save it so we can help
+	# users that have a broken package.conf.d
+	cp -pR "${package_confdir}"{,.initial} || die "failed to backup intial package.conf.d"
+
+	# copy the package.conf, including timestamp, save it so we later can put it
+	# back before uninstalling, or when upgrading.
+	cp -p "${PKGCACHE}"{,.shipped} \
+		|| die "failed to copy package.conf.d/package.cache"
+}
+
+pkg_preinst() {
+	# have we got an earlier version of ghc installed?
+	if has_version "<${CATEGORY}/${PF}"; then
+		haskell_updater_warn="1"
+	fi
+}
+
+pkg_postinst() {
+	ghc-reregister
+
+	# path to the package.cache
+	PKGCACHE="${EROOT}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d/package.cache"
+
+	# give the cache a new timestamp, it must be as recent as
+	# the package.conf.d directory.
+	touch "${PKGCACHE}"
+
+	if [[ "${haskell_updater_warn}" == "1" ]]; then
+		ewarn
+		ewarn "\e[1;31m************************************************************************\e[0m"
+		ewarn
+		ewarn "You have just upgraded from an older version of GHC."
+		ewarn "You may have to run"
+		ewarn "      'haskell-updater'"
+		ewarn "to rebuild all ghc-based Haskell libraries."
+		ewarn
+		ewarn "\e[1;31m************************************************************************\e[0m"
+		ewarn
+	fi
+}
+
+pkg_prerm() {
+	PKGCACHE="${EROOT}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d/package.cache"
+	rm -rf "${PKGCACHE}"
+
+	cp -p "${PKGCACHE}"{.shipped,}
+}
+
+pkg_postrm() {
+	ghc-package_pkg_postrm
+}


^ permalink raw reply related	[flat|nested] 15+ messages in thread
* [gentoo-commits] repo/gentoo:master commit in: dev-lang/ghc/, dev-lang/ghc/files/
@ 2017-09-02 20:50 Sergei Trofimovich
  0 siblings, 0 replies; 15+ messages in thread
From: Sergei Trofimovich @ 2017-09-02 20:50 UTC (permalink / raw
  To: gentoo-commits

commit:     cec8a745f68e5e471f5cd0cd9005e443bc337d42
Author:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
AuthorDate: Sat Sep  2 20:48:51 2017 +0000
Commit:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
CommitDate: Sat Sep  2 20:50:32 2017 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=cec8a745

dev-lang/ghc: bachport *-darwin* triplets

yuuko has CHOST=x86_64-apple-darwin16 which
does not work on ghc-8.2.1.
Backport upstream commit
http://git.haskell.org/ghc.git/commitdiff/d39a3409acd3c40fb018ec1c114f15d3ecef6ef9

Package-Manager: Portage-2.3.8, Repoman-2.3.3

 dev-lang/ghc/files/ghc-8.2.1-darwin.patch | 31 +++++++++++++++++++++++++++++++
 dev-lang/ghc/ghc-8.2.1.ebuild             |  1 +
 2 files changed, 32 insertions(+)

diff --git a/dev-lang/ghc/files/ghc-8.2.1-darwin.patch b/dev-lang/ghc/files/ghc-8.2.1-darwin.patch
new file mode 100644
index 00000000000..53fedc4e440
--- /dev/null
+++ b/dev-lang/ghc/files/ghc-8.2.1-darwin.patch
@@ -0,0 +1,31 @@
+From d39a3409acd3c40fb018ec1c114f15d3ecef6ef9 Mon Sep 17 00:00:00 2001
+From: Sergei Trofimovich <slyfox@gentoo.org>
+Date: Thu, 1 Jun 2017 22:30:05 +0100
+Subject: [PATCH] aclocal.m4: add support for versioned darwin triplets
+
+The change adds support for 'darwin*' OS:
+    $ ./configure --target=aarch64-apple-darwin14
+
+Reported-by: jp_rider
+Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
+---
+ aclocal.m4 | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/aclocal.m4 b/aclocal.m4
+index 7ad9c36453..437974a0c7 100644
+--- a/aclocal.m4
++++ b/aclocal.m4
+@@ -1906,6 +1906,9 @@ AC_DEFUN([GHC_CONVERT_OS],[
+       aix*) # e.g. powerpc-ibm-aix7.1.3.0
+         $3="aix"
+         ;;
++      darwin*) # e.g. aarch64-apple-darwin14
++        $3="darwin"
++        ;;
+       freebsd*) # like i686-gentoo-freebsd7
+                 #      i686-gentoo-freebsd8
+                 #      i686-gentoo-freebsd8.2
+-- 
+2.14.1
+

diff --git a/dev-lang/ghc/ghc-8.2.1.ebuild b/dev-lang/ghc/ghc-8.2.1.ebuild
index 753ef86b498..66a642bf929 100644
--- a/dev-lang/ghc/ghc-8.2.1.ebuild
+++ b/dev-lang/ghc/ghc-8.2.1.ebuild
@@ -481,6 +481,7 @@ src_prepare() {
 		cd "${S}" # otherwise epatch will break
 
 		epatch "${FILESDIR}"/${PN}-7.0.4-CHOST-prefix.patch
+		epatch "${FILESDIR}"/${PN}-8.2.1-darwin.patch
 
 		epatch "${FILESDIR}"/${PN}-8.2.1_rc1-cgen-constify.patch
 		epatch "${FILESDIR}"/${PN}-7.8.3-prim-lm.patch


^ permalink raw reply related	[flat|nested] 15+ messages in thread
* [gentoo-commits] repo/gentoo:master commit in: dev-lang/ghc/, dev-lang/ghc/files/
@ 2017-05-23 21:16 Sergei Trofimovich
  0 siblings, 0 replies; 15+ messages in thread
From: Sergei Trofimovich @ 2017-05-23 21:16 UTC (permalink / raw
  To: gentoo-commits

commit:     725c067ee23c5a007d9d282423f170cc3660fdca
Author:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
AuthorDate: Tue May 23 20:58:12 2017 +0000
Commit:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
CommitDate: Tue May 23 21:15:48 2017 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=725c067e

dev-lang/ghc: restore HCFLAGS=-O1 for UNREG arches

This fix is primary to restore ia64 support.

But in general it speeds GHC build up substantially:
from 10+ hours down to 3.5 hours.

Package-Manager: Portage-2.3.6, Repoman-2.3.2

 dev-lang/ghc/files/ghc-8.0.2-O2-unreg.patch | 35 +++++++++++++++++++++++++++++
 dev-lang/ghc/ghc-8.0.2.ebuild               |  1 +
 2 files changed, 36 insertions(+)

diff --git a/dev-lang/ghc/files/ghc-8.0.2-O2-unreg.patch b/dev-lang/ghc/files/ghc-8.0.2-O2-unreg.patch
new file mode 100644
index 00000000000..b64d65b80a0
--- /dev/null
+++ b/dev-lang/ghc/files/ghc-8.0.2-O2-unreg.patch
@@ -0,0 +1,35 @@
+ghc -O2 generates too large C files for unregisterised compiler.
+On ia64 it causes DynFlags to compile for 60 minutes (then assembler
+crashes).
+
+To decrease C code inflation we don't use -O2 in UNREG mode.
+diff --git a/mk/config.mk.in b/mk/config.mk.in
+index bfaaa66..d8f93b3 100644
+--- a/mk/config.mk.in
++++ b/mk/config.mk.in
+@@ -72,11 +72,2 @@ GhcStage3HcOpts=-O2
+
+-# Disable -O2 optimization. Otherwise amount of generated C code
+-# makes things very slow to compile (~5 minutes on core-i7 for 'compiler/hsSyn/HsExpr.lhs')
+-# and sometimes not compile at all (powerpc64 overflows something
+-# on 'compiler/hsSyn/HsExpr.lhs').
+-ifeq "$(GhcUnregisterised)" "YES"
+-GhcStage1HcOpts=
+-GhcStage2HcOpts=
+-GhcStage3HcOpts=
+-endif
+
+@@ -894 +885,13 @@ CURSES_INCLUDE_DIRS = @CURSES_INCLUDE_DIRS@
+ CURSES_LIB_DIRS = @CURSES_LIB_DIRS@
++
++# Disable -O2 optimization. Otherwise amount of generated C code
++# makes things very slow to compile (~5 minutes on core-i7 for 'compiler/hsSyn/HsExpr.lhs')
++# and sometimes not compile at all (powerpc64 overflows something
++# on 'compiler/hsSyn/HsExpr.lhs').
++ifeq "$(GhcUnregisterised)" "YES"
++GhcStage1HcOpts=
++GhcStage2HcOpts=
++GhcStage3HcOpts=
++
++GhcLibHcOpts=
++endif

diff --git a/dev-lang/ghc/ghc-8.0.2.ebuild b/dev-lang/ghc/ghc-8.0.2.ebuild
index 5dc0277ec6f..6ca4874cefe 100644
--- a/dev-lang/ghc/ghc-8.0.2.ebuild
+++ b/dev-lang/ghc/ghc-8.0.2.ebuild
@@ -459,6 +459,7 @@ src_prepare() {
 		epatch "${FILESDIR}"/${PN}-8.0.1-par-g0-on-A32.patch
 		epatch "${FILESDIR}"/${PN}-8.0.2_rc2-old-sphinx.patch
 		epatch "${FILESDIR}"/${PN}-8.0.2-libffi-alpha.patch
+		epatch "${FILESDIR}"/${PN}-8.0.2-O2-unreg.patch
 
 		if use prefix; then
 			# Make configure find docbook-xsl-stylesheets from Prefix


^ permalink raw reply related	[flat|nested] 15+ messages in thread
* [gentoo-commits] repo/gentoo:master commit in: dev-lang/ghc/, dev-lang/ghc/files/
@ 2017-01-29 12:54 Sergei Trofimovich
  0 siblings, 0 replies; 15+ messages in thread
From: Sergei Trofimovich @ 2017-01-29 12:54 UTC (permalink / raw
  To: gentoo-commits

commit:     7e002c40c695e591f8d9ceadaee4c5013e6df256
Author:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 29 12:54:14 2017 +0000
Commit:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
CommitDate: Sun Jan 29 12:54:28 2017 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=7e002c40

dev-lang/ghc: apply gentoo dev-libs/libffi patch for alpha

Package-Manager: Portage-2.3.3, Repoman-2.3.1

 dev-lang/ghc/files/ghc-8.0.2-libffi-alpha.patch | 57 +++++++++++++++++++++++++
 dev-lang/ghc/ghc-8.0.2.ebuild                   |  1 +
 2 files changed, 58 insertions(+)

diff --git a/dev-lang/ghc/files/ghc-8.0.2-libffi-alpha.patch b/dev-lang/ghc/files/ghc-8.0.2-libffi-alpha.patch
new file mode 100644
index 00000000..166f7fe
--- /dev/null
+++ b/dev-lang/ghc/files/ghc-8.0.2-libffi-alpha.patch
@@ -0,0 +1,57 @@
+commit 2c220c4b053c8efb2098ee20910084a42a0b2dcd
+Author: Sergei Trofimovich <siarheit@google.com>
+Date:   Sun Jan 29 11:59:36 2017 +0000
+
+    libffi: fix build COMPLEX build failure on alpha
+    
+    libtool: compile:  alpha-unknown-linux-gnu-gcc -DHAVE_CONFIG_H -I. -I.. -I. -I../include -Iinclude \
+        -I../src -I. -I../include -Iinclude -I../src -Wall -w -mieee -D_REENTRANT -fno-stack-protector \
+        -w -MT src/alpha/osf.lo -MMD -MP -MF src/alpha/.deps/osf.Tpo \
+        -c ../src/alpha/osf.S  -fPIC -DPIC -o src/alpha/.libs/osf.o
+    
+      ../src/alpha/osf.S:298:2: error: #error "osf.S out of sync with ffi.h"
+       #error "osf.S out of sync with ffi.h"
+        ^
+    
+    Signed-off-by: Sergei Trofimovich <siarheit@google.com>
+
+diff --git a/libffi/ghc.mk b/libffi/ghc.mk
+index 7c5bc9e1b3..4297ed449e 100644
+--- a/libffi/ghc.mk
++++ b/libffi/ghc.mk
+@@ -63,6 +63,9 @@ $(libffi_STAMP_CONFIGURE): $(TOUCH_DEP)
+ # will use cygwin symbolic links which cannot be read by mingw gcc.
+ 	chmod +x libffi/ln
+ 
++	# fix libffi build failure on alpha
++	( cd libffi/build && "$(PATCH_CMD)" -p0 < ../libffi.3.2.1-complex_alpha.diff; )
++
+ 	# We need to use -MMD rather than -MD, as otherwise we get paths
+ 	# like c:/... in the dependency files on Windows, and the extra
+ 	# colons break make
+diff --git a/libffi/libffi.3.2.1-complex_alpha.diff b/libffi/libffi.3.2.1-complex_alpha.diff
+new file mode 100644
+index 0000000000..0d6e0bc290
+--- /dev/null
++++ b/libffi/libffi.3.2.1-complex_alpha.diff
+@@ -0,0 +1,20 @@
++--- src/alpha/osf.S.orig	2015-01-16 10:46:15.000000000 +0100
+++++ src/alpha/osf.S	2015-01-16 10:46:24.000000000 +0100
++@@ -279,6 +279,7 @@
++ 	.gprel32 $load_64	# FFI_TYPE_SINT64
++ 	.gprel32 $load_none	# FFI_TYPE_STRUCT
++ 	.gprel32 $load_64	# FFI_TYPE_POINTER
+++	.gprel32 $load_none	# FFI_TYPE_COMPLEX
++ 
++ /* Assert that the table above is in sync with ffi.h.  */
++ 
++@@ -294,7 +295,8 @@
++ 	|| FFI_TYPE_SINT64 != 12	\
++ 	|| FFI_TYPE_STRUCT != 13	\
++ 	|| FFI_TYPE_POINTER != 14	\
++-	|| FFI_TYPE_LAST != 14
+++	|| FFI_TYPE_COMPLEX != 15       \
+++	|| FFI_TYPE_LAST != 15
++ #error "osf.S out of sync with ffi.h"
++ #endif
++ 

diff --git a/dev-lang/ghc/ghc-8.0.2.ebuild b/dev-lang/ghc/ghc-8.0.2.ebuild
index 53d6413..e6dc320 100644
--- a/dev-lang/ghc/ghc-8.0.2.ebuild
+++ b/dev-lang/ghc/ghc-8.0.2.ebuild
@@ -452,6 +452,7 @@ src_prepare() {
 		epatch "${FILESDIR}"/${PN}-8.0.1-ww-args-limit.patch
 		epatch "${FILESDIR}"/${PN}-8.0.1-par-g0-on-A32.patch
 		epatch "${FILESDIR}"/${PN}-8.0.2_rc2-old-sphinx.patch
+		epatch "${FILESDIR}"/${PN}-8.0.2-libffi-alpha.patch
 
 		if use prefix; then
 			# Make configure find docbook-xsl-stylesheets from Prefix


^ permalink raw reply related	[flat|nested] 15+ messages in thread
* [gentoo-commits] repo/gentoo:master commit in: dev-lang/ghc/, dev-lang/ghc/files/
@ 2017-01-16  9:50 Sergei Trofimovich
  0 siblings, 0 replies; 15+ messages in thread
From: Sergei Trofimovich @ 2017-01-16  9:50 UTC (permalink / raw
  To: gentoo-commits

commit:     ef416f3d1295dfc8fb4a0638a3c5f0cab4f9bab2
Author:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
AuthorDate: Mon Jan 16 09:45:51 2017 +0000
Commit:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
CommitDate: Mon Jan 16 09:50:00 2017 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=ef416f3d

dev-lang/ghc: bump up to 8.0.2, no KEYWORDS or binaries yet

Package-Manager: Portage-2.3.3, Repoman-2.3.1

 dev-lang/ghc/Manifest                              |   1 +
 dev-lang/ghc/files/ghc-8.0.1-limit-jN.patch        |  50 ++
 dev-lang/ghc/files/ghc-8.0.1-par-g0-on-A32.patch   |  65 ++
 dev-lang/ghc/files/ghc-8.0.1-ww-args-limit.patch   | 127 ++++
 .../ghc/files/ghc-8.0.1_rc1-cgen-constify.patch    |  34 ++
 dev-lang/ghc/files/ghc-8.0.2_rc2-old-sphinx.patch  |  12 +
 dev-lang/ghc/ghc-8.0.2.ebuild                      | 653 +++++++++++++++++++++
 7 files changed, 942 insertions(+)

diff --git a/dev-lang/ghc/Manifest b/dev-lang/ghc/Manifest
index d15ace8..8fd1e4e 100644
--- a/dev-lang/ghc/Manifest
+++ b/dev-lang/ghc/Manifest
@@ -2,6 +2,7 @@ DIST binary-0.7.6.1.tar.gz 47086 SHA256 8f85cafc15be660757878a665d024ce595d4422f
 DIST ghc-7.10.3-src.tar.bz2 13281867 SHA256 3e29a56a74ed6a74d3ee2a6db9389f2462837da46ca6dce9d2965f9c152f0c15 SHA512 97a8282d8a75399c78d85d6faab7ac253a993dc69f1840358572f1878b8fd1a527c28801e5823c8200b5690e268e4a0c00941945ada13790852c75a83b612c17 WHIRLPOOL 04af6ea2738a1cc9e266efbb0e1b41b70d4cd915b48ca1265fade62b1c56cd51056fd1a82fc14cebc19a0c16782609a991c1a181ebe59574f1a10b4f26ad830d
 DIST ghc-7.8.4-ia64-CLOSUREs-regenerated.patch.gz 13268 SHA256 3bdff22e654aee6f942d43edf1bf6cf70404c0152c4fcf89276f10d2c4c5b4b9 SHA512 a655713e06324b56f0041edf70837487e296d28e6f3ee35fe116b9938765aaf3469d25e92645e0940655ed3607dff27d3826fe0f995c84e81b51bfc956816e7d WHIRLPOOL d2cb53bdc6debc0278d554168ea3ab22b0fd8314adac81444637278a92d21b766280fedfb4b7d1b4540c7381c7962dec6b13a799ab2fee4d456fe2875d5c6a5b
 DIST ghc-7.8.4-src.tar.bz2 10600755 SHA256 59e3bd514a1820cc1c03e1808282205c0b8518369acae12645ceaf839e6f114b SHA512 079a53891d8ebd8d9b88da96170e60981608a619f8282e4b7948f35244e99bd87277649ac7fcebc227a61a4d21960db8d5e5b9e92f2c69c82d8d68d7fd0a41d3 WHIRLPOOL a9be7641adbd237ed6e0f644c312e655e98be9566097aee5e2c0022e8756d5b2236e42dd86d76c638a001b5ca3f67307e89ec0cd003a92cd112a5d6d3e3d8467
+DIST ghc-8.0.2-src.tar.xz 10687760 SHA256 11625453e1d0686b3fa6739988f70ecac836cadc30b9f0c8b49ef9091d6118b1 SHA512 58ea3853cd93b556ecdc4abd0be079b2621171b8491f59004ea4e036a4cba4470aaafe6591b942e0a50a64bdc47540e01fe6900212a1ef7087850112d9bfc5ef WHIRLPOOL 5ffd94f797c32c87d9d818acbb1a41f2c140d6f1da169854aab6eece7a41499b55fc573f9a4fbcccf09dcfc92e460d8c91be5efd8650837e8bfba009b04261b1
 DIST ghc-bin-7.10.3-alpha.tbz2 183558856 SHA256 780ac45b9b38fb40f08eeb7dae741649ac19dce2271df4bc764cac9be6c5c225 SHA512 08709fe9b4036ab41715c9a637a2a160104e3ab9e0ed9efaaf73428e3cfe19619e50c42b72c60bbbd27be2b9c2ea68f63d72c1a27d4519756e7c0d909f724230 WHIRLPOOL f488ecc945c6100ba86b9ae25eb6a472693556be0205a6c8634f2c235e779fe17b391ced7fec5d89c0c6c3d21583fe9f9b80bf628f3307890becf3f3ffb57a96
 DIST ghc-bin-7.10.3-amd64.tbz2 112040431 SHA256 c3c71aff288f7de2785d1c3d54f0fd636144eb3dcb590bdda087b0775203e517 SHA512 e1554b3944edbe8e16537de5a29132dc6a22d780d9a700cdc9b76387b94191164398d6f2242bf8199527802572e2bb02545569d4f0930a0ee0dbfdeb25978558 WHIRLPOOL c2497a9565abf7d37e7928f508f7bf7241dd529aa252da708517f9f067e3d016341b7a73cac34888b99c9b84a8d01fd9e8d76f2b332d53e0d708b078f20ee807
 DIST ghc-bin-7.10.3-ia64.tbz2 238680956 SHA256 0da9b5966f0920341f4cf041b814817e1ed06060e8a491481ab19a68153767db SHA512 3694011aec8a6dc37889418b318993cb82f9b46a5175dd837713f396c8f59a19a920e0b0669fe3b4ec37d5bd8837c115264c0a8fc97c5a4ce06a3bdd52fcfce5 WHIRLPOOL 9e059a953607b6477ea7c27bf55175d838c6aa3c57fcf92f13fa6112e9e728037073047be300a5a757395d759d30545546cb46816ec879a2d31c3c0a78868e42

diff --git a/dev-lang/ghc/files/ghc-8.0.1-limit-jN.patch b/dev-lang/ghc/files/ghc-8.0.1-limit-jN.patch
new file mode 100644
index 00000000..dc5410d
--- /dev/null
+++ b/dev-lang/ghc/files/ghc-8.0.1-limit-jN.patch
@@ -0,0 +1,50 @@
+commit 501e05bb1b8974fc8b6c9eee86c87c367e87a211
+Author: Sergei Trofimovich <slyfox@gentoo.org>
+Date:   Tue Aug 30 12:10:47 2016 +0100
+
+    GhcMake: limit Capability count to CPU count in parallel mode
+    
+    In Trac #9221 one of problems using high --jobs=<N>
+    is amount of mutator (or GC) threads we crate.
+    
+    We use userspace spinning-and-yielding (see ACQUIRE_SPIN_LOCK)
+    to acess work stealing queues. In case of
+    N-worker-threads > N-CPUs fraction of time when
+    thread holding spin lock gets descheduled by kernel
+    increases. That causes other threads to waste CPU time
+    before giving up CPU.
+    
+    Signed-off-by: Sergei Trofimovich <siarheit@google.com>
+    
+    Test Plan:
+    ghc --make -j8 and -j80 have comparable sys time
+    on a 8-core system.
+    
+    Reviewers: austin, gintas, bgamari, simonmar
+    
+    Reviewed By: bgamari, simonmar
+    
+    Subscribers: thomie
+    
+    Differential Revision: https://phabricator.haskell.org/D2482
+    
+    GHC Trac Issues: #9221
+
+diff --git a/compiler/main/GhcMake.hs b/compiler/main/GhcMake.hs
+index 9dc43cd..905df63 100644
+--- a/compiler/main/GhcMake.hs
++++ b/compiler/main/GhcMake.hs
+@@ -761,7 +761,12 @@ parUpsweep n_jobs old_hpt stable_mods cleanup sccs = do
+ 
+     let updNumCapabilities = liftIO $ do
+             n_capabilities <- getNumCapabilities
+-            unless (n_capabilities /= 1) $ setNumCapabilities n_jobs
++            n_cpus <- getNumProcessors
++            -- Setting number of capabilities more than
++            -- CPU count usually leads to high userspace
++            -- lock contention. Trac #9221
++            let n_caps = min n_jobs n_cpus
++            unless (n_capabilities /= 1) $ setNumCapabilities n_caps
+             return n_capabilities
+     -- Reset the number of capabilities once the upsweep ends.
+     let resetNumCapabilities orig_n = liftIO $ setNumCapabilities orig_n

diff --git a/dev-lang/ghc/files/ghc-8.0.1-par-g0-on-A32.patch b/dev-lang/ghc/files/ghc-8.0.1-par-g0-on-A32.patch
new file mode 100644
index 00000000..b46e573
--- /dev/null
+++ b/dev-lang/ghc/files/ghc-8.0.1-par-g0-on-A32.patch
@@ -0,0 +1,65 @@
+commit bdfc5375f219d6def81effda4e57cb56d01fc917
+Author: Sergei Trofimovich <slyfox@gentoo.org>
+Date:   Tue Aug 30 12:10:54 2016 +0100
+
+    rts: enable parallel GC scan of large (32M+) allocation area
+    
+    Parallel GC does not scan large allocation area (-A)
+    effectively as it does not do work stealing from nursery
+    by default.
+    
+    That leads to large imbalance when only one of threads
+    overflows allocation area: most of GC threads finish
+    quickly (as there is not much to collect) and sit idle
+    waiting while single GC thread finishes scan of single
+    allocation area for that thread.
+    
+    The patch enables work stealing for (equivalent of -qb0)
+    allocation area of -A32M or higher.
+    
+    Tested on a highlighting-kate package from Trac #9221
+    
+    On 8-core machine the difference is around 5% faster
+    of wall-clock time. On 24-core VM the speedup is 20%.
+    
+    Signed-off-by: Sergei Trofimovich <siarheit@google.com>
+    
+    Test Plan: measured wall time and GC parallelism on highlighting-kate build
+    
+    Reviewers: austin, bgamari, erikd, simonmar
+    
+    Reviewed By: bgamari, simonmar
+    
+    Subscribers: thomie
+    
+    Differential Revision: https://phabricator.haskell.org/D2483
+    
+    GHC Trac Issues: #9221
+
+diff --git a/rts/RtsFlags.c b/rts/RtsFlags.c
+index fda33f0..7a719b9 100644
+--- a/rts/RtsFlags.c
++++ b/rts/RtsFlags.c
+@@ -237,1 +237,1 @@ void initRtsFlagsDefaults(void)
+-    RtsFlags.ParFlags.parGcLoadBalancingGen = 1;
++    RtsFlags.ParFlags.parGcLoadBalancingGen = ~0u; /* auto, based on -A */
+@@ -1398,2 +1390,19 @@ static void normaliseRtsOpts (void)
+     }
+ 
++#ifdef THREADED_RTS
++    if (RtsFlags.ParFlags.parGcLoadBalancingGen == ~0u) {
++        StgWord alloc_area_bytes
++            = RtsFlags.GcFlags.minAllocAreaSize * BLOCK_SIZE;
++
++        // If allocation area is larger that CPU cache
++        // we can finish scanning quicker doing work-stealing
++        // scan. Trac #9221
++        // 32M looks big enough not to fit into L2 cache
++        // of popular modern CPUs.
++        if (alloc_area_bytes >= 32 * 1024 * 1024) {
++            RtsFlags.ParFlags.parGcLoadBalancingGen = 0;
++        } else {
++            RtsFlags.ParFlags.parGcLoadBalancingGen = 1;
++        }
++    }
++#endif

diff --git a/dev-lang/ghc/files/ghc-8.0.1-ww-args-limit.patch b/dev-lang/ghc/files/ghc-8.0.1-ww-args-limit.patch
new file mode 100644
index 00000000..4752f44
--- /dev/null
+++ b/dev-lang/ghc/files/ghc-8.0.1-ww-args-limit.patch
@@ -0,0 +1,127 @@
+commit 5efbf0d243984444cf352ad6f0d147e226c64498
+Author: Sergei Trofimovich <slyfox@gentoo.org>
+Date:   Thu Sep 1 17:34:58 2016 +0100
+
+    restore -fmax-worker-args handling (Trac #11565)
+    
+    maxWorkerArgs handling was accidentally lost 3 years ago
+    in a major update of demand analysis
+        commit 0831a12ea2fc73c33652eeec1adc79fa19700578
+    
+    Old regression is noticeable as:
+    - code bloat (requires stack reshuffling)
+    - compilation slowdown (more code to optimise/generate)
+    - and increased heap usage (DynFlags unboxing/reboxing?)
+    
+    On a simple compile benchmark this change causes heap
+    allocation drop from 70G don to 67G (ghc perf build).
+    
+    Signed-off-by: Sergei Trofimovich <siarheit@google.com>
+    
+    Reviewers: simonpj, ezyang, goldfire, austin, bgamari
+    
+    Reviewed By: simonpj, ezyang
+    
+    Subscribers: thomie
+    
+    Differential Revision: https://phabricator.haskell.org/D2503
+    
+    GHC Trac Issues: #11565
+
+diff --git a/compiler/specialise/SpecConstr.hs b/compiler/specialise/SpecConstr.hs
+index 10d5614..7166f57 100644
+--- a/compiler/specialise/SpecConstr.hs
++++ b/compiler/specialise/SpecConstr.hs
+@@ -29,7 +29,7 @@ import CoreFVs          ( exprsFreeVarsList )
+ import CoreMonad
+ import Literal          ( litIsLifted )
+ import HscTypes         ( ModGuts(..) )
+-import WwLib            ( mkWorkerArgs )
++import WwLib            ( isWorkerSmallEnough, mkWorkerArgs )
+ import DataCon
+ import Coercion         hiding( substCo )
+ import Rules
+@@ -1533,10 +1533,14 @@ specialise env bind_calls (RI { ri_fn = fn, ri_lam_bndrs = arg_bndrs
+ 
+   | Just all_calls <- lookupVarEnv bind_calls fn
+   = -- pprTrace "specialise entry {" (ppr fn <+> ppr (length all_calls)) $
+-    do  { (boring_call, pats) <- callsToPats env specs arg_occs all_calls
+-
++    do  { (boring_call, all_pats) <- callsToPats env specs arg_occs all_calls
+                 -- Bale out if too many specialisations
+-        ; let n_pats      = length pats
++        ; let pats = filter (is_small_enough . fst) all_pats
++              is_small_enough vars = isWorkerSmallEnough (sc_dflags env) vars
++                  -- We are about to construct w/w pair in 'spec_one'.
++                  -- Omit specialisation leading to high arity workers.
++                  -- See Note [Limit w/w arity]
++              n_pats      = length pats
+               spec_count' = n_pats + spec_count
+         ; case sc_count env of
+             Just max | not (sc_force env) && spec_count' > max
+diff --git a/compiler/stranal/WwLib.hs b/compiler/stranal/WwLib.hs
+index 09bc204..d9460d9 100644
+--- a/compiler/stranal/WwLib.hs
++++ b/compiler/stranal/WwLib.hs
+@@ -8,6 +8,7 @@
+ 
+ module WwLib ( mkWwBodies, mkWWstr, mkWorkerArgs
+              , deepSplitProductType_maybe, findTypeShape
++             , isWorkerSmallEnough
+  ) where
+ 
+ #include "HsVersions.h"
+@@ -144,7 +145,8 @@ mkWwBodies dflags fam_envs fun_ty demands res_info one_shots
+               wrapper_body = wrap_fn_args . wrap_fn_cpr . wrap_fn_str . applyToVars work_call_args . Var
+               worker_body = mkLams work_lam_args. work_fn_str . work_fn_cpr . work_fn_args
+ 
+-        ; if useful1 && not (only_one_void_argument) || useful2
++        ; if isWorkerSmallEnough dflags work_args
++             && (useful1 && not only_one_void_argument || useful2)
+           then return (Just (worker_args_dmds, wrapper_body, worker_body))
+           else return Nothing
+         }
+@@ -165,6 +167,12 @@ mkWwBodies dflags fam_envs fun_ty demands res_info one_shots
+       | otherwise
+       = False
+ 
++-- See Note [Limit w/w arity]
++isWorkerSmallEnough :: DynFlags -> [Var] -> Bool
++isWorkerSmallEnough dflags vars = count isId vars <= maxWorkerArgs dflags
++    -- We count only Free variables (isId) to skip Type, Kind
++    -- variables which have no runtime representation.
++
+ {-
+ Note [Always do CPR w/w]
+ ~~~~~~~~~~~~~~~~~~~~~~~~
+@@ -178,6 +186,30 @@ a disaster, because then the enclosing function might say it has the CPR
+ property, but now doesn't and there a cascade of disaster.  A good example
+ is Trac #5920.
+ 
++Note [Limit w/w arity]
++~~~~~~~~~~~~~~~~~~~~~~~~
++Guard against high worker arity as it generates a lot of stack traffic.
++A simplified example is Trac #11565#comment:6
++
++Current strategy is very simple: don't perform w/w transformation at all
++if the result produces a wrapper with arity higher than -fmax-worker-args=.
++
++It is a bit all or nothing, consider
++
++        f (x,y) (a,b,c,d,e ... , z) = rhs
++
++Currently we will remove all w/w ness entirely. But actually we could
++w/w on the (x,y) pair... it's the huge product that is the problem.
++
++Could we instead refrain from w/w on an arg-by-arg basis? Yes, that'd
++solve f. But we can get a lot of args from deeply-nested products:
++
++        g (a, (b, (c, (d, ...)))) = rhs
++
++This is harder to spot on an arg-by-arg basis. Previously mkWwStr was
++given some "fuel" saying how many arguments it could add; when we ran
++out of fuel it would stop w/wing.
++Still not very clever because it had a left-right bias.
+ 
+ ************************************************************************
+ *                                                                      *

diff --git a/dev-lang/ghc/files/ghc-8.0.1_rc1-cgen-constify.patch b/dev-lang/ghc/files/ghc-8.0.1_rc1-cgen-constify.patch
new file mode 100644
index 00000000..877a582
--- /dev/null
+++ b/dev-lang/ghc/files/ghc-8.0.1_rc1-cgen-constify.patch
@@ -0,0 +1,34 @@
+commit b0cf3ab7a69b878a4335d21a347b56e4b0ca0b7b
+Author: Sergei Trofimovich <slyfox@gentoo.org>
+Date:   Mon Apr 14 19:06:24 2014 +0300
+
+    compiler/cmm/PprC.hs: constify local string literals
+    
+    Consider one-line module
+        module B (v) where v = "hello"
+    in -fvia-C mode it generates code like
+        static char gibberish_str[] = "hello";
+    
+    It uselessly eats data section (precious resource on ia64!).
+    The patch switches genrator to emit:
+        static const char gibberish_str[] = "hello";
+    
+    Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
+
+diff --git a/compiler/cmm/PprC.hs b/compiler/cmm/PprC.hs
+index 2398981..fdb578d 100644
+--- a/compiler/cmm/PprC.hs
++++ b/compiler/cmm/PprC.hs
+@@ -112,6 +112,12 @@ pprTop (CmmProc infos clbl _ graph) =
+ 
+ -- We only handle (a) arrays of word-sized things and (b) strings.
+ 
++pprTop (CmmData (Section ReadOnlyData _) (Statics lbl [CmmString str])) =
++  hcat [
++    pprLocalness lbl, ptext (sLit "const char "), ppr lbl,
++    ptext (sLit "[] = "), pprStringInCStyle str, semi
++  ]
++
+ pprTop (CmmData _section (Statics lbl [CmmString str])) =
+   hcat [
+     pprLocalness lbl, ptext (sLit "char "), ppr lbl,

diff --git a/dev-lang/ghc/files/ghc-8.0.2_rc2-old-sphinx.patch b/dev-lang/ghc/files/ghc-8.0.2_rc2-old-sphinx.patch
new file mode 100644
index 00000000..a4d49d3
--- /dev/null
+++ b/dev-lang/ghc/files/ghc-8.0.2_rc2-old-sphinx.patch
@@ -0,0 +1,12 @@
+diff --git a/docs/users_guide/profiling.rst b/docs/users_guide/profiling.rst
+index 4d0bb3a..f980f72 100644
+--- a/docs/users_guide/profiling.rst
++++ b/docs/users_guide/profiling.rst
+@@ -435,7 +435,2 @@ To generate a heap profile from your program:
+ 
+-For example, here is a heap profile produced for the ``sphere`` program
+-from GHC's ``nofib`` benchmark suite,
+-
+-.. image:: images/prof_scc.*
+-
+ You might also want to take a look at

diff --git a/dev-lang/ghc/ghc-8.0.2.ebuild b/dev-lang/ghc/ghc-8.0.2.ebuild
new file mode 100644
index 00000000..2cba08e
--- /dev/null
+++ b/dev-lang/ghc/ghc-8.0.2.ebuild
@@ -0,0 +1,653 @@
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+EAPI=5
+
+# to make make a crosscompiler use crossdev and symlink ghc tree into
+# cross overlay. result would look like 'cross-sparc-unknown-linux-gnu/ghc'
+#
+# 'CTARGET' definition and 'is_crosscompile' are taken from 'toolchain.eclass'
+export CTARGET=${CTARGET:-${CHOST}}
+if [[ ${CTARGET} = ${CHOST} ]] ; then
+	if [[ ${CATEGORY/cross-} != ${CATEGORY} ]] ; then
+		export CTARGET=${CATEGORY/cross-}
+	fi
+fi
+
+inherit autotools bash-completion-r1 eutils flag-o-matic ghc-package
+inherit multilib pax-utils toolchain-funcs versionator prefix
+
+DESCRIPTION="The Glasgow Haskell Compiler"
+HOMEPAGE="http://www.haskell.org/ghc/"
+
+# we don't have any binaries yet
+arch_binaries=""
+
+# sorted!
+#arch_binaries="$arch_binaries alpha? ( http://code.haskell.org/~slyfox/ghc-alpha/ghc-bin-${PV}-alpha.tbz2 )"
+#arch_binaries="$arch_binaries arm? ( http://code.haskell.org/~slyfox/ghc-arm/ghc-bin-${PV}-arm.tbz2 )"
+#arch_binaries="$arch_binaries amd64? ( http://code.haskell.org/~slyfox/ghc-amd64/ghc-bin-${PV}-amd64.tbz2 )"
+#arch_binaries="$arch_binaries ia64?  ( http://code.haskell.org/~slyfox/ghc-ia64/ghc-bin-${PV}-ia64-fixed-fiw.tbz2 )"
+#arch_binaries="$arch_binaries ppc? ( http://code.haskell.org/~slyfox/ghc-ppc/ghc-bin-${PV}-ppc.tbz2 )"
+#arch_binaries="$arch_binaries ppc64? ( http://code.haskell.org/~slyfox/ghc-ppc64/ghc-bin-${PV}-ppc64.tbz2 )"
+#arch_binaries="$arch_binaries sparc? ( http://code.haskell.org/~slyfox/ghc-sparc/ghc-bin-${PV}-sparc.tbz2 )"
+#arch_binaries="$arch_binaries x86? ( http://code.haskell.org/~slyfox/ghc-x86/ghc-bin-${PV}-x86.tbz2 )"
+
+# various ports:
+#arch_binaries="$arch_binaries x86-fbsd? ( http://code.haskell.org/~slyfox/ghc-x86-fbsd/ghc-bin-${PV}-x86-fbsd.tbz2 )"
+
+# 0 - yet
+yet_binary() {
+	case "${ARCH}" in
+		#alpha) return 0 ;;
+		#arm)
+		#	ewarn "ARM binary is built on armv5tel-eabi toolchain. Use with caution."
+		#	return 0
+		#;;
+		#amd64) return 0 ;;
+		#ia64) return 0 ;;
+		#ppc) return 0 ;;
+		#ppc64) return 0 ;;
+		#sparc) return 0 ;;
+		#x86) return 0 ;;
+		*) return 1 ;;
+	esac
+}
+
+GHC_PV=${PV}
+#GHC_PV=8.0.1.20161213 # uncomment only for -rc ebuilds
+GHC_P=${PN}-${GHC_PV} # using ${P} is almost never correct
+
+SRC_URI="!binary? ( http://downloads.haskell.org/~ghc/${PV/_rc/-rc}/${GHC_P}-src.tar.xz )"
+S="${WORKDIR}"/${GHC_P}
+
+[[ -n $arch_binaries ]] && SRC_URI+=" !ghcbootstrap? ( $arch_binaries )"
+
+BUMP_LIBRARIES=(
+	# "hackage-name          hackage-version"
+)
+
+LICENSE="BSD"
+SLOT="0/${PV}"
+#KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux"
+IUSE="doc ghcbootstrap ghcmakebinary +gmp +profile"
+IUSE+=" binary"
+
+RDEPEND="
+	>=dev-lang/perl-5.6.1
+	dev-libs/gmp:0=
+	sys-libs/ncurses:=[unicode]
+	!ghcmakebinary? ( virtual/libffi:= )
+"
+# gentoo binaries are built against ncurses-6
+RDEPEND+="
+	binary? (
+		|| (
+			sys-libs/ncurses:0/6
+			sys-libs/ncurses:5/6
+		)
+	)
+"
+
+DEPEND="${RDEPEND}
+	doc? ( app-text/docbook-xml-dtd:4.2
+		app-text/docbook-xml-dtd:4.5
+		app-text/docbook-xsl-stylesheets
+		dev-python/sphinx
+		>=dev-libs/libxslt-1.1.2 )
+"
+
+PDEPEND="!ghcbootstrap? ( =app-admin/haskell-updater-1.2* )"
+
+REQUIRED_USE="?? ( ghcbootstrap binary )"
+
+# haskell libraries built with cabal in configure mode, #515354
+QA_CONFIGURE_OPTIONS+=" --with-compiler --with-gcc"
+
+is_crosscompile() {
+	[[ ${CHOST} != ${CTARGET} ]]
+}
+
+# returns tool prefix for crosscompiler.
+# Example:
+#  CTARGET=armv7a-unknown-linux-gnueabi
+#  CHOST=x86_64-pc-linux-gnu
+#    "armv7a-unknown-linux-gnueabi-"
+#  CTARGET=${CHOST}
+#    ""
+# Used in tools and library prefix:
+#    "${ED}"/usr/bin/$(cross)haddock
+#    "${ED}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d"
+
+cross() {
+	if is_crosscompile; then
+		echo "${CTARGET}-"
+	else
+		echo ""
+	fi
+}
+
+append-ghc-cflags() {
+	local persistent compile assemble link
+	local flag ghcflag
+
+	for flag in $*; do
+		case ${flag} in
+			persistent)	persistent="yes";;
+			compile)	compile="yes";;
+			assemble)	assemble="yes";;
+			link)		link="yes";;
+			*)
+				[[ ${compile}  ]] && ghcflag="-optc${flag}"  CFLAGS+=" ${flag}" && GHC_FLAGS+=" ${ghcflag}" &&
+					[[ ${persistent} ]] && GHC_PERSISTENT_FLAGS+=" ${ghcflag}"
+				[[ ${assemble} ]] && ghcflag="-opta${flag}"  CFLAGS+=" ${flag}" && GHC_FLAGS+=" ${ghcflag}" &&
+					[[ ${persistent} ]] && GHC_PERSISTENT_FLAGS+=" ${ghcflag}"
+				[[ ${link}     ]] && ghcflag="-optl${flag}" LDFLAGS+=" ${flag}" && GHC_FLAGS+=" ${ghcflag}" &&
+					[[ ${persistent} ]] && GHC_PERSISTENT_FLAGS+=" ${ghcflag}"
+				;;
+		esac
+	done
+}
+
+# $1 - lib name (under libraries/)
+# $2 - lib version
+# example: bump_lib "transformers" "0.4.2.0"
+bump_lib() {
+	local pn=$1 pv=$2
+	local p=${pn}-${pv}
+	local f
+
+	einfo "Bumping ${pn} up to ${pv}"
+
+	for f in ghc.mk GNUmakefile; do
+		mv libraries/"${pn}"/$f "${WORKDIR}"/"${p}"/$f || die
+	done
+	mv libraries/"${pn}" "${WORKDIR}"/"${pn}".old || die
+	mv "${WORKDIR}"/"${p}" libraries/"${pn}" || die
+}
+
+update_SRC_URI() {
+	local p pn pv
+	for p in "${BUMP_LIBRARIES[@]}"; do
+		set -- $p
+		pn=$1 pv=$2
+
+		SRC_URI+=" mirror://hackage/package/${pn}/${pn}-${pv}.tar.gz"
+	done
+}
+
+update_SRC_URI
+
+bump_libs() {
+	local p pn pv
+	for p in "${BUMP_LIBRARIES[@]}"; do
+		set -- $p
+		pn=$1 pv=$2
+
+		bump_lib "${pn}" "${pv}"
+	done
+}
+
+ghc_setup_cflags() {
+	if is_crosscompile; then
+		export CFLAGS=${GHC_CFLAGS-"-O2 -pipe"}
+		export LDFLAGS=${GHC_LDFLAGS-"-Wl,-O1"}
+		einfo "Crosscompiling mode:"
+		einfo "   CHOST:   ${CHOST}"
+		einfo "   CTARGET: ${CTARGET}"
+		einfo "   CFLAGS:  ${CFLAGS}"
+		einfo "   LDFLAGS: ${LDFLAGS}"
+		einfo "   prefix: $(cross)"
+		return
+	fi
+	# We need to be very careful with the CFLAGS we ask ghc to pass through to
+	# gcc. There are plenty of flags which will make gcc produce output that
+	# breaks ghc in various ways. The main ones we want to pass through are
+	# -mcpu / -march flags. These are important for arches like alpha & sparc.
+	# We also use these CFLAGS for building the C parts of ghc, ie the rts.
+	strip-flags
+	strip-unsupported-flags
+
+	# Cmm can't parse line numbers #482086
+	replace-flags -ggdb[3-9] -ggdb2
+
+	GHC_FLAGS=""
+	GHC_PERSISTENT_FLAGS=""
+	for flag in ${CFLAGS}; do
+		case ${flag} in
+
+			# Ignore extra optimisation (ghc passes -O to gcc anyway)
+			# -O2 and above break on too many systems
+			-O*) ;;
+
+			# Arch and ABI flags are what we're really after
+			-m*) append-ghc-cflags compile assemble ${flag};;
+
+			# Sometimes it's handy to see backtrace of RTS
+			# to get an idea what happens there
+			-g*) append-ghc-cflags compile ${flag};;
+
+			# Ignore all other flags, including all -f* flags
+		esac
+	done
+
+	for flag in ${LDFLAGS}; do
+		append-ghc-cflags link ${flag}
+	done
+
+	# hardened-gcc needs to be disabled, because the mangler doesn't accept
+	# its output.
+	gcc-specs-pie && append-ghc-cflags persistent compile link -nopie
+	gcc-specs-ssp && append-ghc-cflags persistent compile      -fno-stack-protector
+
+	# prevent from failind building unregisterised ghc:
+	# http://www.mail-archive.com/debian-bugs-dist@lists.debian.org/msg171602.html
+	use ppc64 && append-ghc-cflags persistent compile -mminimal-toc
+}
+
+# substitutes string $1 to $2 in files $3 $4 ...
+relocate_path() {
+	local from=$1
+	local   to=$2
+	shift 2
+	local file=
+	for file in "$@"
+	do
+		sed -i -e "s|$from|$to|g" \
+			"$file" || die "path relocation failed for '$file'"
+	done
+}
+
+# changes hardcoded ghc paths and updates package index
+# $1 - new absolute root path
+relocate_ghc() {
+	local to=$1
+
+	# libdir for prebuilt binary and for current system may mismatch
+	# It does for prefix installation for example: bug #476998
+	local bin_ghc_prefix=${WORKDIR}/usr
+	local bin_libpath=$(echo "${bin_ghc_prefix}"/lib*)
+	local bin_libdir=${bin_libpath#${bin_ghc_prefix}/}
+
+	# backup original script to use it later after relocation
+	local gp_back="${T}/ghc-pkg-${GHC_PV}-orig"
+	cp "${WORKDIR}/usr/bin/$(cross)ghc-pkg-${GHC_PV}" "$gp_back" || die "unable to backup ghc-pkg wrapper"
+
+	if [[ ${bin_libdir} != $(get_libdir) ]]; then
+		einfo "Relocating '${bin_libdir}' to '$(get_libdir)' (bug #476998)"
+		# moving the dir itself is not strictly needed
+		# but then USE=binary would result in installing
+		# in '${bin_libdir}'
+		mv "${bin_ghc_prefix}/${bin_libdir}" "${bin_ghc_prefix}/$(get_libdir)" || die
+
+		relocate_path "/usr/${bin_libdir}" "/usr/$(get_libdir)" \
+			"${WORKDIR}/usr/bin/$(cross)ghc-${GHC_PV}" \
+			"${WORKDIR}/usr/bin/$(cross)ghci-${GHC_PV}" \
+			"${WORKDIR}/usr/bin/$(cross)ghc-pkg-${GHC_PV}" \
+			"${WORKDIR}/usr/bin/$(cross)hsc2hs" \
+			"${WORKDIR}/usr/bin/$(cross)runghc-${GHC_PV}" \
+			"$gp_back" \
+			"${WORKDIR}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d/"*
+	fi
+
+	# Relocate from /usr to ${EPREFIX}/usr
+	relocate_path "/usr" "${to}/usr" \
+		"${WORKDIR}/usr/bin/$(cross)ghc-${GHC_PV}" \
+		"${WORKDIR}/usr/bin/$(cross)ghci-${GHC_PV}" \
+		"${WORKDIR}/usr/bin/$(cross)ghc-pkg-${GHC_PV}" \
+		"${WORKDIR}/usr/bin/$(cross)hsc2hs" \
+		"${WORKDIR}/usr/bin/$(cross)runghc-${GHC_PV}" \
+		"${WORKDIR}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d/"*
+
+	# this one we will use to regenerate cache
+	# so it should point to current tree location
+	relocate_path "/usr" "${WORKDIR}/usr" "$gp_back"
+
+	if use prefix; then
+		# and insert LD_LIBRARY_PATH entry to EPREFIX dir tree
+		# TODO: add the same for darwin's CHOST and it's DYLD_
+		local new_ldpath='LD_LIBRARY_PATH="'${EPREFIX}/$(get_libdir):${EPREFIX}/usr/$(get_libdir)'${LD_LIBRARY_PATH:+:}${LD_LIBRARY_PATH}"\nexport LD_LIBRARY_PATH'
+		sed -i -e '2i'"$new_ldpath" \
+			"${WORKDIR}/usr/bin/$(cross)ghc-${GHC_PV}" \
+			"${WORKDIR}/usr/bin/$(cross)ghci-${GHC_PV}" \
+			"${WORKDIR}/usr/bin/$(cross)ghc-pkg-${GHC_PV}" \
+			"${WORKDIR}/usr/bin/$(cross)hsc2hs" \
+			"${WORKDIR}/usr/bin/$(cross)runghc-${GHC_PV}" \
+			"$gp_back" \
+			|| die "Adding LD_LIBRARY_PATH for wrappers failed"
+		hprefixify "${bin_libpath}"/${PN}*/settings
+	fi
+
+	# regenerate the binary package cache
+	"$gp_back" recache || die "failed to update cache after relocation"
+	rm "$gp_back"
+}
+
+pkg_setup() {
+	# quiet portage about prebuilt binaries
+	use binary && QA_PREBUILT="*"
+
+	[[ ${MERGE_TYPE} == binary ]] && return
+
+	if use ghcbootstrap; then
+		ewarn "You requested ghc bootstrapping, this is usually only used"
+		ewarn "by Gentoo developers to make binary .tbz2 packages."
+
+		[[ -z $(type -P ghc) ]] && \
+			die "Could not find a ghc to bootstrap with."
+	else
+		if ! yet_binary; then
+			eerror "Please try emerging with USE=ghcbootstrap and report build"
+			eerror "sucess or failure to the haskell team (haskell@gentoo.org)"
+			die "No binary available for '${ARCH}' arch yet, USE=ghcbootstrap"
+		fi
+	fi
+}
+
+src_unpack() {
+	# Create the ${S} dir if we're using the binary version
+	use binary && mkdir "${S}"
+
+	# the Solaris and Darwin binaries from ghc (maeder) need to be
+	# unpacked separately, so prevent them from being unpacked
+	local ONLYA=${A}
+	case ${CHOST} in
+		*-darwin* | *-solaris*)  ONLYA=${GHC_P}-src.tar.bz2  ;;
+	esac
+	unpack ${ONLYA}
+}
+
+src_prepare() {
+	ghc_setup_cflags
+
+	if ! use ghcbootstrap && [[ ${CHOST} != *-darwin* && ${CHOST} != *-solaris* ]]; then
+		# Modify the wrapper script from the binary tarball to use GHC_PERSISTENT_FLAGS.
+		# See bug #313635.
+		sed -i -e "s|\"\$topdir\"|\"\$topdir\" ${GHC_PERSISTENT_FLAGS}|" \
+			"${WORKDIR}/usr/bin/$(cross)ghc-${GHC_PV}"
+
+		# allow hardened users use vanilla binary to bootstrap ghc
+		# ghci uses mmap with rwx protection at it implements dynamic
+		# linking on it's own (bug #299709)
+		pax-mark -m "${WORKDIR}/usr/$(get_libdir)/$(cross)${GHC_P}/bin/ghc"
+	fi
+
+	if use binary; then
+		if use prefix; then
+			relocate_ghc "${EPREFIX}"
+		fi
+
+		# Move unpacked files to the expected place
+		mv "${WORKDIR}/usr" "${S}"
+	else
+		if ! use ghcbootstrap; then
+			case ${CHOST} in
+				*-darwin* | *-solaris*)
+				# UPDATE ME for ghc-7
+				mkdir "${WORKDIR}"/ghc-bin-installer || die
+				pushd "${WORKDIR}"/ghc-bin-installer > /dev/null || die
+				use sparc-solaris && unpack ghc-6.10.4-sparc-sun-solaris2.tar.bz2
+				use x86-solaris && unpack ghc-7.0.3-i386-unknown-solaris2.tar.bz2
+				use x86-macos && unpack ghc-7.4.1-i386-apple-darwin.tar.bz2
+				use x64-macos && unpack ghc-7.4.1-x86_64-apple-darwin.tar.bz2
+				popd > /dev/null
+
+				pushd "${WORKDIR}"/ghc-bin-installer/ghc-[67].?*.? > /dev/null || die
+				# fix the binaries so they run, on Solaris we need an
+				# LD_LIBRARY_PATH which has our prefix libdirs, on
+				# Darwin we need to replace the frameworks with our libs
+				# from the prefix fix before installation, because some
+				# of the tools are actually used during configure/make
+				if [[ ${CHOST} == *-solaris* ]] ; then
+					export LD_LIBRARY_PATH="${EPREFIX}/$(get_libdir):${EPREFIX}/usr/$(get_libdir):${LD_LIBRARY_PATH}"
+				elif [[ ${CHOST} == *-darwin* ]] ; then
+					local readline_framework=GNUreadline.framework/GNUreadline
+					local gmp_framework=/opt/local/lib/libgmp.10.dylib
+					local ncurses_file=/opt/local/lib/libncurses.5.dylib
+					for binary in $(scanmacho -BRE MH_EXECUTE -F '%F' .) ; do
+						install_name_tool -change \
+							${readline_framework} \
+							"${EPREFIX}"/lib/libreadline.dylib \
+							${binary} || die
+						install_name_tool -change \
+							${gmp_framework} \
+							"${EPREFIX}"/usr/lib/libgmp.dylib \
+							${binary} || die
+						install_name_tool -change \
+							${ncurses_file} \
+							"${EPREFIX}"/usr/lib/libncurses.dylib \
+							${binary} || die
+					done
+					# we don't do frameworks!
+					sed -i \
+						-e 's/\(frameworks = \)\["GMP"\]/\1[]/g' \
+						-e 's/\(extraLibraries = \)\["m"\]/\1["m","gmp"]/g' \
+						rts/package.conf.in || die
+				fi
+
+				# it is autoconf, but we really don't want to give it too
+				# much arguments, in fact we do the make in-place anyway
+				./configure --prefix="${WORKDIR}"/usr || die
+				make install || die
+				popd > /dev/null
+				;;
+				*)
+				relocate_ghc "${WORKDIR}"
+				;;
+			esac
+		fi
+
+		sed -i -e "s|\"\$topdir\"|\"\$topdir\" ${GHC_PERSISTENT_FLAGS}|" \
+			"${S}/ghc/ghc.wrapper"
+
+		cd "${S}" # otherwise epatch will break
+
+		epatch "${FILESDIR}"/${PN}-7.0.4-CHOST-prefix.patch
+
+		epatch "${FILESDIR}"/${PN}-8.0.1_rc1-cgen-constify.patch
+		epatch "${FILESDIR}"/${PN}-7.8.3-prim-lm.patch
+
+		epatch "${FILESDIR}"/${PN}-8.0.1-limit-jN.patch
+		epatch "${FILESDIR}"/${PN}-8.0.1-ww-args-limit.patch
+		epatch "${FILESDIR}"/${PN}-8.0.1-par-g0-on-A32.patch
+		epatch "${FILESDIR}"/${PN}-8.0.2_rc2-old-sphinx.patch
+
+		if use prefix; then
+			# Make configure find docbook-xsl-stylesheets from Prefix
+			sed -e '/^FP_DIR_DOCBOOK_XSL/s:\[.*\]:['"${EPREFIX}"'/usr/share/sgml/docbook/xsl-stylesheets/]:' \
+				-i utils/haddock/doc/configure.ac || die
+		fi
+
+		bump_libs
+
+		# as we have changed the build system
+		eautoreconf
+	fi
+}
+
+src_configure() {
+	if ! use binary; then
+		# initialize build.mk
+		echo '# Gentoo changes' > mk/build.mk
+
+		# Put docs into the right place, ie /usr/share/doc/ghc-${GHC_PV}
+		echo "docdir = ${EPREFIX}/usr/share/doc/${P}" >> mk/build.mk
+		echo "htmldir = ${EPREFIX}/usr/share/doc/${P}" >> mk/build.mk
+
+		# We also need to use the GHC_FLAGS flags when building ghc itself
+		echo "SRC_HC_OPTS+=${HCFLAGS} ${GHC_FLAGS}" >> mk/build.mk
+		echo "SRC_CC_OPTS+=${CFLAGS}" >> mk/build.mk
+		echo "SRC_LD_OPTS+=${LDFLAGS}" >> mk/build.mk
+		# Speed up initial Cabal bootstrap
+		echo "utils/ghc-cabal_dist_EXTRA_HC_OPTS+=$(ghc-make-args)" >> mk/build.mk
+
+		# We can't depend on haddock except when bootstrapping when we
+		# must build docs and include them into the binary .tbz2 package
+		# app-text/dblatex is not in portage, can not build PDF or PS
+		echo "BUILD_SPHINX_PDF  = NO"  >> mk/build.mk
+		echo "BUILD_SPHINX_HTML = $(usex doc YES NO)" >> mk/build.mk
+
+		# this controls presence on 'xhtml' and 'haddock' in final install
+		echo "HADDOCK_DOCS       = YES" >> mk/build.mk
+
+		# allows overriding build flavours for libraries:
+		# v   - vanilla (static libs)
+		# p   - profiled
+		# dyn - shared libraries
+		# example: GHC_LIBRARY_WAYS="v dyn"
+		if [[ -n ${GHC_LIBRARY_WAYS} ]]; then
+			echo "GhcLibWays=${GHC_LIBRARY_WAYS}" >> mk/build.mk
+		fi
+		echo "BUILD_PROF_LIBS = $(usex profile YES NO)" >> mk/build.mk
+
+		# Get ghc from the unpacked binary .tbz2
+		# except when bootstrapping we just pick ghc up off the path
+		if ! use ghcbootstrap; then
+			export PATH="${WORKDIR}/usr/bin:${PATH}"
+		fi
+
+		echo "INTEGER_LIBRARY = $(usex gmp integer-gmp integer-simple)" >> mk/build.mk
+
+		# don't strip anything. Very useful when stage2 SIGSEGVs on you
+		echo "STRIP_CMD = :" >> mk/build.mk
+
+		local econf_args=()
+
+		# GHC embeds 'gcc' it was built by and uses it later.
+		# Don't allow things like ccache or versioned binary slip.
+		# We use stable thing across gcc upgrades.
+		is_crosscompile || econf_args+=(--with-gcc=${CHOST}-gcc)
+
+		if use ghcmakebinary; then
+			# When building booting libary we are trying to
+			# bundle or restrict most of external depends
+			# with unstable ABI:
+			#  - embed libffi (default GHC behaviour)
+			#  - disable ncurses support for ghci (via haskeline)
+			#    https://bugs.gentoo.org/557478
+			#  - disable ncurses support for ghc-pkg
+			echo "libraries/haskeline_CONFIGURE_OPTS += --flag=-terminfo" >> mk/build.mk
+			echo "utils/ghc-pkg_HC_OPTS += -DBOOTSTRAPPING" >> mk/build.mk
+		else
+			econf_args+=(--with-system-libffi)
+			econf_args+=(--with-ffi-includes=$(pkg-config libffi --cflags-only-I | sed -e 's@^-I@@'))
+		fi
+
+		elog "Final mk/build.mk:"
+		cat mk/build.mk || die
+
+		econf ${econf_args[@]} --enable-bootstrap-with-devel-snapshot
+
+		if [[ ${PV} == *9999* ]]; then
+			GHC_PV="$(grep 'S\[\"PACKAGE_VERSION\"\]' config.status | sed -e 's@^.*=\"\(.*\)\"@\1@')"
+			GHC_P=${PN}-${GHC_PV}
+		fi
+	fi # ! use binary
+}
+
+src_compile() {
+	if ! use binary; then
+		# 1. build/pax-mark compiler binary first
+		emake ghc/stage2/build/tmp/ghc-stage2
+		pax-mark -m ghc/stage2/build/tmp/ghc-stage2
+		# 2. build/pax-mark haddock using ghc-stage2
+		emake utils/haddock/dist/build/tmp/haddock
+		pax-mark -m utils/haddock/dist/build/tmp/haddock
+		# 3. and then all the rest
+		emake all
+	fi # ! use binary
+}
+
+src_install() {
+	if use binary; then
+		use prefix && mkdir -p "${ED}"
+		mv "${S}/usr" "${ED}"
+	else
+
+		emake install DESTDIR="${D}"
+		dodoc "distrib/README" "ANNOUNCE" "LICENSE" "VERSION"
+
+		# rename ghc-shipped files to avoid collision
+		# of external packages. Motivating example:
+		#  user had installed:
+		#      dev-lang/ghc-7.8.4-r0 (with transformers-0.3.0.0)
+		#      dev-haskell/transformers-0.4.2.0
+		#  then user tried to update to
+		#      dev-lang/ghc-7.8.4-r1 (with transformers-0.4.2.0)
+		#  this will lead to single .conf file collision.
+		local shipped_conf renamed_conf
+		local package_confdir="${ED}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d"
+		for shipped_conf in "${package_confdir}"/*.conf; do
+			# rename 'pkg-ver-id.conf' to 'pkg-ver-id-gentoo-${PF}.conf'
+			renamed_conf=${shipped_conf%.conf}-gentoo-${PF}.conf
+			mv "${shipped_conf}" "${renamed_conf}" || die
+		done
+
+		# remove link, but leave 'haddock-${GHC_P}'
+		rm -f "${ED}"/usr/bin/$(cross)haddock
+
+		if [[ ! -f "${S}/VERSION" ]]; then
+			echo "${GHC_PV}" > "${S}/VERSION" \
+				|| die "Could not create file ${S}/VERSION"
+		fi
+		if ! is_crosscompile; then
+			newbashcomp "${FILESDIR}"/ghc-bash-completion ghc-pkg
+			newbashcomp utils/completion/ghc.bash         ghc
+		fi
+	fi
+
+	# path to the package.cache
+	local package_confdir="${ED}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d"
+	PKGCACHE="${package_confdir}"/package.cache
+	# copy the package.conf.d, including timestamp, save it so we can help
+	# users that have a broken package.conf.d
+	cp -pR "${package_confdir}"{,.initial} || die "failed to backup intial package.conf.d"
+
+	# copy the package.conf, including timestamp, save it so we later can put it
+	# back before uninstalling, or when upgrading.
+	cp -p "${PKGCACHE}"{,.shipped} \
+		|| die "failed to copy package.conf.d/package.cache"
+}
+
+pkg_preinst() {
+	# have we got an earlier version of ghc installed?
+	if has_version "<${CATEGORY}/${PF}"; then
+		haskell_updater_warn="1"
+	fi
+}
+
+pkg_postinst() {
+	ghc-reregister
+
+	# path to the package.cache
+	PKGCACHE="${EROOT}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d/package.cache"
+
+	# give the cache a new timestamp, it must be as recent as
+	# the package.conf.d directory.
+	touch "${PKGCACHE}"
+
+	if [[ "${haskell_updater_warn}" == "1" ]]; then
+		ewarn
+		ewarn "\e[1;31m************************************************************************\e[0m"
+		ewarn
+		ewarn "You have just upgraded from an older version of GHC."
+		ewarn "You may have to run"
+		ewarn "      'haskell-updater'"
+		ewarn "to rebuild all ghc-based Haskell libraries."
+		ewarn
+		ewarn "\e[1;31m************************************************************************\e[0m"
+		ewarn
+	fi
+}
+
+pkg_prerm() {
+	PKGCACHE="${EROOT}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d/package.cache"
+	rm -rf "${PKGCACHE}"
+
+	cp -p "${PKGCACHE}"{.shipped,}
+}
+
+pkg_postrm() {
+	ghc-package_pkg_postrm
+}


^ permalink raw reply related	[flat|nested] 15+ messages in thread
* [gentoo-commits] repo/gentoo:master commit in: dev-lang/ghc/, dev-lang/ghc/files/
@ 2016-03-15 22:01 Sergei Trofimovich
  0 siblings, 0 replies; 15+ messages in thread
From: Sergei Trofimovich @ 2016-03-15 22:01 UTC (permalink / raw
  To: gentoo-commits

commit:     39a2ed4121c53aafd5a1178bb8f1526f8f71608a
Author:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
AuthorDate: Tue Mar 15 21:53:39 2016 +0000
Commit:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
CommitDate: Tue Mar 15 22:01:32 2016 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=39a2ed41

dev-lang/ghc: bump up to 7.10.3, added binaries for x86, amd64

Package-Manager: portage-2.2.28

 dev-lang/ghc/Manifest                         |   5 +
 dev-lang/ghc/files/ghc-7.10.3-hardfloat.patch |  26 +
 dev-lang/ghc/files/ghc-7.10.3-relnotes.patch  |  45 ++
 dev-lang/ghc/ghc-7.10.3.ebuild                | 672 ++++++++++++++++++++++++++
 4 files changed, 748 insertions(+)

diff --git a/dev-lang/ghc/Manifest b/dev-lang/ghc/Manifest
index 2b1151c..1f076a7 100644
--- a/dev-lang/ghc/Manifest
+++ b/dev-lang/ghc/Manifest
@@ -1,5 +1,7 @@
 DIST binary-0.7.5.0.tar.gz 45764 SHA256 4709c5aa7cc99cb4a465a68de1648968208d0c60c368e2fece476d977530ef19 SHA512 232e7c3da1c0055f3e9f211a86e81c76bc44ab1b70cabd23c93634dbaa42eed8bd9314fbedc16b9703d3ca92b0bbf232e6c30bb1384687dad0e6e85c9abb8947 WHIRLPOOL 1d8dcf9d5125ff398375f4024c0e43fa168004811db7824e2739ec5c0451b38dae9ad74f757c7708427deed0044580b182e35d1c7ecffec25f7b10c70bd32075
+DIST binary-0.7.6.1.tar.gz 47086 SHA256 8f85cafc15be660757878a665d024ce595d4422fead174e20a501c9ec8f81067 SHA512 655daa93a52b845a85d440810452933d7bc3398ad1b51e1e955b2d19a0a32679325a0d1751ad50d252531e493528262e14dab32af4b9a515855fe7f64e0730b2 WHIRLPOOL 6853eb2c817e8ae792226c6c7764ce495833f965c3d503fe7e39c0502019d12f7bd46309b72dfdb276c7dbce8c004cb59fdea4936d69ede0a7c8b487acda2702
 DIST ghc-7.10.2-src.tar.bz2 12651156 SHA256 908a01ca86238318f4e880fda400ea399d0a0008d699c912b85d0e0f746e5689 SHA512 e3f99a9e848c12b728212da24bf9029ec8cde88cdfa7eeb4ee2ea223ad8bcaae3e7c27456d09d60a3d21efa8f907ccd2490caf5630ca5fe3ce87f04901275a66 WHIRLPOOL dee757e79de8ac6bcf127212703985282ce96d050be50e78c3f249f13dc0212c9fd96899502748ceb26b9fc3a804379a456e19a9bedfef72f6890992b00492da
+DIST ghc-7.10.3-src.tar.bz2 13281867 SHA256 3e29a56a74ed6a74d3ee2a6db9389f2462837da46ca6dce9d2965f9c152f0c15 SHA512 97a8282d8a75399c78d85d6faab7ac253a993dc69f1840358572f1878b8fd1a527c28801e5823c8200b5690e268e4a0c00941945ada13790852c75a83b612c17 WHIRLPOOL 04af6ea2738a1cc9e266efbb0e1b41b70d4cd915b48ca1265fade62b1c56cd51056fd1a82fc14cebc19a0c16782609a991c1a181ebe59574f1a10b4f26ad830d
 DIST ghc-7.4.2-src.tar.bz2 25836446 SHA256 f2ee1289a33cc70539287129841acc7eaf16112bb60c59b5a6ee91887bfd836d SHA512 5a3d06a36702fa7e337b482c9de92ce1f84a68f18d8560bcc11f3617d6d46f93167fee27e786de6483a9ef0eab3b1ac6909a71dd53908d36156df4e465075050 WHIRLPOOL 61865eed2bf92728e7c4c4a0c48be44081bf728cfd824760d643e2fad838d96c19e173052d3aac073e0795b5efa3720ba5ddf13cca1ec7952b7524bbe1f204bc
 DIST ghc-7.6.3-src.tar.bz2 110763823 SHA256 bd43823d31f6b5d0b2ca7b74151a8f98336ab0800be85f45bb591c9c26aac998 SHA512 ac86f18b4feeb0bdc9e867261600b210caf62740d73ae657259bbe8149b8c2c4f5a73d09d74d944d4e50f85cc87503485365f0a0ae65befe8d2b6844e5e1253a WHIRLPOOL 0fe1f5f2987699067494559e6a679d28f027eee8fb2a00c683161dbce5443b1faeebfb51572209b75231cee24c7f0c929cabbc82a93f70e16d05e351fdfe2eaf
 DIST ghc-7.8.3-src.tar.xz 9160092 SHA256 b0cd96a549ba3b5e512847a4a8cd1a3174e4b2b75dadfc41c568fb812887b958 SHA512 2cc8c2aa6f18ba565c1e2aa637045e246f1214c2a77e95c2a97dfb97203b8983e4ad3cc13178b4b51aff70c58d59a1f68f94cd813d043745cb02411bad04bb00 WHIRLPOOL 3a2e8eea0db7a150e4732efed488a3a5eb56da00a9a90a3379afcb4090323925a2a7485fec6676e784139f112d7c825e8d18a576c34c760af4a7f3adb22c021a
@@ -9,6 +11,8 @@ DIST ghc-bin-7.10.2-amd64.tbz2 112028560 SHA256 536297ac402da44ec1aafb1a93796088
 DIST ghc-bin-7.10.2-r1-amd64-noncurses.tbz2 111863814 SHA256 782a68a13343ac8d6ed97540b411f714c4e826ccc3d152724198548c9240aceb SHA512 b154dbd7fb4fefc4283ec337b0c6ce6b6b6b3a62e9d889ca9c5dd5b5e5987f811a1c87845239ca94941afea630fc8bf1d8db94eb11a4023abd4b1d772dfb17c1 WHIRLPOOL 1e1f1ec82c831d115cd5f0b27f1914da94d92a9eca9af634210eb5f72b54281de6e08ea8e304bebaec8a456659b40866b9f0e24ef0e72c3f5a63d85296eb172a
 DIST ghc-bin-7.10.2-r1-x86-noncurses.tbz2 113572461 SHA256 3ad1e2888d26b6858cd1efe0e9863bc325b97c47be19fdd2e8dd5bbc86f7266b SHA512 573b7228b576a47ca1c3796cc2d4180a6c9dcaff58555cf52fc85a9b487920fc19487ff9ee8e0b6c33d6196ba05b9908f0d984bf3a4c0d91f52667e7389580a5 WHIRLPOOL 2c8cda95d04e9f345aa2f20fe8758761dd35648b788b7bf9b8f571687a8aae92456552883684d83ec2d2acaf22a002121643316df3c82349400c7de3d0300f7d
 DIST ghc-bin-7.10.2-x86.tbz2 113900477 SHA256 eefb7a3002e3dcdd6d936b2b2826eadf3cd100352babad4c9a355b944064240a SHA512 61dae4b9c80bfef6b1e0550c77b70f25d11f4a9fbe3b57d6c4ad451b4b584884432405d39dc32b9f85f3a5ad9d02657356ae0ebd99518848f3d330314c74b595 WHIRLPOOL da0d7eb62d2ee2aeb80a3f495da2ff123e29151b7517fbcd212f83ab3722638f10019511f4f237e8e001c68dd957ed2817fb0f1a2b42c2710239343f1d801496
+DIST ghc-bin-7.10.3-amd64.tbz2 112040431 SHA256 c3c71aff288f7de2785d1c3d54f0fd636144eb3dcb590bdda087b0775203e517 SHA512 e1554b3944edbe8e16537de5a29132dc6a22d780d9a700cdc9b76387b94191164398d6f2242bf8199527802572e2bb02545569d4f0930a0ee0dbfdeb25978558 WHIRLPOOL c2497a9565abf7d37e7928f508f7bf7241dd529aa252da708517f9f067e3d016341b7a73cac34888b99c9b84a8d01fd9e8d76f2b332d53e0d708b078f20ee807
+DIST ghc-bin-7.10.3-x86.tbz2 113877175 SHA256 a06d54e7256292123b49c4d429761794b53d2440d2efeb98bcfe79920c65b044 SHA512 75096fe9106d975c15e646b0a559c544621fd02791f491bce54926efabf0e55b97150069ddfa7a9f02cc30bb6975d3d3121a82207a9f67b8dda5ebfe17ec4744 WHIRLPOOL 63fea83be14ae317f313251b7c952c974a8e4f9671d78d1b3ef77c3ab317d2194faddc8d71431c5e1fc42215abed1842913f2f40ba383288784e984c47cd27f0
 DIST ghc-bin-7.4.2-alpha.tbz2 130483507 SHA256 cd8e72e569574f137bf10fcdb4337bb0dc320deb2a2c4d72529a821735c53ae6 SHA512 6fb99dea706965afa60f4aeb68da3da1c69dda477f5fcfb4e67b73d75b78583193148ce9f623a356679a57f1a740f8010f28a22f08e56ace50f3fcd42142f83f WHIRLPOOL e5ec69ab24dc963ac709f13928c0e35931d5d50ca6b21dfb0aa79f9088c0ce1196b64bb4d9668e35d73dcdf9e2df9c3da59c95eaf3db8b793a6bb65b1f4ba6c0
 DIST ghc-bin-7.4.2-amd64-stable-glibc.tbz2 93139900 SHA256 f06dff00585cc1a8ecc8ac29aeca7fdc601d272eed29d7613f7a2f2924cad585 SHA512 9b725f2613dd9013851a16eaea4000ea424c51cbafa97d3860f120fdb9936247f8c65208775a80a2f49b74946ddda2e843a54dec00b78c521197374aa3dd2d50 WHIRLPOOL 9e2630b1de40a059c324be38a1fe68b16ea484bc7afc2a397ea05192263d1964aed1d29fde543622ceab12ed2df111204576fdc72b7e35b2bbf9c6b9519901d1
 DIST ghc-bin-7.4.2-ia64.tbz2 155787636 SHA256 a1d89221645832cc5d11cde4937cce75d564e6a79eba334b92a4c465eb3f161f SHA512 c7138ed8eaf40ee7e7559b6063096351b64fc35cbd1adb4c734b2f2c6b77fb98368b1296fcb67c1a0b21b0faf053a82f8f98c3656b89c593e677ce78165d0c74 WHIRLPOOL 7ff2db2932a6d56961dcca386c9ec8f8eb1ee12e1b84230fbb089ff137eeb216117eecaa37b33b4c037ebee0063a07cd380077b754e64ef0219759b54a4f7fe2
@@ -33,4 +37,5 @@ DIST ghc-bin-7.8.4-ppc64.tbz2 129284515 SHA256 1e8a350af39d1db1e58a74c9bc4a4c577
 DIST ghc-bin-7.8.4-sparc.tbz2 147340595 SHA256 1cde749ce3c47016c5c7a7179423d0aa2b174ddae4af0392ae3b7f57b098ec0c SHA512 ee5f0b2f1cf2693a0f2be9df71ef61b52bc2327225d40b8be955c1584b9901ffc6aaab63c1e46bf9bb352633b605c98378f8fd3e6cd71aef1c089007e4110217 WHIRLPOOL 27d55a016ffb49852553f920c29929c3bdf383e28b4b806ceb9ffc8b46a59b438801101402e498b069aa6eb56870b70a00ba7b1f4098f3fd8d8ddf1b20caa626
 DIST ghc-bin-7.8.4-x86.tbz2 102312459 SHA256 4c53148836e5a1ba55b8db5bb7c3eb915103e0955fb503b2facdc5a72f12a974 SHA512 cabc5bd6d8760ce4120e7053f6c1dffca7d161ba454b6201087760096c037c932e3ff8c82e53346c8278855bf0cff1c2f5fb8046242ca4d8307355b060a9556e WHIRLPOOL 0171d67dc1b63381a491e1577a783eb0e8f53cb579ba96a9b4fdf6685d494d78eb2be780f77ff33422d3b7c320ed102d9b48f6e954f8fee5532982575001a4a5
 DIST hoopl-3.10.1.0.tar.gz 241582 SHA256 7af615dfd4051670dccf31e5a7e1e71a9ae5f301e6a0668557fd84f61f6bc2d4 SHA512 943fe7034c89f4f914617cf1bccf7f66c3e660328fbbd9ae40f78a3f78a4a5b6fdd86c2afd40c11d4c4c4a34bc8fd47ab7e6227cdf9f3f4887b5cc796720e7aa WHIRLPOOL 3a410081f70c4ebbb563a48d71ec6f1e226a13b965ea12d01ca521b32041308394c7da6d3b3e36e75d1322c188b81fc08f4b2bf6037df5d8ac4998a944326be2
+DIST hoopl-3.10.2.0.tar.gz 241940 SHA256 6740814c774e51815e8260ae1b4ac8af6ab69f02e112904450f689c4792f1121 SHA512 083baa8a5eb53247aff8d5b9b2144e0f63adb9400934297bbd80bfcec607dd90a34def4301045a60472ef10b0fb90ab84692fc08f786e7f806c28afdab1ef66a WHIRLPOOL 761e7440d2bc32b594ab55ea967c5b075bb638b2fdba6606beaf9c31a90e20031e914146828004b3d11203668210a6994be9fabc3b0ebb428d516b57cae9ee68
 DIST transformers-0.4.3.0.tar.gz 28632 SHA256 b3d0a797e815ca50d411e20c02f781efe7751308007d880af7f0b5c4365c3a9d SHA512 c3ec0893ebba4fbd6087c3202e919552c4a9bff3350b5c0589e7ebb18751a515d98b8cac15b0a3252906ea72b5a0eb09b7fe88c8da88b09d6ce4fbf0f50b2780 WHIRLPOOL 89591781926b1d025056dedcfc5de61705056c1e3a8eba72f2e89789e78d2ed4d8909f84d6560dfc66bc0b360f98cb3dc3835f3a05c2325f747498373c88aa4b

diff --git a/dev-lang/ghc/files/ghc-7.10.3-hardfloat.patch b/dev-lang/ghc/files/ghc-7.10.3-hardfloat.patch
new file mode 100644
index 0000000..106d07a
--- /dev/null
+++ b/dev-lang/ghc/files/ghc-7.10.3-hardfloat.patch
@@ -0,0 +1,26 @@
+commit 5cc08ebf2f346992a0abd4440252165c90b5ec05
+Author: Sergei Trofimovich <siarheit@google.com>
+Date:   Sat Jun 20 12:23:00 2015 +0100
+
+    Recognise 'hardhloat' as a valid vendor in a host tuple
+    
+    Observed on a tuple armv7a-hardfloat-linux-gnueabi:
+    > Unknown vendor hardfloat
+    
+    Reported-by: Sergey Alirzaev
+    Signed-off-by: Sergei Trofimovich <siarheit@google.com>
+
+diff --git a/aclocal.m4 b/aclocal.m4
+index 590edb0..958622c 100644
+--- a/aclocal.m4
++++ b/aclocal.m4
+@@ -1966,6 +1966,9 @@ AC_DEFUN([GHC_CONVERT_VENDOR],[
+   softfloat) # like armv5tel-softfloat-linux-gnueabi
+     $2="unknown"
+     ;;
++  hardfloat) # like armv7a-hardfloat-linux-gnueabi
++    $2="unknown"
++    ;;
+   *)
+     #pass thru by default
+     $2="$1"

diff --git a/dev-lang/ghc/files/ghc-7.10.3-relnotes.patch b/dev-lang/ghc/files/ghc-7.10.3-relnotes.patch
new file mode 100644
index 0000000..6750379
--- /dev/null
+++ b/dev-lang/ghc/files/ghc-7.10.3-relnotes.patch
@@ -0,0 +1,45 @@
+diff --git a/ANNOUNCE b/ANNOUNCE
+index 7812eba..0018b37 100644
+--- a/ANNOUNCE
++++ b/ANNOUNCE
+@@ -1,6 +1,6 @@
+ 
+    ==============================================================
+-    The (Interactive) Glasgow Haskell Compiler -- version 7.10.2
++    The (Interactive) Glasgow Haskell Compiler -- version 7.10.3
+    ==============================================================
+ 
+ The GHC Team is pleased to announce a new minor release of GHC. This is a
+@@ -29,7 +29,7 @@ bug-fix release and contains a number of important fixes,
+ A more thorough list of the changes in the release can be found in the release
+ notes,
+ 
+-  http://haskell.org/ghc/docs/7.10.2/html/users_guide/release-7-10-2.html
++  http://haskell.org/ghc/docs/7.10.3/html/users_guide/release-7-10-3.html
+ 
+ 
+ How to get it
+diff --git a/docs/users_guide/intro.xml b/docs/users_guide/intro.xml
+index 3292334..fb7116e 100644
+--- a/docs/users_guide/intro.xml
++++ b/docs/users_guide/intro.xml
+@@ -309,6 +309,7 @@
+ 
+ &relnotes1;
+ &relnotes2;
++&relnotes3;
+ 
+ </chapter>
+ 
+diff --git a/docs/users_guide/ug-ent.xml.in b/docs/users_guide/ug-ent.xml.in
+index b696aad..3629e93 100644
+--- a/docs/users_guide/ug-ent.xml.in
++++ b/docs/users_guide/ug-ent.xml.in
+@@ -5,6 +5,7 @@
+ <!ENTITY intro          SYSTEM "intro.xml" >
+ <!ENTITY relnotes1      SYSTEM "7.10.1-notes.xml" >
+ <!ENTITY relnotes2      SYSTEM "7.10.2-notes.xml" >
++<!ENTITY relnotes3      SYSTEM "7.10.3-notes.xml" >
+ <!ENTITY using          SYSTEM "using.xml" >
+ <!ENTITY code-gens      SYSTEM "codegens.xml" >
+ <!ENTITY runtime        SYSTEM "runtime_control.xml" >

diff --git a/dev-lang/ghc/ghc-7.10.3.ebuild b/dev-lang/ghc/ghc-7.10.3.ebuild
new file mode 100644
index 0000000..d05233d
--- /dev/null
+++ b/dev-lang/ghc/ghc-7.10.3.ebuild
@@ -0,0 +1,672 @@
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+EAPI=5
+
+# to make make a crosscompiler use crossdev and symlink ghc tree into
+# cross overlay. result would look like 'cross-sparc-unknown-linux-gnu/ghc'
+#
+# 'CTARGET' definition and 'is_crosscompile' are taken from 'toolchain.eclass'
+export CTARGET=${CTARGET:-${CHOST}}
+if [[ ${CTARGET} = ${CHOST} ]] ; then
+	if [[ ${CATEGORY/cross-} != ${CATEGORY} ]] ; then
+		export CTARGET=${CATEGORY/cross-}
+	fi
+fi
+
+inherit autotools bash-completion-r1 eutils flag-o-matic ghc-package
+inherit multilib pax-utils toolchain-funcs versionator
+
+DESCRIPTION="The Glasgow Haskell Compiler"
+HOMEPAGE="http://www.haskell.org/ghc/"
+
+# we don't have any binaries yet
+arch_binaries=""
+
+# sorted!
+#arch_binaries="$arch_binaries alpha? ( http://code.haskell.org/~slyfox/ghc-alpha/ghc-bin-${PV}-alpha.tbz2 )"
+#arch_binaries="$arch_binaries arm? ( http://code.haskell.org/~slyfox/ghc-arm/ghc-bin-${PV}-arm.tbz2 )"
+arch_binaries="$arch_binaries amd64? ( http://code.haskell.org/~slyfox/ghc-amd64/ghc-bin-${PVR}-amd64.tbz2 )"
+#arch_binaries="$arch_binaries ia64?  ( http://code.haskell.org/~slyfox/ghc-ia64/ghc-bin-${PV}-ia64-fixed-fiw.tbz2 )"
+#arch_binaries="$arch_binaries ppc? ( http://code.haskell.org/~slyfox/ghc-ppc/ghc-bin-${PV}-ppc.tbz2 )"
+#arch_binaries="$arch_binaries ppc64? ( http://code.haskell.org/~slyfox/ghc-ppc64/ghc-bin-${PV}-ppc64.tbz2 )"
+#arch_binaries="$arch_binaries sparc? ( http://code.haskell.org/~slyfox/ghc-sparc/ghc-bin-${PV}-sparc.tbz2 )"
+arch_binaries="$arch_binaries x86? ( http://code.haskell.org/~slyfox/ghc-x86/ghc-bin-${PVR}-x86.tbz2 )"
+
+# various ports:
+#arch_binaries="$arch_binaries x86-fbsd? ( http://code.haskell.org/~slyfox/ghc-x86-fbsd/ghc-bin-${PV}-x86-fbsd.tbz2 )"
+
+# 0 - yet
+yet_binary() {
+	case "${ARCH}" in
+		#alpha) return 0 ;;
+		#arm)
+		#	ewarn "ARM binary is built on armv5tel-eabi toolchain. Use with caution."
+		#	return 0
+		#;;
+		amd64) return 0 ;;
+		#ia64) return 0 ;;
+		#ppc) return 0 ;;
+		#ppc64) return 0 ;;
+		#sparc) return 0 ;;
+		x86) return 0 ;;
+		*) return 1 ;;
+	esac
+}
+
+GHC_PV=${PV}
+#GHC_PV=7.10.2.20151030 # uncomment only for -rc ebuilds
+GHC_P=${PN}-${GHC_PV} # using ${P} is almost never correct
+
+SRC_URI="!binary? ( http://downloads.haskell.org/~ghc/${PV/_rc/-rc}/${GHC_P}-src.tar.bz2 )"
+S="${WORKDIR}"/${GHC_P}
+
+[[ -n $arch_binaries ]] && SRC_URI+=" !ghcbootstrap? ( $arch_binaries )"
+
+BUMP_LIBRARIES=(
+	# "hackage-name          hackage-version"
+	"binary                  0.7.6.1"
+	"hoopl                   3.10.2.0"
+	"transformers            0.4.3.0"
+)
+
+LICENSE="BSD"
+SLOT="0/${PV}"
+KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux"
+IUSE="doc ghcbootstrap ghcmakebinary +gmp"
+IUSE+=" binary"
+IUSE+=" elibc_glibc" # system stuff
+
+RDEPEND="
+	>=dev-lang/perl-5.6.1
+	>=dev-libs/gmp-5:=
+	sys-libs/ncurses:=[unicode]
+	!ghcmakebinary? ( virtual/libffi:= )
+	!kernel_Darwin? ( >=sys-devel/gcc-2.95.3:* )
+	kernel_linux? ( >=sys-devel/binutils-2.17:* )
+	kernel_SunOS? ( >=sys-devel/binutils-2.17:* )
+"
+
+# force dependency on >=gmp-5, even if >=gmp-4.1 would be enough. this is due to
+# that we want the binaries to use the latest versioun available, and not to be
+# built against gmp-4
+
+# similar for glibc. we have bootstrapped binaries against glibc-2.17
+DEPEND="${RDEPEND}
+	doc? ( app-text/docbook-xml-dtd:4.2
+		app-text/docbook-xml-dtd:4.5
+		app-text/docbook-xsl-stylesheets
+		>=dev-libs/libxslt-1.1.2 )
+	!ghcbootstrap? ( !prefix? ( elibc_glibc? ( >=sys-libs/glibc-2.17 ) ) )"
+
+PDEPEND="!ghcbootstrap? ( =app-admin/haskell-updater-1.2* )"
+
+REQUIRED_USE="?? ( ghcbootstrap binary )"
+
+# haskell libraries built with cabal in configure mode, #515354
+QA_CONFIGURE_OPTIONS+=" --with-compiler --with-gcc"
+
+is_crosscompile() {
+	[[ ${CHOST} != ${CTARGET} ]]
+}
+
+# returns tool prefix for crosscompiler.
+# Example:
+#  CTARGET=armv7a-unknown-linux-gnueabi
+#  CHOST=x86_64-pc-linux-gnu
+#    "armv7a-unknown-linux-gnueabi-"
+#  CTARGET=${CHOST}
+#    ""
+# Used in tools and library prefix:
+#    "${ED}"/usr/bin/$(cross)haddock
+#    "${ED}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d"
+
+cross() {
+	if is_crosscompile; then
+		echo "${CTARGET}-"
+	else
+		echo ""
+	fi
+}
+
+append-ghc-cflags() {
+	local persistent compile assemble link
+	local flag ghcflag
+
+	for flag in $*; do
+		case ${flag} in
+			persistent)	persistent="yes";;
+			compile)	compile="yes";;
+			assemble)	assemble="yes";;
+			link)		link="yes";;
+			*)
+				[[ ${compile}  ]] && ghcflag="-optc${flag}"  CFLAGS+=" ${flag}" && GHC_FLAGS+=" ${ghcflag}" &&
+					[[ ${persistent} ]] && GHC_PERSISTENT_FLAGS+=" ${ghcflag}"
+				[[ ${assemble} ]] && ghcflag="-opta${flag}"  CFLAGS+=" ${flag}" && GHC_FLAGS+=" ${ghcflag}" &&
+					[[ ${persistent} ]] && GHC_PERSISTENT_FLAGS+=" ${ghcflag}"
+				[[ ${link}     ]] && ghcflag="-optl${flag}" LDFLAGS+=" ${flag}" && GHC_FLAGS+=" ${ghcflag}" &&
+					[[ ${persistent} ]] && GHC_PERSISTENT_FLAGS+=" ${ghcflag}"
+				;;
+		esac
+	done
+}
+
+# $1 - lib name (under libraries/)
+# $2 - lib version
+# example: bump_lib "transformers" "0.4.2.0"
+bump_lib() {
+	local pn=$1 pv=$2
+	local p=${pn}-${pv}
+	local f
+
+	einfo "Bumping ${pn} up to ${pv}"
+
+	for f in ghc.mk GNUmakefile; do
+		mv libraries/"${pn}"/$f "${WORKDIR}"/"${p}"/$f || die
+	done
+	mv libraries/"${pn}" "${WORKDIR}"/"${pn}".old || die
+	mv "${WORKDIR}"/"${p}" libraries/"${pn}" || die
+}
+
+update_SRC_URI() {
+	local p pn pv
+	for p in "${BUMP_LIBRARIES[@]}"; do
+		set -- $p
+		pn=$1 pv=$2
+
+		SRC_URI+=" mirror://hackage/package/${pn}/${pn}-${pv}.tar.gz"
+	done
+}
+
+update_SRC_URI
+
+bump_libs() {
+	local p pn pv
+	for p in "${BUMP_LIBRARIES[@]}"; do
+		set -- $p
+		pn=$1 pv=$2
+
+		bump_lib "${pn}" "${pv}"
+	done
+}
+
+ghc_setup_cflags() {
+	if is_crosscompile; then
+		export CFLAGS=${GHC_CFLAGS-"-O2 -pipe"}
+		export LDFLAGS=${GHC_LDFLAGS-"-Wl,-O1"}
+		einfo "Crosscompiling mode:"
+		einfo "   CHOST:   ${CHOST}"
+		einfo "   CTARGET: ${CTARGET}"
+		einfo "   CFLAGS:  ${CFLAGS}"
+		einfo "   LDFLAGS: ${LDFLAGS}"
+		einfo "   prefix: $(cross)"
+		return
+	fi
+	# We need to be very careful with the CFLAGS we ask ghc to pass through to
+	# gcc. There are plenty of flags which will make gcc produce output that
+	# breaks ghc in various ways. The main ones we want to pass through are
+	# -mcpu / -march flags. These are important for arches like alpha & sparc.
+	# We also use these CFLAGS for building the C parts of ghc, ie the rts.
+	strip-flags
+	strip-unsupported-flags
+
+	# Cmm can't parse line numbers #482086
+	replace-flags -ggdb[3-9] -ggdb2
+
+	GHC_FLAGS=""
+	GHC_PERSISTENT_FLAGS=""
+	for flag in ${CFLAGS}; do
+		case ${flag} in
+
+			# Ignore extra optimisation (ghc passes -O to gcc anyway)
+			# -O2 and above break on too many systems
+			-O*) ;;
+
+			# Arch and ABI flags are what we're really after
+			-m*) append-ghc-cflags compile assemble ${flag};;
+
+			# Sometimes it's handy to see backtrace of RTS
+			# to get an idea what happens there
+			-g*) append-ghc-cflags compile ${flag};;
+
+			# Ignore all other flags, including all -f* flags
+		esac
+	done
+
+	for flag in ${LDFLAGS}; do
+		append-ghc-cflags link ${flag}
+	done
+
+	# hardened-gcc needs to be disabled, because the mangler doesn't accept
+	# its output.
+	gcc-specs-pie && append-ghc-cflags persistent compile link -nopie
+	gcc-specs-ssp && append-ghc-cflags persistent compile      -fno-stack-protector
+
+	# prevent from failind building unregisterised ghc:
+	# http://www.mail-archive.com/debian-bugs-dist@lists.debian.org/msg171602.html
+	use ppc64 && append-ghc-cflags persistent compile -mminimal-toc
+	# fix the similar issue as ppc64 TOC on ia64. ia64 has limited size of small data
+	# currently ghc fails to build haddock
+	# http://osdir.com/ml/gnu.binutils.bugs/2004-10/msg00050.html
+	use ia64 && append-ghc-cflags persistent compile -G0
+}
+
+# substitutes string $1 to $2 in files $3 $4 ...
+relocate_path() {
+	local from=$1
+	local   to=$2
+	shift 2
+	local file=
+	for file in "$@"
+	do
+		sed -i -e "s|$from|$to|g" \
+			"$file" || die "path relocation failed for '$file'"
+	done
+}
+
+# changes hardcoded ghc paths and updates package index
+# $1 - new absolute root path
+relocate_ghc() {
+	local to=$1
+
+	# libdir for prebuilt binary and for current system may mismatch
+	# It does for prefix installation for example: bug #476998
+	local bin_ghc_prefix=${WORKDIR}/usr
+	local bin_libpath=$(echo "${bin_ghc_prefix}"/lib*)
+	local bin_libdir=${bin_libpath#${bin_ghc_prefix}/}
+
+	# backup original script to use it later after relocation
+	local gp_back="${T}/ghc-pkg-${GHC_PV}-orig"
+	cp "${WORKDIR}/usr/bin/$(cross)ghc-pkg-${GHC_PV}" "$gp_back" || die "unable to backup ghc-pkg wrapper"
+
+	if [[ ${bin_libdir} != $(get_libdir) ]]; then
+		einfo "Relocating '${bin_libdir}' to '$(get_libdir)' (bug #476998)"
+		# moving the dir itself is not strictly needed
+		# but then USE=binary would result in installing
+		# in '${bin_libdir}'
+		mv "${bin_ghc_prefix}/${bin_libdir}" "${bin_ghc_prefix}/$(get_libdir)" || die
+
+		relocate_path "/usr/${bin_libdir}" "/usr/$(get_libdir)" \
+			"${WORKDIR}/usr/bin/$(cross)ghc-${GHC_PV}" \
+			"${WORKDIR}/usr/bin/$(cross)ghci-${GHC_PV}" \
+			"${WORKDIR}/usr/bin/$(cross)ghc-pkg-${GHC_PV}" \
+			"${WORKDIR}/usr/bin/$(cross)hsc2hs" \
+			"${WORKDIR}/usr/bin/$(cross)runghc-${GHC_PV}" \
+			"$gp_back" \
+			"${WORKDIR}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d/"*
+	fi
+
+	# Relocate from /usr to ${EPREFIX}/usr
+	relocate_path "/usr" "${to}/usr" \
+		"${WORKDIR}/usr/bin/$(cross)ghc-${GHC_PV}" \
+		"${WORKDIR}/usr/bin/$(cross)ghci-${GHC_PV}" \
+		"${WORKDIR}/usr/bin/$(cross)ghc-pkg-${GHC_PV}" \
+		"${WORKDIR}/usr/bin/$(cross)hsc2hs" \
+		"${WORKDIR}/usr/bin/$(cross)runghc-${GHC_PV}" \
+		"${WORKDIR}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d/"*
+
+	# this one we will use to regenerate cache
+	# so it should point to current tree location
+	relocate_path "/usr" "${WORKDIR}/usr" "$gp_back"
+
+	if use prefix; then
+		# and insert LD_LIBRARY_PATH entry to EPREFIX dir tree
+		# TODO: add the same for darwin's CHOST and it's DYLD_
+		local new_ldpath='LD_LIBRARY_PATH="'${EPREFIX}/$(get_libdir):${EPREFIX}/usr/$(get_libdir)'${LD_LIBRARY_PATH:+:}${LD_LIBRARY_PATH}"\nexport LD_LIBRARY_PATH'
+		sed -i -e '2i'"$new_ldpath" \
+			"${WORKDIR}/usr/bin/$(cross)ghc-${GHC_PV}" \
+			"${WORKDIR}/usr/bin/$(cross)ghci-${GHC_PV}" \
+			"${WORKDIR}/usr/bin/$(cross)ghc-pkg-${GHC_PV}" \
+			"${WORKDIR}/usr/bin/$(cross)hsc2hs" \
+			"${WORKDIR}/usr/bin/$(cross)runghc-${GHC_PV}" \
+			"$gp_back" \
+			|| die "Adding LD_LIBRARY_PATH for wrappers failed"
+	fi
+
+	# regenerate the binary package cache
+	"$gp_back" recache || die "failed to update cache after relocation"
+	rm "$gp_back"
+}
+
+pkg_setup() {
+	# quiet portage about prebuilt binaries
+	use binary && QA_PREBUILT="*"
+
+	[[ ${MERGE_TYPE} == binary ]] && return
+
+	if use ghcbootstrap; then
+		ewarn "You requested ghc bootstrapping, this is usually only used"
+		ewarn "by Gentoo developers to make binary .tbz2 packages."
+
+		[[ -z $(type -P ghc) ]] && \
+			die "Could not find a ghc to bootstrap with."
+	else
+		if ! yet_binary; then
+			eerror "Please try emerging with USE=ghcbootstrap and report build"
+			eerror "sucess or failure to the haskell team (haskell@gentoo.org)"
+			die "No binary available for '${ARCH}' arch yet, USE=ghcbootstrap"
+		fi
+	fi
+}
+
+src_unpack() {
+	# Create the ${S} dir if we're using the binary version
+	use binary && mkdir "${S}"
+
+	# the Solaris and Darwin binaries from ghc (maeder) need to be
+	# unpacked separately, so prevent them from being unpacked
+	local ONLYA=${A}
+	case ${CHOST} in
+		*-darwin* | *-solaris*)  ONLYA=${GHC_P}-src.tar.bz2  ;;
+	esac
+	unpack ${ONLYA}
+
+	if [[ -d "${S}"/libraries/dph ]]; then
+		# Sometimes dph libs get accidentally shipped with ghc
+		# but they are not installed unless user requests it.
+		# We never install them.
+		elog "Removing 'libraries/dph'"
+		rm -rf "${S}"/libraries/dph
+	fi
+}
+
+src_prepare() {
+	ghc_setup_cflags
+
+	if ! use ghcbootstrap && [[ ${CHOST} != *-darwin* && ${CHOST} != *-solaris* ]]; then
+		# Modify the wrapper script from the binary tarball to use GHC_PERSISTENT_FLAGS.
+		# See bug #313635.
+		sed -i -e "s|\"\$topdir\"|\"\$topdir\" ${GHC_PERSISTENT_FLAGS}|" \
+			"${WORKDIR}/usr/bin/$(cross)ghc-${GHC_PV}"
+
+		# allow hardened users use vanilla binary to bootstrap ghc
+		# ghci uses mmap with rwx protection at it implements dynamic
+		# linking on it's own (bug #299709)
+		pax-mark -m "${WORKDIR}/usr/$(get_libdir)/$(cross)${GHC_P}/bin/ghc"
+	fi
+
+	if use binary; then
+		if use prefix; then
+			relocate_ghc "${EPREFIX}"
+		fi
+
+		# Move unpacked files to the expected place
+		mv "${WORKDIR}/usr" "${S}"
+	else
+		if ! use ghcbootstrap; then
+			case ${CHOST} in
+				*-darwin* | *-solaris*)
+				# UPDATE ME for ghc-7
+				mkdir "${WORKDIR}"/ghc-bin-installer || die
+				pushd "${WORKDIR}"/ghc-bin-installer > /dev/null || die
+				use sparc-solaris && unpack ghc-6.10.4-sparc-sun-solaris2.tar.bz2
+				use x86-solaris && unpack ghc-7.0.3-i386-unknown-solaris2.tar.bz2
+				use x86-macos && unpack ghc-7.4.1-i386-apple-darwin.tar.bz2
+				use x64-macos && unpack ghc-7.4.1-x86_64-apple-darwin.tar.bz2
+				popd > /dev/null
+
+				pushd "${WORKDIR}"/ghc-bin-installer/ghc-[67].?*.? > /dev/null || die
+				# fix the binaries so they run, on Solaris we need an
+				# LD_LIBRARY_PATH which has our prefix libdirs, on
+				# Darwin we need to replace the frameworks with our libs
+				# from the prefix fix before installation, because some
+				# of the tools are actually used during configure/make
+				if [[ ${CHOST} == *-solaris* ]] ; then
+					export LD_LIBRARY_PATH="${EPREFIX}/$(get_libdir):${EPREFIX}/usr/$(get_libdir):${LD_LIBRARY_PATH}"
+				elif [[ ${CHOST} == *-darwin* ]] ; then
+					local readline_framework=GNUreadline.framework/GNUreadline
+					local gmp_framework=/opt/local/lib/libgmp.10.dylib
+					local ncurses_file=/opt/local/lib/libncurses.5.dylib
+					for binary in $(scanmacho -BRE MH_EXECUTE -F '%F' .) ; do
+						install_name_tool -change \
+							${readline_framework} \
+							"${EPREFIX}"/lib/libreadline.dylib \
+							${binary} || die
+						install_name_tool -change \
+							${gmp_framework} \
+							"${EPREFIX}"/usr/lib/libgmp.dylib \
+							${binary} || die
+						install_name_tool -change \
+							${ncurses_file} \
+							"${EPREFIX}"/usr/lib/libncurses.dylib \
+							${binary} || die
+					done
+					# we don't do frameworks!
+					sed -i \
+						-e 's/\(frameworks = \)\["GMP"\]/\1[]/g' \
+						-e 's/\(extraLibraries = \)\["m"\]/\1["m","gmp"]/g' \
+						rts/package.conf.in || die
+				fi
+
+				# it is autoconf, but we really don't want to give it too
+				# much arguments, in fact we do the make in-place anyway
+				./configure --prefix="${WORKDIR}"/usr || die
+				make install || die
+				popd > /dev/null
+				;;
+				*)
+				relocate_ghc "${WORKDIR}"
+				;;
+			esac
+		fi
+
+		sed -i -e "s|\"\$topdir\"|\"\$topdir\" ${GHC_PERSISTENT_FLAGS}|" \
+			"${S}/ghc/ghc.wrapper"
+
+		cd "${S}" # otherwise epatch will break
+
+		epatch "${FILESDIR}"/${PN}-7.0.4-CHOST-prefix.patch
+
+		epatch "${FILESDIR}"/${PN}-7.8.2-cgen-constify.patch
+		epatch "${FILESDIR}"/${PN}-7.8.3-prim-lm.patch
+		epatch "${FILESDIR}"/${PN}-7.10.1-rc3-ghc-7.10-bootstrap.patch
+		epatch "${FILESDIR}"/${PN}-7.10.3-relnotes.patch
+		epatch "${FILESDIR}"/${PN}-7.10.3-hardfloat.patch
+
+		# Since ${S}/packages does not include base, etc. add them to gen_contents_index
+		sed -e 's@\(for REPO in .*\)@\1 base integer-gmp integer-gmp2 integer-simple template-haskell@' \
+			-i libraries/gen_contents_index || die
+
+		if use prefix; then
+			# Make configure find docbook-xsl-stylesheets from Prefix
+			sed -e '/^FP_DIR_DOCBOOK_XSL/s:\[.*\]:['"${EPREFIX}"'/usr/share/sgml/docbook/xsl-stylesheets/]:' \
+				-i utils/haddock/doc/configure.ac || die
+		fi
+
+		bump_libs
+
+		# as we have changed the build system
+		eautoreconf
+	fi
+}
+
+src_configure() {
+	if ! use binary; then
+		# initialize build.mk
+		echo '# Gentoo changes' > mk/build.mk
+
+		# Put docs into the right place, ie /usr/share/doc/ghc-${GHC_PV}
+		echo "docdir = ${EPREFIX}/usr/share/doc/${P}" >> mk/build.mk
+		echo "htmldir = ${EPREFIX}/usr/share/doc/${P}" >> mk/build.mk
+
+		# We also need to use the GHC_FLAGS flags when building ghc itself
+		echo "SRC_HC_OPTS+=${HCFLAGS} ${GHC_FLAGS}" >> mk/build.mk
+		echo "SRC_CC_OPTS+=${CFLAGS}" >> mk/build.mk
+		echo "SRC_LD_OPTS+=${LDFLAGS}" >> mk/build.mk
+
+		# We can't depend on haddock except when bootstrapping when we
+		# must build docs and include them into the binary .tbz2 package
+		# app-text/dblatex is not in portage, can not build PDF or PS
+		echo "BUILD_DOCBOOK_PDF  = NO"  >> mk/build.mk
+		echo "BUILD_DOCBOOK_PS   = NO"  >> mk/build.mk
+		if use doc; then
+			echo "BUILD_DOCBOOK_HTML = YES" >> mk/build.mk
+		else
+			echo "BUILD_DOCBOOK_HTML = NO" >> mk/build.mk
+		fi
+
+		# this controls presence on 'xhtml' and 'haddock' in final install
+		echo "HADDOCK_DOCS       = YES" >> mk/build.mk
+
+		# allows overriding build flavours for libraries:
+		# v   - vanilla (static libs)
+		# p   - profiled
+		# dyn - shared libraries
+		# example: GHC_LIBRARY_WAYS="v dyn"
+		if [[ -n ${GHC_LIBRARY_WAYS} ]]; then
+			echo "GhcLibWays=${GHC_LIBRARY_WAYS}" >> mk/build.mk
+		fi
+
+		# Get ghc from the unpacked binary .tbz2
+		# except when bootstrapping we just pick ghc up off the path
+		if ! use ghcbootstrap; then
+			export PATH="${WORKDIR}/usr/bin:${PATH}"
+		fi
+
+		if use gmp; then
+			echo "INTEGER_LIBRARY=integer-gmp2" >> mk/build.mk
+		else
+			echo "INTEGER_LIBRARY=integer-simple" >> mk/build.mk
+		fi
+
+		# don't strip anything. Very useful when stage2 SIGSEGVs on you
+		echo "STRIP_CMD = :" >> mk/build.mk
+
+		local econf_args=()
+
+		# GHC embeds 'gcc' it was built by and uses it later.
+		# Don't allow things like ccache or versioned binary slip.
+		# We use stable thing across gcc upgrades.
+		is_crosscompile || econf_args+=(--with-gcc=${CHOST}-gcc)
+
+		if use ghcmakebinary; then
+			# When building booting libary we are trying to
+			# bundle or restrict most of external depends
+			# with unstable ABI:
+			#  - embed libffi (default GHC behaviour)
+			#  - disable ncurses support for ghci (via haskeline)
+			#    https://bugs.gentoo.org/557478
+			#  - disable ncurses support for ghc-pkg
+			echo "libraries/haskeline_CONFIGURE_OPTS += --flag=-terminfo" >> mk/build.mk
+			echo "utils/ghc-pkg_HC_OPTS += -DBOOTSTRAPPING" >> mk/build.mk
+		else
+			econf_args+=(--with-system-libffi)
+			econf_args+=(--with-ffi-includes=$(pkg-config libffi --cflags-only-I | sed -e 's@^-I@@'))
+		fi
+
+		elog "Final mk/build.mk:"
+		cat mk/build.mk || die
+
+		econf ${econf_args[@]} --enable-bootstrap-with-devel-snapshot
+
+		if [[ ${PV} == *9999* ]]; then
+			GHC_PV="$(grep 'S\[\"PACKAGE_VERSION\"\]' config.status | sed -e 's@^.*=\"\(.*\)\"@\1@')"
+			GHC_P=${PN}-${GHC_PV}
+		fi
+	fi # ! use binary
+}
+
+src_compile() {
+	if ! use binary; then
+		# 1. build compiler binary first
+		emake ghc/stage2/build/tmp/ghc-stage2
+		# 2. pax-mark (bug #516430)
+		pax-mark -m ghc/stage2/build/tmp/ghc-stage2
+		# 3. and then all the rest
+		emake all
+	fi # ! use binary
+}
+
+src_install() {
+	if use binary; then
+		use prefix && mkdir -p "${ED}"
+		mv "${S}/usr" "${ED}"
+	else
+
+		emake -j1 install DESTDIR="${D}"
+		dodoc "distrib/README" "ANNOUNCE" "LICENSE" "VERSION"
+
+		# rename ghc-shipped files to avoid collision
+		# of external packages. Motivating example:
+		#  user had installed:
+		#      dev-lang/ghc-7.8.4-r0 (with transformers-0.3.0.0)
+		#      dev-haskell/transformers-0.4.2.0
+		#  then user tried to update to
+		#      dev-lang/ghc-7.8.4-r1 (with transformers-0.4.2.0)
+		#  this will lead to single .conf file collision.
+		local shipped_conf renamed_conf
+		local package_confdir="${ED}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d"
+		for shipped_conf in "${package_confdir}"/*.conf; do
+			# rename 'pkg-ver-id.conf' to 'pkg-ver-id-gentoo-${PF}.conf'
+			renamed_conf=${shipped_conf%.conf}-gentoo-${PF}.conf
+			mv "${shipped_conf}" "${renamed_conf}" || die
+		done
+
+		# remove link, but leave 'haddock-${GHC_P}'
+		rm -f "${ED}"/usr/bin/$(cross)haddock
+
+		if [[ ! -f "${S}/VERSION" ]]; then
+			echo "${GHC_PV}" > "${S}/VERSION" \
+				|| die "Could not create file ${S}/VERSION"
+		fi
+		if ! is_crosscompile; then
+			newbashcomp "${FILESDIR}"/ghc-bash-completion ghc-pkg
+			newbashcomp utils/completion/ghc.bash         ghc
+		fi
+	fi
+
+	# path to the package.cache
+	local package_confdir="${ED}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d"
+	PKGCACHE="${package_confdir}"/package.cache
+	# copy the package.conf.d, including timestamp, save it so we can help
+	# users that have a broken package.conf.d
+	cp -pR "${package_confdir}"{,.initial} || die "failed to backup intial package.conf.d"
+
+	# copy the package.conf, including timestamp, save it so we later can put it
+	# back before uninstalling, or when upgrading.
+	cp -p "${PKGCACHE}"{,.shipped} \
+		|| die "failed to copy package.conf.d/package.cache"
+}
+
+pkg_preinst() {
+	# have we got an earlier version of ghc installed?
+	if has_version "<${CATEGORY}/${PF}"; then
+		haskell_updater_warn="1"
+	fi
+}
+
+pkg_postinst() {
+	ghc-reregister
+
+	# path to the package.cache
+	PKGCACHE="${EROOT}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d/package.cache"
+
+	# give the cache a new timestamp, it must be as recent as
+	# the package.conf.d directory.
+	touch "${PKGCACHE}"
+
+	if [[ "${haskell_updater_warn}" == "1" ]]; then
+		ewarn
+		ewarn "\e[1;31m************************************************************************\e[0m"
+		ewarn
+		ewarn "You have just upgraded from an older version of GHC."
+		ewarn "You may have to run"
+		ewarn "      'haskell-updater'"
+		ewarn "to rebuild all ghc-based Haskell libraries."
+		ewarn
+		ewarn "\e[1;31m************************************************************************\e[0m"
+		ewarn
+	fi
+}
+
+pkg_prerm() {
+	PKGCACHE="${EROOT}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d/package.cache"
+	rm -rf "${PKGCACHE}"
+
+	cp -p "${PKGCACHE}"{.shipped,}
+}
+
+pkg_postrm() {
+	ghc-package_pkg_postrm
+}


^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2023-02-04 23:11 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-21  2:25 [gentoo-commits] repo/gentoo:master commit in: dev-lang/ghc/, dev-lang/ghc/files/ Sam James
  -- strict thread matches above, loose matches on Subject: below --
2023-02-04 23:11 Sam James
2022-08-14 20:52 Sam James
2022-07-04  0:33 Sam James
2021-12-14 11:46 Sam James
2021-08-27  8:23 Mark Wright
2020-12-18  8:52 Sergei Trofimovich
2020-03-24 23:34 Sergei Trofimovich
2019-10-04  6:46 Sergei Trofimovich
2018-06-09 19:09 Sergei Trofimovich
2017-09-02 20:50 Sergei Trofimovich
2017-05-23 21:16 Sergei Trofimovich
2017-01-29 12:54 Sergei Trofimovich
2017-01-16  9:50 Sergei Trofimovich
2016-03-15 22:01 Sergei Trofimovich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox