From 623ee73d661e5ed8475cb264511f683407d87365 Mon Sep 17 00:00:00 2001
From: V3n3RiX <venerix@redcorelinux.org>
Date: Sun, 12 Apr 2020 03:41:30 +0100
Subject: gentoo Easter resync : 12.04.2020

---
 dev-lang/ghc/Manifest                              |  36 +-
 .../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-7.10.3.ebuild                     |   6 +-
 dev-lang/ghc/ghc-7.8.4.ebuild                      |   4 +-
 dev-lang/ghc/ghc-8.0.2.ebuild                      |   4 +-
 dev-lang/ghc/ghc-8.10.1.ebuild                     | 794 ++++++++++++++++++++
 dev-lang/ghc/ghc-8.2.1.ebuild                      |   4 +-
 dev-lang/ghc/ghc-8.2.2.ebuild                      |   4 +-
 dev-lang/ghc/ghc-8.4.1.ebuild                      |   4 +-
 dev-lang/ghc/ghc-8.4.2.ebuild                      |   4 +-
 dev-lang/ghc/ghc-8.4.3.ebuild                      |   4 +-
 dev-lang/ghc/ghc-8.6.4.ebuild                      |   4 +-
 dev-lang/ghc/ghc-8.6.5.ebuild                      |   2 +-
 dev-lang/ghc/ghc-8.8.1.ebuild                      |   2 +-
 dev-lang/ghc/ghc-8.8.2.ebuild                      |   2 +-
 dev-lang/ghc/ghc-8.8.3.ebuild                      | 805 +++++++++++++++++++++
 17 files changed, 1681 insertions(+), 34 deletions(-)
 create mode 100644 dev-lang/ghc/files/ghc-8.10.1-allow-cross-bootstrap.patch
 create mode 100644 dev-lang/ghc/files/ghc-8.10.1-no-relax-everywhere.patch
 create mode 100644 dev-lang/ghc/ghc-8.10.1.ebuild
 create mode 100644 dev-lang/ghc/ghc-8.8.3.ebuild

(limited to 'dev-lang/ghc')

diff --git a/dev-lang/ghc/Manifest b/dev-lang/ghc/Manifest
index 74999bbb2c94..b58f1ba39dce 100644
--- a/dev-lang/ghc/Manifest
+++ b/dev-lang/ghc/Manifest
@@ -20,6 +20,8 @@ AUX ghc-8.0.2-binutils-2.30.patch 2115 BLAKE2B 5affd1954283773ab1f4717b5cc735f86
 AUX ghc-8.0.2-libffi-alpha.patch 2133 BLAKE2B 596410d5bead5a3c5f1f4a1e33a767bf2ade92204e469652e3ce005dd275a54e0e084799af2967529008654f4c45148b955e5e0b299a48cd5e78cf1c209e3d7c SHA512 77964b82be47219d709ed4b79ac255c4762986decadef2d65d6643cb2d1b6cb0f3210cce1bd46bc16b6e6c51a4aabc73c5bc5e1bdaa8797a5f23033194f91a4a
 AUX ghc-8.0.2-no-relax-everywhere.patch 766 BLAKE2B 76ca925d56a9d2961cd342971ef8fb0165158d707f0089f3726560511e57ee5c08adeaf996595378d1cef3ec7b59ddf1df06d0255bf20da51c5b26e817f4057b SHA512 b729ddc27bbf089324f0b4d7229925226b59c0047cec0c0230e022fb8554389373e309e93a108f0aaa155fd9ff6957a7d41cdd35a90c6ca59b216381ff21483b
 AUX ghc-8.0.2_rc2-old-sphinx.patch 434 BLAKE2B ede17cd4e5848b452edeaa3b429a7485f324cf1c9133098c7d9f84a22816eedeaf55143fea082e514b5e987ca40f65b68a476060e0c18d19bb5f8b5b993fda92 SHA512 fc8fd8d40c70a77a3aecfbdb0993bee9ef1582402b7220ed3066e1c6d4bc480c5b569cab44b58b3c54d1e68f506dc5b86ff87518d744a5a846d4de6cb1093db2
+AUX ghc-8.10.1-allow-cross-bootstrap.patch 541 BLAKE2B b77b3c9ebb7a33af6f82ec1b9927664e9bfce04450560a8e436ffa87feca50d606824192b7333e3b98d5552622592b6d39d0b184037ce646d6f7ebd205deb348 SHA512 d87a99ac96846e161d8c939079f8314d380be8e1dc62f956e3afcce1339a76447a14002b30bac1c86c807fd8eba23a0648912a3d074248f3513f9aadacd27489
+AUX ghc-8.10.1-no-relax-everywhere.patch 910 BLAKE2B 3afdc92313cb48a00698b8c4cc8af822b843dd107d546a95d598fa0d7e7fc4507e3e7dc8ab06faaafcb0cd24770df28826987088898a6cc2d1b914fc7576ec75 SHA512 21f1c64ed75c5b062a00f48b7439753aab15083c583a1cbea76b63398873ac14f52a45fe62e4cf3751c5dbb623e75a4f96c416f5e8f7a1f7822798b21cadcbb1
 AUX ghc-8.2.1-darwin.patch 910 BLAKE2B 2f1a44dd7ead59301b5dd59c8cab932710655416640f2c8d5273cf07da4a45bf702d840768e2d32822e89f1b07cc9ed3a6110e1847e11468fca5c515e9e26f70 SHA512 0177fda8717d9158a99d96853feb1bf40ff13df8f5c5669c7c48f33accf69d6ddb05876776cda66705e85ee56c5ecff8f81722d8e748b6c2ed6b9bf611e42a2c
 AUX ghc-8.2.1_rc1-cgen-constify.patch 14371 BLAKE2B 96f9607cf857bb113b475d173a62998f2b0424f09f14c20ae3cab8497a25ab2df7523850f46e3b2867dcd75a499b3487345376b7cdd8e6f4a5e8008e160cf3d0 SHA512 8715c2f7c497eeefffd13b578ff718f36ec22bfe397501f685db0c781c614ebaa1178a9ca7550a722876d1cf9ace39aaa44493ecb934a828fa5010471672acfa
 AUX ghc-8.2.1_rc1-ghci-cross.patch 2828 BLAKE2B 89776c87d4ca8c0b74f0d7ef11680d2cea217774389bf297df1a61f9d95ea515b5f9d44387eac7715fec59d9c91e91bd06215c851c94f091c05b03f84d0b8699 SHA512 55e8f2e6bf69ff26976005e0b89c400df9facda5eb974f7340af89625361adce48371616a5d292dafbd4d98cbfbc0b656d36749f2e16918b275a0469ed88cea2
@@ -42,6 +44,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
@@ -55,6 +59,8 @@ DIST ghc-8.8.1-src.tar.xz 28634672 BLAKE2B 3a012db5d9798efddf806542a88cd9fef1d09
 DIST ghc-8.8.1-testsuite.tar.xz 1959220 BLAKE2B 8606a6439f7d5b4c837b2325c4ef5705dbcea17c4b59daf7aafd0de68e55179bb2c03ce7a4f376398b185b6dbfb361d18592756558461ee43722d2142370d815 SHA512 e13b651c60deb86522efbfe8aa42679cc81a413475f70580d9ef28dbb711617c523951441a30fb46f3be9418c4c0bb4dbc522b04aaa51313afd2d39027696c30
 DIST ghc-8.8.2-src.tar.xz 19365816 BLAKE2B 85dbd2a4696755f43c28ec578d5ecfe706b27ba7f640f66b464b7aa7b959ca5f02b8b51d130299c30d024c46b9ce6a115606bde46be400fb8ee221ff18177d65 SHA512 11eec0bc03254ea848a5c86bc3e2da317801a1227dd91406a157e11cb675891d77d61177b740b6df88bd823063f6cb2af5a928a7540e25392d9d0769ea121069
 DIST ghc-8.8.2-testsuite.tar.xz 1976924 BLAKE2B cec6c5dab1782332aca6364f995cffc1e9f3506649c3410b6eaa220e665b66f033dfad8ab6cae7677e15a6a1bd51237ed491b7fd04a19fa1d4f9cd8904617c64 SHA512 0fc41a0b3cb5f172442863c8a3b1cf549f2f660a070965e6083baa2c90c27b6a7c17550625105799010f4329dc189f4e392c86991844a9704a3e3a72a6d4e2f5
+DIST ghc-8.8.3-src.tar.xz 19343672 BLAKE2B 4b33b4a386926f0ee625c7c18a3997f02bf664b8f553d7cdfb231553bf9510f44f72c0b46911539f6209f28ecab52ee520e61e2c9e750cc217b170b3596ffca0 SHA512 7db0d820a288e56bd32935cc03584295900605f6e7cac6fe6adcb3ec6c24d8d2cebf7a8efa421f2d2fa192602d7f24dfad1ddeeba252455e4cb8baa9889dcaa9
+DIST ghc-8.8.3-testsuite.tar.xz 1965236 BLAKE2B 9cd10769336513284d8e0fbca1c3fce9e298ec67eb63eb10d41087fccba0f6281f1509aee684778fd23710ffe65843c43b4042e6692940af67766056c4503273 SHA512 4ebf3eabcd7591762dfcf45716b06293fb14c00b51307f7788c90dcf4e01f67e6bbb7a887b74d8d30272919486441ac236b42a54c4874aac69d90391b76f81c9
 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
@@ -76,6 +82,8 @@ DIST ghc-bin-8.0.2-ia64-unknown-linux-gnu.tbz2 256581880 BLAKE2B 7a9b41fccf3a097
 DIST ghc-bin-8.0.2-ppc.tbz2 144760090 BLAKE2B 32410f3563f7f2555350806db460d2083c7248c57223c9c681d0b4913df942f023c7c1f5fda145179a524ee7ef105a9b8309ba87c20dc393a9f49151579b6767 SHA512 bc6bf8998064ffc1692c3bb83c44d1787760a3f4a1e6b79dedaefda5fe32b9052049a60f0ddd3c0b0bd24a722fb35e310e0189b3511721ff89d4d02b3d7c14bb
 DIST ghc-bin-8.0.2-ppc64.tbz2 117432068 BLAKE2B cae202f0d6e825127d543996b2fe7ae02578c47325674cbf22fddc53b1c4c9413f45c60d76ec3d07860cb8d0aae1ec792e4141822cc5c08ef9013308c5d29bf5 SHA512 0eaff0557b68649a15bbeb2019f46fa9e9e7b8a916aa210ab56888090a5b887d20d818e7987177bc6a8e7fde503de560026e6bb55fe39679b8b1ee13c6b7c4f9
 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.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
@@ -96,18 +104,22 @@ DIST ghc-bin-8.8.1-powerpc64le-unknown-linux-gnu.tbz2 173653088 BLAKE2B 6c29777b
 DIST ghc-bin-8.8.1-x86_64-pc-linux-gnu.tbz2 119317594 BLAKE2B 98f0fb262ac485dcfd6a8a67304912ffad2bf2634111fcc3b60346697a836867006bbacaab1e1be0cd5be34b4595d12bec13af644c451c10f7e3843ebaf5922f SHA512 e6acb11755db18fd86a346de642b8579a6b48b303c19795949757f5e351ad3b8892906e989dc57a7fd4471d0efe30fc8175df5bac741d7faecfe42a855a67980
 DIST ghc-bin-8.8.2-i686-pc-linux-gnu.tbz2 120289601 BLAKE2B df65bc6aa4ee22c979b9d8eda29f51188c96700d61fb4cf141ebad8a55e26b6cd959fce3ec0b8d780b68e7baf15a1ce7654dc4ef084aa4671fe05f00f9c4e9aa SHA512 da059f3fea00e14df346143e714da6484ae51d362d9e237607817791e02ec81e29e1ff7f9929fac44044f63196b395287c42f5829884c34391289179b4f6e204
 DIST ghc-bin-8.8.2-x86_64-pc-linux-gnu.tbz2 118957404 BLAKE2B cddedbb0fe8d38e9821bd8f51f5177d35922b25bf4fc8a537e921443560f141cdef44e54a0b4ef2dde07dbe33d9c1cba2e67ba80db4313f67e9bac089d967f56 SHA512 b0b801dd6abe9f5e6217e18568e2911dbfea11b1b45ff526950e87c73a34bcd597afc5105fcff2dc46bb13cf95e63db90c0d24ca9babf174b397a53001e8e0ac
+DIST ghc-bin-8.8.3-i686-pc-linux-gnu.tbz2 120243899 BLAKE2B 7f932523a71dcfd4cdd468bf67f470a942c314888c0093c21c211d54b3e158f45f051f027c78644a651047d81e809e1422bbaa5043e8559c6a4622ac0472f7e4 SHA512 12bf08b85652fd061849b9adb528d7a5c6fe9c2260cf02b92fab470fff16c3121bcb4e0f7044d05f252012083d622a1a490fa7f7c949142a3b5d03ccf0dd3ebc
+DIST ghc-bin-8.8.3-x86_64-pc-linux-gnu.tbz2 118988294 BLAKE2B 4e5aa3844934ae2726bf9c8690acd5a887f10cd49386ffadbc536f9309d33b3894b49507964eaf0d8a052747eb33aeabbe4d2cd22493297c295cf9414fcb766c SHA512 dd656157fe744c1df1c8ed34d1129ec358b26f3042c6da68e704e0f6a45d8114789000479e28a06dc16961afb283b3c666b427025590498a3d2da9b741b435c7
 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
-EBUILD ghc-7.10.3.ebuild 21693 BLAKE2B 78f2ccf72b5a7b0ab9fb61ad59cb44b602ac0ab4720a4a46d860dd933620f5986172e85be63a67e5a0d2f157fe281f74b7801f07a0fdeb6e26a493e5935a995d SHA512 15591a3661696b6ef2b01445d83cf6f33b1c66e8310c2e38a4c019543a5b5eb8515ce0fabe4ebbcb6f2589c11a19205ef54f7418c968973a4809c3802359215a
-EBUILD ghc-7.8.4.ebuild 19824 BLAKE2B ca021443410d34fe8a67fb4b4124b2ffc7ddbba0156fd9d1d574bcc819c9239e788e4f3a751383f5fba8bf3b13ff46b8c81d1866e880c3b2bbd3a241fdeeb684 SHA512 9cc0ac4c6a4cf6bf11ab73b5c5f37e2e4554b77f98434c648e8429c50ed008519185f5424057d734b595c754ea2170c6542e0e0c9b015c4dfdca721cfa9c6f5d
-EBUILD ghc-8.0.2.ebuild 21608 BLAKE2B b72e44acd3df2a1866f911fbf507b0abdb6f2a42d82bee20fb161084464a5459fd3d747c0f50be561b33dcde1fe895cad97d0a6ea09d3ff840cc1b01eb1be4d9 SHA512 471c80febf2b979be15b3b747cec60fd855ad5a2b4b023c70d3b314122e00b4a6c54b2180f8d25ad0fefcd57bc58e83e6c40b8e87e6b8718d376b78321bddf9d
-EBUILD ghc-8.2.1.ebuild 24831 BLAKE2B 96416bebee7f411a3c047511bfb653ae2f13242f07122db969ee919775c41d6150ea4f49f0c0fc66d97c2be7c69b9e8bce21fab36fc6d0e946aff71fc618630b SHA512 1e85c2cd01069e7a863c264176d3690f26343e3aebcc11a8ccee84be36dbc3673b9fe420e4558eb039fc19ec1d52044fdc2242d38e192331599947e2507a197b
-EBUILD ghc-8.2.2.ebuild 24800 BLAKE2B 5b37be2d91a910d102ab8c1eee628900889e9cb281dcdb1357954b73035fbc46c59ab6acf1e79bff254dc32b14860542923c85accda450d98c89c258e0545c0a SHA512 5956e7ef35528f970b4cba93be8851ee6239e293703a48e3fee445d518b130cb8e9592251080fd25cbeafa3aebc2a8bd8ee78f8bb2f979358f50cf9dab3293ff
-EBUILD ghc-8.4.1.ebuild 24618 BLAKE2B 7a0d7dc1076ae580db5fc42df6bf03d03452ffeffb991b0755ec8dff1e611a08cd41abc18ea3ab35549a3df3ca5914931ece4ab2720c6e704231bae0d35a587f SHA512 010b89559b1f8cd5e7cf55fcdb67d3eb04d6f6d19dae6331db718d2ea056b05717c482c78c87f1b4fd575ecd75e627fcc73e47daea076a44a1f777714d3fdcd9
-EBUILD ghc-8.4.2.ebuild 24843 BLAKE2B 5169665b1042741251bee3518a1f66f04ad0bed20ca90720091d4013e2c335e13b8c267fcd4adfbfbdee03fba7d980a3c377db9f52056c3870cb80785e5125f5 SHA512 88716c59e726b8faf59f444fd6d91a26f839b968fb41f60e96d4ae37a3815745f9220c8ca34a7a9cd79963efd31c1177b023d2dd3d328f70459307889fefdedc
-EBUILD ghc-8.4.3.ebuild 24788 BLAKE2B 898e4ce54eb995a687b812b7a8fecea6c39fdb1bcc3bdf36b621ed880d252c8efeb8c5866828d2c127eb4b2f40bc2e6fa4171e0da264500bec088a72dffa76a2 SHA512 81688cb74ab3860e01d6daa023f295400a51d40c06a1878d05d252589824fdfd56a46841e269a8cad2aef1aaf447c43e922580446ef69981fd8a98eaccaf0d61
-EBUILD ghc-8.6.4.ebuild 25288 BLAKE2B 9465a1b030d93a7f19e342f170adda744b70bbe5c501ce8f67ddfc0ac0e16a63279dfab7b771ccdc280e5533859134dd4c642dd20753c861f97db7c234715ce8 SHA512 e1ab5166aadfaf04dd684bbc3b0cb205c3f657cc78dee1996cdac98dc085387b64d655447ee224b23c063e1c9d92ed1efe8c21fffc20d33407b261bc58b501b0
-EBUILD ghc-8.6.5.ebuild 25606 BLAKE2B 53ebf37e1c8412e086fc483bf3f83c40b2faeca68a0475a15cad38b9f75d94bc885017cca5e607ee766204968b4429c4b6c2acde7b462e367391284cec6c3d17 SHA512 b7d88e4075252c7492e8cc87c3761499b93f43c4858566e47d1929ca2ee68dd05c3560650c319d2cb448687127f90250277dc7c8f756a92290f60722b152edca
-EBUILD ghc-8.8.1.ebuild 26258 BLAKE2B 58f3e1dfd326a36a5f4b1befaf7b70a09f24cb764e722e517ee7e27e35f3df4425b61d56bcc9f582ac1e94ac53f2cd6ede7c01ff8e999980496f11e67267ffce SHA512 45eb991e899bf3d4fe61e98635f78ae9ffecc5435ba7be621b410a2df3be560e1208e0993be5e2a019b79b6ab19a02c1b18e79f4b4d3af1d1dd9d45d2c4d32c5
-EBUILD ghc-8.8.2.ebuild 26214 BLAKE2B 44319d6ca709330c260a89595cd426236474e161212427d2604629d627bab0bf8a67be937a83223c4899cc780567a0a4169cfe2c845dd608b61dd4d527494654 SHA512 54f68171f1c89d998bdc7768f9f731d24c16b3642dddb82b43e3a42d97c9ae5088f9d4c40947cf074173377e4d7c46d56e4d50e1bb8d0520e6f1ea97c2f7ec22
+EBUILD ghc-7.10.3.ebuild 21680 BLAKE2B e66ff4c021021db67975cc979a9e66fedd8d1a06af0bb90b2d5f4bafd53aaf8ff81eed7dd8cdfab02a4dae4bba9e06859a19233423b767aa4aaf16c798407f54 SHA512 0fbe5b28cf59a5a62c9ca4637626f34ecc1c40506062c31ff077b22f4def5b89b2b63a63bdda605e3a0c08780d1ea8a863b041fcfbe10fb8a00b2af22cba968d
+EBUILD ghc-7.8.4.ebuild 19813 BLAKE2B e68fa2cc887773c700082f2931e542643cea5d4e5937966df613ab6162007402a089fa8622ae716812073b10822c503992b5fe06e1212f446f21b0712650349e SHA512 60c2391f3121365dbfe38aabad3498578fa1e62e2f944700a3cc963c0ffbd5fdccc5416c00562ae9aec251586b73ed4dc137cd6ac0b252ede43adff9ed083c61
+EBUILD ghc-8.0.2.ebuild 21603 BLAKE2B ff73c59f0bda917b3697dd616a81b13a20f422e57a0f8953ff9d236bfe454e195f2a5b1c943aaa791c9fad1c1b329d62876e3793caa9633d586d504da741e22a SHA512 caf75e0f0afa2dc6cac50f9ef233eb56ee3a7ee06224f982e92af7308d81b205e5c15939fde7128e23bb340c6631ecad5791c47e8650f85446b019fa35c9f79e
+EBUILD ghc-8.10.1.ebuild 25743 BLAKE2B a300e17111e2b010f3104b390834ce1abef7e93e1b89ec7640f6f86244bb4d8f0dffa186b82c70afd01004c5b362c7adbb5524ddb5e93531f3a45dc564cdefc9 SHA512 194a75123b31b3c325021073edc64b4e1403b9fd66b9b6413e7c49f3c4f0c28774c63ca3e2aaeed068164e4987bb30f91c7285e0b97aacd1c02c38760d17864b
+EBUILD ghc-8.2.1.ebuild 24832 BLAKE2B 7cc220f4b771b73699e7a1c743ffd6833c12fef94b708b8d204ce7df6ad72d309a10279f2f941f29393c096e57244a6e9f7ba9a36784b704916eacb7eff570c3 SHA512 63b3f31cd775b15409ef411004cdb7c54161a33a9c577a282e25de09dfc563d84cbfc21f800111830e1e7b297540f972f4b3e434c4aa92dd4fcc350a37bab636
+EBUILD ghc-8.2.2.ebuild 24801 BLAKE2B 16cce6b61873c9800a0d3da9708617b5d36082bf730f8d7c09490f003f8a5d227ab8fe1c081e3c9803c083e7f334a0dd5bafa8066d8900defce9734df7ee905a SHA512 dbf3e47857474f59bf64f334589db3d9920b25717647cbbf7d7f29420af0f7023a2d6dad3aa91ee7eb2d023558de5758c30242901cbf9885095df4b15e38b717
+EBUILD ghc-8.4.1.ebuild 24619 BLAKE2B e7e4aa8b95f4c227f6ee0416b8577384c90c269a9a01effe5f295772c758f6bb8cfe9c995c7d4719b3ed5e5f0e05071383319ec997365b6652a66ad409496877 SHA512 20377bc82ba6b6da7f5a09313cb6bf3e467361b16e2a294958d61bd3f56eca91c2b92020516071cc25e0533c82869bc50a8d1c83342f990ceec7029c0b4d3082
+EBUILD ghc-8.4.2.ebuild 24844 BLAKE2B 2d815ea8d33027625f0f4f8a75d32e32150d85c9fc783378d0c79af98ac7205cb8bf25e795bb8e7ccd80941b82da8fe1f3a652721f9c31f2a9cb0f667e75ea46 SHA512 fc346dd2d464d3e8265624162ce70e6f160b40b313944602c88b47751a4683ca0bfa507a637d247e34c2905b1e4adaf635f5d3fa0747f0caecbf1ae088a83edb
+EBUILD ghc-8.4.3.ebuild 24789 BLAKE2B 8d4191e4bd518982f8a1f144ac29095cdd5b4f5fe6ba3fe231e3b227127b28016b5c62b83a3c5e3cc6b87ea4a4846f80a7636839c9aebd720d166609618c9da4 SHA512 961a4742ce76470b147f220582ff63d74839051b996928d8367719361e048d1fc5b606ecd02904e21c6cc532b97c3339a9bdedf9461ea6afb6c48b0edf724474
+EBUILD ghc-8.6.4.ebuild 25289 BLAKE2B bf53b84818447bcd942a12f1af974a3f137e910ead6ec877442a1615e26fb1b579fbe2f83998c98dbdc11574d78f0032dc07a6309c5beaf11249bc45cd24f8e8 SHA512 522465b47c2e1c2fc87467f6fac7dac06eff172f71568996ecb4dbac36cfdda23ce10a7e68812de54a4c74433faced696ce39ac54bd9ae45f4c5eada23867704
+EBUILD ghc-8.6.5.ebuild 25607 BLAKE2B 778f0ec72191f6edf04efb5f8fac9a7de8f143ab6bcf0962783fd2f21759d18bd06149129b5ae0070033982d5d38c3a50aa1787834c7b6442690617ab638ce69 SHA512 82f53bf9901189ea7e7d12311db34eb6797a72cffd18011d3f1b1f20c1a3377ac49598b8d8507d2ba3ae72058edb3c51d19d4a1ad645545aa22e86ddf5ae4fd0
+EBUILD ghc-8.8.1.ebuild 26259 BLAKE2B 6ceee4e2783a016ae5bb8fbed41c56813a54bfa52e29848c3493a4cbb7cf56bfb4fb442d65e80678a84fda26d3a3df0f4a070231833ce11da3518a33790bf338 SHA512 422510598addac07b785529d7be3eb8b17a8da602d4394260ae887860cdde08d442736c9a05ec0c09902984ece7d72f4b63249f124971ba63ef926c00d6d8133
+EBUILD ghc-8.8.2.ebuild 26215 BLAKE2B f3b143b12e4d0593327d8fae16cc52386f45409dd3e899c83e1ff039c897ead4fb851237b222b0bff8c742a52c4c064f1ea7994803cb307569b111aa5821a0e0 SHA512 026d6f79d453a679fb885fad3338ad16087ab0c9f6bcd29c8ccd2df24848d8cf5df39843887fe71495076c63d69008390e1f26e410a891ba28b1d4ad994c119e
+EBUILD ghc-8.8.3.ebuild 26277 BLAKE2B f713ba082a0d19f91515e696653adf2eb5a344527b29008e99c5314bec090afbce4af0d005503baba279cb8c83c140495b797bf627ca5ddadcdf642e7cd077d1 SHA512 8cae344ae3791e969f1ee35fdb5134ac36f7c66b26620a529765edb14e5fa2e4f3898da38585168f2fa09beaeec133d7e7d9f145fe4aa62caa3f9830e9af4072
 MISC metadata.xml 878 BLAKE2B aa6aa11c4c60763eb1d29253a6b63057ce98b16dce26d46de216064809665330102cb5313258197a95dda4be91ff843fbe778090110460883f5a367fe4837afd SHA512 97c636844d70431fc41a39318d2d29bf686fab362d0f962a95039c740ef91c6642f229539f34493e7a3f300211d6550a5a976d84d0fcef6f7dfaf026bcbc62e2
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 000000000000..7495cc8bff8d
--- /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 000000000000..19c8b4bccc48
--- /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-7.10.3.ebuild b/dev-lang/ghc/ghc-7.10.3.ebuild
index 7726e119c3c3..9a351c0e7641 100644
--- a/dev-lang/ghc/ghc-7.10.3.ebuild
+++ b/dev-lang/ghc/ghc-7.10.3.ebuild
@@ -1,4 +1,4 @@
-# Copyright 1999-2019 Gentoo Authors
+# Copyright 1999-2020 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 EAPI=5
@@ -72,7 +72,7 @@ BUMP_LIBRARIES=(
 
 LICENSE="BSD"
 SLOT="0/${PV}"
-KEYWORDS="~alpha amd64 ~ia64 ~ppc ~ppc64 ~sparc x86 ~amd64-linux ~x86-linux"
+KEYWORDS="amd64 ~ia64 ~ppc ~ppc64 x86 ~amd64-linux ~x86-linux"
 IUSE="doc ghcbootstrap ghcmakebinary +gmp"
 IUSE+=" binary"
 IUSE+=" elibc_glibc" # system stuff
@@ -81,7 +81,7 @@ RDEPEND="
 	>=dev-lang/perl-5.6.1
 	>=dev-libs/gmp-5:=
 	sys-libs/ncurses:0=[unicode]
-	!ghcmakebinary? ( virtual/libffi:= )
+	!ghcmakebinary? ( dev-libs/libffi:= )
 "
 
 # This set of dependencies is needed to run
diff --git a/dev-lang/ghc/ghc-7.8.4.ebuild b/dev-lang/ghc/ghc-7.8.4.ebuild
index b368f87ec193..bd936355ae3f 100644
--- a/dev-lang/ghc/ghc-7.8.4.ebuild
+++ b/dev-lang/ghc/ghc-7.8.4.ebuild
@@ -65,7 +65,7 @@ S="${WORKDIR}"/${GHC_P}
 SRC_URI+=" https://dev.gentoo.org/~slyfox/distfiles/${P}-ia64-CLOSUREs-regenerated.patch.gz"
 LICENSE="BSD"
 SLOT="0/${PV}"
-KEYWORDS="~alpha amd64 ia64 ppc ppc64 sparc x86 ~amd64-linux ~x86-linux"
+KEYWORDS="amd64 ~ia64 ppc ppc64 x86 ~amd64-linux ~x86-linux"
 IUSE="doc ghcbootstrap ghcmakebinary +gmp"
 IUSE+=" binary"
 IUSE+=" elibc_glibc" # system stuff
@@ -74,7 +74,7 @@ RDEPEND="
 	>=dev-lang/perl-5.6.1
 	>=dev-libs/gmp-5:=
 	sys-libs/ncurses:0=[unicode]
-	!ghcmakebinary? ( virtual/libffi:= )
+	!ghcmakebinary? ( dev-libs/libffi:= )
 "
 
 PREBUILT_BINARY_DEPENDS="
diff --git a/dev-lang/ghc/ghc-8.0.2.ebuild b/dev-lang/ghc/ghc-8.0.2.ebuild
index 853817376276..40cc58192d97 100644
--- a/dev-lang/ghc/ghc-8.0.2.ebuild
+++ b/dev-lang/ghc/ghc-8.0.2.ebuild
@@ -71,7 +71,7 @@ BUMP_LIBRARIES=(
 
 LICENSE="BSD"
 SLOT="0/${PV}"
-KEYWORDS="~alpha amd64 ia64 x86 ~amd64-linux ~x86-linux"
+KEYWORDS="amd64 ~ia64 x86 ~amd64-linux ~x86-linux"
 IUSE="doc ghcbootstrap ghcmakebinary +gmp +profile"
 IUSE+=" binary"
 
@@ -79,7 +79,7 @@ RDEPEND="
 	>=dev-lang/perl-5.6.1
 	dev-libs/gmp:0=
 	sys-libs/ncurses:0=[unicode]
-	!ghcmakebinary? ( virtual/libffi:= )
+	!ghcmakebinary? ( dev-libs/libffi:= )
 "
 
 # This set of dependencies is needed to run
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 000000000000..b9624ca1fcce
--- /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? ( 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} )"
+
+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
+}
diff --git a/dev-lang/ghc/ghc-8.2.1.ebuild b/dev-lang/ghc/ghc-8.2.1.ebuild
index 266b59e2bfe8..c701609e940a 100644
--- a/dev-lang/ghc/ghc-8.2.1.ebuild
+++ b/dev-lang/ghc/ghc-8.2.1.ebuild
@@ -1,4 +1,4 @@
-# Copyright 1999-2019 Gentoo Authors
+# Copyright 1999-2020 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 EAPI=5
@@ -75,7 +75,7 @@ RDEPEND="
 	>=dev-lang/perl-5.6.1
 	dev-libs/gmp:0=
 	sys-libs/ncurses:0=[unicode]
-	!ghcmakebinary? ( virtual/libffi:= )
+	!ghcmakebinary? ( dev-libs/libffi:= )
 "
 
 # This set of dependencies is needed to run
diff --git a/dev-lang/ghc/ghc-8.2.2.ebuild b/dev-lang/ghc/ghc-8.2.2.ebuild
index 6db8290ea34b..7304fe4bcc2e 100644
--- a/dev-lang/ghc/ghc-8.2.2.ebuild
+++ b/dev-lang/ghc/ghc-8.2.2.ebuild
@@ -1,4 +1,4 @@
-# Copyright 1999-2019 Gentoo Authors
+# Copyright 1999-2020 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 EAPI=6
@@ -75,7 +75,7 @@ RDEPEND="
 	>=dev-lang/perl-5.6.1
 	dev-libs/gmp:0=
 	sys-libs/ncurses:0=[unicode]
-	!ghcmakebinary? ( virtual/libffi:= )
+	!ghcmakebinary? ( dev-libs/libffi:= )
 "
 
 # This set of dependencies is needed to run
diff --git a/dev-lang/ghc/ghc-8.4.1.ebuild b/dev-lang/ghc/ghc-8.4.1.ebuild
index 2fb1025b91f4..bb77c83651a1 100644
--- a/dev-lang/ghc/ghc-8.4.1.ebuild
+++ b/dev-lang/ghc/ghc-8.4.1.ebuild
@@ -1,4 +1,4 @@
-# Copyright 1999-2019 Gentoo Authors
+# Copyright 1999-2020 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 EAPI=6
@@ -75,7 +75,7 @@ RDEPEND="
 	>=dev-lang/perl-5.6.1
 	dev-libs/gmp:0=
 	sys-libs/ncurses:0=[unicode]
-	!ghcmakebinary? ( virtual/libffi:= )
+	!ghcmakebinary? ( dev-libs/libffi:= )
 "
 
 # This set of dependencies is needed to run
diff --git a/dev-lang/ghc/ghc-8.4.2.ebuild b/dev-lang/ghc/ghc-8.4.2.ebuild
index 529e6682ff97..1560843584db 100644
--- a/dev-lang/ghc/ghc-8.4.2.ebuild
+++ b/dev-lang/ghc/ghc-8.4.2.ebuild
@@ -1,4 +1,4 @@
-# Copyright 1999-2019 Gentoo Authors
+# Copyright 1999-2020 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 EAPI=6
@@ -75,7 +75,7 @@ RDEPEND="
 	>=dev-lang/perl-5.6.1
 	dev-libs/gmp:0=
 	sys-libs/ncurses:0=[unicode]
-	!ghcmakebinary? ( virtual/libffi:= )
+	!ghcmakebinary? ( dev-libs/libffi:= )
 "
 
 # This set of dependencies is needed to run
diff --git a/dev-lang/ghc/ghc-8.4.3.ebuild b/dev-lang/ghc/ghc-8.4.3.ebuild
index 238882613374..8d8af4264738 100644
--- a/dev-lang/ghc/ghc-8.4.3.ebuild
+++ b/dev-lang/ghc/ghc-8.4.3.ebuild
@@ -1,4 +1,4 @@
-# Copyright 1999-2019 Gentoo Authors
+# Copyright 1999-2020 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 EAPI=6
@@ -75,7 +75,7 @@ RDEPEND="
 	>=dev-lang/perl-5.6.1
 	dev-libs/gmp:0=
 	sys-libs/ncurses:0=[unicode]
-	!ghcmakebinary? ( virtual/libffi:= )
+	!ghcmakebinary? ( dev-libs/libffi:= )
 "
 
 # This set of dependencies is needed to run
diff --git a/dev-lang/ghc/ghc-8.6.4.ebuild b/dev-lang/ghc/ghc-8.6.4.ebuild
index 9400b701afb3..2d192b4e58e0 100644
--- a/dev-lang/ghc/ghc-8.6.4.ebuild
+++ b/dev-lang/ghc/ghc-8.6.4.ebuild
@@ -1,4 +1,4 @@
-# Copyright 1999-2019 Gentoo Authors
+# Copyright 1999-2020 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 EAPI=6
@@ -81,7 +81,7 @@ RDEPEND="
 	>=dev-lang/perl-5.6.1
 	dev-libs/gmp:0=
 	sys-libs/ncurses:0=[unicode]
-	!ghcmakebinary? ( virtual/libffi:= )
+	!ghcmakebinary? ( dev-libs/libffi:= )
 "
 
 # This set of dependencies is needed to run
diff --git a/dev-lang/ghc/ghc-8.6.5.ebuild b/dev-lang/ghc/ghc-8.6.5.ebuild
index 2e4e523c095c..e95768813eac 100644
--- a/dev-lang/ghc/ghc-8.6.5.ebuild
+++ b/dev-lang/ghc/ghc-8.6.5.ebuild
@@ -85,7 +85,7 @@ RDEPEND="
 	dev-libs/gmp:0=
 	sys-libs/ncurses:0=[unicode]
 	elfutils? ( dev-libs/elfutils )
-	!ghcmakebinary? ( virtual/libffi:= )
+	!ghcmakebinary? ( dev-libs/libffi:= )
 	numa? ( sys-process/numactl )
 "
 
diff --git a/dev-lang/ghc/ghc-8.8.1.ebuild b/dev-lang/ghc/ghc-8.8.1.ebuild
index 7b8c9321190f..8d13a22eea76 100644
--- a/dev-lang/ghc/ghc-8.8.1.ebuild
+++ b/dev-lang/ghc/ghc-8.8.1.ebuild
@@ -84,7 +84,7 @@ RDEPEND="
 	dev-libs/gmp:0=
 	sys-libs/ncurses:0=[unicode]
 	elfutils? ( dev-libs/elfutils )
-	!ghcmakebinary? ( virtual/libffi:= )
+	!ghcmakebinary? ( dev-libs/libffi:= )
 	numa? ( sys-process/numactl )
 "
 
diff --git a/dev-lang/ghc/ghc-8.8.2.ebuild b/dev-lang/ghc/ghc-8.8.2.ebuild
index 0726cf1c9bc7..4d206d287dd2 100644
--- a/dev-lang/ghc/ghc-8.8.2.ebuild
+++ b/dev-lang/ghc/ghc-8.8.2.ebuild
@@ -84,7 +84,7 @@ RDEPEND="
 	dev-libs/gmp:0=
 	sys-libs/ncurses:0=[unicode]
 	elfutils? ( dev-libs/elfutils )
-	!ghcmakebinary? ( virtual/libffi:= )
+	!ghcmakebinary? ( dev-libs/libffi:= )
 	numa? ( sys-process/numactl )
 "
 
diff --git a/dev-lang/ghc/ghc-8.8.3.ebuild b/dev-lang/ghc/ghc-8.8.3.ebuild
new file mode 100644
index 000000000000..5d6e67ece459
--- /dev/null
+++ b/dev-lang/ghc/ghc-8.8.3.ebuild
@@ -0,0 +1,805 @@
+# 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? ( !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 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=""
+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} )"
+
+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
+		# 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
+}
+
+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
+		# 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)${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
+}
-- 
cgit v1.2.3