summaryrefslogtreecommitdiff
path: root/dev-lang/ghc
diff options
context:
space:
mode:
authorV3n3RiX <venerix@redcorelinux.org>2017-10-09 18:53:29 +0100
committerV3n3RiX <venerix@redcorelinux.org>2017-10-09 18:53:29 +0100
commit4f2d7949f03e1c198bc888f2d05f421d35c57e21 (patch)
treeba5f07bf3f9d22d82e54a462313f5d244036c768 /dev-lang/ghc
reinit the tree, so we can have metadata
Diffstat (limited to 'dev-lang/ghc')
-rw-r--r--dev-lang/ghc/Manifest71
-rw-r--r--dev-lang/ghc/files/ghc-7.0.4-CHOST-prefix.patch17
-rw-r--r--dev-lang/ghc/files/ghc-7.10.1-rc3-ghc-7.10-bootstrap.patch78
-rw-r--r--dev-lang/ghc/files/ghc-7.10.3-hardfloat.patch26
-rw-r--r--dev-lang/ghc/files/ghc-7.10.3-relnotes.patch45
-rw-r--r--dev-lang/ghc/files/ghc-7.6.3-preserve-inplace-xattr.patch14
-rw-r--r--dev-lang/ghc/files/ghc-7.8.1_rc1-libbfd.patch81
-rw-r--r--dev-lang/ghc/files/ghc-7.8.2-cgen-constify.patch34
-rw-r--r--dev-lang/ghc/files/ghc-7.8.3-linker-warn.patch35
-rw-r--r--dev-lang/ghc/files/ghc-7.8.3-pic-sparc.patch31
-rw-r--r--dev-lang/ghc/files/ghc-7.8.3-ppc32-fPIC.patch351
-rw-r--r--dev-lang/ghc/files/ghc-7.8.3-prim-lm.patch12
-rw-r--r--dev-lang/ghc/files/ghc-7.8.4-gold.patch27
-rw-r--r--dev-lang/ghc/files/ghc-7.8.4-ia64-CLOSUREs.patch66
-rw-r--r--dev-lang/ghc/files/ghc-8.0.1-limit-jN.patch50
-rw-r--r--dev-lang/ghc/files/ghc-8.0.1-par-g0-on-A32.patch65
-rw-r--r--dev-lang/ghc/files/ghc-8.0.1-ww-args-limit.patch127
-rw-r--r--dev-lang/ghc/files/ghc-8.0.1_rc1-cgen-constify.patch34
-rw-r--r--dev-lang/ghc/files/ghc-8.0.2-O2-unreg.patch35
-rw-r--r--dev-lang/ghc/files/ghc-8.0.2-libffi-alpha.patch57
-rw-r--r--dev-lang/ghc/files/ghc-8.0.2_rc2-old-sphinx.patch12
-rw-r--r--dev-lang/ghc/files/ghc-8.2.1-darwin.patch31
-rw-r--r--dev-lang/ghc/files/ghc-8.2.1_rc1-cgen-constify.patch378
-rw-r--r--dev-lang/ghc/files/ghc-8.2.1_rc1-ghci-cross.patch60
-rw-r--r--dev-lang/ghc/files/ghc-8.2.1_rc1-hp2ps-cross.patch104
-rw-r--r--dev-lang/ghc/files/ghc-8.2.1_rc1-stage2-cross.patch81
-rw-r--r--dev-lang/ghc/files/ghc-8.2.1_rc1-staged-cross.patch43
-rw-r--r--dev-lang/ghc/files/ghc-8.2.1_rc1-unphased-cross.patch30
-rw-r--r--dev-lang/ghc/files/ghc-8.2.1_rc1-win32-cross-1.patch124
-rw-r--r--dev-lang/ghc/files/ghc-8.2.1_rc1-win32-cross-2-hack.patch144
-rw-r--r--dev-lang/ghc/files/ghc-8.2.1_rc2-O2-unreg.patch35
-rw-r--r--dev-lang/ghc/files/ghc-8.2.1_rc3-any-vendor.patch44
-rw-r--r--dev-lang/ghc/files/ghc-8.2.1_rc3-stginit-data.patch27
-rw-r--r--dev-lang/ghc/files/ghc-bash-completion218
-rw-r--r--dev-lang/ghc/ghc-7.10.3.ebuild686
-rw-r--r--dev-lang/ghc/ghc-7.8.4.ebuild616
-rw-r--r--dev-lang/ghc/ghc-8.0.2.ebuild681
-rw-r--r--dev-lang/ghc/ghc-8.2.1.ebuild765
-rw-r--r--dev-lang/ghc/metadata.xml13
39 files changed, 5348 insertions, 0 deletions
diff --git a/dev-lang/ghc/Manifest b/dev-lang/ghc/Manifest
new file mode 100644
index 000000000000..aca5828dc470
--- /dev/null
+++ b/dev-lang/ghc/Manifest
@@ -0,0 +1,71 @@
+AUX ghc-7.0.4-CHOST-prefix.patch 272 SHA256 83942dfcbe1968c7f5e0ae09e4d84d77d85778839814fca1689e168cad3a4f66 SHA512 e969478289c9bb99e24ce73acc8da866e2d2944405849fe10308999a386c57c2058037e142ab8c6548f1f4e01b7722efe4af9fa6c375f0988ff5a023bd2a96dc WHIRLPOOL a8ea4c41a895fab20c7db9bddec330d2a9192785d5a0b488dee622a8a739d37c187d5585f57d98c78379a1dea21dea7cf8f0c3a58dd1c44de2fcbdc11f732427
+AUX ghc-7.10.1-rc3-ghc-7.10-bootstrap.patch 2648 SHA256 5a071e103187750f4945a66855558d908c08b6f1add70b9de0a28161e0f8fafd SHA512 ea2c9cd8fde754803950e29b2eea113227ca5504c58392847090e13640bdfa6b39ef714eff985947aa27e66c2506ef2a2867696f68a7ff34418a7fbf49765d48 WHIRLPOOL 2b45342e670df1a170a53246cdd5bb2de0692c2864154d8565515d122eb97c40a6eaa0d36c5c3c3776f1b9b8064e074257a326f12826572b1651f03038fda579
+AUX ghc-7.10.3-hardfloat.patch 747 SHA256 338d86fa83460da1ec0504616509626022fe3930360dfd883edf4820a0dc8a7d SHA512 a9a186ff62236d63b4b841bcfb1da1a902b3f300eb7d768c5316b5d636190d58fc71177f2d1670df261d0b681b104621f98cfdd76b30a0fb6917525874759264 WHIRLPOOL 2b4753ea0962b4c7407e81b01f1c2c6e3bd7a0020535c21fd2d81853c0be77d5673fd7e0810ffd28c20a5f82294c4a57cec4bf8e9438587cab5fc06c4155068a
+AUX ghc-7.10.3-relnotes.patch 1584 SHA256 c0d9cf98b61f7326db6aff5b2c48826b99c0bab8ea2a48eacf818fc626f985c8 SHA512 20d61d9f73bd0efa39c920897bdb18b69cff453f5ab24193aa3f7fafa70a9aa346ab4402604f81471f989c2401ca28d901fb85b8862577790559a35cfa3d3f05 WHIRLPOOL 29133ebe027e6cfce91556f9b907cbb014af8bb282049efbc660f7e3028df1fc977a08d7919d7f69945f534ec82f75a4714dee5fe3d32374a49fdbb08450e8e4
+AUX ghc-7.6.3-preserve-inplace-xattr.patch 495 SHA256 45e04a186e594ef4b550541fa43f9ed5ed7f83974ecac954f952279499de3c5b SHA512 98504e3b72446607deb520521c4abdd15e41e4ff69ad64e2ad13faca396bd7c7784b92c2bc7b5d8190668da480d5b1dd886f5e47e2e192d76b7fbbd58a42d44b WHIRLPOOL 3d634c6279d91df16653ede2b87edc4ac89256d34793abd6eac1bae7ec3e7986d87894ce88ac7a350b131d0e32fba3bed96af225329cb049126d708239965df0
+AUX ghc-7.8.1_rc1-libbfd.patch 2771 SHA256 d3d27bc0d161df7b9c7c64aca0138f04f0a2317f1e7194d549a8865848026071 SHA512 e232596342675769c6bf97686aff0fa7a8991e1edd3bf607068482cd0d0c9f9a9500e5b15f176a2025732474c9e547c0bae603d373c81b374c96787d46bbfa4a WHIRLPOOL 1fff73527c348a9561583f36e232cbb15c8e681b5b2ba81b786783ec5486db6c31b1d445201d9e56701a32d1210d5d2b47fa4b48e1688913b0c0111a080cbb57
+AUX ghc-7.8.2-cgen-constify.patch 1173 SHA256 604738d87e786b8b52e8e5a7059213fd7231f7998e76e125a0a0962e18931653 SHA512 3e1bca7d7f9062d231c45a6765485291871df833da31b0a5573bb04639791c554dd5c0d8fe33bab05455fe06d3f36fe81dd1db6d3819c739284a3af5c4ec8fb0 WHIRLPOOL c246ef43917caff35d85b80f3231de54fa5ff703cf6ebf3a6822406ec2b28e5b650736bc7688e4823fa16d40c700ca3db615c346435e79db89b7f1e09f472fc8
+AUX ghc-7.8.3-linker-warn.patch 1317 SHA256 0beacf4d6a43784fc77b95c5b8d0dd752261ba442501e72177b59e1a628242eb SHA512 3b0ece4a6536ef43f15e97e723d036401dcf41d47c15e29dd8fe30c9f1563894102922617982db7b6c7cf3ed8aea64458b540ef92ffe690ff72994b1246834c9 WHIRLPOOL 0e17c8d0d675b330f4bdea3ab60d6b17ac68eb4421fb8cd919d5924c269be3761335c2712270800e84c1d1d43918e9a53b49233c67a7f7fd85d3962c2f429667
+AUX ghc-7.8.3-pic-sparc.patch 1007 SHA256 71a77d9d43c76a5bb712bbd4bc00892058f51944157684b00758219e379cb2e7 SHA512 d3d81142a1e606c85c22127e2fbb26ceaeb2116435bf0bbc3743273577f04991e28c38a375a78b3f633a9b0e25f10951146d1f322e0ad7972089c1e5d977d16b WHIRLPOOL aebaa832e59ff50bbfb5447f89b9df0394167228bdab3da15399f9604cdfef5252bbc647c001af0b8b5753b34e5b554304e21f5cab7e65a30e8891e00045c000
+AUX ghc-7.8.3-ppc32-fPIC.patch 14549 SHA256 413638aeec8e7cf35495f163e584d459870ea001e74360c546419e801eb36b57 SHA512 aa6f13e04a52e7f25db456c02031b63c01b71adf41262361b36ca97aec18965f618ebba73494b4283ad3c0224f15d5c80dbd43076553e604d86a07baf7fa86db WHIRLPOOL 98b008bf28280b878446f3aab83176334c4dc27c759d408eff2a6a52e84d8d7f002f3cb15be8022e6c8ebdb3d364067db0738a9ca96c4159c213eaa925ea63e6
+AUX ghc-7.8.3-prim-lm.patch 444 SHA256 c147880c5c9f784cd731749589009a777317bd32b80b63f508730854025fcb7e SHA512 6979e002589a54c870c70eee8357dad4feb55b4e5102350cc09a466145677dacaa1bab5ebe4818cf0d3cd8ab50ee0ec2ab642ab0fb3fd34f4a266e5e90f9f389 WHIRLPOOL e33b43f42fa5e408d7879822c5081c89688cb924fadea32bb3c7ba426661c6b345e2051aac29e5f73ec2c7eafd63ae87413b4d52228e7e345308f5f816e1117a
+AUX ghc-7.8.4-gold.patch 1025 SHA256 632b044022c6ec60038164274250a34a3aaee9bd419e6f53ffe17d22ac145f06 SHA512 3087084d8b6a202496fc7ac71fadde06f7d1622d0e3f44f1b52fd04f1451d690f54b6bd8ee0da85663d252c6110340402bd1864f746117e59ce7b02e0247ec94 WHIRLPOOL 725031bcfaadd54b426600915ca4ef7a8815b6882ba0c723acf3a93c3a804282ea30c188954b4c4e1d869f4b9769f79b0db19718946279b256fc8ef5ecaf33db
+AUX ghc-7.8.4-ia64-CLOSUREs.patch 2243 SHA256 557841c6a05d7148235aa2290d19e0e7927de2451182dce04a7a83493eb8ac27 SHA512 9981d13f294fe0a28d1cabfd4db98bfb18110c6adb390f509667e3166a931c7d9f7b4b0079dfb1a22c174556944fef62f0e67ec855a9c3bccc5b54b0d0952c09 WHIRLPOOL c8d8f52e9c063106cb972e402966be8095c7a2761126cdc7dfe5e2584ab5d3e5fa11fae64db7b15fabdbd161123f1db4d5477f5653557ba22273cfce8da2ba3b
+AUX ghc-8.0.1-limit-jN.patch 1896 SHA256 f5077b57004c686cb5666d83915ea86048380e78143a3e463d7fd76a283341f6 SHA512 5eb69e0d5f87e326da82f018f0466a62e307f3acec47d991c7735ddf828c98c836dbff5d8164a4dfd08829b36a9d573828b9553fe89d65f5ac6be6c0190a110a WHIRLPOOL 83cc97e022b7c1620069d35a74e45efab341f4c84a8341b78779145573412f419f13050f46542a05afd3a0b6b70fb27ad91d0280816d667fedd779c7ce859d0d
+AUX ghc-8.0.1-par-g0-on-A32.patch 2276 SHA256 abcff6d7f711844570a5517cf056c1cb24719efdf3b0e403d58ff68f3de1a286 SHA512 0aab32a6f289c2a4e83bea2479c04cbd226f3399b5cb4a8a596ed756769a1b29bbbad261d7006c28ab56faa48c1c02e9e52cd35a7bba56ccc87f49ac1d17b0a5 WHIRLPOOL 215c3d2e7fdc621a221bd8cf147eb42d37913326fb9bbbce3bb34cb9f486ae78232c4073b5f8d7b473a43a3cd19e810afd197561b630463d0af26b54058a6f39
+AUX ghc-8.0.1-ww-args-limit.patch 5212 SHA256 529b30607e3622094a7227c47178a195dca04c337d46abbc23cd46d5dd555178 SHA512 5b3e34f52406649dca1cb3079565cfd068872387956dda296902c2e1ae8a092be0e70a1fc1d96f0e578fef0b82ff48b655d35a1e21911484f04d34809b295428 WHIRLPOOL 36b23f528bc4f3feb9bb6dac27f0572e0f7caf0315e314038adc53e8349a33bd6595e31dec66b09929ffbfb730d063f30250f7d42435a1ad9db8a75936f2578e
+AUX ghc-8.0.1_rc1-cgen-constify.patch 1185 SHA256 617f4a6e56f78ad97eed991809f78b296d12776df0c37bc6bbd6592d51cf203f SHA512 338c887a643b31ce6df2cbc28df03d1b98f48ae6b66afd0440cde7fafdc8ee51520f18c7f026645c3c995f106f78f451733b80abcdf8d4e4c3e9fcbcea597394 WHIRLPOOL 62fd7d6a171b62bdea4ca0ea5e952b586c72878f6f7cfda5d5077e3c92af15b86e9648387b357f4932303119f1bfda2486515747a77a2698c2bd3f524d14df63
+AUX ghc-8.0.2-O2-unreg.patch 1203 SHA256 e983a8df34cc49c705e8370c8a144162d62f3c9b6f969f5b660766b570eb56c8 SHA512 0d0252bb7c49cce2a38fb81673e6f6a6aad16728f66be6287f5a765064ebe5e5fa43f30f247fecaadc7fdd07af416522e5eb28656b3220ff3832ef8164c94019 WHIRLPOOL cf669382ed9a4b0a056e017a3317d61352980ce9588ca757a2076b8ed76fc8569ffc72f1ad1548ce72f1bbd1c7394cbbb00a552cc6c1b6c698bdaaf1579603fb
+AUX ghc-8.0.2-libffi-alpha.patch 2133 SHA256 29350d23998fd56b2260f2b2ef384bc57b70f6f328cd611b1b732970d722f3e3 SHA512 77964b82be47219d709ed4b79ac255c4762986decadef2d65d6643cb2d1b6cb0f3210cce1bd46bc16b6e6c51a4aabc73c5bc5e1bdaa8797a5f23033194f91a4a WHIRLPOOL ac8d54f233efb5bbd56fc61864c6a259c39bb93da7d9cb54d6054d3b4ca46c6f18689424f235074cef68868310abc7b56e98b407a2cae6eac6980218e83f275b
+AUX ghc-8.0.2_rc2-old-sphinx.patch 434 SHA256 4daa2d14789575304ac23284459c940034d19f15fc3ce09247369a81f7a32fec SHA512 fc8fd8d40c70a77a3aecfbdb0993bee9ef1582402b7220ed3066e1c6d4bc480c5b569cab44b58b3c54d1e68f506dc5b86ff87518d744a5a846d4de6cb1093db2 WHIRLPOOL fff4ab6612290088c5704a549fd0614e5e401ee9cd4f9483c6b782e8ee3d0e3ca8fd1528d1248cbd7280d76966e61d326e008d43ec96fba820fc53cda1a0ce87
+AUX ghc-8.2.1-darwin.patch 910 SHA256 020f390b635abfdf57bc5c3eb5c7c85d9ce0cf68d4bacf3d180ffd4f35fbe9ae SHA512 0177fda8717d9158a99d96853feb1bf40ff13df8f5c5669c7c48f33accf69d6ddb05876776cda66705e85ee56c5ecff8f81722d8e748b6c2ed6b9bf611e42a2c WHIRLPOOL 140b21eac0a40dc14bc7bcc65b3d084da2151d526e5ae87e34dd6780d2bce8b552aa3c17059b4307f8cf92d34c68298fb461cec5f2e3b49b65663a4922cc3e26
+AUX ghc-8.2.1_rc1-cgen-constify.patch 14371 SHA256 37e9c601eb146c4b53babd51a1a3522bd83cacb29d87ae6a877dbaf7d187f041 SHA512 8715c2f7c497eeefffd13b578ff718f36ec22bfe397501f685db0c781c614ebaa1178a9ca7550a722876d1cf9ace39aaa44493ecb934a828fa5010471672acfa WHIRLPOOL bdeecf23589066073a7d8686bcd21969b9aaf58d1475e8ed6ca58af5745a1b4c63b2f0df45af647d7d2d58e5eac167af9a7bf28113f7f5629585a14c0df047a8
+AUX ghc-8.2.1_rc1-ghci-cross.patch 2828 SHA256 85693e0ad4f0541529b56a48b48cccd1943a9cec690d36853065e35ed769636b SHA512 55e8f2e6bf69ff26976005e0b89c400df9facda5eb974f7340af89625361adce48371616a5d292dafbd4d98cbfbc0b656d36749f2e16918b275a0469ed88cea2 WHIRLPOOL 6c7865bdfd73c549e6712ddd3c5b2817df2a2213631413438c11f9637ee9c94498034f7cd4921a98032ee3224e8ad6be167d9a018ad101ac18feca7c6f42d1f0
+AUX ghc-8.2.1_rc1-hp2ps-cross.patch 3865 SHA256 837fd46648995e0e5162ce1c36aa542313ace11f7ba07435b250edbe7ca4273c SHA512 d2ed48701216f5c03567e61c207e32d6218009380941275c690edd8eb0197728e7e3c0edb00d512792dc2041a958de82ceef393e96d3324b690157162e28d29a WHIRLPOOL 09fec6cd2f5ce000e91f010a73c033c35242ebf874869769e55e711c08eec64a64ffa8532ab01e1cdde259b734a42716ddced4e27bae9010c62517e05f2b5923
+AUX ghc-8.2.1_rc1-stage2-cross.patch 2986 SHA256 d5f270b368768e4ef6e01c91312be60b8fd539f32e9dd502045d8dc75b0c9101 SHA512 7dcae0f9ff090e521befc9aa593a674ae9175ec07ebab91bc5a72097be509a89de12bf7c959870b12219074919eef115096b74f78e7cef00360aea32126ec8fa WHIRLPOOL 5456fc314e6cc10b030d2025fcfdf309157408f961cdbd6a59e902198a656fce3b7272f98f0d87792c9901d0fb7fa498a6efd844a7efb83a6fec1a4d77c4a0ba
+AUX ghc-8.2.1_rc1-staged-cross.patch 1605 SHA256 ee1630d6eb89fecae9a835e515dea330c094ccd7f7b1c4920cbaec69a9c2aac1 SHA512 d9005f0310002f87972b0db8484b714d15664209b41eb84ce26950c4a19e854203e9b78e959755ec65a2a50a73bbce4999b39a3ad4da844cfe65098e65171450 WHIRLPOOL e6922cf0802839def8a03c92c5337cac8a83798d54245971e105a23e26ad8905d4b48a0dde37aebc1e5adbd0aa89062d817c895c62b27bfa4bd37530844b5023
+AUX ghc-8.2.1_rc1-unphased-cross.patch 1066 SHA256 6d6a40828b9769104666f584e3a29cf5d81a5d65c323fe4294f3d53f8a8d0d8c SHA512 24b9b864e984cf3e34c2a23e0ba24a7f2c961dc590c6bb8e6461afeee7bc4a6361e5bbccf17754486c81136b60e12ae7e9ed06f485ef2f178084bcb2caa5edd9 WHIRLPOOL b91d00c94b1f8b7d531e324192092452ea0ce28553730c965b17c9f1438f2a0b47ea84ffbf1bc1e597d1ae295eae930cf37dfd6a3bae5971236e7aaef7c16eb2
+AUX ghc-8.2.1_rc1-win32-cross-1.patch 4535 SHA256 7875c0955531181ca0ad479e676838b2c3d4bc0ffef54d68e676723fe3e355e6 SHA512 16e8be604af1e856bcec0603caa9d4fa66d5e4773a68fecaf4a57f509cd241cc7fb37fb9705d253e28d871ce2afc942e940ca171b45d41715acae5ef6e0fde8b WHIRLPOOL e735a2852542c9ef23c9c664cbd230b1c4e6f73c28bd0bc5acbaccdd9a647f0dfea11d48f81f218106e544c780313fa2691e496b81d981d71ed523ad38e4d42f
+AUX ghc-8.2.1_rc1-win32-cross-2-hack.patch 6231 SHA256 828c281ceffd86bae491600d1fd4dbd54220b1f423e304bd2cf14c78e922e67c SHA512 8617c1346ba7aa2b41ee01feaa47f2ca477353f9b825be48c5d3505a134e0a80b613efc6cb92e7fbd3fe062e77450e197c826151a42c0c77177fc6ef8e65287f WHIRLPOOL c5ecf31cc31196f015378ef13339130c5d57266ff1678313ed399c847dd9215f2dd6f3c6c7d49be00f079d692261b179a3c087f3ede41362d05716b4fea1423f
+AUX ghc-8.2.1_rc2-O2-unreg.patch 1199 SHA256 1c097453ad6d10786f035543eb2f3489ba8c36affee77e1bb2de5c8f1dcef91e SHA512 708f68234f3678af3d41e7a50f9b914030536aad081b1a09a6169b12ed61ffd9db207a03f8f73d1761a93c5f2a21e92cdc23475501f96cac3bf98b046f3a6dba WHIRLPOOL 1d9c12897c4bf5ba2d3a4b53a912e8aa0b542b01d1c24a86e09bfa54838bd5b3437c9df21bed5cddef606a2cdd433bb7d1589031ea0f39b781d2bea42ab1afb3
+AUX ghc-8.2.1_rc3-any-vendor.patch 1288 SHA256 836e6635ba4c656891f94265598da2871389f7270141e27e7c39e921386c63d5 SHA512 934d6d91a434ef1ec8fbeb8b13f7a20b0654a97df05d10e8d4f577567b5a0498eed484261bc1348926e112c6d4429304f74f10e4ba819120cf5840e9dd2d8329 WHIRLPOOL bbcfaac7910aa1234f4c31b3af763eed9aa1d0f7d44cd46ddc03bcfdfa826e807c6c26fb33b3d528c6bf3105b864715796b941ba4a372639938452e06dda5d63
+AUX ghc-8.2.1_rc3-stginit-data.patch 1179 SHA256 ef5472a60d2c5bc971ade2fa99d8e6a08bbf5dcead7b4df6463c8ba903e08598 SHA512 351b78bce46699c63ba9e02103eda0e80eeb92cba9b364049a11e61bfec3f0bbd9317a4d221b51ea29e42e6735ea4d5e3a6357d0180dc91647b11ccbe5f885e4 WHIRLPOOL 7dd03356400d6380824be327802247d7f55a04ba9e7aa871aef51eb3478b47be55c215a762f16ed6aef4081d92879f9735ffa02f0722fed0da7c1ee1c1da8414
+AUX ghc-bash-completion 6496 SHA256 82a862bea2c9248e06fcf74d307de07b05a55f9eb95f412762bd02e53fece822 SHA512 ede79ccf23555f60f48297d29bd98e3ccfd67d2cf27462153e00beb930398cb497e34ba8316e91df44c577ed11fdbe5606f7c6a2777e35d5e783590e49ccfeb5 WHIRLPOOL 271dc4159ac500beb53981259e4b154b1f96e2909bb7cc43b7364f4fd4f86ce65df04611a46043c14079f699226195a002532fbb1e4ec01715e07e8469f9a7a4
+DIST binary-0.7.6.1.tar.gz 47086 SHA256 8f85cafc15be660757878a665d024ce595d4422fead174e20a501c9ec8f81067 SHA512 655daa93a52b845a85d440810452933d7bc3398ad1b51e1e955b2d19a0a32679325a0d1751ad50d252531e493528262e14dab32af4b9a515855fe7f64e0730b2 WHIRLPOOL 6853eb2c817e8ae792226c6c7764ce495833f965c3d503fe7e39c0502019d12f7bd46309b72dfdb276c7dbce8c004cb59fdea4936d69ede0a7c8b487acda2702
+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-8.2.1-src.tar.xz 10736016 SHA256 cfc2d496708dacea3ea7dde4c6a4b921b97a7f550ee2acea44cfa535840593f0 SHA512 d9aa2aa7f9414db8f4e51d6c275694b46df515e68331a1a2b6018256333a2c63ebd877b75ee90407ecce5be672ec9afc6bebd62aadbf8ae06b94f1760d1736be WHIRLPOOL ecbdf8e3f330ef329fab21865c5f063763a2320e03063aeb8777f6c4769a86b33504c0548df9c6ce859028277851e6e7482b7c3b62986c6186745f894e7567d9
+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
+DIST ghc-bin-7.10.3-ppc.tbz2 125832171 SHA256 67817636f5b91e04ecf94972c0bfe8e4e95efde82c4e23495b869da750409822 SHA512 4eb111e3686656a83515f59d4ace8bc28806dcabfcee5201ce29aee38b8efcefaaf70c50bee55202c2d2abbfbf231a6b41df8b13199332c53055adb1754a3191 WHIRLPOOL 8ec420bebf60b059c10ff0985993def7d1f40919d82e94b845b918f9ca146c8dd087f2abe9c2c7744e0f53acb75a752f8f7f6b72dabc04752dac22045302db2f
+DIST ghc-bin-7.10.3-ppc64.tbz2 142469712 SHA256 c8fa2ea861d4c5373f7f67fd3a29db4e48593d669c8616c2f349592af7e4846f SHA512 eb59d3abc8b10010311d59df9473c5ea649eb0dd7f9ad41a1929a540a0ef8c20abaccd68254f8abab037fb1fc94d824f474e18e4316b8f2a7a954d0645a2a2a4 WHIRLPOOL 14ccfbcf818a80f1daf39b44dc7562304af925e548407ce0deecd2d4593f4e138da38cfe63d4e5b8b0303c0237c678c27eaac4331288ee9b9dcbcf8be7390f74
+DIST ghc-bin-7.10.3-sparc.tbz2 163105069 SHA256 b9ef4179d87f4a56e9a786b28b0674f817118c73784b0dce283affadab296875 SHA512 d467a42487378d7dee311eb33aa1c151f5c16a6e7a4ab5bd8177df229f474adf19da3e1ca1064943a40abafcab6852b0589dd34413da82b33a03ede1ac17bf5d WHIRLPOOL 26ecb662f1d0eae524388008c24b3d25f954668aba781e997afd934c10b379b32e3376bc3a1232b066de84d3e1d1ad838dcef667b0f7606d0ac52acd7ef78a72
+DIST ghc-bin-7.10.3-x86.tbz2 113877175 SHA256 a06d54e7256292123b49c4d429761794b53d2440d2efeb98bcfe79920c65b044 SHA512 75096fe9106d975c15e646b0a559c544621fd02791f491bce54926efabf0e55b97150069ddfa7a9f02cc30bb6975d3d3121a82207a9f67b8dda5ebfe17ec4744 WHIRLPOOL 63fea83be14ae317f313251b7c952c974a8e4f9671d78d1b3ef77c3ab317d2194faddc8d71431c5e1fc42215abed1842913f2f40ba383288784e984c47cd27f0
+DIST ghc-bin-7.8.4-alpha.tbz2 210691009 SHA256 23c9e5ef97b444fa87d3b9509a7b2b7b68c526ca4139739dd60c08fb1279d48a SHA512 f08230de82f0c4112da9d0b48227ca74d5d0b4a84046d746b023557b7aeeb9678f5ac037fe89a863178df4b9036e5c5c63182d14dfbb42c772011de883e3966f WHIRLPOOL d624b4d5eac8aa68f389b81e68d7fa2ea960c9b9c5fabb27ddf4da5140c18fd0ee9080725fb645e2c532bb0a01ade32da2cf6aac08707f9d89a94ea9752b8e72
+DIST ghc-bin-7.8.4-amd64.tbz2 100573133 SHA256 bd9d144c08caa0ff345ada8d7eed7592531b8f8b9ef2f94d0b9a42fd747440aa SHA512 e4416d6dae3c644f74bafb3aecf1a123f985427aba32d0e0c43143a137d64a9220fc5947cd9bde8a3bc44555ae71184fc06a3f7df7976aadd065ad5681b90954 WHIRLPOOL ab0bd6219d68e08cb473cf2f3f15538d65940f28e84f026361032c3a6bc09f7820faf67629e915f27c2afda7de41fa9c6010a1b5cd487df0936d968c7e58a3a4
+DIST ghc-bin-7.8.4-ia64.tbz2 222789275 SHA256 8bbbc11ba64d08bad691593afafc4c6a7cf078b10cf33cb8508bf0a0b3ccf523 SHA512 2d8b89e399cbe9bfeae29cf3ceea736bfaa65ea21483fa2ee95d9814e122fcfbb67ce22ad8175493fab088e9a9d0139610c67e9d5c8b4f797b5e14846df32b6e WHIRLPOOL 181d48bbb53d181c8febf63ddae620bec1a6c212a5b5bf938228689df2ff45ba68d7d4a99ebb1b68aa516d5633be41125321e3f8fdef6e5f0cd1e4a7f9b8774c
+DIST ghc-bin-7.8.4-ppc.tbz2 112803496 SHA256 a47e0fb17137878af1e7b5a166046bee20d456d49da6ba8cde990173f4b3be8d SHA512 9581f55a088e53edcc969960e45c9ad7227d71198ce2d241a4a066a138450a879287e55e7d2210e86143670539711387e36c7f60660c4422dc1b4122278fe4a0 WHIRLPOOL 4904414cbfafdb48f0539b071fe80568da74beb174948ee426da5c22acf1d0c35ade89d2e160ddd109d2fbc0a508459a8e249f3b732b88735070b9522b417108
+DIST ghc-bin-7.8.4-ppc64.tbz2 129284515 SHA256 1e8a350af39d1db1e58a74c9bc4a4c57765eceb33e5b32751fb31340b9ff02ff SHA512 53974e15c26cf6b62d8f838607abd209ec57cf0f45fcc48b90ad62736f5e4e7ff263dcd326ae03d8d5557a22eb9730e5eb8ae4eda55e52dd3d973bc73c84935e WHIRLPOOL adaaa92323d319f6576423ac41678f7d263f36e0e30d89fc14ee89104b006772c26d7b408be7f85225d1bddaf5f15ebdcbb7136f5c8bf7bda4bb0938eefbe6c2
+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 ghc-bin-8.0.2-alpha.tbz2 234361847 SHA256 fbf8f0662cd2ed7f8c233bbc176fcbc050f90dd627acf0729626d6d96798baf8 SHA512 c8b588feeab85f7b8fd60e2e8bf755d46790d4882d2ecf6b2c8b8e02c62a11b7e6453bf0cfbc646bfbf24310fdc775337f3957ba5783675a271b68f0af2e9070 WHIRLPOOL fbd9cdbab00daad446f0110c2bb989189248ecd4ef504f57c874caf2845f863d4800940ee69c328b8dfa5eb4adf57698a16c1b2921cba149485bb4df206fe8a0
+DIST ghc-bin-8.0.2-amd64.tbz2 131007452 SHA256 d68b0682de40ff42b7f91ebd113d774cf5145cb9609c689e31cb1eaea75ee355 SHA512 d960c40966e392d5497f694f0b47df4a6ec22ad1b4a607437c8af7c33dfbf122ccefb525d807716539af57c31660378e52fc495dd0a1d0fc3bccaef3578be177 WHIRLPOOL af5703c3df66f61b82746d784d6c937ce490944f387354b90846bcda9dbb02ee226abe6715d227be34677890fd0e6865d046c10a24d1309e9b6d8875398d501b
+DIST ghc-bin-8.0.2-arm64.tbz2 191332951 SHA256 eb016875bb7bed6a03c72f142d05e2c4992526d4b5c674810fff723240b62b28 SHA512 b9cabfda8fc6e851ba99f53274c1a63c5a6a365311a9203f1247ecf90ab843dd94960ad44c4e67032f4690f07d67bfd8bdfbe59f857d6c63344430539e2082fc WHIRLPOOL e70f703acddf5e1778533ff221aa6dd0149e0381dfee352be66d72996bd67752bf17fc550dd27c7cf0a34e2f81995126b6edcb1f9c39f3e281a8bbd9f99a0735
+DIST ghc-bin-8.0.2-ia64.tbz2 250237654 SHA256 f3e74db697900d031c4d405310c3bf3f40f663c5029b51039358914f835b8287 SHA512 e8cb381de12ccc0a7b513683deb5de555fecea22a735d09b073b0199ab4124305bbd8a093b4710b827513d33fd4224007e7bd210b146508eb183be7dfd283a26 WHIRLPOOL 284d780f6d3f7b786209ef5cbf844df37b3cda89ad4c2c7e6ffbe8bd4f890f512f4fbfef28373a40f91f0644ef4fb0ce49a3425cac9431bdaa1bb90e3aa810ec
+DIST ghc-bin-8.0.2-ppc.tbz2 144760090 SHA256 a261dd97df396296d1a94c311c757040f74284b812634d97734557915d0a44ca SHA512 bc6bf8998064ffc1692c3bb83c44d1787760a3f4a1e6b79dedaefda5fe32b9052049a60f0ddd3c0b0bd24a722fb35e310e0189b3511721ff89d4d02b3d7c14bb WHIRLPOOL b070acb230dccc2faed66002f4384c8c9b17ce58655b5861766582558a66236136b1d02ab6226c7de5c74960c7d2d37c3c0069e38dfa980730043f623df4baa6
+DIST ghc-bin-8.0.2-ppc64.tbz2 117432068 SHA256 f2eb278c4d40d92233767d48149ec96a6c6097159ec846a984152c99a559803a SHA512 0eaff0557b68649a15bbeb2019f46fa9e9e7b8a916aa210ab56888090a5b887d20d818e7987177bc6a8e7fde503de560026e6bb55fe39679b8b1ee13c6b7c4f9 WHIRLPOOL 8a4ba955183cb7c94ecb59f62eab18a4ee75aa422d3c6e7172d347112b8445dccf86c718fcd84d3271dcb1f35fee0451fece184840403a02f7ed8bb39785075e
+DIST ghc-bin-8.0.2-x86.tbz2 133372061 SHA256 5e56bff6831a9c151d5d6f82db49b21d33bea05f05cdf74fca5adc423d546711 SHA512 020ce0e597e2907550c080f1bb0f863dbf83d5d45df2b3f44173506475bc4ef5423c5a060fdacd87614c3ec398ad94c2dcab9cff0376a54a2c54c2eb1e2f657d WHIRLPOOL 221eae08caff5c2157fae7df901c94d6d1393be3ab0526bb9d8a80d4304af4c4a420fcc2fe62926bf01c3bb02f161f1eb61c7eb47d3c6801cfacb25c1a33e983
+DIST ghc-bin-8.2.1-i686-pc-linux-gnu.tbz2 96157437 SHA256 2a05584fd51a4e9040a3611a0687d814b62b28c5ccd4102b00cf8bbfecadeec9 SHA512 e891e76557fa61853e28829b8bedc4a6abb92954f90cc1ebcf22a13cc137556bbe9262e7398b7e1aedbabeb997916b008bf1561a52f16a569f3d58ea9404f41e WHIRLPOOL c955dbc501b6c3effe08a91ba8b6584e74b224427c56232744c4ddedad72039e2cdb2f3ea1193e6ae2e7fd8a46a947cf7a835399c81f5dd5568c3ce1ad8a5adc
+DIST ghc-bin-8.2.1-x86_64-pc-linux-gnu.tbz2 97490496 SHA256 b67f4f7518a4e2ec5cfc0434dde0365cbfe37c4c7e164e9e8e38199bb6f083cd SHA512 52630a185d0eab56bce0469a612a54109895bfee041ec362ced59a9b35ba3b9c185e86bc7dbf0a5939081d3626baa19fbb3306e36d1857530248a7b9bfc100bb WHIRLPOOL 7998e0c351bd6943bd351909f5e9af0146a3e08f04141fc54807ebea994e4bbcec44247c885865eaa5af8786dfb514eed4fffc35ffaabe81f2d7f8a856ed10d9
+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
+EBUILD ghc-7.10.3.ebuild 22300 SHA256 354bad8f2eab34406be6b39e1c079566cb3ce6fef7d1df8d9aeee9fbab396ee5 SHA512 99f2a4a831f75341b63526d00f243a7284dbd7cc35a4875efd3f014cab30cf3dc48bcc428cb1eb6e1562c7a2a06f34be3b64b65bc21cb65e84c65461d65c300d WHIRLPOOL 35304b2a7a5f5f3cc8cf883ece80f7b85b061c0f9e092cfc6cba1198a1fab38fc3ad55d57c893389f922a24491c27b52ebddb849ff29f00b6ff07500ecfbf82a
+EBUILD ghc-7.8.4.ebuild 20466 SHA256 af321e3a26f242d6b7f93d9811493fb3832f176e4043471922b198a2b5681f9a SHA512 d9eca875ad4bbccade1ebb31b83f10e57c9cf84577a3b25f86a9869af8555813db48d028df76c9c47d624ae461f1b6c32369b18ca4c39c889333ad19fb37f1ac WHIRLPOOL 7584b84e45012c2ecf0091e5dc7d4390d200fd8a1de24b3e38d23a7b37196cbe13fef95a460085722929c60aece924f2943d0a53d2f1caba69cb1e389960ca90
+EBUILD ghc-8.0.2.ebuild 22010 SHA256 a7229d35ae1d56672aa1dd8c9a0cdf59cba141e0c55e44b9227fdf98a6f67471 SHA512 cb77220223b8a00457d17c9dd7d8ff2e4221bc26382067d3dd0049ed13f65dad12fae69ee99fb2077dc003baaad42b605c5c448d366c9f251fd091a699c8381e WHIRLPOOL 561e46af6efda37c0b8cd6644dba6dbdfc486593df63ab82d1974aa90a9e4a4a68ef8b5badcebb7a404b924bb1bc34f1dba39d880f67a9cefdaeacc88ca20624
+EBUILD ghc-8.2.1.ebuild 25345 SHA256 06f270d334f53cf8da7df363b08f2caac39f50810a54f67610682a9b612f491f SHA512 deab1abb757ecba2113be9cdb82d9ce7ee7ee1094c4ce6d8f0c0bac8c8d5bd2dd584e8dd07d667afcf682fa304f4a23273c8331dc010de6c6c25bda6f0da68a8 WHIRLPOOL dcfc8cceeaa3b5bf06d8f4c2c02ebee3d65f684c0aad39fc7c2d6b2368093e2d48db1eff81028db68b645ea1070bc158f9746b3589046d3d9d87090bf9cdd257
+MISC ChangeLog 6712 SHA256 edb50720c9aabde7fe6a43923903005fdc456d6e7553ec352b9a5e1d4a6a2671 SHA512 dfd4cb4838bc5c9e829f130df499f33782650cb5315cbdd84025677d4b428d4c301dbb32374de69cea95e62e15070659b774d97aaaee0e306217ee11d459b872 WHIRLPOOL 02c53782c7f98222bf6c5496f8795648460890ee1a51108a324c3a6bc0b6b7d014b3ffbf4050507fb477218ee5517397713c9b45d9b1a06b202897423711993e
+MISC ChangeLog-2015 52851 SHA256 feddaa2305430f9f381bc36281fc3c3b3a4c0a60ce00f6de9a00bf9bf6b1ff62 SHA512 db3d92c600335d49cdbe77cfa0863c9ca025359dff8e58b2d792598e95edb03ab5dbbf2399a54ea5fec96b2d72d5c5b33d0447cf8409c73722e575a178d41970 WHIRLPOOL 650bb4225e167a478586daa1d1305f17fcb84306c512974b93d1f0ae1b859056233955ee5b0563405221093ffa3ac948565422228d7ef9967d12124b9fd6d8a6
+MISC metadata.xml 577 SHA256 c015496208354e95808fac7ec7b8f5a8383e7a3065bd33bf8e95e8e070abd918 SHA512 7484ae45b530169fd0cf616af4f87bb0d551aadb7784dbde24ff4a63f7346cf0c94550240a7d22599cfb04a72ef4ec984edc325ce7e0b787709681ef10193873 WHIRLPOOL 56d0df6aead35b637669b54eb3c401b8dee2d0189d92dfc764182cf9785b4eaf2c5cfddce5115de6be2e48e1ba87f87f7b59cd91043767f52b4a70e50652fe39
diff --git a/dev-lang/ghc/files/ghc-7.0.4-CHOST-prefix.patch b/dev-lang/ghc/files/ghc-7.0.4-CHOST-prefix.patch
new file mode 100644
index 000000000000..682c573c90a6
--- /dev/null
+++ b/dev-lang/ghc/files/ghc-7.0.4-CHOST-prefix.patch
@@ -0,0 +1,17 @@
+Strip versioning components from *HOST for Darwin and Solaris
+
+--- aclocal.m4
++++ aclocal.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-7.10.1-rc3-ghc-7.10-bootstrap.patch b/dev-lang/ghc/files/ghc-7.10.1-rc3-ghc-7.10-bootstrap.patch
new file mode 100644
index 000000000000..60db34b8b362
--- /dev/null
+++ b/dev-lang/ghc/files/ghc-7.10.1-rc3-ghc-7.10-bootstrap.patch
@@ -0,0 +1,78 @@
+--- ghc-7.10.0.20150316-orig/compiler/utils/Pair.hs 2015-03-10 05:43:13.000000000 +1100
++++ ghc-7.10.0.20150316/compiler/utils/Pair.hs 2015-03-17 09:50:48.491115080 +1100
+@@ -15,6 +15,8 @@
+ import Data.Foldable
+ import Data.Monoid
+ import Data.Traversable
++#else
++import Control.Applicative ((<$>))
+ #endif
+
+ data Pair a = Pair { pFst :: a, pSnd :: a }
+--- ghc-7.10.0.20150316-orig/compiler/types/Coercion.hs 2015-03-10 05:43:13.000000000 +1100
++++ ghc-7.10.0.20150316/compiler/types/Coercion.hs 2015-03-17 10:11:21.636047380 +1100
+@@ -104,6 +104,8 @@
+ #if __GLASGOW_HASKELL__ < 709
+ import Control.Applicative hiding ( empty )
+ import Data.Traversable (traverse, sequenceA)
++#else
++import Control.Applicative ((<$>))
+ #endif
+ import FastString
+ import ListSetOps
+--- ghc-7.10.0.20150316-orig/compiler/typecheck/TcEvidence.hs 2015-03-14 08:48:57.000000000 +1100
++++ ghc-7.10.0.20150316/compiler/typecheck/TcEvidence.hs 2015-03-17 10:26:03.251433371 +1100
+@@ -50,6 +50,8 @@
+ #if __GLASGOW_HASKELL__ < 709
+ import Control.Applicative
+ import Data.Traversable (traverse, sequenceA)
++#else
++import Control.Applicative ((<$>))
+ #endif
+ import qualified Data.Data as Data
+ import Outputable
+--- ghc-7.10.0.20150316-orig/compiler/hsSyn/HsBinds.hs 2015-03-10 05:43:13.000000000 +1100
++++ ghc-7.10.0.20150316/compiler/hsSyn/HsBinds.hs 2015-03-17 10:42:21.459519033 +1100
+@@ -47,6 +47,8 @@
+ import Data.Traversable ( Traversable(..) )
+ import Data.Monoid ( mappend )
+ import Control.Applicative hiding (empty)
++#else
++import Control.Applicative ((<$>))
+ #endif
+
+ {-
+--- ghc-7.10.0.20150316-orig/compiler/parser/RdrHsSyn.hs 2015-03-10 05:43:13.000000000 +1100
++++ ghc-7.10.0.20150316/compiler/parser/RdrHsSyn.hs 2015-03-17 11:17:48.950929542 +1100
+@@ -91,9 +91,7 @@
+ import Util
+ import ApiAnnotation
+
+-#if __GLASGOW_HASKELL__ < 709
+ import Control.Applicative ((<$>))
+-#endif
+ import Control.Monad
+
+ import Text.ParserCombinators.ReadP as ReadP
+--- ghc-7.10.0.20150316-orig/compiler/typecheck/TcGenDeriv.hs 2015-03-14 08:48:57.000000000 +1100
++++ ghc-7.10.0.20150316/compiler/typecheck/TcGenDeriv.hs 2015-03-17 11:30:39.106508173 +1100
+@@ -59,6 +59,8 @@
+ import Var
+ #if __GLASGOW_HASKELL__ < 709
+ import MonadUtils
++#else
++import Control.Applicative ((<$>))
+ #endif
+ import Outputable
+ import Lexeme
+--- ghc-7.10.0.20150316-orig/compiler/vectorise/Vectorise/Exp.hs 2015-03-10 05:43:13.000000000 +1100
++++ ghc-7.10.0.20150316/compiler/vectorise/Vectorise/Exp.hs 2015-03-17 11:46:41.829481669 +1100
+@@ -46,6 +46,8 @@
+ import Util
+ #if __GLASGOW_HASKELL__ < 709
+ import MonadUtils
++#else
++import Control.Applicative ((<$>))
+ #endif
+
+ import Control.Monad
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 000000000000..106d07aa31c8
--- /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 000000000000..675037946e75
--- /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/files/ghc-7.6.3-preserve-inplace-xattr.patch b/dev-lang/ghc/files/ghc-7.6.3-preserve-inplace-xattr.patch
new file mode 100644
index 000000000000..08410fa0cd9b
--- /dev/null
+++ b/dev-lang/ghc/files/ghc-7.6.3-preserve-inplace-xattr.patch
@@ -0,0 +1,14 @@
+On hardened 'cp' drops out XT-pax parking.
+perfinion suggested using 'install', where portage
+might have a chance to save our marking.
+
+Reported-by: Jay Yang
+Gentoo-bug: https://bugs.gentoo.org/518734
+diff --git a/rules/build-prog.mk b/rules/build-prog.mk
+index 399369e..2ee9cd5 100644
+--- a/rules/build-prog.mk
++++ b/rules/build-prog.mk
+@@ -288,3 +288,3 @@ endif
+ $$($1_$2_INPLACE) : $1/$2/build/tmp/$$($1_$2_PROG_INPLACE) | $$$$(dir $$$$@)/.
+- "$$(CP)" -p $$< $$@
++ $$(INSTALL) -m 755 $$< $$@
diff --git a/dev-lang/ghc/files/ghc-7.8.1_rc1-libbfd.patch b/dev-lang/ghc/files/ghc-7.8.1_rc1-libbfd.patch
new file mode 100644
index 000000000000..d01cb49affbd
--- /dev/null
+++ b/dev-lang/ghc/files/ghc-7.8.1_rc1-libbfd.patch
@@ -0,0 +1,81 @@
+commit bb5953484579968c984d074ca1af5d21e1c9e7a0
+Author: Sergei Trofimovich <slyfox@gentoo.org>
+Date: Mon Feb 10 12:45:58 2014 +0300
+
+ rts: unrust 'libbfd' debug symbols parser
+
+ Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
+
+diff --git a/configure.ac b/configure.ac
+index e7fbc7f..e47979c 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -801,7 +801,8 @@ fi
+ dnl ** check whether this machine has BFD and libiberty installed (used for debugging)
+ dnl the order of these tests matters: bfd needs libiberty
+ AC_CHECK_LIB(iberty, xmalloc)
+-AC_CHECK_LIB(bfd, bfd_uncompress_section_contents)
++dnl 'bfd_init' is a rare non-macro in libbfd
++AC_CHECK_LIB(bfd, bfd_init)
+
+ dnl ################################################################
+ dnl Check for libraries
+diff --git a/rts/Printer.c b/rts/Printer.c
+index ca9ca49..ce02b02 100644
+--- a/rts/Printer.c
++++ b/rts/Printer.c
+@@ -48,6 +48,9 @@ void printPtr( StgPtr p )
+ raw = lookupGHCName(p);
+ if (raw != NULL) {
+ printZcoded(raw);
++ /* it can be just a C symbol, like 'stg_returnToStackTop' */
++ debugBelch("<%s>", raw);
++ debugBelch("[%p]", p);
+ } else {
+ debugBelch("%p", p);
+ }
+@@ -794,7 +797,7 @@ static void printZcoded( const char *raw )
+ disabling this for now.
+ */
+ #ifdef USING_LIBBFD
+-
++#include "../mk/config.h" /* silly BFD's requirement */
+ #include <bfd.h>
+
+ /* Fairly ad-hoc piece of code that seems to filter out a lot of
+@@ -863,7 +866,10 @@ extern void DEBUG_LoadSymbols( char *name )
+ for( i = 0; i != number_of_symbols; ++i ) {
+ symbol_info info;
+ bfd_get_symbol_info(abfd,symbol_table[i],&info);
+- /*debugBelch("\t%c\t0x%x \t%s\n",info.type,(nat)info.value,info.name); */
++ if (0)
++ {
++ debugBelch("\t%c\t0x%x \t%s\n",info.type,(nat)info.value,info.name);
++ }
+ if (isReal(info.type, info.name)) {
+ num_real_syms += 1;
+ }
+diff --git a/rts/RtsStartup.c b/rts/RtsStartup.c
+index aa7306f..5bdef94 100644
+--- a/rts/RtsStartup.c
++++ b/rts/RtsStartup.c
+@@ -19,6 +19,7 @@
+ #include "RtsFlags.h"
+ #include "RtsUtils.h"
+ #include "Prelude.h"
++#include "Printer.h" /* DEBUG_LoadSymbols */
+ #include "Schedule.h" /* initScheduler */
+ #include "Stats.h" /* initStats */
+ #include "STM.h" /* initSTM */
+@@ -162,6 +163,11 @@ hs_init_ghc(int *argc, char **argv[], RtsConfig rts_config)
+ rts_config.rts_opts_enabled, rts_config.rts_opts, rts_config.rts_hs_main);
+ }
+
++#ifdef DEBUG
++ /* load debugging symbols */
++ DEBUG_LoadSymbols((*argv)[0]);
++#endif /* DEBUG */
++
+ /* Initialise the stats department, phase 1 */
+ initStats1();
+
diff --git a/dev-lang/ghc/files/ghc-7.8.2-cgen-constify.patch b/dev-lang/ghc/files/ghc-7.8.2-cgen-constify.patch
new file mode 100644
index 000000000000..efdd54fbf3fb
--- /dev/null
+++ b/dev-lang/ghc/files/ghc-7.8.2-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 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-7.8.3-linker-warn.patch b/dev-lang/ghc/files/ghc-7.8.3-linker-warn.patch
new file mode 100644
index 000000000000..c8570c06940b
--- /dev/null
+++ b/dev-lang/ghc/files/ghc-7.8.3-linker-warn.patch
@@ -0,0 +1,35 @@
+commit 326046739801a380c5457ef4c87bce8fb95497ba
+Author: Sergei Trofimovich <slyfox@gentoo.org>
+Date: Sun Aug 10 22:12:28 2014 +0300
+
+ systools info: fix warning about C compiler (message said about linker)
+
+ Summary: Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
+
+ Test Plan: build-tested
+
+ Reviewers: austin
+
+ Reviewed By: austin
+
+ Subscribers: phaskell, simonmar, relrod, ezyang, carter
+
+ Differential Revision: https://phabricator.haskell.org/D132
+
+diff --git a/compiler/main/SysTools.lhs b/compiler/main/SysTools.lhs
+index 1c1c52c..72fa19b 100644
+--- a/compiler/main/SysTools.lhs
++++ b/compiler/main/SysTools.lhs
+@@ -809,10 +809,10 @@ getCompilerInfo' dflags = do
+ )
+ (\err -> do
+ debugTraceMsg dflags 2
+- (text "Error (figuring out compiler information):" <+>
++ (text "Error (figuring out C compiler information):" <+>
+ text (show err))
+ errorMsg dflags $ hang (text "Warning:") 9 $
+- text "Couldn't figure out linker information!" $$
++ text "Couldn't figure out C compiler information!" $$
+ text "Make sure you're using GNU gcc, or clang"
+ return UnknownCC)
+ return info
diff --git a/dev-lang/ghc/files/ghc-7.8.3-pic-sparc.patch b/dev-lang/ghc/files/ghc-7.8.3-pic-sparc.patch
new file mode 100644
index 000000000000..16a552fdd4be
--- /dev/null
+++ b/dev-lang/ghc/files/ghc-7.8.3-pic-sparc.patch
@@ -0,0 +1,31 @@
+commit 78863edbb0751f5c9694ea10c6132a87cfd0ee10
+Author: Sergei Trofimovich <slyfox@gentoo.org>
+Date: Wed Aug 27 22:20:33 2014 +0300
+
+ Revert "disable shared libs on sparc (linux/solaris) (fixes #8857)"
+
+ This reverts commit 623883f1ed0ee11cc925c4590fb09565403fd231.
+
+ The commit a93ab43ab5f40cadbedea2f6342b93c245e91434
+ driver: pass '-fPIC' option to assembler as well
+ fixes shared libraries on sparc at least on linux.
+
+ Properly fixes Issue #8857
+
+ Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
+
+diff --git a/mk/config.mk.in b/mk/config.mk.in
+index c210cd3..392237f 100644
+--- a/mk/config.mk.in
++++ b/mk/config.mk.in
+@@ -97,9 +97,7 @@ endif
+ # Some platforms don't support shared libraries
+ NoSharedLibsPlatformList = powerpc-unknown-linux \
+ x86_64-unknown-mingw32 \
+- i386-unknown-mingw32 \
+- sparc-sun-solaris2 \
+- sparc-unknown-linux
++ i386-unknown-mingw32
+
+ ifeq "$(SOLARIS_BROKEN_SHLD)" "YES"
+ NoSharedLibsPlatformList += i386-unknown-solaris2
diff --git a/dev-lang/ghc/files/ghc-7.8.3-ppc32-fPIC.patch b/dev-lang/ghc/files/ghc-7.8.3-ppc32-fPIC.patch
new file mode 100644
index 000000000000..434be8b1bdad
--- /dev/null
+++ b/dev-lang/ghc/files/ghc-7.8.3-ppc32-fPIC.patch
@@ -0,0 +1,351 @@
+commit fa31e8f4a0f853848d96549a429083941877bf8d
+Author: Sergei Trofimovich <siarheit@google.com>
+Date: Sun Dec 14 14:30:12 2014 +0000
+
+ powerpc: fix and enable shared libraries by default on linux
+
+ Summary:
+ And fix things all the way down to it. Namely:
+ - remove 'r30' from free registers, it's an .LCTOC1 register
+ for gcc. generated .plt stubs expect it to be initialised.
+ - fix PicBase computation, which originally forgot to use 'tmp'
+ reg in 'initializePicBase_ppc.fetchPC'
+ - mark 'ForeighTarget's as implicitly using 'PicBase' register
+ (see comment for details)
+ - add 64-bit MO_Sub and test on alloclimit3/4 regtests
+ - fix dynamic label offsets to match with .LCTOC1 offset
+
+ Signed-off-by: Sergei Trofimovich <siarheit@google.com>
+
+ Test Plan: validate passes equal amount of vanilla/dyn tests
+
+ Reviewers: simonmar, erikd, austin
+
+ Reviewed By: erikd, austin
+
+ Subscribers: carter, thomie
+
+ Differential Revision: https://phabricator.haskell.org/D560
+
+ GHC Trac Issues: #8024, #9831
+
+diff --git a/compiler/cmm/CLabel.hs b/compiler/cmm/CLabel.hs
+index 0f2c0ae..37b8ada 100644
+--- a/compiler/cmm/CLabel.hs
++++ b/compiler/cmm/CLabel.hs
+@@ -1170,7 +1170,8 @@ pprDynamicLinkerAsmLabel platform dllInfo lbl
+ else if osElfTarget (platformOS platform)
+ then if platformArch platform == ArchPPC
+ then case dllInfo of
+- CodeStub -> ppr lbl <> text "@plt"
++ CodeStub -> -- See Note [.LCTOC1 in PPC PIC code]
++ ppr lbl <> text "+32768@plt"
+ SymbolPtr -> text ".LC_" <> ppr lbl
+ _ -> panic "pprDynamicLinkerAsmLabel"
+ else if platformArch platform == ArchX86_64
+diff --git a/compiler/nativeGen/PIC.hs b/compiler/nativeGen/PIC.hs
+index 9b5c080..6326a8b 100644
+--- a/compiler/nativeGen/PIC.hs
++++ b/compiler/nativeGen/PIC.hs
+@@ -54,7 +54,6 @@ import qualified X86.Instr as X86
+
+ import Platform
+ import Instruction
+-import Size
+ import Reg
+ import NCGMonad
+
+@@ -468,11 +467,8 @@ pprGotDeclaration dflags ArchX86 OSDarwin
+ pprGotDeclaration _ _ OSDarwin
+ = empty
+
+--- pprGotDeclaration
++-- Emit GOT declaration
+ -- Output whatever needs to be output once per .s file.
+--- The .LCTOC1 label is defined to point 32768 bytes into the table,
+--- to make the most of the PPC's 16-bit displacements.
+--- Only needed for PIC.
+ pprGotDeclaration dflags arch os
+ | osElfTarget os
+ , arch /= ArchPPC_64
+@@ -482,6 +478,7 @@ pprGotDeclaration dflags arch os
+ | osElfTarget os
+ , arch /= ArchPPC_64
+ = vcat [
++ -- See Note [.LCTOC1 in PPC PIC code]
+ ptext (sLit ".section \".got2\",\"aw\""),
+ ptext (sLit ".LCTOC1 = .+32768") ]
+
+@@ -688,12 +685,7 @@ pprImportedSymbol _ _ _
+
+
+ -- Get a pointer to our own fake GOT, which is defined on a per-module basis.
+--- This is exactly how GCC does it, and it's quite horrible:
+--- We first fetch the address of a local label (mkPicBaseLabel).
+--- Then we add a 16-bit offset to that to get the address of a .long that we
+--- define in .text space right next to the proc. This .long literal contains
+--- the (32-bit) offset from our local label to our global offset table
+--- (.LCTOC1 aka gotOffLabel).
++-- This is exactly how GCC does it in linux.
+
+ initializePicBase_ppc
+ :: Arch -> OS -> Reg
+@@ -704,18 +696,9 @@ initializePicBase_ppc ArchPPC os picReg
+ (CmmProc info lab live (ListGraph blocks) : statics)
+ | osElfTarget os
+ = do
+- dflags <- getDynFlags
+- gotOffLabel <- getNewLabelNat
+- tmp <- getNewRegNat $ intSize (wordWidth dflags)
+ let
+- gotOffset = CmmData Text $ Statics gotOffLabel [
+- CmmStaticLit (CmmLabelDiffOff gotLabel
+- mkPicBaseLabel
+- 0)
+- ]
+- offsetToOffset
+- = PPC.ImmConstantDiff
+- (PPC.ImmCLbl gotOffLabel)
++ gotOffset = PPC.ImmConstantDiff
++ (PPC.ImmCLbl gotLabel)
+ (PPC.ImmCLbl mkPicBaseLabel)
+
+ blocks' = case blocks of
+@@ -726,15 +709,23 @@ initializePicBase_ppc ArchPPC os picReg
+ | bID `mapMember` info = fetchPC b
+ | otherwise = b
+
++ -- GCC does PIC prologs thusly:
++ -- bcl 20,31,.L1
++ -- .L1:
++ -- mflr 30
++ -- addis 30,30,.LCTOC1-.L1@ha
++ -- addi 30,30,.LCTOC1-.L1@l
++ -- TODO: below we use it over temporary register,
++ -- it can and should be optimised by picking
++ -- correct PIC reg.
+ fetchPC (BasicBlock bID insns) =
+ BasicBlock bID (PPC.FETCHPC picReg
+- : PPC.ADDIS tmp picReg (PPC.HI offsetToOffset)
+- : PPC.LD PPC.archWordSize tmp
+- (PPC.AddrRegImm tmp (PPC.LO offsetToOffset))
+- : PPC.ADD picReg picReg (PPC.RIReg picReg)
++ : PPC.ADDIS picReg picReg (PPC.HA gotOffset)
++ : PPC.ADDI picReg picReg (PPC.LO gotOffset)
++ : PPC.MR PPC.r30 picReg
+ : insns)
+
+- return (CmmProc info lab live (ListGraph blocks') : gotOffset : statics)
++ return (CmmProc info lab live (ListGraph blocks') : statics)
+
+
+ initializePicBase_ppc ArchPPC OSDarwin picReg
+diff --git a/compiler/nativeGen/PPC/CodeGen.hs b/compiler/nativeGen/PPC/CodeGen.hs
+index ddf483a..c1c4a74 100644
+--- a/compiler/nativeGen/PPC/CodeGen.hs
++++ b/compiler/nativeGen/PPC/CodeGen.hs
+@@ -54,7 +54,7 @@ import Outputable
+ import Unique
+ import DynFlags
+
+-import Control.Monad ( mapAndUnzipM )
++import Control.Monad ( mapAndUnzipM, when )
+ import Data.Bits
+ import Data.Word
+
+@@ -355,6 +355,19 @@ iselExpr64 (CmmMachOp (MO_Add _) [e1,e2]) = do
+ ADDE rhi r1hi r2hi ]
+ return (ChildCode64 code rlo)
+
++iselExpr64 (CmmMachOp (MO_Sub _) [e1,e2]) = do
++ ChildCode64 code1 r1lo <- iselExpr64 e1
++ ChildCode64 code2 r2lo <- iselExpr64 e2
++ (rlo,rhi) <- getNewRegPairNat II32
++ let
++ r1hi = getHiVRegFromLo r1lo
++ r2hi = getHiVRegFromLo r2lo
++ code = code1 `appOL`
++ code2 `appOL`
++ toOL [ SUBFC rlo r2lo r1lo,
++ SUBFE rhi r2hi r1hi ]
++ return (ChildCode64 code rlo)
++
+ iselExpr64 (CmmMachOp (MO_UU_Conv W32 W64) [expr]) = do
+ (expr_reg,expr_code) <- getSomeReg expr
+ (rlo, rhi) <- getNewRegPairNat II32
+@@ -918,8 +931,12 @@ genCCall' dflags gcp target dest_regs args0
+ (toOL []) []
+
+ (labelOrExpr, reduceToFF32) <- case target of
+- ForeignTarget (CmmLit (CmmLabel lbl)) _ -> return (Left lbl, False)
+- ForeignTarget expr _ -> return (Right expr, False)
++ ForeignTarget (CmmLit (CmmLabel lbl)) _ -> do
++ uses_pic_base_implicitly
++ return (Left lbl, False)
++ ForeignTarget expr _ -> do
++ uses_pic_base_implicitly
++ return (Right expr, False)
+ PrimTarget mop -> outOfLineMachOp mop
+
+ let codeBefore = move_sp_down finalStack `appOL` passArgumentsCode
+@@ -940,6 +957,13 @@ genCCall' dflags gcp target dest_regs args0
+ where
+ platform = targetPlatform dflags
+
++ uses_pic_base_implicitly = do
++ -- See Note [implicit register in PPC PIC code]
++ -- on why we claim to use PIC register here
++ when (gopt Opt_PIC dflags) $ do
++ _ <- getPicBaseNat archWordSize
++ return ()
++
+ initialStackOffset = case gcp of
+ GCPDarwin -> 24
+ GCPLinux -> 8
+@@ -1431,3 +1455,21 @@ coerceFP2Int _ toRep x = do
+ -- read low word of value (high word is undefined)
+ LD II32 dst (spRel dflags 3)]
+ return (Any (intSize toRep) code')
++
++-- Note [.LCTOC1 in PPC PIC code]
++-- The .LCTOC1 label is defined to point 32768 bytes into the GOT table
++-- to make the most of the PPC's 16-bit displacements.
++-- As 16-bit signed offset is used (usually via addi/lwz instructions)
++-- first element will have '-32768' offset against .LCTOC1.
++
++-- Note [implicit register in PPC PIC code]
++-- PPC generates calls by labels in assembly
++-- in form of:
++-- bl puts+32768@plt
++-- in this form it's not seen directly (by GHC NCG)
++-- that r30 (PicBaseReg) is used,
++-- but r30 is a required part of PLT code setup:
++-- puts+32768@plt:
++-- lwz r11,-30484(r30) ; offset in .LCTOC1
++-- mtctr r11
++-- bctr
+diff --git a/compiler/nativeGen/PPC/Instr.hs b/compiler/nativeGen/PPC/Instr.hs
+index f5b9506..b7081f9 100644
+--- a/compiler/nativeGen/PPC/Instr.hs
++++ b/compiler/nativeGen/PPC/Instr.hs
+@@ -205,8 +205,11 @@ data Instr
+ | ADD Reg Reg RI -- dst, src1, src2
+ | ADDC Reg Reg Reg -- (carrying) dst, src1, src2
+ | ADDE Reg Reg Reg -- (extend) dst, src1, src2
++ | ADDI Reg Reg Imm -- Add Immediate dst, src1, src2
+ | ADDIS Reg Reg Imm -- Add Immediate Shifted dst, src1, src2
+ | SUBF Reg Reg Reg -- dst, src1, src2 ; dst = src2 - src1
++ | SUBFC Reg Reg Reg -- (carrying) dst, src1, src2 ; dst = src2 - src1
++ | SUBFE Reg Reg Reg -- (extend) dst, src1, src2 ; dst = src2 - src1
+ | MULLW Reg Reg RI
+ | DIVW Reg Reg Reg
+ | DIVWU Reg Reg Reg
+@@ -284,8 +287,11 @@ ppc_regUsageOfInstr platform instr
+ ADD reg1 reg2 ri -> usage (reg2 : regRI ri, [reg1])
+ ADDC reg1 reg2 reg3 -> usage ([reg2,reg3], [reg1])
+ ADDE reg1 reg2 reg3 -> usage ([reg2,reg3], [reg1])
++ ADDI reg1 reg2 _ -> usage ([reg2], [reg1])
+ ADDIS reg1 reg2 _ -> usage ([reg2], [reg1])
+ SUBF reg1 reg2 reg3 -> usage ([reg2,reg3], [reg1])
++ SUBFC reg1 reg2 reg3 -> usage ([reg2,reg3], [reg1])
++ SUBFE reg1 reg2 reg3 -> usage ([reg2,reg3], [reg1])
+ MULLW reg1 reg2 ri -> usage (reg2 : regRI ri, [reg1])
+ DIVW reg1 reg2 reg3 -> usage ([reg2,reg3], [reg1])
+ DIVWU reg1 reg2 reg3 -> usage ([reg2,reg3], [reg1])
+@@ -358,8 +364,11 @@ ppc_patchRegsOfInstr instr env
+ ADD reg1 reg2 ri -> ADD (env reg1) (env reg2) (fixRI ri)
+ ADDC reg1 reg2 reg3 -> ADDC (env reg1) (env reg2) (env reg3)
+ ADDE reg1 reg2 reg3 -> ADDE (env reg1) (env reg2) (env reg3)
++ ADDI reg1 reg2 imm -> ADDI (env reg1) (env reg2) imm
+ ADDIS reg1 reg2 imm -> ADDIS (env reg1) (env reg2) imm
+ SUBF reg1 reg2 reg3 -> SUBF (env reg1) (env reg2) (env reg3)
++ SUBFC reg1 reg2 reg3 -> SUBFC (env reg1) (env reg2) (env reg3)
++ SUBFE reg1 reg2 reg3 -> SUBFE (env reg1) (env reg2) (env reg3)
+ MULLW reg1 reg2 ri -> MULLW (env reg1) (env reg2) (fixRI ri)
+ DIVW reg1 reg2 reg3 -> DIVW (env reg1) (env reg2) (env reg3)
+ DIVWU reg1 reg2 reg3 -> DIVWU (env reg1) (env reg2) (env reg3)
+diff --git a/compiler/nativeGen/PPC/Ppr.hs b/compiler/nativeGen/PPC/Ppr.hs
+index 6851769..f59d51f 100644
+--- a/compiler/nativeGen/PPC/Ppr.hs
++++ b/compiler/nativeGen/PPC/Ppr.hs
+@@ -525,6 +525,16 @@ pprInstr (BCTRL _) = hcat [
+ ptext (sLit "bctrl")
+ ]
+ pprInstr (ADD reg1 reg2 ri) = pprLogic (sLit "add") reg1 reg2 ri
++pprInstr (ADDI reg1 reg2 imm) = hcat [
++ char '\t',
++ ptext (sLit "addi"),
++ char '\t',
++ pprReg reg1,
++ ptext (sLit ", "),
++ pprReg reg2,
++ ptext (sLit ", "),
++ pprImm imm
++ ]
+ pprInstr (ADDIS reg1 reg2 imm) = hcat [
+ char '\t',
+ ptext (sLit "addis"),
+@@ -539,6 +549,8 @@ pprInstr (ADDIS reg1 reg2 imm) = hcat [
+ pprInstr (ADDC reg1 reg2 reg3) = pprLogic (sLit "addc") reg1 reg2 (RIReg reg3)
+ pprInstr (ADDE reg1 reg2 reg3) = pprLogic (sLit "adde") reg1 reg2 (RIReg reg3)
+ pprInstr (SUBF reg1 reg2 reg3) = pprLogic (sLit "subf") reg1 reg2 (RIReg reg3)
++pprInstr (SUBFC reg1 reg2 reg3) = pprLogic (sLit "subfc") reg1 reg2 (RIReg reg3)
++pprInstr (SUBFE reg1 reg2 reg3) = pprLogic (sLit "subfe") reg1 reg2 (RIReg reg3)
+ pprInstr (MULLW reg1 reg2 ri@(RIReg _)) = pprLogic (sLit "mullw") reg1 reg2 ri
+ pprInstr (MULLW reg1 reg2 ri@(RIImm _)) = pprLogic (sLit "mull") reg1 reg2 ri
+ pprInstr (DIVW reg1 reg2 reg3) = pprLogic (sLit "divw") reg1 reg2 (RIReg reg3)
+diff --git a/compiler/nativeGen/PPC/Regs.hs b/compiler/nativeGen/PPC/Regs.hs
+index 0f636bf..69e69c0 100644
+--- a/compiler/nativeGen/PPC/Regs.hs
++++ b/compiler/nativeGen/PPC/Regs.hs
+@@ -37,7 +37,8 @@ module PPC.Regs (
+ fits16Bits,
+ makeImmediate,
+ fReg,
+- sp, r3, r4, r27, r28, f1, f20, f21,
++ sp, r3, r4, r27, r28, r30,
++ f1, f20, f21,
+
+ allocatableRegs
+
+@@ -295,12 +296,13 @@ point registers.
+ fReg :: Int -> RegNo
+ fReg x = (32 + x)
+
+-sp, r3, r4, r27, r28, f1, f20, f21 :: Reg
++sp, r3, r4, r27, r28, r30, f1, f20, f21 :: Reg
+ sp = regSingle 1
+ r3 = regSingle 3
+ r4 = regSingle 4
+ r27 = regSingle 27
+ r28 = regSingle 28
++r30 = regSingle 30
+ f1 = regSingle $ fReg 1
+ f20 = regSingle $ fReg 20
+ f21 = regSingle $ fReg 21
+diff --git a/includes/CodeGen.Platform.hs b/includes/CodeGen.Platform.hs
+index 9916e0e..1d46a01 100644
+--- a/includes/CodeGen.Platform.hs
++++ b/includes/CodeGen.Platform.hs
+@@ -881,6 +881,8 @@ freeReg 1 = fastBool False -- The Stack Pointer
+ # if !MACHREGS_darwin
+ -- most non-darwin powerpc OSes use r2 as a TOC pointer or something like that
+ freeReg 2 = fastBool False
++-- at least linux in -fPIC relies on r30 in PLT stubs
++freeReg 30 = fastBool False
+ # endif
+ # ifdef REG_Base
+ freeReg REG_Base = fastBool False
+diff --git a/mk/config.mk.in b/mk/config.mk.in
+index 0f5820f..8f134bc 100644
+--- a/mk/config.mk.in
++++ b/mk/config.mk.in
+@@ -95,7 +95,7 @@ TargetElf = YES
+ endif
+
+ # Some platforms don't support shared libraries
+-NoSharedLibsPlatformList = powerpc-unknown-linux \
++NoSharedLibsPlatformList = \
+ x86_64-unknown-mingw32 \
+ i386-unknown-mingw32
+
diff --git a/dev-lang/ghc/files/ghc-7.8.3-prim-lm.patch b/dev-lang/ghc/files/ghc-7.8.3-prim-lm.patch
new file mode 100644
index 000000000000..3ef2313fcec1
--- /dev/null
+++ b/dev-lang/ghc/files/ghc-7.8.3-prim-lm.patch
@@ -0,0 +1,12 @@
+Fix underlinking on ghc-prim.
+Fixes ghc-stage2 crahs on hardened toolchain.
+Reported-by: aranea
+diff --git a/libraries/ghc-prim/ghc-prim.cabal b/libraries/ghc-prim/ghc-prim.cabal
+index ffb32af..0431380 100644
+--- a/libraries/ghc-prim/ghc-prim.cabal
++++ b/libraries/ghc-prim/ghc-prim.cabal
+@@ -68,0 +68,4 @@ Library
++
++ -- ghc 'sin' (and other) primops generate 'libm' calls,
++ -- but ghc itself does not add '-lm'
++ extra-libraries: m
diff --git a/dev-lang/ghc/files/ghc-7.8.4-gold.patch b/dev-lang/ghc/files/ghc-7.8.4-gold.patch
new file mode 100644
index 000000000000..a8e9b1e6c857
--- /dev/null
+++ b/dev-lang/ghc/files/ghc-7.8.4-gold.patch
@@ -0,0 +1,27 @@
+Gentoo-bug: https://bugs.gentoo.org/536426
+Reported-by: Eric Siegel
+commit 021b7978d14799bae779907faf7490cfd21b3f46
+Author: Austin Seipp <austin@well-typed.com>
+Date: Sun Jul 20 10:13:15 2014 -0500
+
+ driver: use absolute paths in ld scripts (#7452)
+
+ Patch contributed by slowmo.
+
+ Signed-off-by: Austin Seipp <austin@well-typed.com>
+
+diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs
+index 11427e2..49126fe 100644
+--- a/compiler/main/DriverPipeline.hs
++++ b/compiler/main/DriverPipeline.hs
+@@ -2166,7 +2166,9 @@ joinObjectFiles dflags o_files output_fn = do
+ if ldIsGnuLd
+ then do
+ script <- newTempName dflags "ldscript"
+- writeFile script $ "INPUT(" ++ unwords o_files ++ ")"
++ cwd <- getCurrentDirectory
++ let o_files_abs = map (cwd </>) o_files
++ writeFile script $ "INPUT(" ++ unwords o_files_abs ++ ")"
+ ld_r [SysTools.FileOption "" script] ccInfo
+ else if sLdSupportsFilelist mySettings
+ then do
diff --git a/dev-lang/ghc/files/ghc-7.8.4-ia64-CLOSUREs.patch b/dev-lang/ghc/files/ghc-7.8.4-ia64-CLOSUREs.patch
new file mode 100644
index 000000000000..9d50792bcf45
--- /dev/null
+++ b/dev-lang/ghc/files/ghc-7.8.4-ia64-CLOSUREs.patch
@@ -0,0 +1,66 @@
+From b677ba51cf8131a6f6ddcdfee8dd2a8c4c2b4ac7 Mon Sep 17 00:00:00 2001
+From: Sergei Trofimovich <siarheit@google.com>
+Date: Sat, 17 Jan 2015 14:27:13 +0000
+Subject: [PATCH 1/3] CMM: add a mechanism to import C data labels
+
+Fixes threaded runtime on ia64.
+sm_mutex there was not referenced correctly.
+
+Signed-off-by: Sergei Trofimovich <siarheit@google.com>
+---
+ compiler/cmm/CmmParse.y | 4 ++++
+ rts/Exception.cmm | 2 +-
+ rts/PrimOps.cmm | 6 +++---
+ 3 files changed, 8 insertions(+), 4 deletions(-)
+
+diff --git a/compiler/cmm/CmmParse.y.source b/compiler/cmm/CmmParse.y.source
+index 6b51e51..fd9489b 100644
+--- a/compiler/cmm/CmmParse.y.source
++++ b/compiler/cmm/CmmParse.y.source
+@@ -575,6 +575,10 @@ importName
+ : NAME
+ { ($1, mkForeignLabel $1 Nothing ForeignLabelInExternalPackage IsFunction) }
+
++ -- as previous 'NAME', but 'IsData'
++ | 'CLOSURE' NAME
++ { ($2, mkForeignLabel $2 Nothing ForeignLabelInExternalPackage IsData) }
++
+ -- A label imported with an explicit packageId.
+ | STRING NAME
+ { ($2, mkCmmCodeLabel (fsToPackageKey (mkFastString $1)) $2) }
+diff --git a/rts/Exception.cmm b/rts/Exception.cmm
+index 5007ef3..8d19c14 100644
+--- a/rts/Exception.cmm
++++ b/rts/Exception.cmm
+@@ -13,7 +13,7 @@
+ #include "Cmm.h"
+ #include "RaiseAsync.h"
+
+-import ghczmprim_GHCziTypes_True_closure;
++import CLOSURE ghczmprim_GHCziTypes_True_closure;
+
+ /* -----------------------------------------------------------------------------
+ Exception Primitives
+diff --git a/rts/PrimOps.cmm b/rts/PrimOps.cmm
+index 3e8612c..2e6ca46 100644
+--- a/rts/PrimOps.cmm
++++ b/rts/PrimOps.cmm
+@@ -28,12 +28,12 @@
+ import pthread_mutex_lock;
+ import pthread_mutex_unlock;
+ #endif
+-import base_ControlziExceptionziBase_nestedAtomically_closure;
++import CLOSURE base_ControlziExceptionziBase_nestedAtomically_closure;
+ import EnterCriticalSection;
+ import LeaveCriticalSection;
+-import ghczmprim_GHCziTypes_False_closure;
++import CLOSURE ghczmprim_GHCziTypes_False_closure;
+ #if defined(USE_MINIINTERPRETER) || !defined(mingw32_HOST_OS)
+-import sm_mutex;
++import CLOSURE sm_mutex;
+ #endif
+
+ /*-----------------------------------------------------------------------------
+--
+2.2.1
+
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 000000000000..dc5410da3020
--- /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 000000000000..b46e57301782
--- /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 000000000000..4752f4482678
--- /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 000000000000..877a5827e4ea
--- /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-O2-unreg.patch b/dev-lang/ghc/files/ghc-8.0.2-O2-unreg.patch
new file mode 100644
index 000000000000..b64d65b80a05
--- /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/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 000000000000..166f7fe42991
--- /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/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 000000000000..a4d49d3ef808
--- /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/files/ghc-8.2.1-darwin.patch b/dev-lang/ghc/files/ghc-8.2.1-darwin.patch
new file mode 100644
index 000000000000..53fedc4e4402
--- /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/files/ghc-8.2.1_rc1-cgen-constify.patch b/dev-lang/ghc/files/ghc-8.2.1_rc1-cgen-constify.patch
new file mode 100644
index 000000000000..2e1ef932b454
--- /dev/null
+++ b/dev-lang/ghc/files/ghc-8.2.1_rc1-cgen-constify.patch
@@ -0,0 +1,378 @@
+From 7e00046772e053c63ac93630a60b0f396e32a2d7 Mon Sep 17 00:00:00 2001
+From: Sergei Trofimovich <slyfox@gentoo.org>
+Date: Sun, 16 Apr 2017 10:43:38 +0100
+Subject: [PATCH] compiler/cmm/PprC.hs: constify labels in .rodata
+
+Summary:
+Consider one-line module
+ module B (v) where v = "hello"
+in -fvia-C mode it generates code like
+ static char gibberish_str[] = "hello";
+
+It resides in data section (precious resource on ia64!).
+The patch switches genrator to emit:
+ static const char gibberish_str[] = "hello";
+
+Other types if symbols that gained 'const' qualifier are:
+
+- info tables (from haskell and CMM)
+- static reference tables (from haskell and CMM)
+
+Cleanups along the way:
+
+- fixed info tables defined in .cmm to reside in .rodata
+- split out closure declaration into 'IC_' / 'EC_'
+- added label declaration (based on label type) right before
+ each label definition (based on section type) so that C
+ compiler could check if declaration and definition matches
+ at definition site.
+
+Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
+
+Test Plan: ran testsuite on unregisterised x86_64 compiler
+
+Reviewers: simonmar, ezyang, austin, bgamari, erikd
+
+Subscribers: rwbarton, thomie
+
+GHC Trac Issues: #8996
+
+Differential Revision: https://phabricator.haskell.org/D3481
+---
+ compiler/cmm/CLabel.hs | 24 ++++++++++++++
+ compiler/cmm/Cmm.hs | 13 ++++++++
+ compiler/cmm/CmmInfo.hs | 2 +-
+ compiler/cmm/PprC.hs | 62 +++++++++++++++++++++++-------------
+ compiler/llvmGen/LlvmCodeGen/Data.hs | 12 -------
+ includes/Stg.h | 22 +++++++++----
+ includes/rts/storage/InfoTables.h | 2 +-
+ includes/stg/MiscClosures.h | 14 ++++----
+ 8 files changed, 102 insertions(+), 49 deletions(-)
+
+diff --git a/compiler/cmm/CLabel.hs b/compiler/cmm/CLabel.hs
+index 3ba4f7647a..62c8037e9c 100644
+--- a/compiler/cmm/CLabel.hs
++++ b/compiler/cmm/CLabel.hs
+@@ -89,6 +89,8 @@ module CLabel (
+ foreignLabelStdcallInfo,
+ isBytesLabel,
+ isForeignLabel,
++ isSomeRODataLabel,
++ isStaticClosureLabel,
+ mkCCLabel, mkCCSLabel,
+
+ DynamicLinkerLabelInfo(..),
+@@ -575,6 +577,28 @@ isForeignLabel :: CLabel -> Bool
+ isForeignLabel (ForeignLabel _ _ _ _) = True
+ isForeignLabel _lbl = False
+
++-- | Whether label is a static closure label (can come from haskell or cmm)
++isStaticClosureLabel :: CLabel -> Bool
++-- Closure defined in haskell (.hs)
++isStaticClosureLabel (IdLabel _ _ Closure) = True
++-- Closure defined in cmm
++isStaticClosureLabel (CmmLabel _ _ CmmClosure) = True
++isStaticClosureLabel _lbl = False
++
++-- | Whether label is a .rodata label
++isSomeRODataLabel :: CLabel -> Bool
++-- info table defined in haskell (.hs)
++isSomeRODataLabel (IdLabel _ _ ClosureTable) = True
++isSomeRODataLabel (IdLabel _ _ ConInfoTable) = True
++isSomeRODataLabel (IdLabel _ _ InfoTable) = True
++isSomeRODataLabel (IdLabel _ _ LocalInfoTable) = True
++-- static reference tables defined in haskell (.hs)
++isSomeRODataLabel (IdLabel _ _ SRT) = True
++isSomeRODataLabel (SRTLabel _) = True
++-- info table defined in cmm (.cmm)
++isSomeRODataLabel (CmmLabel _ _ CmmInfo) = True
++isSomeRODataLabel _lbl = False
++
+ -- | Get the label size field from a ForeignLabel
+ foreignLabelStdcallInfo :: CLabel -> Maybe Int
+ foreignLabelStdcallInfo (ForeignLabel _ info _ _) = info
+diff --git a/compiler/cmm/Cmm.hs b/compiler/cmm/Cmm.hs
+index d2ee531686..bab20f3fdd 100644
+--- a/compiler/cmm/Cmm.hs
++++ b/compiler/cmm/Cmm.hs
+@@ -9,6 +9,7 @@ module Cmm (
+ CmmBlock,
+ RawCmmDecl, RawCmmGroup,
+ Section(..), SectionType(..), CmmStatics(..), CmmStatic(..),
++ isSecConstant,
+
+ -- ** Blocks containing lists
+ GenBasicBlock(..), blockId,
+@@ -167,6 +168,18 @@ data SectionType
+ | OtherSection String
+ deriving (Show)
+
++-- | Should a data in this section be considered constant
++isSecConstant :: Section -> Bool
++isSecConstant (Section t _) = case t of
++ Text -> True
++ ReadOnlyData -> True
++ RelocatableReadOnlyData -> True
++ ReadOnlyData16 -> True
++ CString -> True
++ Data -> False
++ UninitialisedData -> False
++ (OtherSection _) -> False
++
+ data Section = Section SectionType CLabel
+
+ data CmmStatic
+diff --git a/compiler/cmm/CmmInfo.hs b/compiler/cmm/CmmInfo.hs
+index b5e800a977..35e3a1888d 100644
+--- a/compiler/cmm/CmmInfo.hs
++++ b/compiler/cmm/CmmInfo.hs
+@@ -133,7 +133,7 @@ mkInfoTable dflags proc@(CmmProc infos entry_lbl live blocks)
+ --
+ return (top_decls ++
+ [CmmProc mapEmpty entry_lbl live blocks,
+- mkDataLits (Section Data info_lbl) info_lbl
++ mkRODataLits info_lbl
+ (CmmLabel entry_lbl : rel_std_info ++ rel_extra_bits)])
+
+ --
+diff --git a/compiler/cmm/PprC.hs b/compiler/cmm/PprC.hs
+index 56de94079f..21ed6f6516 100644
+--- a/compiler/cmm/PprC.hs
++++ b/compiler/cmm/PprC.hs
+@@ -83,12 +83,13 @@ pprC tops = vcat $ intersperse blankLine $ map pprTop tops
+ -- top level procs
+ --
+ pprTop :: RawCmmDecl -> SDoc
+-pprTop (CmmProc infos clbl _ graph) =
++pprTop (CmmProc infos clbl _in_live_regs graph) =
+
+ (case mapLookup (g_entry graph) infos of
+ Nothing -> empty
+- Just (Statics info_clbl info_dat) -> pprDataExterns info_dat $$
+- pprWordArray info_clbl info_dat) $$
++ Just (Statics info_clbl info_dat) ->
++ pprDataExterns info_dat $$
++ pprWordArray info_is_in_rodata info_clbl info_dat) $$
+ (vcat [
+ blankLine,
+ extern_decls,
+@@ -99,6 +100,8 @@ pprTop (CmmProc infos clbl _ graph) =
+ rbrace ]
+ )
+ where
++ -- info tables are always in .rodata
++ info_is_in_rodata = True
+ blocks = toBlockListEntryFirst graph
+ (temp_decls, extern_decls) = pprTempAndExternDecls blocks
+
+@@ -107,21 +110,23 @@ pprTop (CmmProc infos clbl _ graph) =
+
+ -- We only handle (a) arrays of word-sized things and (b) strings.
+
+-pprTop (CmmData _section (Statics lbl [CmmString str])) =
++pprTop (CmmData section (Statics lbl [CmmString str])) =
++ pprExternDecl lbl $$
+ hcat [
+- pprLocalness lbl, text "char ", ppr lbl,
++ pprLocalness lbl, pprConstness (isSecConstant section), text "char ", ppr lbl,
+ text "[] = ", pprStringInCStyle str, semi
+ ]
+
+-pprTop (CmmData _section (Statics lbl [CmmUninitialised size])) =
++pprTop (CmmData section (Statics lbl [CmmUninitialised size])) =
++ pprExternDecl lbl $$
+ hcat [
+- pprLocalness lbl, text "char ", ppr lbl,
++ pprLocalness lbl, pprConstness (isSecConstant section), text "char ", ppr lbl,
+ brackets (int size), semi
+ ]
+
+-pprTop (CmmData _section (Statics lbl lits)) =
++pprTop (CmmData section (Statics lbl lits)) =
+ pprDataExterns lits $$
+- pprWordArray lbl lits
++ pprWordArray (isSecConstant section) lbl lits
+
+ -- --------------------------------------------------------------------------
+ -- BasicBlocks are self-contained entities: they always end in a jump.
+@@ -141,10 +146,12 @@ pprBBlock block =
+ -- Info tables. Just arrays of words.
+ -- See codeGen/ClosureInfo, and nativeGen/PprMach
+
+-pprWordArray :: CLabel -> [CmmStatic] -> SDoc
+-pprWordArray lbl ds
++pprWordArray :: Bool -> CLabel -> [CmmStatic] -> SDoc
++pprWordArray is_ro lbl ds
+ = sdocWithDynFlags $ \dflags ->
+- hcat [ pprLocalness lbl, text "StgWord"
++ -- TODO: align closures only
++ pprExternDecl lbl $$
++ hcat [ pprLocalness lbl, pprConstness is_ro, text "StgWord"
+ , space, ppr lbl, text "[]"
+ -- See Note [StgWord alignment]
+ , pprAlignment (wordWidth dflags)
+@@ -180,6 +187,10 @@ pprLocalness :: CLabel -> SDoc
+ pprLocalness lbl | not $ externallyVisibleCLabel lbl = text "static "
+ | otherwise = empty
+
++pprConstness :: Bool -> SDoc
++pprConstness is_ro | is_ro = text "const "
++ | otherwise = empty
++
+ -- --------------------------------------------------------------------------
+ -- Statements.
+ --
+@@ -984,31 +995,38 @@ is_cishCC JavaScriptCallConv = False
+ pprTempAndExternDecls :: [CmmBlock] -> (SDoc{-temps-}, SDoc{-externs-})
+ pprTempAndExternDecls stmts
+ = (pprUFM (getUniqSet temps) (vcat . map pprTempDecl),
+- vcat (map (pprExternDecl False{-ToDo-}) (Map.keys lbls)))
++ vcat (map pprExternDecl (Map.keys lbls)))
+ where (temps, lbls) = runTE (mapM_ te_BB stmts)
+
+ pprDataExterns :: [CmmStatic] -> SDoc
+ pprDataExterns statics
+- = vcat (map (pprExternDecl False{-ToDo-}) (Map.keys lbls))
++ = vcat (map pprExternDecl (Map.keys lbls))
+ where (_, lbls) = runTE (mapM_ te_Static statics)
+
+ pprTempDecl :: LocalReg -> SDoc
+ pprTempDecl l@(LocalReg _ rep)
+ = hcat [ machRepCType rep, space, pprLocalReg l, semi ]
+
+-pprExternDecl :: Bool -> CLabel -> SDoc
+-pprExternDecl _in_srt lbl
++pprExternDecl :: CLabel -> SDoc
++pprExternDecl lbl
+ -- do not print anything for "known external" things
+ | not (needsCDecl lbl) = empty
+ | Just sz <- foreignLabelStdcallInfo lbl = stdcall_decl sz
+ | otherwise =
+- hcat [ visibility, label_type lbl,
+- lparen, ppr lbl, text ");" ]
++ hcat [ visibility, label_type lbl , lparen, ppr lbl, text ");"
++ -- occasionally useful to see label type
++ -- , text "/* ", pprDebugCLabel lbl, text " */"
++ ]
+ where
+- label_type lbl | isBytesLabel lbl = text "B_"
+- | isForeignLabel lbl && isCFunctionLabel lbl = text "FF_"
+- | isCFunctionLabel lbl = text "F_"
+- | otherwise = text "I_"
++ label_type lbl | isBytesLabel lbl = text "B_"
++ | isForeignLabel lbl && isCFunctionLabel lbl
++ = text "FF_"
++ | isCFunctionLabel lbl = text "F_"
++ | isStaticClosureLabel lbl = text "C_"
++ -- generic .rodata labels
++ | isSomeRODataLabel lbl = text "RO_"
++ -- generic .data labels (common case)
++ | otherwise = text "RW_"
+
+ visibility
+ | externallyVisibleCLabel lbl = char 'E'
+diff --git a/compiler/llvmGen/LlvmCodeGen/Data.hs b/compiler/llvmGen/LlvmCodeGen/Data.hs
+index 9bb5a75bda..adb86d312d 100644
+--- a/compiler/llvmGen/LlvmCodeGen/Data.hs
++++ b/compiler/llvmGen/LlvmCodeGen/Data.hs
+@@ -56,18 +56,6 @@ genLlvmData (sec, Statics lbl xs) = do
+
+ return ([globDef], [tyAlias])
+
+--- | Should a data in this section be considered constant
+-isSecConstant :: Section -> Bool
+-isSecConstant (Section t _) = case t of
+- Text -> True
+- ReadOnlyData -> True
+- RelocatableReadOnlyData -> True
+- ReadOnlyData16 -> True
+- CString -> True
+- Data -> False
+- UninitialisedData -> False
+- (OtherSection _) -> False
+-
+ -- | Format the section type part of a Cmm Section
+ llvmSectionType :: Platform -> SectionType -> FastString
+ llvmSectionType p t = case t of
+diff --git a/includes/Stg.h b/includes/Stg.h
+index 619984d8e5..b1b3190307 100644
+--- a/includes/Stg.h
++++ b/includes/Stg.h
+@@ -223,13 +223,23 @@ typedef StgInt I_;
+ typedef StgWord StgWordArray[];
+ typedef StgFunPtr F_;
+
+-#define EB_(X) extern char X[]
+-#define IB_(X) static char X[]
+-#define EI_(X) extern StgWordArray (X) GNU_ATTRIBUTE(aligned (8))
+-#define II_(X) static StgWordArray (X) GNU_ATTRIBUTE(aligned (8))
++/* byte arrays (and strings): */
++#define EB_(X) extern const char X[]
++#define IB_(X) static const char X[]
++/* static (non-heap) closures (requires alignment for pointer tagging): */
++#define EC_(X) extern StgWordArray (X) GNU_ATTRIBUTE(aligned (8))
++#define IC_(X) static StgWordArray (X) GNU_ATTRIBUTE(aligned (8))
++/* writable data (does not require alignment): */
++#define ERW_(X) extern StgWordArray (X)
++#define IRW_(X) static StgWordArray (X)
++/* read-only data (does not require alignment): */
++#define ERO_(X) extern const StgWordArray (X)
++#define IRO_(X) static const StgWordArray (X)
++/* stg-native functions: */
+ #define IF_(f) static StgFunPtr GNUC3_ATTRIBUTE(used) f(void)
+-#define FN_(f) StgFunPtr f(void)
+-#define EF_(f) StgFunPtr f(void) /* External Cmm functions */
++#define FN_(f) StgFunPtr f(void)
++#define EF_(f) StgFunPtr f(void) /* External Cmm functions */
++/* foreign functions: */
+ #define EFF_(f) void f() /* See Note [External function prototypes] */
+
+ /* Note [External function prototypes] See Trac #8965, #11395
+diff --git a/includes/rts/storage/InfoTables.h b/includes/rts/storage/InfoTables.h
+index 307aac371c..163f1d1c87 100644
+--- a/includes/rts/storage/InfoTables.h
++++ b/includes/rts/storage/InfoTables.h
+@@ -266,7 +266,7 @@ typedef struct {
+ } StgFunInfoTable;
+
+ // canned bitmap for each arg type, indexed by constants in FunTypes.h
+-extern StgWord stg_arg_bitmaps[];
++extern const StgWord stg_arg_bitmaps[];
+
+ /* -----------------------------------------------------------------------------
+ Return info tables
+diff --git a/includes/stg/MiscClosures.h b/includes/stg/MiscClosures.h
+index 9d907ab3ba..b604f1c42b 100644
+--- a/includes/stg/MiscClosures.h
++++ b/includes/stg/MiscClosures.h
+@@ -21,10 +21,10 @@
+ #define STGMISCCLOSURES_H
+
+ #if IN_STG_CODE
+-# define RTS_RET_INFO(i) extern W_(i)[]
+-# define RTS_FUN_INFO(i) extern W_(i)[]
+-# define RTS_THUNK_INFO(i) extern W_(i)[]
+-# define RTS_INFO(i) extern W_(i)[]
++# define RTS_RET_INFO(i) extern const W_(i)[]
++# define RTS_FUN_INFO(i) extern const W_(i)[]
++# define RTS_THUNK_INFO(i) extern const W_(i)[]
++# define RTS_INFO(i) extern const W_(i)[]
+ # define RTS_CLOSURE(i) extern W_(i)[]
+ # define RTS_FUN_DECL(f) extern DLL_IMPORT_RTS StgFunPtr f(void)
+ #else
+@@ -489,9 +489,9 @@ extern StgWord RTS_VAR(sched_mutex);
+
+ // Apply.cmm
+ // canned bitmap for each arg type
+-extern StgWord stg_arg_bitmaps[];
+-extern StgWord stg_ap_stack_entries[];
+-extern StgWord stg_stack_save_entries[];
++extern const StgWord stg_arg_bitmaps[];
++extern const StgWord stg_ap_stack_entries[];
++extern const StgWord stg_stack_save_entries[];
+
+ // Storage.c
+ extern unsigned int RTS_VAR(g0);
+--
+2.12.2
+
diff --git a/dev-lang/ghc/files/ghc-8.2.1_rc1-ghci-cross.patch b/dev-lang/ghc/files/ghc-8.2.1_rc1-ghci-cross.patch
new file mode 100644
index 000000000000..dbba18e85c7f
--- /dev/null
+++ b/dev-lang/ghc/files/ghc-8.2.1_rc1-ghci-cross.patch
@@ -0,0 +1,60 @@
+commit 732b3dbbff194eb8650c75afd79d892801afa0dc
+Author: Sergei Trofimovich <slyfox@gentoo.org>
+Date: Thu Apr 6 22:48:13 2017 +0100
+
+ add $(CrossCompilePrefix) to 'runghc' and 'ghci'
+
+ When Stage1Only=YES install mode is used one of rare tools
+ that lack $(CrossCompilePrefix) prefix are 'runghc' and 'ghci'.
+
+ This causes file collisions when multiple GHC crosscompilers
+ are installed in system.
+
+ Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
+
+diff --git a/driver/ghci/ghc.mk b/driver/ghci/ghc.mk
+index 41d1f15c17..0f31884080 100644
+--- a/driver/ghci/ghc.mk
++++ b/driver/ghci/ghc.mk
+@@ -16,16 +16,16 @@ ifneq "$(Windows_Host)" "YES"
+ install: install_driver_ghci
+
+ .PHONY: install_driver_ghci
+-install_driver_ghci: WRAPPER=$(DESTDIR)$(bindir)/ghci-$(ProjectVersion)
++install_driver_ghci: WRAPPER=$(DESTDIR)$(bindir)/$(CrossCompilePrefix)ghci-$(ProjectVersion)
+ install_driver_ghci:
+ $(INSTALL_DIR) "$(DESTDIR)$(bindir)"
+ $(call removeFiles, "$(WRAPPER)")
+ $(CREATE_SCRIPT) "$(WRAPPER)"
+ echo '#!$(SHELL)' >> "$(WRAPPER)"
+- echo 'exec "$(bindir)/ghc-$(ProjectVersion)" --interactive "$$@"' >> "$(WRAPPER)"
++ echo 'exec "$(bindir)/$(CrossCompilePrefix)ghc-$(ProjectVersion)" --interactive "$$@"' >> "$(WRAPPER)"
+ $(EXECUTABLE_FILE) "$(WRAPPER)"
+- $(call removeFiles,"$(DESTDIR)$(bindir)/ghci")
+- $(LN_S) ghci-$(ProjectVersion) "$(DESTDIR)$(bindir)/ghci"
++ $(call removeFiles,"$(DESTDIR)$(bindir)/$(CrossCompilePrefix)ghci")
++ $(LN_S) $(CrossCompilePrefix)ghci-$(ProjectVersion) "$(DESTDIR)$(bindir)/$(CrossCompilePrefix)ghci"
+
+ else # Windows_Host...
+
+diff --git a/utils/runghc/ghc.mk b/utils/runghc/ghc.mk
+index 9169ca21bd..50b11a612e 100644
+--- a/utils/runghc/ghc.mk
++++ b/utils/runghc/ghc.mk
+@@ -34,11 +34,11 @@ install: install_runhaskell
+ .PHONY: install_runhaskell
+ ifeq "$(Windows_Host)" "YES"
+ install_runhaskell: install_bins
+- "$(CP)" $(DESTDIR)$(bindir)/runghc$(exeext1) $(DESTDIR)$(bindir)/runhaskell$(exeext1)
++ "$(CP)" $(DESTDIR)$(bindir)/$(CrossCompilePrefix)runghc$(exeext1) $(DESTDIR)$(bindir)/$(CrossCompilePrefix)runhaskell$(exeext1)
+ else
+ install_runhaskell:
+- $(call removeFiles,"$(DESTDIR)$(bindir)/runhaskell")
+- $(LN_S) runghc "$(DESTDIR)$(bindir)/runhaskell"
+- $(call removeFiles,"$(DESTDIR)$(bindir)/runghc")
+- $(LN_S) runghc-$(ProjectVersion) "$(DESTDIR)$(bindir)/runghc"
++ $(call removeFiles,"$(DESTDIR)$(bindir)/$(CrossCompilePrefix)runhaskell")
++ $(LN_S) $(CrossCompilePrefix)runghc "$(DESTDIR)$(bindir)/$(CrossCompilePrefix)runhaskell"
++ $(call removeFiles,"$(DESTDIR)$(bindir)/$(CrossCompilePrefix)runghc")
++ $(LN_S) $(CrossCompilePrefix)runghc-$(ProjectVersion) "$(DESTDIR)$(bindir)/$(CrossCompilePrefix)runghc"
+ endif
diff --git a/dev-lang/ghc/files/ghc-8.2.1_rc1-hp2ps-cross.patch b/dev-lang/ghc/files/ghc-8.2.1_rc1-hp2ps-cross.patch
new file mode 100644
index 000000000000..26382b3cf44c
--- /dev/null
+++ b/dev-lang/ghc/files/ghc-8.2.1_rc1-hp2ps-cross.patch
@@ -0,0 +1,104 @@
+commit ff84d052850b637b03bbb98cf05202e44886257d
+Author: Sergei Trofimovich <slyfox@gentoo.org>
+Date: Sat Apr 8 10:02:34 2017 +0100
+
+ cross-build 'unlit' and 'hp2ps' for stage2 install
+
+ In navive build case it does not matter much if we build
+ 'unlit' and 'hp2ps' tools with ghc-stage0 or ghc-stage1:
+ both GHCs are native compilers and both tools are written
+ in C (have no haskell code).
+
+ But in cross-case the difference is substantial:
+ In Stag1Only=YES case we need to install native tools built
+ by ghc-stage0/${host}-cc.
+ In Stag1Only=NO case we need to install cross-built tools
+ built by ghc-stage1/${target}-cc.
+
+ Before this change GHC did not have a rule to build cross-built
+ 'unlit' and 'hp2ps'.
+
+ The change adds cross-built 'unlit' and 'hp2ps' as 'dist-install'
+ targets.
+
+ 'inplace/lib/bin/unlit.bin' target is unchanged and still contains
+ native binary.
+
+ As a result this change allows cross-building and packaging whole
+ GHC for target platform!
+
+ Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
+
+diff --git a/utils/hp2ps/ghc.mk b/utils/hp2ps/ghc.mk
+index f6e01ec6c1..21ce87dcfa 100644
+--- a/utils/hp2ps/ghc.mk
++++ b/utils/hp2ps/ghc.mk
+@@ -10,6 +10,7 @@
+ #
+ # -----------------------------------------------------------------------------
+
++# stage0
+ utils/hp2ps_dist_C_SRCS = AreaBelow.c Curves.c Error.c Main.c \
+ Reorder.c TopTwenty.c AuxFile.c Deviation.c \
+ HpFile.c Marks.c Scale.c TraceElement.c \
+@@ -17,11 +18,27 @@ utils/hp2ps_dist_C_SRCS = AreaBelow.c Curves.c Error.c Main.c \
+ Utilities.c
+ utils/hp2ps_dist_EXTRA_LIBRARIES = m
+ utils/hp2ps_dist_PROGNAME = hp2ps
+-utils/hp2ps_dist_INSTALL = YES
+ utils/hp2ps_dist_INSTALL_INPLACE = YES
+ utils/hp2ps_dist_SHELL_WRAPPER = YES
+ utils/hp2ps_dist_INSTALL_SHELL_WRAPPER_NAME = hp2ps
+
+ utils/hp2ps_CC_OPTS += $(addprefix -I,$(GHC_INCLUDE_DIRS))
+
++# stage 1
++utils/hp2ps_dist-install_C_SRCS = $(utils/hp2ps_dist_C_SRCS)
++utils/hp2ps_dist-install_EXTRA_LIBRARIES = $(utils/hp2ps_dist_EXTRA_LIBRARIES)
++utils/hp2ps_dist-install_PROGNAME = $(utils/hp2ps_dist_PROGNAME)
++utils/hp2ps_dist-install_INSTALL_INPLACE = NO
++utils/hp2ps_dist-install_SHELL_WRAPPER = YES
++utils/hp2ps_dist-install_INSTALL_SHELL_WRAPPER_NAME = $(utils/hp2ps_dist_INSTALL_SHELL_WRAPPER_NAME)
++
++ifeq "$(Stage1Only)" "YES"
++utils/hp2ps_dist_INSTALL = YES
++utils/hp2ps_dist-install_INSTALL = NO
++else
++utils/hp2ps_dist_INSTALL = NO
++utils/hp2ps_dist-install_INSTALL = YES
++endif
++
+ $(eval $(call build-prog,utils/hp2ps,dist,0))
++$(eval $(call build-prog,utils/hp2ps,dist-install,1))
+diff --git a/utils/unlit/ghc.mk b/utils/unlit/ghc.mk
+index e947989b5e..8911f4e856 100644
+--- a/utils/unlit/ghc.mk
++++ b/utils/unlit/ghc.mk
+@@ -10,11 +10,25 @@
+ #
+ # -----------------------------------------------------------------------------
+
++# built by ghc-stage0
+ utils/unlit_dist_C_SRCS = unlit.c
+ utils/unlit_dist_PROGNAME = unlit
+ utils/unlit_dist_TOPDIR = YES
+-utils/unlit_dist_INSTALL = YES
+ utils/unlit_dist_INSTALL_INPLACE = YES
+
+-$(eval $(call build-prog,utils/unlit,dist,0))
++# built by ghc-stage1
++utils/unlit_dist-install_C_SRCS = $(utils/unlit_dist_C_SRCS)
++utils/unlit_dist-install_PROGNAME = $(utils/unlit_dist_PROGNAME)
++utils/unlit_dist-install_TOPDIR = $(utils/unlit_dist_TOPDIR)
++utils/unlit_dist-install_INSTALL_INPLACE = NO
++
++ifeq "$(Stage1Only)" "YES"
++utils/unlit_dist_INSTALL = YES
++utils/unlit_dist-install_INSTALL = NO
++else
++utils/unlit_dist_INSTALL = NO
++utils/unlit_dist-install_INSTALL = YES
++endif
+
++$(eval $(call build-prog,utils/unlit,dist,0))
++$(eval $(call build-prog,utils/unlit,dist-install,1))
diff --git a/dev-lang/ghc/files/ghc-8.2.1_rc1-stage2-cross.patch b/dev-lang/ghc/files/ghc-8.2.1_rc1-stage2-cross.patch
new file mode 100644
index 000000000000..1439d722fef4
--- /dev/null
+++ b/dev-lang/ghc/files/ghc-8.2.1_rc1-stage2-cross.patch
@@ -0,0 +1,81 @@
+commit 54895c90440cb81f18657537b91f2aa35bd54173
+Author: Sergei Trofimovich <slyfox@gentoo.org>
+Date: Fri Apr 7 10:08:58 2017 +0100
+
+ fix 'make install' for cross-stage2
+
+ When cross-built GHC is being installed one of
+ latest steps is to register installed libraries
+ with 'ghc-pkg'.
+
+ GHC uses freshly installed 'ghc-pkg' and 'ghc-stage2'
+ for that.
+
+ Tested as:
+ ./configure --target=aarch64-unknown-linux-gnu
+ make install DESTDIR=$(pwd)/__s2 STRIP_CMD=:
+
+ Before the change install failed on ghc-pkg execution phase:
+
+ ".../ghc-cross/__s2/usr/local/lib/ghc-8.3.20170406/bin/ghc-pkg" \
+ --force \
+ --global-package-db \
+ ".../ghc-cross/__s2/usr/local/lib/ghc-8.3.20170406/package.conf.d" \
+ update rts/dist/package.conf.install
+ /bin/sh: .../ghc-cross/__s2/usr/local/lib/ghc-8.3.20170406/bin/ghc-pkg: \
+ No such file or directory
+
+ To avoid breakage we use 'ghc' and 'ghc-pkg' built by stage0.
+
+ Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
+
+ Test Plan: run 'make install' on stage2 crosscompiler
+
+ Reviewers: rwbarton, austin, bgamari
+
+ Subscribers: thomie, snowleopard
+
+ Differential Revision: https://phabricator.haskell.org/D3432
+
+diff --git a/ghc.mk b/ghc.mk
+index caa6c38fbb..8971f25981 100644
+--- a/ghc.mk
++++ b/ghc.mk
+@@ -962,6 +962,12 @@ endif
+
+ INSTALLED_PACKAGE_CONF=$(DESTDIR)$(topdir)/package.conf.d
+
++ifeq "$(CrossCompiling)" "YES"
++# when installing ghc-stage2 we can't run target's
++# 'ghc-pkg' and 'ghc-stage2' but those are needed for registration.
++INSTALLED_GHC_REAL=$(TOP)/inplace/bin/ghc-stage1
++INSTALLED_GHC_PKG_REAL=$(TOP)/$(ghc-pkg_DIST_BINARY)
++else # CrossCompiling
+ # Install packages in the right order, so that ghc-pkg doesn't complain.
+ # Also, install ghc-pkg first.
+ ifeq "$(Windows_Host)" "NO"
+@@ -971,6 +977,7 @@ else
+ INSTALLED_GHC_REAL=$(DESTDIR)$(bindir)/ghc.exe
+ INSTALLED_GHC_PKG_REAL=$(DESTDIR)$(bindir)/ghc-pkg.exe
+ endif
++endif # CrossCompiling
+
+ # Set the INSTALL_DISTDIR_p for each package; compiler is special
+ $(foreach p,$(filter-out compiler,$(INSTALL_PACKAGES)),\
+diff --git a/utils/ghc-pkg/ghc.mk b/utils/ghc-pkg/ghc.mk
+index 002c8122f2..4d5ef4e108 100644
+--- a/utils/ghc-pkg/ghc.mk
++++ b/utils/ghc-pkg/ghc.mk
+@@ -49,6 +49,12 @@ utils/ghc-pkg_dist_PROGNAME = ghc-pkg
+ utils/ghc-pkg_dist_SHELL_WRAPPER = YES
+ utils/ghc-pkg_dist_INSTALL_INPLACE = YES
+
++# When cross-built ghc-stage2 is installed 'make install' needs to call
++# native ghc-pkg (not the cross-built one) to register installed packages
++# 'ghc-pkg_DIST_BINARY' variable only refer to native binary.
++ghc-pkg_DIST_BINARY_NAME = ghc-pkg$(exeext0)
++ghc-pkg_DIST_BINARY = utils/ghc-pkg/dist/build/tmp/$(ghc-pkg_DIST_BINARY_NAME)
++
+ # See Note [Stage1Only vs stage=1] in mk/config.mk.in.
+ ifeq "$(Stage1Only)" "YES"
+ # Install the copy of ghc-pkg from the dist directory when running 'make
diff --git a/dev-lang/ghc/files/ghc-8.2.1_rc1-staged-cross.patch b/dev-lang/ghc/files/ghc-8.2.1_rc1-staged-cross.patch
new file mode 100644
index 000000000000..7e4ea7a9f610
--- /dev/null
+++ b/dev-lang/ghc/files/ghc-8.2.1_rc1-staged-cross.patch
@@ -0,0 +1,43 @@
+commit f2685df3b10e13f142736f28835e9064334bc143
+Author: Sergei Trofimovich <slyfox@gentoo.org>
+Date: Wed Apr 5 22:31:37 2017 +0100
+
+ avoid $(CrossCompilerPrefix) for stage2 install
+
+ Suppose we are crossbuilding ghc (when ghc-stage2
+ is a normal compiler for $target):
+
+ For this case 'make install' should install unprefixed
+ stage2 'ghc' and not '$(CorssCompilePrefix)-ghc'.
+
+ That way cross-built ghc is installable and
+ usable on target as if it would be built natively
+ on a target.
+
+ Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
+
+diff --git a/mk/config.mk.in b/mk/config.mk.in
+index 4d5d82aa80..5e274bb71f 100644
+--- a/mk/config.mk.in
++++ b/mk/config.mk.in
+@@ -530,7 +530,7 @@ SUPPORTS_THIS_UNIT_ID = @SUPPORTS_THIS_UNIT_ID@
+ # needs to know which gcc you're using in order to perform its tests.
+
+ GccVersion = @GccVersion@
+-CrossCompilePrefix = @CrossCompilePrefix@
++
+ # TargetPlatformFull retains the string passed to configure so we have it in
+ # the necessary format to pass to libffi's configure.
+ TargetPlatformFull = @TargetPlatformFull@
+@@ -567,6 +567,11 @@ CrossCompiling = @CrossCompiling@
+ # See Note [Stage1Only vs stage=1]
+ Stage1Only = NO
+
++# Installed tools prefix:
++# we add prefix to crosscompiler GHC only (ghc-stage1),
++# not cross-built GHC (not ghc-stage2).
++CrossCompilePrefix = $(if $(filter YES,$(Stage1Only)),@CrossCompilePrefix@,)
++
+ # Install stage 2 by default, or stage 1 in the cross compiler
+ # case. Can be changed to 3
+ INSTALL_GHC_STAGE= $(if $(filter YES,$(Stage1Only)),1,2)
diff --git a/dev-lang/ghc/files/ghc-8.2.1_rc1-unphased-cross.patch b/dev-lang/ghc/files/ghc-8.2.1_rc1-unphased-cross.patch
new file mode 100644
index 000000000000..a5528956de14
--- /dev/null
+++ b/dev-lang/ghc/files/ghc-8.2.1_rc1-unphased-cross.patch
@@ -0,0 +1,30 @@
+commit 6ff98b962db15d18eb1d082fe344cef692ecef8e
+Author: Sergei Trofimovich <slyfox@gentoo.org>
+Date: Thu Apr 6 08:55:56 2017 +0100
+
+ config.mk.in: remove phase=0 hack for CrossCompilePrefix
+
+ $(CrossCompilePrefix) is used only in 'make install'
+ target filenames in $(DESTDIR). None of inplace (or boot)
+ files contain $(CrossCompilePrefix).
+
+ Thus we don't need to worry about phases.
+
+ Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
+
+diff --git a/mk/config.mk.in b/mk/config.mk.in
+index 4e61eea821..4d5d82aa80 100644
+--- a/mk/config.mk.in
++++ b/mk/config.mk.in
+@@ -530,11 +530,7 @@ SUPPORTS_THIS_UNIT_ID = @SUPPORTS_THIS_UNIT_ID@
+ # needs to know which gcc you're using in order to perform its tests.
+
+ GccVersion = @GccVersion@
+-ifeq "$(phase)" "0"
+-CrossCompilePrefix =
+-else
+ CrossCompilePrefix = @CrossCompilePrefix@
+-endif
+ # TargetPlatformFull retains the string passed to configure so we have it in
+ # the necessary format to pass to libffi's configure.
+ TargetPlatformFull = @TargetPlatformFull@
diff --git a/dev-lang/ghc/files/ghc-8.2.1_rc1-win32-cross-1.patch b/dev-lang/ghc/files/ghc-8.2.1_rc1-win32-cross-1.patch
new file mode 100644
index 000000000000..79751e1ecbda
--- /dev/null
+++ b/dev-lang/ghc/files/ghc-8.2.1_rc1-win32-cross-1.patch
@@ -0,0 +1,124 @@
+commit a691f6a7a191a268380805481d8e63134764a4a1
+Author: Sergei Trofimovich <slyfox@inbox.ru>
+Date: Sat Apr 29 22:02:24 2017 +0100
+
+ add basic cross-compilation support (#87)
+
+ * fix include case: s/#include <Lmcons.h>/#include <lmcons.h>
+
+ Noticed when cross-compiling win32 on linux to i686-w64-mingw32-gcc.
+ i686-w64-mingw32 provides all headers in lowercase.
+
+ Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
+
+ * Pen.hsc: don't use c99-style comments in enum declarations
+
+ Ths change workarounds hsc2hs bug in cross-compile mode:
+ https://ghc.haskell.org/trac/ghc/ticket/13619
+
+ To reproduce the build failure it's enough to run
+ $ cabal configure --hsc2hs-options='--cross-safe --cross-compile'
+ $ cabal build --hsc2hs-options='--cross-safe --cross-compile'
+
+ Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
+
+ * SimpleMAPI.hsc: don't use #ifdef in enum declarations
+
+ This change workarounds hsc2hs bug in cross-compile mode:
+ https://ghc.haskell.org/trac/ghc/ticket/13620
+
+ To reproduce the build failure it's enough to run
+ $ cabal configure --hsc2hs-options='--cross-safe --cross-compile'
+ $ cabal build --hsc2hs-options='--cross-safe --cross-compile'
+
+ Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
+
+diff --git a/Graphics/Win32/GDI/Pen.hsc b/Graphics/Win32/GDI/Pen.hsc
+index c880170..8d8df5d 100644
+--- a/Graphics/Win32/GDI/Pen.hsc
++++ b/Graphics/Win32/GDI/Pen.hsc
+@@ -56,7 +56,7 @@ foreign import WINDOWS_CCONV unsafe "windows.h DeleteObject"
+
+ type PenStyle = INT
+
+-#{enum PenStyle, // Pick one of these
++#{enum PenStyle,
+ , pS_SOLID = PS_SOLID // default
+ , pS_DASH = PS_DASH // -------
+ , pS_DOT = PS_DOT // .......
+@@ -69,14 +69,14 @@ type PenStyle = INT
+ , pS_STYLE_MASK = PS_STYLE_MASK // all the above
+ }
+
+-#{enum PenStyle , // "or" with one of these
++#{enum PenStyle,
+ , pS_ENDCAP_ROUND = PS_ENDCAP_ROUND // default
+ , pS_ENDCAP_SQUARE = PS_ENDCAP_SQUARE
+ , pS_ENDCAP_FLAT = PS_ENDCAP_FLAT
+ , pS_ENDCAP_MASK = PS_ENDCAP_MASK // all the above
+ }
+
+-#{enum PenStyle, // "or" with one of these
++#{enum PenStyle,
+ , pS_JOIN_ROUND = PS_JOIN_ROUND // default
+ , pS_JOIN_BEVEL = PS_JOIN_BEVEL
+ , pS_JOIN_MITER = PS_JOIN_MITER
+@@ -87,7 +87,7 @@ If PS_JOIN_MASK is not defined with your GNU Windows32 header files,
+ you'll have to define it.
+ -}
+
+-#{enum PenStyle, // "or" with one of these
++#{enum PenStyle,
+ , pS_COSMETIC = PS_COSMETIC // default
+ , pS_GEOMETRIC = PS_GEOMETRIC
+ , pS_TYPE_MASK = PS_TYPE_MASK // all the above
+diff --git a/System/Win32/Info/Computer.hsc b/System/Win32/Info/Computer.hsc
+index bb2eb72..65ae8dc 100644
+--- a/System/Win32/Info/Computer.hsc
++++ b/System/Win32/Info/Computer.hsc
+@@ -65,7 +65,7 @@ import System.Win32.Utils ( tryWithoutNull )
+ import System.Win32.Word ( DWORD, LPDWORD )
+
+ #include <windows.h>
+-#include <Lmcons.h>
++#include <lmcons.h>
+ #include "alignment.h"
+ ##include "windows_cconv.h"
+
+diff --git a/System/Win32/SimpleMAPI.hsc b/System/Win32/SimpleMAPI.hsc
+index 9727cfc..5ebf06b 100644
+--- a/System/Win32/SimpleMAPI.hsc
++++ b/System/Win32/SimpleMAPI.hsc
+@@ -53,12 +53,6 @@ type MapiFlag = ULONG
+ , mAPI_LOGON_UI = MAPI_LOGON_UI
+ , mAPI_NEW_SESSION = MAPI_NEW_SESSION
+ , mAPI_FORCE_DOWNLOAD = MAPI_FORCE_DOWNLOAD
+-#ifdef MAPI_LOGOFF_SHARED
+- , mAPI_LOGOFF_SHARED = MAPI_LOGOFF_SHARED
+-#endif
+-#ifdef MAPI_LOGOFF_UI
+- , mAPI_LOGOFF_UI = MAPI_LOGOFF_UI
+-#endif
+ , mAPI_DIALOG = MAPI_DIALOG
+ , mAPI_UNREAD_ONLY = MAPI_UNREAD_ONLY
+ , mAPI_LONG_MSGID = MAPI_LONG_MSGID
+@@ -74,6 +68,19 @@ type MapiFlag = ULONG
+ , mAPI_RECEIPT_REQUESTED = MAPI_RECEIPT_REQUESTED
+ , mAPI_SENT = MAPI_SENT
+ }
++-- Have to define enum values outside previous declaration due to
++-- hsc2hs bug in --cross-compile mode:
++-- https://ghc.haskell.org/trac/ghc/ticket/13620
++#ifdef MAPI_LOGOFF_SHARED
++#{enum MapiFlag,
++ , mAPI_LOGOFF_SHARED = MAPI_LOGOFF_SHARED
++}
++#endif
++#ifdef MAPI_LOGOFF_UI
++#{enum MapiFlag,
++ , mAPI_LOGOFF_UI = MAPI_LOGOFF_UI
++}
++#endif
+
+ mapiErrors :: [(ULONG,String)]
+ mapiErrors =
diff --git a/dev-lang/ghc/files/ghc-8.2.1_rc1-win32-cross-2-hack.patch b/dev-lang/ghc/files/ghc-8.2.1_rc1-win32-cross-2-hack.patch
new file mode 100644
index 000000000000..6fdcf2d1278f
--- /dev/null
+++ b/dev-lang/ghc/files/ghc-8.2.1_rc1-win32-cross-2-hack.patch
@@ -0,0 +1,144 @@
+hsc2hs can't detect values at compile-time if those are
+declared as pointers: https://github.com/haskell/win32/issues/88
+
+This patch is a huge hack: we encode absolute vaues from <windows.h>
+diff --git a/Graphics/Win32/GDI/Types.hsc b/Graphics/Win32/GDI/Types.hsc
+index c363530..8643cee 100644
+--- a/Graphics/Win32/GDI/Types.hsc
++++ b/Graphics/Win32/GDI/Types.hsc
+@@ -216,10 +216,10 @@ type HWND = HANDLE
+ type MbHWND = Maybe HWND
+
+ #{enum HWND, castUINTPtrToPtr
+- , hWND_BOTTOM = (UINT_PTR)HWND_BOTTOM
+- , hWND_NOTOPMOST = (UINT_PTR)HWND_NOTOPMOST
+- , hWND_TOP = (UINT_PTR)HWND_TOP
+- , hWND_TOPMOST = (UINT_PTR)HWND_TOPMOST
++ , hWND_BOTTOM = (UINT_PTR)(INT_PTR)(1)
++ , hWND_NOTOPMOST = (UINT_PTR)(INT_PTR)(-2)
++ , hWND_TOP = (UINT_PTR)(INT_PTR)(0)
++ , hWND_TOPMOST = (UINT_PTR)(INT_PTR)(-1)
+ }
+
+ type HMENU = HANDLE
+diff --git a/Graphics/Win32/Misc.hsc b/Graphics/Win32/Misc.hsc
+index 1248b5a..c791a20 100644
+--- a/Graphics/Win32/Misc.hsc
++++ b/Graphics/Win32/Misc.hsc
+@@ -67,23 +67,23 @@ foreign import WINDOWS_CCONV unsafe "windows.h LoadIconW"
+ c_LoadIcon :: HINSTANCE -> Icon -> IO HICON
+
+ #{enum Cursor, castUINTPtrToPtr
+- , iDC_ARROW = (UINT_PTR)IDC_ARROW
+- , iDC_IBEAM = (UINT_PTR)IDC_IBEAM
+- , iDC_WAIT = (UINT_PTR)IDC_WAIT
+- , iDC_CROSS = (UINT_PTR)IDC_CROSS
+- , iDC_UPARROW = (UINT_PTR)IDC_UPARROW
+- , iDC_SIZENWSE = (UINT_PTR)IDC_SIZENWSE
+- , iDC_SIZENESW = (UINT_PTR)IDC_SIZENESW
+- , iDC_SIZEWE = (UINT_PTR)IDC_SIZEWE
+- , iDC_SIZENS = (UINT_PTR)IDC_SIZENS
++ , iDC_ARROW = (UINT_PTR)(32512)
++ , iDC_IBEAM = (UINT_PTR)(32513)
++ , iDC_WAIT = (UINT_PTR)(32514)
++ , iDC_CROSS = (UINT_PTR)(32515)
++ , iDC_UPARROW = (UINT_PTR)(32516)
++ , iDC_SIZENWSE = (UINT_PTR)(32642)
++ , iDC_SIZENESW = (UINT_PTR)(32643)
++ , iDC_SIZEWE = (UINT_PTR)(32644)
++ , iDC_SIZENS = (UINT_PTR)(32645)
+ }
+
+ #{enum Icon, castUINTPtrToPtr
+- , iDI_APPLICATION = (UINT_PTR)IDI_APPLICATION
+- , iDI_HAND = (UINT_PTR)IDI_HAND
+- , iDI_QUESTION = (UINT_PTR)IDI_QUESTION
+- , iDI_EXCLAMATION = (UINT_PTR)IDI_EXCLAMATION
+- , iDI_ASTERISK = (UINT_PTR)IDI_ASTERISK
++ , iDI_APPLICATION = (UINT_PTR)(32512)
++ , iDI_HAND = (UINT_PTR)(32513)
++ , iDI_QUESTION = (UINT_PTR)(32514)
++ , iDI_EXCLAMATION = (UINT_PTR)(32515)
++ , iDI_ASTERISK = (UINT_PTR)(32516)
+ }
+
+ ----------------------------------------------------------------
+diff --git a/Graphics/Win32/Resource.hsc b/Graphics/Win32/Resource.hsc
+index e8ad565..ca58fa2 100644
+--- a/Graphics/Win32/Resource.hsc
++++ b/Graphics/Win32/Resource.hsc
+@@ -61,23 +61,23 @@ foreign import WINDOWS_CCONV unsafe "windows.h EndUpdateResourceW"
+ type ResourceType = LPCTSTR
+
+ #{enum ResourceType, castUINTPtrToPtr
+- , rT_ACCELERATOR = (UINT_PTR)RT_ACCELERATOR // Accelerator table
+- , rT_ANICURSOR = (UINT_PTR)RT_ANICURSOR // Animated cursor
+- , rT_ANIICON = (UINT_PTR)RT_ANIICON // Animated icon
+- , rT_BITMAP = (UINT_PTR)RT_BITMAP // Bitmap resource
+- , rT_CURSOR = (UINT_PTR)RT_CURSOR // Hardware-dependent cursor resource
+- , rT_DIALOG = (UINT_PTR)RT_DIALOG // Dialog box
+- , rT_FONT = (UINT_PTR)RT_FONT // Font resource
+- , rT_FONTDIR = (UINT_PTR)RT_FONTDIR // Font directory resource
+- , rT_GROUP_CURSOR = (UINT_PTR)RT_GROUP_CURSOR // Hardware-independent cursor resource
+- , rT_GROUP_ICON = (UINT_PTR)RT_GROUP_ICON // Hardware-independent icon resource
+- , rT_HTML = (UINT_PTR)RT_HTML // HTML document
+- , rT_ICON = (UINT_PTR)RT_ICON // Hardware-dependent icon resource
+- , rT_MENU = (UINT_PTR)RT_MENU // Menu resource
+- , rT_MESSAGETABLE = (UINT_PTR)RT_MESSAGETABLE // Message-table entry
+- , rT_RCDATA = (UINT_PTR)RT_RCDATA // Application-defined resource (raw data)
+- , rT_STRING = (UINT_PTR)RT_STRING // String-table entry
+- , rT_VERSION = (UINT_PTR)RT_VERSION // Version resource
++ , rT_ACCELERATOR = (UINT_PTR)(9)
++ , rT_ANICURSOR = (UINT_PTR)(21)
++ , rT_ANIICON = (UINT_PTR)(22)
++ , rT_BITMAP = (UINT_PTR)(2)
++ , rT_CURSOR = (UINT_PTR)(1)
++ , rT_DIALOG = (UINT_PTR)(5)
++ , rT_FONT = (UINT_PTR)(8)
++ , rT_FONTDIR = (UINT_PTR)(7)
++ , rT_GROUP_CURSOR = (UINT_PTR)(1 + DIFFERENCE)
++ , rT_GROUP_ICON = (UINT_PTR)(3 + DIFFERENCE)
++ , rT_HTML = (UINT_PTR)(23)
++ , rT_ICON = (UINT_PTR)(3)
++ , rT_MENU = (UINT_PTR)(4)
++ , rT_MESSAGETABLE = (UINT_PTR)(11)
++ , rT_RCDATA = (UINT_PTR)(10)
++ , rT_STRING = (UINT_PTR)(6)
++ , rT_VERSION = (UINT_PTR)(16)
+ }
+
+ findResource :: HMODULE -> String -> ResourceType -> IO HRSRC
+diff --git a/Graphics/Win32/Window/PostMessage.hsc b/Graphics/Win32/Window/PostMessage.hsc
+index 7f4c9f0..609f3f6 100644
+--- a/Graphics/Win32/Window/PostMessage.hsc
++++ b/Graphics/Win32/Window/PostMessage.hsc
+@@ -41,7 +41,7 @@ foreign import WINDOWS_CCONV "windows.h PostThreadMessageW"
+ c_PostThreadMessage :: DWORD -> WindowMessage -> WPARAM -> LPARAM -> IO BOOL
+
+ #{enum HWND, castUINTPtrToPtr
+- , hWND_BROADCAST = (UINT_PTR)HWND_BROADCAST
++ , hWND_BROADCAST = (UINT_PTR)(0xffff)
+ }
+
+ foreign import WINDOWS_CCONV "windows.h InSendMessage"
+diff --git a/System/Win32/Registry.hsc b/System/Win32/Registry.hsc
+index afbb011..c7edfc1 100644
+--- a/System/Win32/Registry.hsc
++++ b/System/Win32/Registry.hsc
+@@ -80,11 +80,11 @@ import System.Win32.Types (castUINTPtrToPtr, failUnlessSuccessOr, maybePtr)
+ #include <windows.h>
+
+ #{enum HKEY, (unsafePerformIO . newForeignHANDLE . castUINTPtrToPtr)
+- , hKEY_CLASSES_ROOT = (UINT_PTR)HKEY_CLASSES_ROOT
+- , hKEY_CURRENT_CONFIG = (UINT_PTR)HKEY_CURRENT_CONFIG
+- , hKEY_CURRENT_USER = (UINT_PTR)HKEY_CURRENT_USER
+- , hKEY_LOCAL_MACHINE = (UINT_PTR)HKEY_LOCAL_MACHINE
+- , hKEY_USERS = (UINT_PTR)HKEY_USERS
++ , hKEY_CLASSES_ROOT = (UINT_PTR)(0x80000000)
++ , hKEY_CURRENT_CONFIG = (UINT_PTR)(0x80000005)
++ , hKEY_CURRENT_USER = (UINT_PTR)(0x80000001)
++ , hKEY_LOCAL_MACHINE = (UINT_PTR)(0x80000002)
++ , hKEY_USERS = (UINT_PTR)(0x80000003)
+ }
+ -- , PKEYERFORMANCE_DATA NT only
+ -- , HKEY_DYN_DATA 95/98 only
diff --git a/dev-lang/ghc/files/ghc-8.2.1_rc2-O2-unreg.patch b/dev-lang/ghc/files/ghc-8.2.1_rc2-O2-unreg.patch
new file mode 100644
index 000000000000..00f9ca4fdff9
--- /dev/null
+++ b/dev-lang/ghc/files/ghc-8.2.1_rc2-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 4e61eea..15a56e9 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.hs')
+-# and sometimes not compile at all (powerpc64 overflows something
+-# on 'compiler/hsSyn/HsExpr.hs').
+-ifeq "$(GhcUnregisterised)" "YES"
+-GhcStage1HcOpts=
+-GhcStage2HcOpts=
+-GhcStage3HcOpts=
+-endif
+
+@@ -904 +895,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.hs')
++# and sometimes not compile at all (powerpc64 overflows something
++# on 'compiler/hsSyn/HsExpr.hs').
++ifeq "$(GhcUnregisterised)" "YES"
++GhcStage1HcOpts=
++GhcStage2HcOpts=
++GhcStage3HcOpts=
++
++GhcLibHcOpts=
++endif
diff --git a/dev-lang/ghc/files/ghc-8.2.1_rc3-any-vendor.patch b/dev-lang/ghc/files/ghc-8.2.1_rc3-any-vendor.patch
new file mode 100644
index 000000000000..b55e37a8bf94
--- /dev/null
+++ b/dev-lang/ghc/files/ghc-8.2.1_rc3-any-vendor.patch
@@ -0,0 +1,44 @@
+From c2303dff95aa174021a1950656fdf9a1cf983959 Mon Sep 17 00:00:00 2001
+From: Sergei Trofimovich <slyfox@gentoo.org>
+Date: Sat, 8 Jul 2017 09:47:12 +0100
+Subject: [PATCH] aclocal.m4: allow arbitrary <vendor> string in toolchain
+ triplets
+
+Canonical triplets have a form of
+ <arch>-<vendor>-<os>[-<abi>]
+
+Checking for vendor is almost never correct as it's an
+arbitrary string.
+
+It's useful to have multiple "vendors" to denote
+otherwise the same (WRT <arch>, <os>, <abi>) target:
+ --target=x86_64-pc-linux-gnu
+ --target=x86_64-unknown-linux-gnu
+ --target=x86_64-ghc80-linux-gnu
+ --target=x86_64-ghchead-linux-gnu
+
+Do not fail unknown vendors. Only emit a warning.
+Ideally configure checks should never use "vendor".
+
+Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
+---
+ aclocal.m4 | 3 +--
+ 1 file changed, 1 insertion(+), 2 deletions(-)
+
+diff --git a/aclocal.m4 b/aclocal.m4
+index 001f813dfc..1d9c09b0cd 100644
+--- a/aclocal.m4
++++ b/aclocal.m4
+@@ -230,8 +230,7 @@ AC_DEFUN([FPTOOLS_SET_HASKELL_PLATFORM_VARS],
+ dec|none|unknown|hp|apple|next|sun|sgi|ibm|montavista|portbld)
+ ;;
+ *)
+- echo "Unknown vendor [$]1"
+- exit 1
++ AC_MSG_WARN([Unknown vendor [$]1])
+ ;;
+ esac
+ }
+--
+2.13.3
+
diff --git a/dev-lang/ghc/files/ghc-8.2.1_rc3-stginit-data.patch b/dev-lang/ghc/files/ghc-8.2.1_rc3-stginit-data.patch
new file mode 100644
index 000000000000..81e751d778c8
--- /dev/null
+++ b/dev-lang/ghc/files/ghc-8.2.1_rc3-stginit-data.patch
@@ -0,0 +1,27 @@
+Fix label type for __stginit_* labels: those are .data labels, not .text
+
+Noticed when was building --enable-unregisterised build for x86_64:
+
+/tmp/ghc22931_0/ghc_3.hc:5:9: error:
+ error: '__stginit_ghczmprim_GHCziTypes' redeclared as different kind of symbol
+ StgWord __stginit_ghczmprim_GHCziTypes[]__attribute__((aligned(8)))= {
+ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ |
+5 | StgWord __stginit_ghczmprim_GHCziTypes[]__attribute__((aligned(8)))= {
+ | ^
+
+In file included from /tmp/ghc22931_0/ghc_3.hc:3:0: error:
+
+/tmp/ghc22931_0/ghc_3.hc:4:5: error:
+ note: previous declaration of '__stginit_ghczmprim_GHCziTypes' was here
+ EF_(__stginit_ghczmprim_GHCziTypes);
+ ^
+diff --git a/compiler/cmm/CLabel.hs b/compiler/cmm/CLabel.hs
+index 77a889a..05d71ab 100644
+--- a/compiler/cmm/CLabel.hs
++++ b/compiler/cmm/CLabel.hs
+@@ -956,3 +956,3 @@ labelType (CaseLabel _ CaseReturnInfo) = DataLabel
+ labelType (CaseLabel _ _) = CodeLabel
+-labelType (PlainModuleInitLabel _) = CodeLabel
++labelType (PlainModuleInitLabel _) = DataLabel
+ labelType (SRTLabel _) = DataLabel
diff --git a/dev-lang/ghc/files/ghc-bash-completion b/dev-lang/ghc/files/ghc-bash-completion
new file mode 100644
index 000000000000..0ee2149cd81b
--- /dev/null
+++ b/dev-lang/ghc/files/ghc-bash-completion
@@ -0,0 +1,218 @@
+# ghc-pkg command line completion for bash
+#
+# Copyright 2006-2007 Lennart Kolmodin <kolmodin@dtek.chalmers.se>
+
+_ghc-pkg-get-ghc-pkg()
+{
+ echo ghc-pkg
+}
+
+_ghc-pkg-pkg-fields()
+{
+ # usage: _ghc-pkg-pkg-fields pkg-id
+ #
+ # list all fields of the pkg-id
+
+ # same fields for all packages but different in different versions of
+ # ghc-pkg? this can probably be done better/faster
+
+ if [[ -z "$1" ]]; then
+ echo "usage: _ghc-pkg-pkg-fields pkg-id"
+ return 1
+ fi
+
+ local fields
+
+ fields="$( $(_ghc-pkg-get-ghc-pkg) describe $1 )"
+
+ #if [[ fields != *"cannot find package"* ]]; then
+ echo "$fields" | grep ".*:.*" | sed "s/^\(.*\):.*\$/\1/"
+ #fi
+}
+
+_ghc-pkg-pkg-ids()
+{
+ # usage: _ghc-pkg-pkg-ids
+ #
+ # simply lists all package ids known by ghc-pkg.
+ $(_ghc-pkg-get-ghc-pkg) list --simple-output
+}
+
+_ghc-pkg-pkgs()
+{
+ # usage: _ghc-pkg-pkgs [include-pkgs] [include-ids]
+ #
+ # with optional parameter include-pkgs it will list all packages known
+ # to ghc-pkg.
+ # with optional parameter include-ids it will list all package-ids known
+ # to ghc-pkg.
+ local pkgs
+ local result
+ pkgs=( $( _ghc-pkg-pkg-ids ) )
+ result=( )
+
+ local withPkgs="no" withIds="no"
+ while [[ -n "$1" ]]; do
+ case "$1" in
+ include-pkgs)
+ withPkgs="yes" ;;
+ include-ids)
+ withIds="yes" ;;
+ *)
+ echo "unknown parameter '$1' to _ghc-pkg-pkgs"
+ return 1 ;;
+ esac
+ shift
+ done
+
+ # user must supply either include-pkgs, include-ids or both
+ if [[ $withPkgs != "yes" && $withIds != "yes" ]]; then
+ echo "usage: _ghc-pkg-pkgs [include-pkgs] [include-ids]"
+ return 1
+ fi
+
+ # find all packages if the user requested them
+ if [[ $withPkgs == "yes" ]]; then
+ # O(n^2) algorithm to exclude duplicates
+ for p in ${pkgs[*]}; do
+ p="${p//-[0-9.]*/}"
+ for existing in ${result[*]}; do
+ if [[ "$existing" == "$p" ]]; then
+ continue 2
+ fi
+ done
+ result=( "${result[@]}" "${p}" )
+ done
+ fi
+
+ # include all pkg-ids if requested
+ if [[ $withIds == "yes" ]]; then
+ result=( "${result[@]}" "${pkgs[@]}" )
+ fi
+
+ # we are finished, echo the result
+ echo "${result[*]}"
+
+ # happy ending
+ return 0
+}
+
+_ghc-pkg()
+{
+ local cur
+ cur=${COMP_WORDS[COMP_CWORD]}
+
+ COMPREPLY=()
+
+ local actions flags
+ actions='register update unregister expose hide list latest describe field'
+ dbflags="--user \
+ --global \
+ -f --package-conf= \
+ --global-conf="
+ registerflags="--force \
+ -g --auto-ghci-libs \
+ -D --define-name="
+ listflags="--simple-output"
+ flags="$dbflags \
+ $registerflags \
+ $listflags \
+ -? --help \
+ -V --version"
+
+ # if it's the users first word; complete it and return
+ if (($COMP_CWORD == 1)); then
+ COMPREPLY=( $( compgen -W "$actions $flags" -- $cur ) )
+ return 0
+ fi
+
+ # now we know we have at least one word written
+
+ local action="unknown" \
+ prev numwords \
+ cword act
+ prev=${COMP_WORDS[COMP_CWORD-1]}
+ numwords=${#COMP_WORDS[@]}
+
+ # find the action with O(n*m) algorithm
+ # where n = ${#COMP_WORDS[*]}
+ # m = number of actions
+ for cword in ${COMP_WORDS[*]}; do
+ for act in $actions; do
+ if [[ "$cword" == "$act" ]]; then
+ action=$cword
+ fi
+ done
+ done
+
+ case $action in
+ register|update)
+ # we want to complete both flags and paths, how?
+ # we do it by checking if the user has started to write a flag
+ # or a path, and then decide what to complete.
+ # that is, to complete a flag, the user must start to write a '-'
+ if [[ "$cur" == -* ]]; then
+ # (we assume) it's the start of a flag
+ # set COMPREPLY to flags relevant to these actions
+ COMPREPLY=( $( compgen -W "$dbflags $registerflags" -- $cur ) )
+ fi
+ ;;
+ unregister|expose|hide|list|describe)
+ # all these actions can be completed with exactly one argument,
+ # a pkg-id.
+ COMPREPLY=( $( compgen -W "$dbflags" -- $cur ) )
+
+ # add special flags for some actions
+ if [[ "$action" == "list" ]]; then
+ COMPREPLY+=( $( compgen -W "$listflags" -- $cur ) )
+ fi
+
+ COMPREPLY+=( $( compgen -W "$( _ghc-pkg-pkgs include-ids )" -- $cur ) )
+ ;;
+ latest)
+ # complete only packages, not package ids
+ COMPREPLY=( $( compgen -W "$( _ghc-pkg-pkgs include-pkgs )" -- $cur ) )
+ ;;
+ field)
+ # we should always complete on the flags...
+ COMPREPLY=( $( compgen -W "$dbflags" -- $cur ) )
+
+ # then, we should either complete the package name or the field
+ # lets find out which one
+
+ # find the number of words in COMP_WORDS before COMP_CWORD that
+ # isn't flags. it should be 2 or 3 for us to complete it,
+ # exactly 2 if we should complete the package name
+ # exactly 3 if we should complete the field name
+ # otherwise, don't do any additional completion except the
+ # flags
+
+ # count the number of non flags up till the current word
+ local numnonflags=0 lastword i
+ for (( i=0 ; $i < $COMP_CWORD ; i++ )); do
+ if [[ ${COMP_WORDS[$i]} != -* ]]; then
+ lastword=${COMP_WORDS[$i]}
+ numnonflags=$(( ++numnonflags ))
+ fi
+ done
+
+ case $numnonflags in
+ 2)
+ # complete on pkg-ids
+ COMPREPLY+=( $( compgen -W "$( _ghc-pkg-pkgs include-ids )" -- $cur ) ) ;;
+ 3)
+ # complete on fields
+ COMPREPLY+=( $( compgen -W "$( _ghc-pkg-pkg-fields $lastword )" -- $cur ) ) ;;
+ esac
+ ;;
+ *)
+ # unknown action, not yet given by the user
+ # return all possible completions
+ COMPREPLY=( $( compgen -W "$actions $flags" -- $cur ) )
+ ;;
+ esac
+}
+
+complete -F _ghc-pkg -o default ghc-pkg
+
+# vim: set ft=sh tw=80 sw=4 et :
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 000000000000..4afb2420ef3e
--- /dev/null
+++ b/dev-lang/ghc/ghc-7.10.3.ebuild
@@ -0,0 +1,686 @@
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+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-${PVR}-amd64.tbz2 )"
+arch_binaries="$arch_binaries ia64? ( http://code.haskell.org/~slyfox/ghc-ia64/ghc-bin-${PV}-ia64.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="~alpha amd64 ~ia64 ~ppc ~ppc64 ~sparc 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: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:5/5
+"
+
+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-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} ]]
+}
+
+# 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 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
+ 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"
+ 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}
+
+ 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
+}
diff --git a/dev-lang/ghc/ghc-7.8.4.ebuild b/dev-lang/ghc/ghc-7.8.4.ebuild
new file mode 100644
index 000000000000..16a49986a1cb
--- /dev/null
+++ b/dev-lang/ghc/ghc-7.8.4.ebuild
@@ -0,0 +1,616 @@
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+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-${PV}-amd64.tbz2 )"
+arch_binaries="$arch_binaries ia64? ( http://code.haskell.org/~slyfox/ghc-ia64/ghc-bin-${PV}-ia64.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=7.8.3.20141119 # 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 )"
+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"
+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:0=[unicode]
+ !ghcmakebinary? ( virtual/libffi:= )
+"
+
+PREBUILT_BINARY_DEPENDS="
+ !prefix? ( elibc_glibc? ( >=sys-libs/glibc-2.17 ) )
+ sys-libs/ncurses:5/5
+"
+
+RDEPEND+="binary? ( ${PREBUILT_BINARY_DEPENDS} )"
+
+DEPEND="${RDEPEND}
+ ghcbootstrap? (
+ 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? ( ${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} ]]
+}
+
+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
+}
+
+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}"
+ 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/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/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
+ # 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/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/bin/hsc2hs" \
+ || 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/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}"
+ 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.1_rc1-libbfd.patch
+
+ epatch "${FILESDIR}"/${PN}-7.8.2-cgen-constify.patch
+ epatch "${FILESDIR}"/${PN}-7.8.3-prim-lm.patch
+ # bug 518734
+ epatch "${FILESDIR}"/${PN}-7.6.3-preserve-inplace-xattr.patch
+ # fix threaded runtime on ia64
+ epatch "${FILESDIR}"/${PN}-7.8.4-ia64-CLOSUREs.patch
+ epatch "${WORKDIR}"/${PN}-7.8.4-ia64-CLOSUREs-regenerated.patch
+
+ # upstream backports
+ epatch "${FILESDIR}"/${PN}-7.8.3-linker-warn.patch
+ epatch "${FILESDIR}"/${PN}-7.8.3-pic-sparc.patch
+ epatch "${FILESDIR}"/${PN}-7.8.3-ppc32-fPIC.patch
+ epatch "${FILESDIR}"/${PN}-7.8.4-gold.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
+
+ # 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+=${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
+ if use ghcbootstrap && use doc; then
+ echo "BUILD_DOCBOOK_PDF = NO" >> mk/build.mk
+ echo "BUILD_DOCBOOK_PS = NO" >> mk/build.mk
+ echo "BUILD_DOCBOOK_HTML = YES" >> mk/build.mk
+ echo "HADDOCK_DOCS = YES" >> mk/build.mk
+ else
+ echo "BUILD_DOCBOOK_PDF = NO" >> mk/build.mk
+ echo "BUILD_DOCBOOK_PS = NO" >> mk/build.mk
+ echo "BUILD_DOCBOOK_HTML = NO" >> mk/build.mk
+ echo "HADDOCK_DOCS = NO" >> 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
+
+ # 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-gmp" >> 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
+ econf_args+=(--with-system-libffi)
+ econf_args+=(--with-ffi-includes=$(pkg-config libffi --cflags-only-I | sed -e 's@^-I@@'))
+ fi
+
+ 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
+ GHC_TPF="$(grep 'S\[\"TargetPlatformFull\"\]' config.status | sed -e 's@^.*=\"\(.*\)\"@\1@')"
+ 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}"
+
+ # Remove the docs if not requested
+ if ! use doc; then
+ rm -rf "${ED}/usr/share/doc/${P}/*/" \
+ "${ED}/usr/share/doc/${P}/*.html" \
+ || die "could not remove docs (P vs PF revision mismatch?)"
+ fi
+ else
+ # We only build docs if we were bootstrapping, otherwise
+ # we copy them out of the unpacked binary .tbz2
+ if use doc && ! use ghcbootstrap; then
+ mkdir -p "${ED}/usr/share/doc"
+ mv "${WORKDIR}/usr/share/doc/${P}" "${ED}/usr/share/doc" \
+ || die "failed to copy docs"
+ else
+ dodoc "${S}/distrib/README" "${S}/ANNOUNCE" "${S}/LICENSE" "${S}/VERSION"
+ fi
+
+ emake -j1 install DESTDIR="${D}"
+
+ # remove link, but leave 'haddock-${GHC_P}'
+ rm -f "${ED}"/usr/bin/haddock
+
+ if [[ ! -f "${S}/VERSION" ]]; then
+ echo "${GHC_PV}" > "${S}/VERSION" \
+ || die "Could not create file ${S}/VERSION"
+ fi
+ newbashcomp "${FILESDIR}/ghc-bash-completion" ghc-pkg
+
+ fi
+
+ # path to the package.cache
+ local package_confdir="${ED}/usr/$(get_libdir)/${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)/${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 --upgrade'"
+ ewarn "to rebuild all ghc-based Haskell libraries."
+ ewarn
+ ewarn "\e[1;31m************************************************************************\e[0m"
+ ewarn
+ fi
+}
+
+pkg_prerm() {
+ # Be very careful here... Call order when upgrading is (according to PMS):
+ # * src_install for new package
+ # * pkg_preinst for new package
+ # * pkg_postinst for new package
+ # * pkg_prerm for the package being replaced
+ # * pkg_postrm for the package being replaced
+ # so you'll actually be touching the new packages files, not the one you
+ # uninstall, due to that or installation directory ${GHC_P} will be the same for
+ # both packages.
+
+ # Call order for reinstalling is (according to PMS):
+ # * src_install
+ # * pkg_preinst
+ # * pkg_prerm for the package being replaced
+ # * pkg_postrm for the package being replaced
+ # * pkg_postinst
+
+ # Overwrite the modified package.cache with a copy of the
+ # original one, so that it will be removed during uninstall.
+
+ PKGCACHE="${EROOT}/usr/$(get_libdir)/${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.0.2.ebuild b/dev-lang/ghc/ghc-8.0.2.ebuild
new file mode 100644
index 000000000000..c2b48ae466f3
--- /dev/null
+++ b/dev-lang/ghc/ghc-8.0.2.ebuild
@@ -0,0 +1,681 @@
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+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
+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? ( 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 arm64? ( http://code.haskell.org/~slyfox/ghc-arm64/ghc-bin-${PV}-arm64.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.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 ;;
+ arm64) 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="~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} ]]
+}
+
+# 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 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 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"
+}
+
+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/$(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
+ epatch "${FILESDIR}"/${PN}-8.0.2-libffi-alpha.patch
+ epatch "${FILESDIR}"/${PN}-8.0.2-O2-unreg.patch
+
+ 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
+ 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
+
+ # 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 -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
+}
diff --git a/dev-lang/ghc/ghc-8.2.1.ebuild b/dev-lang/ghc/ghc-8.2.1.ebuild
new file mode 100644
index 000000000000..66a642bf9292
--- /dev/null
+++ b/dev-lang/ghc/ghc-8.2.1.ebuild
@@ -0,0 +1,765 @@
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+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'
+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? ( 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}-armv7a-hardfloat-linux-gnueabi.tbz2 )"
+#arch_binaries="$arch_binaries arm64? ( http://code.haskell.org/~slyfox/ghc-arm64/ghc-bin-${PV}-aarch64-unknown-linux-gnu.tbz2 )"
+arch_binaries="$arch_binaries amd64? ( http://code.haskell.org/~slyfox/ghc-amd64/ghc-bin-${PV}-x86_64-pc-linux-gnu.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}-i686-pc-linux-gnu.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 ;;
+ #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.2.0.20170704 # 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="~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/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
+ # 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/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" \
+ || 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"
+}
+
+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}"
+ 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.2.1-darwin.patch
+
+ epatch "${FILESDIR}"/${PN}-8.2.1_rc1-cgen-constify.patch
+ epatch "${FILESDIR}"/${PN}-7.8.3-prim-lm.patch
+
+ epatch "${FILESDIR}"/${PN}-8.2.1_rc2-O2-unreg.patch
+
+ # a bunch of crosscompiler patches
+ epatch "${FILESDIR}"/${PN}-8.2.1_rc1-unphased-cross.patch
+ epatch "${FILESDIR}"/${PN}-8.2.1_rc1-staged-cross.patch
+ epatch "${FILESDIR}"/${PN}-8.2.1_rc1-ghci-cross.patch
+ epatch "${FILESDIR}"/${PN}-8.2.1_rc1-stage2-cross.patch
+ epatch "${FILESDIR}"/${PN}-8.2.1_rc1-hp2ps-cross.patch
+ epatch "${FILESDIR}"/${PN}-8.2.1_rc3-any-vendor.patch
+ epatch "${FILESDIR}"/${PN}-8.2.1_rc3-stginit-data.patch
+
+ # needs a new libffi release
+ epatch "${FILESDIR}"/${PN}-8.0.2-libffi-alpha.patch
+
+ # mingw32 target
+ pushd "${S}/libraries/Win32"
+ epatch "${FILESDIR}"/${PN}-8.2.1_rc1-win32-cross-1.patch # upstreamed, waits for merge to -HEAD
+ epatch "${FILESDIR}"/${PN}-8.2.1_rc1-win32-cross-2-hack.patch # bad workaround
+ popd
+
+ 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/$(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
+ LD=${CTARGET}-ld
+ # these should be inferred by GHC but ghc defaults
+ # to using bundled tools on windows.
+ Windres=${CTARGET}-windres
+ DllWrap=${CTARGET}-dllwrap
+ )
+ if [[ ${CTARGET} == arm* ]] ; then
+ # 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)
+ fi
+
+ 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
+}
diff --git a/dev-lang/ghc/metadata.xml b/dev-lang/ghc/metadata.xml
new file mode 100644
index 000000000000..521a174394e8
--- /dev/null
+++ b/dev-lang/ghc/metadata.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+ <maintainer type="project">
+ <email>haskell@gentoo.org</email>
+ <name>Gentoo Haskell</name>
+ </maintainer>
+ <use>
+ <flag name="binary">Install the binary version directly, rather than using it to build the source version.</flag>
+ <flag name="ghcbootstrap">Bootstrap from an existing GHC installation.</flag>
+ <flag name="ghcmakebinary">Build with less runtime depends (bundle libffi for building bootstrap binaries).</flag>
+ </use>
+</pkgmetadata>