diff options
Diffstat (limited to 'dev-lang/ghc')
46 files changed, 8458 insertions, 0 deletions
diff --git a/dev-lang/ghc/Manifest b/dev-lang/ghc/Manifest new file mode 100644 index 000000000000..fc4897ec0e3d --- /dev/null +++ b/dev-lang/ghc/Manifest @@ -0,0 +1,88 @@ +AUX ghc-7.0.4-CHOST-prefix.patch 276 BLAKE2B 77c706d291928a229edad6bcde37786b2c11cf52f42b22f44d3bbb7cfe12f83b8725cae020f95994e0f12022989b125d1f1e6f43ad0cc6698452264b8634651c SHA512 9d5d30b95c0467bb77f320c82458be5eaace5bbd77684725b9f3fd70d9640accdd771e36aa957c66f9bfb01e45088d32a5f811444b472058574ccbf89e10efbb +AUX ghc-7.10.1-rc3-ghc-7.10-bootstrap.patch 2648 BLAKE2B 82145d17ff3f7535b80b76d98a30355895d1a43ab9cd5cab1606f989764f77b5b00d8d098ad327bfb6f3318ea8d188fcd55bcba15789234fceb0de5c132e9cbc SHA512 ea2c9cd8fde754803950e29b2eea113227ca5504c58392847090e13640bdfa6b39ef714eff985947aa27e66c2506ef2a2867696f68a7ff34418a7fbf49765d48 +AUX ghc-7.10.3-hardfloat.patch 747 BLAKE2B e2a328372ddd113752400957aa697d171b3367693c3d098c9b5b8b02b9e1ef1cc0cb86c2af4a0385a142791b4e7efbf4c7d64835f7e296a03abff2fccc9e9ef6 SHA512 a9a186ff62236d63b4b841bcfb1da1a902b3f300eb7d768c5316b5d636190d58fc71177f2d1670df261d0b681b104621f98cfdd76b30a0fb6917525874759264 +AUX ghc-7.10.3-relnotes.patch 1584 BLAKE2B e247668b1fb2a5b8ff69b00f31b8b642a7ba47cba0cacf9ac254b08cd736ee0d5276e77f64665ce37d8d85250c7cf4cc9924c86e21b35a3abfffded45b72ae9b SHA512 20d61d9f73bd0efa39c920897bdb18b69cff453f5ab24193aa3f7fafa70a9aa346ab4402604f81471f989c2401ca28d901fb85b8862577790559a35cfa3d3f05 +AUX ghc-7.6.3-preserve-inplace-xattr.patch 495 BLAKE2B f9f32485af27b76d62466bc03a17826e18efa40a87858a46b41d4f094e1c0989d2773ddd92e206d4285ae1791bf00daaabd4f19dedcd80610db1127b440394fd SHA512 98504e3b72446607deb520521c4abdd15e41e4ff69ad64e2ad13faca396bd7c7784b92c2bc7b5d8190668da480d5b1dd886f5e47e2e192d76b7fbbd58a42d44b +AUX ghc-7.8.1_rc1-libbfd.patch 2771 BLAKE2B 8730551d3900012d04eafed69894740f603618ae59bef59e71194efb5b1e417799647c4aa1cda4cea9041504d116d74085bb99b0e9f0c543d2429529e030faca SHA512 e232596342675769c6bf97686aff0fa7a8991e1edd3bf607068482cd0d0c9f9a9500e5b15f176a2025732474c9e547c0bae603d373c81b374c96787d46bbfa4a +AUX ghc-7.8.2-cgen-constify.patch 1173 BLAKE2B f61bef77e23e47becb8b5f99e8cfdb5f4e8858787da21b62215f5538c02d5c8d92bf58d29b080468c81d8b732dafa34969e5138df7c113e2e805c7b4e4ccdb1f SHA512 3e1bca7d7f9062d231c45a6765485291871df833da31b0a5573bb04639791c554dd5c0d8fe33bab05455fe06d3f36fe81dd1db6d3819c739284a3af5c4ec8fb0 +AUX ghc-7.8.3-linker-warn.patch 1317 BLAKE2B 399c117a216cbeff9d863893ef821b965d91428e55b447e72469ccc6940d0eccd4bca33f2ceaaea096de23789e74ca7ffe38a5fdd08005bbcc016c06db4ec8c2 SHA512 3b0ece4a6536ef43f15e97e723d036401dcf41d47c15e29dd8fe30c9f1563894102922617982db7b6c7cf3ed8aea64458b540ef92ffe690ff72994b1246834c9 +AUX ghc-7.8.3-pic-sparc.patch 1007 BLAKE2B 64a1214b1df6cc2d894e898dc21983a3df17da95f6ace2b7dfb2469ca62bf10b548a65c6242bd97e63a70fe7ae6e921e3e5828b664fa1ce04d10323fd8a4dfa6 SHA512 d3d81142a1e606c85c22127e2fbb26ceaeb2116435bf0bbc3743273577f04991e28c38a375a78b3f633a9b0e25f10951146d1f322e0ad7972089c1e5d977d16b +AUX ghc-7.8.3-ppc32-fPIC.patch 14549 BLAKE2B 05811de54b2896c75456a0f61c64325fd347ccd3a47f86d7e9697d04266f11af0b3f3b8081b39318e8d90d76e3f763ad292adeb0114d8b7bf60157b5a90b13a1 SHA512 aa6f13e04a52e7f25db456c02031b63c01b71adf41262361b36ca97aec18965f618ebba73494b4283ad3c0224f15d5c80dbd43076553e604d86a07baf7fa86db +AUX ghc-7.8.3-prim-lm.patch 444 BLAKE2B a930bb9657441a48941debf79711e06223c5680df0f60d7d972e0150950109bf8f8a99c35c7dbcda21172dddcb15d8a379085813e44647583e3888f27f597568 SHA512 6979e002589a54c870c70eee8357dad4feb55b4e5102350cc09a466145677dacaa1bab5ebe4818cf0d3cd8ab50ee0ec2ab642ab0fb3fd34f4a266e5e90f9f389 +AUX ghc-7.8.4-gold.patch 1025 BLAKE2B f62a45f9761690a685217654e45c037c63e2cf0ae297f14f3c70c038c4b02e048899b1a787fedfd30fa4e41839f729d20c2442ec3410fb59508da57222ac19fd SHA512 3087084d8b6a202496fc7ac71fadde06f7d1622d0e3f44f1b52fd04f1451d690f54b6bd8ee0da85663d252c6110340402bd1864f746117e59ce7b02e0247ec94 +AUX ghc-7.8.4-ia64-CLOSUREs.patch 2243 BLAKE2B 7bfdd4f42917a7b856ce18b85a2131bc0b566151fda16a77412331f38a4465efa080f6aa3eb52cfe12fb9c2c3fdefc1fe4a533fa5b339f4f22ac70c2a4a404b1 SHA512 9981d13f294fe0a28d1cabfd4db98bfb18110c6adb390f509667e3166a931c7d9f7b4b0079dfb1a22c174556944fef62f0e67ec855a9c3bccc5b54b0d0952c09 +AUX ghc-8.0.1-limit-jN.patch 1896 BLAKE2B 3acabcf982c0520d628d502cf2ddc01d6fda8ead7341d8f0341a309b4cc314d01b4e9237afe810b5265b7a952c847e605dbc3fb2e35d76a35ec2c832cc7653f3 SHA512 5eb69e0d5f87e326da82f018f0466a62e307f3acec47d991c7735ddf828c98c836dbff5d8164a4dfd08829b36a9d573828b9553fe89d65f5ac6be6c0190a110a +AUX ghc-8.0.1-par-g0-on-A32.patch 2276 BLAKE2B da7f6dd5d68e911886448afe04e3d0da6cddbdae686e040e8b060ade871075b87e464cf350f1272d33a7ee16e8e73cfa2d7f4c64ab7540980c0283b898817602 SHA512 0aab32a6f289c2a4e83bea2479c04cbd226f3399b5cb4a8a596ed756769a1b29bbbad261d7006c28ab56faa48c1c02e9e52cd35a7bba56ccc87f49ac1d17b0a5 +AUX ghc-8.0.1-ww-args-limit.patch 5212 BLAKE2B 1079855da7599a83d6e950eb1caf40da4bbb5b856746dc7d2e2e50651071e3acca45773cb0f1db35a6c7c9657ffd40c911ae4c1085b9e33ba4ab815d1773a8bb SHA512 5b3e34f52406649dca1cb3079565cfd068872387956dda296902c2e1ae8a092be0e70a1fc1d96f0e578fef0b82ff48b655d35a1e21911484f04d34809b295428 +AUX ghc-8.0.1_rc1-cgen-constify.patch 1185 BLAKE2B 3fc5807f31cbb5c30ec5782d27539987195bd83a6be28dc510568f0cc2d4d328cada1f111838e1ac79a3790ee197a4fb5cc41c040fbde66ca279c1fad01f9f5c SHA512 338c887a643b31ce6df2cbc28df03d1b98f48ae6b66afd0440cde7fafdc8ee51520f18c7f026645c3c995f106f78f451733b80abcdf8d4e4c3e9fcbcea597394 +AUX ghc-8.0.2-O2-unreg.patch 1203 BLAKE2B fd0ec53968fec2f4415a367c729b9b69e15f6e2c76f8ec39d6b3de24fdb0de0b9c87559b04f8b1031a05fee8a653c5f0b2ec09064f43eb9a6afaa8cf4f179e8d SHA512 0d0252bb7c49cce2a38fb81673e6f6a6aad16728f66be6287f5a765064ebe5e5fa43f30f247fecaadc7fdd07af416522e5eb28656b3220ff3832ef8164c94019 +AUX ghc-8.0.2-binutils-2.30.patch 2115 BLAKE2B 5affd1954283773ab1f4717b5cc735f864db9ea3eff3f859cff5548b059ef00e66230795aed8c3866f8b839d74e24bc5d767bd73bb928bf19c1bcd17acdfde5c SHA512 d7542cbf8ad2ccbf6a3b5f50125c98521f10872e319043eb048c06ffc416c6c835772190d58f6a09d10e55942168ca9588f3f1bb1cb835e1c1993a44403329a4 +AUX ghc-8.0.2-libffi-alpha.patch 2133 BLAKE2B 596410d5bead5a3c5f1f4a1e33a767bf2ade92204e469652e3ce005dd275a54e0e084799af2967529008654f4c45148b955e5e0b299a48cd5e78cf1c209e3d7c SHA512 77964b82be47219d709ed4b79ac255c4762986decadef2d65d6643cb2d1b6cb0f3210cce1bd46bc16b6e6c51a4aabc73c5bc5e1bdaa8797a5f23033194f91a4a +AUX ghc-8.0.2-no-relax-everywhere.patch 766 BLAKE2B 76ca925d56a9d2961cd342971ef8fb0165158d707f0089f3726560511e57ee5c08adeaf996595378d1cef3ec7b59ddf1df06d0255bf20da51c5b26e817f4057b SHA512 b729ddc27bbf089324f0b4d7229925226b59c0047cec0c0230e022fb8554389373e309e93a108f0aaa155fd9ff6957a7d41cdd35a90c6ca59b216381ff21483b +AUX ghc-8.0.2_rc2-old-sphinx.patch 434 BLAKE2B ede17cd4e5848b452edeaa3b429a7485f324cf1c9133098c7d9f84a22816eedeaf55143fea082e514b5e987ca40f65b68a476060e0c18d19bb5f8b5b993fda92 SHA512 fc8fd8d40c70a77a3aecfbdb0993bee9ef1582402b7220ed3066e1c6d4bc480c5b569cab44b58b3c54d1e68f506dc5b86ff87518d744a5a846d4de6cb1093db2 +AUX ghc-8.2.1-darwin.patch 910 BLAKE2B 2f1a44dd7ead59301b5dd59c8cab932710655416640f2c8d5273cf07da4a45bf702d840768e2d32822e89f1b07cc9ed3a6110e1847e11468fca5c515e9e26f70 SHA512 0177fda8717d9158a99d96853feb1bf40ff13df8f5c5669c7c48f33accf69d6ddb05876776cda66705e85ee56c5ecff8f81722d8e748b6c2ed6b9bf611e42a2c +AUX ghc-8.2.1_rc1-cgen-constify.patch 14371 BLAKE2B 96f9607cf857bb113b475d173a62998f2b0424f09f14c20ae3cab8497a25ab2df7523850f46e3b2867dcd75a499b3487345376b7cdd8e6f4a5e8008e160cf3d0 SHA512 8715c2f7c497eeefffd13b578ff718f36ec22bfe397501f685db0c781c614ebaa1178a9ca7550a722876d1cf9ace39aaa44493ecb934a828fa5010471672acfa +AUX ghc-8.2.1_rc1-ghci-cross.patch 2828 BLAKE2B 89776c87d4ca8c0b74f0d7ef11680d2cea217774389bf297df1a61f9d95ea515b5f9d44387eac7715fec59d9c91e91bd06215c851c94f091c05b03f84d0b8699 SHA512 55e8f2e6bf69ff26976005e0b89c400df9facda5eb974f7340af89625361adce48371616a5d292dafbd4d98cbfbc0b656d36749f2e16918b275a0469ed88cea2 +AUX ghc-8.2.1_rc1-hp2ps-cross.patch 3865 BLAKE2B d68b1e15c091047d086be780dc0bb5ce2a1b713244ee240ae045052ccac947baf6a5bdea8cad50d0fac2984700069af7dcd320b96ca09af8c7b81021329da41c SHA512 d2ed48701216f5c03567e61c207e32d6218009380941275c690edd8eb0197728e7e3c0edb00d512792dc2041a958de82ceef393e96d3324b690157162e28d29a +AUX ghc-8.2.1_rc1-stage2-cross.patch 2986 BLAKE2B c50b502adca0730fc382831631851c61aeb067bc9f7c028d983bc9b528c22fe75839e63589a714f06c848e72cffb77d4c80d6a617908e7bbec87166652a38624 SHA512 7dcae0f9ff090e521befc9aa593a674ae9175ec07ebab91bc5a72097be509a89de12bf7c959870b12219074919eef115096b74f78e7cef00360aea32126ec8fa +AUX ghc-8.2.1_rc1-staged-cross.patch 1605 BLAKE2B 5b5f203e17912396539530f40c5a93f72f1982a07ee8eb2b367d6b02ca82a2b41ac38d06e8694abe226da7761f169822b74c8c3ed1025a55bc2dc61214fe8996 SHA512 d9005f0310002f87972b0db8484b714d15664209b41eb84ce26950c4a19e854203e9b78e959755ec65a2a50a73bbce4999b39a3ad4da844cfe65098e65171450 +AUX ghc-8.2.1_rc1-unphased-cross.patch 1066 BLAKE2B aa29454f12ba0073779df08885c587cc5ef5ef21d72247d52b9f71bd455ba5fd0c01b144f0cf071e712c5e60c5ff1b96afdaad6c701fbaf8b7c418dbcef54efe SHA512 24b9b864e984cf3e34c2a23e0ba24a7f2c961dc590c6bb8e6461afeee7bc4a6361e5bbccf17754486c81136b60e12ae7e9ed06f485ef2f178084bcb2caa5edd9 +AUX ghc-8.2.1_rc1-win32-cross-1.patch 4535 BLAKE2B 546af93363a16fdcc7dc7b4167b30e81fac5dca126fac8d1421632d4fe9d2c3803f1a2ad3bedb7e270bd442e2ca95f99d18ec8d17ca9633079c6d486c6ec9ee2 SHA512 16e8be604af1e856bcec0603caa9d4fa66d5e4773a68fecaf4a57f509cd241cc7fb37fb9705d253e28d871ce2afc942e940ca171b45d41715acae5ef6e0fde8b +AUX ghc-8.2.1_rc1-win32-cross-2-hack.patch 6231 BLAKE2B 8ad4428ebe9a373e08e94e5373ad9578cafdf95b866ced2a4000434d9e5d4298b129e832e13e8e175e8977b9dda9351d01a896e2c320a1a40551d5892b0efc33 SHA512 8617c1346ba7aa2b41ee01feaa47f2ca477353f9b825be48c5d3505a134e0a80b613efc6cb92e7fbd3fe062e77450e197c826151a42c0c77177fc6ef8e65287f +AUX ghc-8.2.1_rc2-O2-unreg.patch 1199 BLAKE2B 7f3fe4b40e026736a3f1c58336274b49eb2cbbdf06c20ccced7cc83fd740128e4c30716cafbb251abe4d963ad224d3c406ec9f66b4b980af5f5c523f01136722 SHA512 708f68234f3678af3d41e7a50f9b914030536aad081b1a09a6169b12ed61ffd9db207a03f8f73d1761a93c5f2a21e92cdc23475501f96cac3bf98b046f3a6dba +AUX ghc-8.2.1_rc3-any-vendor.patch 1288 BLAKE2B ea451228b0304d35ea1047a997e26efba4eab4159b8f84fac833a8561682be15b38734434459d17a02bac8da5df97c957a7f76091c5393dd87121c3ea599c1ba SHA512 934d6d91a434ef1ec8fbeb8b13f7a20b0654a97df05d10e8d4f577567b5a0498eed484261bc1348926e112c6d4429304f74f10e4ba819120cf5840e9dd2d8329 +AUX ghc-8.2.1_rc3-stginit-data.patch 1179 BLAKE2B c67a01bf0dc9b04334592b85ce8c238d34096857759a47d37a91e305d363f1acfd2b7ebb1a65f1dba7a558db65fd4448a11e4309e2c0f4cd7b0c8075e8680990 SHA512 351b78bce46699c63ba9e02103eda0e80eeb92cba9b364049a11e61bfec3f0bbd9317a4d221b51ea29e42e6735ea4d5e3a6357d0180dc91647b11ccbe5f885e4 +AUX ghc-8.4.2-allow-cross-bootstrap.patch 768 BLAKE2B b697a54fde6687d49592398be33ea4feb6404ff24f51b5b82bd71fe8234ad2d0d3322199b12770b23a0fe27ebb5a10eab2400a5c84d28c29f3d8f3d4521cf214 SHA512 1a58408a96d2e35b021f7298b399153973905e6ff8338de8a137c126f0e2598306e0c9cf2925253717c8d7125796094a0490a03947982961f583537b5188fbec +AUX ghc-bash-completion 6496 BLAKE2B dc94a1979e886026a2fbe04bf7b45718ffa3e025a0e8945262e21a1243bfce6517fa1794f2ba6cd54cc853e93ad5d80472b9019b95762f10b5be83634a479955 SHA512 ede79ccf23555f60f48297d29bd98e3ccfd67d2cf27462153e00beb930398cb497e34ba8316e91df44c577ed11fdbe5606f7c6a2777e35d5e783590e49ccfeb5 +DIST binary-0.7.6.1.tar.gz 47086 BLAKE2B 7d81b9c254902d5ff2bafbef4c31a6f6f0396202d8585690c1ae3b63ae6ed157db7221d65a62e393ee8f6725ffd5d80e51030c0351e954b06004fcb70e5867cd SHA512 655daa93a52b845a85d440810452933d7bc3398ad1b51e1e955b2d19a0a32679325a0d1751ad50d252531e493528262e14dab32af4b9a515855fe7f64e0730b2 +DIST ghc-7.10.3-src.tar.bz2 13281867 BLAKE2B 51b0a94cc63269926fd5d04c0fb0871266c45b3168187b891127db71980d180668fb8ef7adc51a7a3df947ecc93b4d4a06965ccf9ef53eb74ed063c54adfebde SHA512 97a8282d8a75399c78d85d6faab7ac253a993dc69f1840358572f1878b8fd1a527c28801e5823c8200b5690e268e4a0c00941945ada13790852c75a83b612c17 +DIST ghc-7.8.4-ia64-CLOSUREs-regenerated.patch.gz 13268 BLAKE2B 35af21163e3a46ee340e29eb88daf617eeb094f02da7fdcb80e947c1d26234232b12d9eb2c38c02c3207c047573521fef3ac5e7b87609e66f0c57072fef1038e SHA512 a655713e06324b56f0041edf70837487e296d28e6f3ee35fe116b9938765aaf3469d25e92645e0940655ed3607dff27d3826fe0f995c84e81b51bfc956816e7d +DIST ghc-7.8.4-src.tar.bz2 10600755 BLAKE2B 6cf27f663178513b25032b648cf36b016e01361966725dbfc219079961e8eb9b1ab3531427c7012dc599e8e102dc87ed6dd43b31e7bd4e231e2d989936eb2c66 SHA512 079a53891d8ebd8d9b88da96170e60981608a619f8282e4b7948f35244e99bd87277649ac7fcebc227a61a4d21960db8d5e5b9e92f2c69c82d8d68d7fd0a41d3 +DIST ghc-8.0.2-src.tar.xz 10687760 BLAKE2B 3b2a487c115680342ce308ff1a42d2b6fa6fb1f31e2670b27a305b4d44160056611b77273c9d47f2e37a1ef01b1aba59c36e76b65c83142a5f09812bf3b1ea02 SHA512 58ea3853cd93b556ecdc4abd0be079b2621171b8491f59004ea4e036a4cba4470aaafe6591b942e0a50a64bdc47540e01fe6900212a1ef7087850112d9bfc5ef +DIST ghc-8.2.1-src.tar.xz 10736016 BLAKE2B 60993cfc9569e83b0c383591ef30a7280e0138fbb7bd696ad62d87e68dcbccf31c0b8ba211b6647922b8595c7aec2c783648f12c67da53e0766b71c7d7c923fc SHA512 d9aa2aa7f9414db8f4e51d6c275694b46df515e68331a1a2b6018256333a2c63ebd877b75ee90407ecce5be672ec9afc6bebd62aadbf8ae06b94f1760d1736be +DIST ghc-8.2.2-src.tar.xz 10753272 BLAKE2B 6fd792390d3df20f84836466705c3f3c931ba2d594dcbe2b808ea0ae284460000b443df8aae74903eabf05ff9064d68a303086cf888ea68222eb1c60959c8f21 SHA512 6549416f470b599973d409fa45f59c25b07e6a94798cef1a19ad432547dc225338cf4dbc4a4793114b4a417798a3b59b122b92b020251074405c5302b7ffe799 +DIST ghc-8.4.1-src.tar.xz 11301528 BLAKE2B 6dcf467d04cace856b68315c85b80f19b517dcbc8ae6e2a08c60afa141c9e0261e012738452c9ca208f9fc40c48bd1a0817e5e0fe9f4737383cd7b44ca65c8d9 SHA512 f8ae11f498bf2911fb92635534c6906c96f1fbe5072c7b7447bd3f69e408026b674564515af02a8aaddc57ee6905ce78d10005b12478a39c220580aaec13a9f7 +DIST ghc-8.4.2-src.tar.xz 11313140 BLAKE2B d6fe90f3c68b137c6029bf08918a51ff43c210ba0485aca8d77541cd455f6f9c94287cd011ecd710a8e5a14a27e8a27c04c517417c5748966afd63a5ba6ed19e SHA512 aeb17c986c597762381d9887679eb0eec194c2938a92b5a33e66b4c80002ead02d672b4aa968e1061ab5652b74e46a3c9f9e3d58d5be4a0ae47aa8aed288cf1f +DIST ghc-8.4.3-src.tar.xz 11315068 BLAKE2B cfb858051aff0c4fb3cdbbe96627cacc82665a6bfc4f863b0353eb3d93d358f7ed4efd7b131280763786f397aabc5c4825f60c3890649303fc97187f2b996d21 SHA512 c6cea84264f32ae888f9931f834a1d721889242f656d14262e787ec54a1793d1862ce76daacaf1006c12b8af12919501afce1dc02571373e24830e4d51803414 +DIST ghc-bin-7.10.3-alpha.tbz2 183558856 BLAKE2B 2bb02aafa49c6a91bec016e8bec2d07257d602e53c9df55792ec6fbbf8e2e46de1d5f3f72c0ccf74d6bd7f7987f53412063ccb02ae85455fce11fa928cbf5291 SHA512 08709fe9b4036ab41715c9a637a2a160104e3ab9e0ed9efaaf73428e3cfe19619e50c42b72c60bbbd27be2b9c2ea68f63d72c1a27d4519756e7c0d909f724230 +DIST ghc-bin-7.10.3-amd64.tbz2 112040431 BLAKE2B 3e59b70ca309a1cd704266c54a7983f9a58362bf700ced89c5649c780c664c650ec091e14026a7b84e339d2ebff39eba1772eebcd9fb4b99b9c99d179453d5cc SHA512 e1554b3944edbe8e16537de5a29132dc6a22d780d9a700cdc9b76387b94191164398d6f2242bf8199527802572e2bb02545569d4f0930a0ee0dbfdeb25978558 +DIST ghc-bin-7.10.3-ia64.tbz2 238680956 BLAKE2B 08593718d376051edfb0c86131e54dafc5c15056757fbeef90c653a7d217e49ff34ffaf7cd4083144c9277e73a290b822a0f889aaf806341375708e4b92654b2 SHA512 3694011aec8a6dc37889418b318993cb82f9b46a5175dd837713f396c8f59a19a920e0b0669fe3b4ec37d5bd8837c115264c0a8fc97c5a4ce06a3bdd52fcfce5 +DIST ghc-bin-7.10.3-ppc.tbz2 125832171 BLAKE2B cbf9c87200062606fddc6fa705666aeabceef954dad17166e24e181d210d7d86aad684e9af5ca05abcc89c947bea295dec3223735a6a915b680667ad32d850a5 SHA512 4eb111e3686656a83515f59d4ace8bc28806dcabfcee5201ce29aee38b8efcefaaf70c50bee55202c2d2abbfbf231a6b41df8b13199332c53055adb1754a3191 +DIST ghc-bin-7.10.3-ppc64.tbz2 142469712 BLAKE2B 05e6ca2498180399dd8a1a209843dd1229a1668d7504c424b9182fff00f78ec9aa2848d562f293dd388dc983851e0e28d481b12f0ae860b5c3a36eb616c3f1cf SHA512 eb59d3abc8b10010311d59df9473c5ea649eb0dd7f9ad41a1929a540a0ef8c20abaccd68254f8abab037fb1fc94d824f474e18e4316b8f2a7a954d0645a2a2a4 +DIST ghc-bin-7.10.3-sparc.tbz2 163105069 BLAKE2B 4a535472bf9ed83164f4da8280215a156b973a3a1f93a742a46050a112b7073d0a5f252686ee2ebde97140748cf3f164f33f1ba9df0b11fe2b35a86a7211b3a5 SHA512 d467a42487378d7dee311eb33aa1c151f5c16a6e7a4ab5bd8177df229f474adf19da3e1ca1064943a40abafcab6852b0589dd34413da82b33a03ede1ac17bf5d +DIST ghc-bin-7.10.3-x86.tbz2 113877175 BLAKE2B 2f3064174f82f3ad6fda615d1f47f30b11f9dbd4a4b721673e5db49013a11ba80e850a0f392460651408fd3b31f8e677f1488fe2c94160881ab34740846b0390 SHA512 75096fe9106d975c15e646b0a559c544621fd02791f491bce54926efabf0e55b97150069ddfa7a9f02cc30bb6975d3d3121a82207a9f67b8dda5ebfe17ec4744 +DIST ghc-bin-7.8.4-alpha.tbz2 210691009 BLAKE2B 7a59cd1dbbe76fcf37ec7d1b2e81a76bd35f268c10614890cc8a39dcd846f6e5fb524ce1851036c315a9e5fe219d3abbb78d55f3e93f4ab5ad1dbf6c946146b7 SHA512 f08230de82f0c4112da9d0b48227ca74d5d0b4a84046d746b023557b7aeeb9678f5ac037fe89a863178df4b9036e5c5c63182d14dfbb42c772011de883e3966f +DIST ghc-bin-7.8.4-amd64.tbz2 100573133 BLAKE2B da6bfb26eac8ef6c996ed10a56da9c535fb5fff4c69474de2cd979fe185876059f9e87940d24db8c52a0f04e81cf312982da75d04f3b96e7a11f2f134b512058 SHA512 e4416d6dae3c644f74bafb3aecf1a123f985427aba32d0e0c43143a137d64a9220fc5947cd9bde8a3bc44555ae71184fc06a3f7df7976aadd065ad5681b90954 +DIST ghc-bin-7.8.4-ia64.tbz2 222789275 BLAKE2B 2e0fc3ea11885b739156dcfbb4d52ded6492bf992ea18be2f91302d82e541a4de52e4bbe215f4d0cdbe54b32aa59e142ad10ae2fb20e8f0dfea22368a88620dd SHA512 2d8b89e399cbe9bfeae29cf3ceea736bfaa65ea21483fa2ee95d9814e122fcfbb67ce22ad8175493fab088e9a9d0139610c67e9d5c8b4f797b5e14846df32b6e +DIST ghc-bin-7.8.4-ppc.tbz2 112803496 BLAKE2B fa60eda8b87dca0e23cbb971bc1f361f280735846cbe628e632981dc86baba0e877112e5c03d09fbb7f256cc078f8bf3248007c013208dab41c5205a82fab494 SHA512 9581f55a088e53edcc969960e45c9ad7227d71198ce2d241a4a066a138450a879287e55e7d2210e86143670539711387e36c7f60660c4422dc1b4122278fe4a0 +DIST ghc-bin-7.8.4-ppc64.tbz2 129284515 BLAKE2B 2e9a1e70830930dda7dcbd696ef3c27e7b64d571042cc0fc26bed42d13b9707ffeb337ffab38e2e04a7dabc56d8305fd77df508928d61fd0c653945afac8984d SHA512 53974e15c26cf6b62d8f838607abd209ec57cf0f45fcc48b90ad62736f5e4e7ff263dcd326ae03d8d5557a22eb9730e5eb8ae4eda55e52dd3d973bc73c84935e +DIST ghc-bin-7.8.4-sparc.tbz2 147340595 BLAKE2B 8e39d6b144f4fce5196ad758f89887476e0482e8b98a012874d293d5e57756659cb9acb897476593a28f98f5c859548efa2e130f3806bfa2bb9e74795078a506 SHA512 ee5f0b2f1cf2693a0f2be9df71ef61b52bc2327225d40b8be955c1584b9901ffc6aaab63c1e46bf9bb352633b605c98378f8fd3e6cd71aef1c089007e4110217 +DIST ghc-bin-7.8.4-x86.tbz2 102312459 BLAKE2B 256cca9b2353af30dd7c239db0e21781d9d8aa352e38b3dd678b1429be6251e81f8955ac6ee0f766cc55f4de71c68acd98bc7b9434c3ea4b056d446ca59adc97 SHA512 cabc5bd6d8760ce4120e7053f6c1dffca7d161ba454b6201087760096c037c932e3ff8c82e53346c8278855bf0cff1c2f5fb8046242ca4d8307355b060a9556e +DIST ghc-bin-8.0.2-alpha.tbz2 234361847 BLAKE2B 8e3439f3bbae1d3f6ab71f69669ea065f5f36c9cb4b334f06161cc1b9507aae56297d5eeb8a9cf72916aa012fab0b444a179a0336f00d5f17a8d402d5807c6f8 SHA512 c8b588feeab85f7b8fd60e2e8bf755d46790d4882d2ecf6b2c8b8e02c62a11b7e6453bf0cfbc646bfbf24310fdc775337f3957ba5783675a271b68f0af2e9070 +DIST ghc-bin-8.0.2-arm64.tbz2 191332951 BLAKE2B 305c4d618a6221e1322a5665544883624de4646e0186c6eab56d0b32877645f0b2bad8381848914751fbd2e11598727c46ab136de74c57207b75ecc6cce9572a SHA512 b9cabfda8fc6e851ba99f53274c1a63c5a6a365311a9203f1247ecf90ab843dd94960ad44c4e67032f4690f07d67bfd8bdfbe59f857d6c63344430539e2082fc +DIST ghc-bin-8.0.2-i686-pc-linux-gnu.tbz2 133679542 BLAKE2B c50597857b53a2bf9d8047c048f86aa1782f74d5d9816d44b7bad7302181b407257ad0b52a03b4ad4936de3a15010b0ff5ca877b9578af6d3e7684dda2284718 SHA512 7f33e0b20a21fe076db142a58a81f68ab8f230ac9ce0167aba31aa0843bce20a9cf4065acc1c0ee2aaa01ea2ad4a8234388b0cf3ef886dccf25d7072602b430b +DIST ghc-bin-8.0.2-ia64-unknown-linux-gnu.tbz2 256581880 BLAKE2B 7a9b41fccf3a097a19e169dcd8f553d38ffb96ebce3a3f0df15af79de77f6e33835a955fb7cc2c373f7bb6bfd3508a45ecf19f8b3e74bb058d2d6cdb6576bc6b SHA512 5d14521cc4f2a8fae1e5f43fce70cb976e4412df468c3bc611c99f57806816c349f4186c8a064c579858a82cc070e5942dd7b0c2d57b88d507215acddcbfcfc1 +DIST ghc-bin-8.0.2-ppc.tbz2 144760090 BLAKE2B 32410f3563f7f2555350806db460d2083c7248c57223c9c681d0b4913df942f023c7c1f5fda145179a524ee7ef105a9b8309ba87c20dc393a9f49151579b6767 SHA512 bc6bf8998064ffc1692c3bb83c44d1787760a3f4a1e6b79dedaefda5fe32b9052049a60f0ddd3c0b0bd24a722fb35e310e0189b3511721ff89d4d02b3d7c14bb +DIST ghc-bin-8.0.2-ppc64.tbz2 117432068 BLAKE2B cae202f0d6e825127d543996b2fe7ae02578c47325674cbf22fddc53b1c4c9413f45c60d76ec3d07860cb8d0aae1ec792e4141822cc5c08ef9013308c5d29bf5 SHA512 0eaff0557b68649a15bbeb2019f46fa9e9e7b8a916aa210ab56888090a5b887d20d818e7987177bc6a8e7fde503de560026e6bb55fe39679b8b1ee13c6b7c4f9 +DIST ghc-bin-8.0.2-x86_64-pc-linux-gnu.tbz2 130852973 BLAKE2B 24d2032bbfc664d924800c1a317334e2342c8ec1e529178f9d1bb99bb4772a9cc100603bf70111b8cfafa715c1cccc643f115c77cf6adcdfb17d1f1735ee6682 SHA512 c36e0e2600fc7c284562a323d396a03062cb6e8fa63c353e672be61e76d2ec5c7698485e3a370a57cf512db9e5ba6a68338fff2ab404d9fe67b1a468ed72638f +DIST ghc-bin-8.2.1-i686-pc-linux-gnu.tbz2 96157437 BLAKE2B 2b9608845db8cea78db07209fa054b3b05085d5c3ac07cbe3de02a93c87fb0cff12b1820f08757221c59c8a0a9e7a5563c44266b181525d916825e5cf5bac34c SHA512 e891e76557fa61853e28829b8bedc4a6abb92954f90cc1ebcf22a13cc137556bbe9262e7398b7e1aedbabeb997916b008bf1561a52f16a569f3d58ea9404f41e +DIST ghc-bin-8.2.1-x86_64-pc-linux-gnu.tbz2 97490496 BLAKE2B 3666ea70cb8b3645db071040d2069fe244042c11954b34e5d92aaa90132d2316c0ee8c176cd4e674772bea3b99df150404f62bd8745c046cdaf102ecf0a0fa54 SHA512 52630a185d0eab56bce0469a612a54109895bfee041ec362ced59a9b35ba3b9c185e86bc7dbf0a5939081d3626baa19fbb3306e36d1857530248a7b9bfc100bb +DIST ghc-bin-8.2.2-i686-pc-linux-gnu.tbz2 96638908 BLAKE2B b470f838e77330969f162196b0f1035fa764f5d123687fbf67c14323280bfe55216af0e16f8b79c62f290905d96abc8bfafee650f8d27c81608853e78329b2c9 SHA512 15b1525890477539878385efc15ce5f1cf2f126cc785c42923be958cabe3298cebe73526a2370cf4c630124160a7ca0f0f9062aebbf035dce807a0374eaddd14 +DIST ghc-bin-8.2.2-x86_64-pc-linux-gnu.tbz2 97696152 BLAKE2B b481cfea186220ee402f9f215dd48b002288766b643f3d8352579735347136c6349d242a9a56728d88ce80f72367dc9fdb6e40c47a0331910dadbb9a4998e17b SHA512 531df6505e8987fb5c5cc0aac59adc6aa153a4757b96936d3f09f27f3614589ff41c227568b780114b2e87c6c8656f2c88683cce86925628d12723f14b893eff +DIST ghc-bin-8.4.1-i686-pc-linux-gnu.tbz2 116995839 BLAKE2B f94f2206d603d57f7fa64bdf63bcd2528019284fbf6641273ea1d8c62324e2f0b26b2cfa50c6ef96e12beba550bcedd17aa824e7cf9a27c794e962526326e105 SHA512 8167ea80fa627a1b55d28363513ac79985229326019288e7334cc87c3017d39781f4d129081d62da112420152a41d23d2dffb0c13721b80cca72d2a21fbd2c0a +DIST ghc-bin-8.4.1-x86_64-pc-linux-gnu.tbz2 117369638 BLAKE2B 583db924a50a3d7d261d2f392a74e0ff487ee662af055ac292ff1943534fb305d6c9f6f0045ba4bdd5afa268d75beb50f64b4760e49cddabe1f56776a5f4769f SHA512 801f4ecd538c7a035a0f573f301769984814fa3ce4cf5b09a914ba012bebe0583b6695a6a93f92c7e6e2b7d58caf812a1214b5b778d7b7835d7eab988ad69ba0 +DIST ghc-bin-8.4.2-i686-pc-linux-gnu.tbz2 117083472 BLAKE2B 7dac18523ed693efb0ec42b31bf7b910e6bb8289cdc13eb309bdb30230fc87fbb060baf41eb4f18af2bb265b42e6aca535ceb70cf0fe09046b0e4650f11bb37c SHA512 f9799bdf7a2a66d1db34b828860203872d7398bab2d667e8982c9ee89301654c3f7f54705b639df2d7adebcfb7a05e071b83d994f5e52a72f604b62098be51cd +DIST ghc-bin-8.4.2-x86_64-pc-linux-gnu.tbz2 117604406 BLAKE2B 644ef535497eb73a2d1ceaab7ff96228e8d4021c09bc061a3f397dc27b3b86bd6d5300736e478671cee0a160bfaa5aa4611f06012285079b40973f468b59664a SHA512 7bf4bcdce954319422b8b8f09e56294012fac145662ba3de1c7765ed86ae9f8b61dcf6dd8febcf85d60db8d1a26edcaf4e89c3644ffa24c7b5b5c41a14105936 +DIST ghc-bin-8.4.3-i686-pc-linux-gnu.tbz2 117028296 BLAKE2B 0c99a2f6fe4af4a1342d948cbda53b178fe9709673e0d09bc3b6a4e0f3ec4e4b8f77830829f149993f51e490692de39024900fb188116816e41441153eac3622 SHA512 13147ae0d6b941b3bc2f0239071a2f6f854a39cb6a381f0e2fda7069ac29bb2c64fb3ccc6191e7527b5f27fe616bd62f2e487b5d50679789927b401f02c62ad7 +DIST ghc-bin-8.4.3-x86_64-pc-linux-gnu.tbz2 117537996 BLAKE2B 2be0102fcc0f1fef5aae194620a43c1c90538215d4eec2550419634ed9c5bbfb17391d57519c20ab53987a36b42488ac43ff968690a4f65b96c52c3485589d10 SHA512 5f26810ec1f0a483f03ef01f56130eba0287b49b912efba03158336ce521000b611192cf021b72c1a0d902532cc4c9470ca1b3233ccba7c7e7c2ac490c6099fa +DIST hoopl-3.10.2.0.tar.gz 241940 BLAKE2B 0ed7bf80486767c81415f99da8780a525401c388dea0b3f380bbecceae9cc7f66d8b5d0d7b31f8cb41796309b7a93adb113485efd14882f8af321989ce900a9b SHA512 083baa8a5eb53247aff8d5b9b2144e0f63adb9400934297bbd80bfcec607dd90a34def4301045a60472ef10b0fb90ab84692fc08f786e7f806c28afdab1ef66a +DIST transformers-0.4.3.0.tar.gz 28632 BLAKE2B 92cabcb654bb11854a3bffbb1262f5cd62eda1aff447157086a61ebc451ebf2fddec53b6a2cc058174f24f0f0e32df671d3717e30a542c8dc90cb87e327d990c SHA512 c3ec0893ebba4fbd6087c3202e919552c4a9bff3350b5c0589e7ebb18751a515d98b8cac15b0a3252906ea72b5a0eb09b7fe88c8da88b09d6ce4fbf0f50b2780 +EBUILD ghc-7.10.3.ebuild 21670 BLAKE2B ad406c6fe4ac067b365b059fea1621799a322489ed783d7d76b877c64d84625fc4cb41d2e0c5f9d5c67ebc7dc780aca5a095c76f7260694355bfba128d2a7241 SHA512 82d5dcc2c7e6cde053687d1d0c541584d00c56bbc03495728ae46af7d805a37f1c0caac9b60a9989462b60dcd4faa6bc8fd2b89c4def4b9b2619dd2701ffc21f +EBUILD ghc-7.8.4.ebuild 19817 BLAKE2B 3859f27e1efea97faad71e3d1e00c43bf334736d51624a2c9e148b482d92f6ad813e2323f6980ce39f9f05860ab5a5311930070317e36660392f57ec87a49d90 SHA512 5f5a55dbdec9abd6cc92a48779377227f3fbdfb99db5e7e5d57daaced1ee2ad8b5395ae59456c837bb70c1c0096cd0db1c9fe7d3439bce9ffe8b21222d0a83d0 +EBUILD ghc-8.0.2.ebuild 21544 BLAKE2B e57a4c97d2231248abef1295a4b825b7cb2d8e2ee9fd6aaa5f3bb554afa6c75d4cd602f33826f3852839804c8fdbd155d1a69782f972095dc41a0f845b0ffc11 SHA512 a6ad1d4f5f2f9156ae1deff8c49090f47e815066f7bd420389421789aa3fb580a63d70653d682a09808eed9be655617864da24d50db3f3b65ad6cca677169dcf +EBUILD ghc-8.2.1.ebuild 24814 BLAKE2B d008223cf21b766701bed924421930e5825c00fad2b6891a1c72149e988fe7cfdf5a7325a32104ce1c0f18cac3db4e35403fe9dd3842135f06111c08ec276287 SHA512 8399b7280bd3f125e54623cdb6ad1d1c14fb353982693bd0b94b25a41b5cfc8e68ef28681c0273d5ffd8434cdf1de6cadf180669e1983424693d0365b9e3c875 +EBUILD ghc-8.2.2.ebuild 24783 BLAKE2B 7759ac0a512d2503d4c79925ae4d72f957d786a70fbd5e7c892e1f9756ac8460aacdf598f1ab9c8eb04a14d7be419a1bcd69c0c3cb09deb56523134f5e2fe9a0 SHA512 8c96d6515440ef176efb4cd7ba70d01e65ab742f094334e31444334cfa6bed590fa103877d3d10f10fdaf146c46aa0d0ba168c27e30681005248cc7ffc806885 +EBUILD ghc-8.4.1.ebuild 24601 BLAKE2B 09e125fb16efc35e009e063c499f984915a3bb358b4b2a4d204bff5cf638bb64e4b41f18f3203e4b81f2c2fdb0eee999f3dbc34b2c5aa6233716b993d95c36f3 SHA512 73e62c14d4c83c8dbeaaebc07605dcb446b6d6bb2ffc9c135cb0a9f327cf107a3716a4ccc32a8e8e038be6cb6b9b6c0131732dae9b78f35526ac74bd5071ac45 +EBUILD ghc-8.4.2.ebuild 24826 BLAKE2B 53724f5db186ede625576b4b25159e27f6a29f9427538039e10edae2abc1cf6c9a1052a1f2a1108bcdf66b345bf792c8f780e03a52fa39232a75776d632c27c0 SHA512 435a51876f8a79c6f24f68775f49ce25d7657af00693729169be0ce17d1ac424f7f026cfdf423d7f8d9254cd11a0ff1fbc279d84f26e180506bbb65cba946ec5 +EBUILD ghc-8.4.3.ebuild 24771 BLAKE2B 8d442d26f3f7fcd08ed3c9fa12b9e132439c5765f07ff067fc42942670cb345d712fcdd8f09f695f018ab56f43b7e9b53f6168ccd58d69661ea53b7cb278bf17 SHA512 6c9eb37b06c25905637d3c15392c110849e139b8142d44408724d6c3bcce625371ef0dde6e18677ccd51c5b9bde415872d56eba30003c297d533d8820fa0e88c +MISC metadata.xml 562 BLAKE2B 98c9bbd3aff50f05f27fe1682524254728413e53820650c91dc0eab26beecb2b682032d4b2d9c99a339059a2d8c4d007711d0dfbd3e47e5306fa4b5304f6b01d SHA512 dff79157435350067f74ae396556346d087e8146e61afe2b9739217b5d0dce6a589dd87705c7626d0c1c16da29613d9f465d357c283fb6c6df2332fec2b269be 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..e38d9165e065 --- /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 + +--- a/aclocal.m4 ++++ b/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-binutils-2.30.patch b/dev-lang/ghc/files/ghc-8.0.2-binutils-2.30.patch new file mode 100644 index 000000000000..f02cb238c6b9 --- /dev/null +++ b/dev-lang/ghc/files/ghc-8.0.2-binutils-2.30.patch @@ -0,0 +1,65 @@ +From 358b508051333882d4099acca8f269e6fb2b7d65 Mon Sep 17 00:00:00 2001 +From: Bertram Felgenhauer <int-e@gmx.de> +Date: Thu, 3 May 2018 18:03:53 +0300 +Subject: [PATCH] Compute DW_FORM_block length correctly; also fixes #15068 + +Before this patch, the pprUnwindwExpr function computed the length of +by the following assembly fragment: + + .uleb128 1f-.-1 + <expression data> +1: + +That is, to compute the length, it takes the difference of the label 1 +and the address of the .uleb128 directive, and subtracts 1. + +In #15068 it was reported that `as` from binutils 4.30 has trouble with +evaluating the `.` part of the expression. However, there is actually a +problem with the expression, if the length of the data ever becomes +larger than 128: In that case, the .uleb128 directive will emit more +than 1 byte, and the computed length will be wrong. + +The present patch changes the assembly fragment to use two labels, +which fixes both these problems. + + .uleb128 2f-1f +1: + <expression data> +2: + +Test Plan: validate + +Reviewers: bgamari, osa1 + +Reviewed By: bgamari + +Subscribers: thomie, carter + +GHC Trac Issues: #15068 + +Differential Revision: https://phabricator.haskell.org/D4654 +--- + compiler/nativeGen/Dwarf/Types.hs | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +diff --git a/compiler/nativeGen/Dwarf/Types.hs b/compiler/nativeGen/Dwarf/Types.hs +index 23a2c920e7..579ed0d256 100644 +--- a/compiler/nativeGen/Dwarf/Types.hs ++++ b/compiler/nativeGen/Dwarf/Types.hs +@@ -492,9 +492,11 @@ pprUnwindExpr spIsCFA expr + pprE (UwPlus u1 u2) = pprE u1 $$ pprE u2 $$ pprByte dW_OP_plus + pprE (UwMinus u1 u2) = pprE u1 $$ pprE u2 $$ pprByte dW_OP_minus + pprE (UwTimes u1 u2) = pprE u1 $$ pprE u2 $$ pprByte dW_OP_mul +- in text "\t.uleb128 1f-.-1" $$ -- DW_FORM_block length ++ in text "\t.uleb128 2f-1f" $$ -- DW_FORM_block length ++ -- computed as the difference of the following local labels 2: and 1: ++ text "1:" $$ + pprE expr $$ +- text "1:" ++ text "2:" + + -- | Generate code for re-setting the unwind information for a + -- register to @undefined@ +-- +2.17.0 + 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-no-relax-everywhere.patch b/dev-lang/ghc/files/ghc-8.0.2-no-relax-everywhere.patch new file mode 100644 index 000000000000..d6cff3373801 --- /dev/null +++ b/dev-lang/ghc/files/ghc-8.0.2-no-relax-everywhere.patch @@ -0,0 +1,17 @@ +https://github.com/gentoo-haskell/gentoo-haskell/issues/704 + +Allow users to specify -W,--relax externally and pass +-Wl,-no-relax unconditonally on all arches. + +Reported-by: wmyrda +diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs +index acd0d61..5830517 100644 +--- a/compiler/main/DriverPipeline.hs ++++ b/compiler/main/DriverPipeline.hs +@@ -2172,5 +2172,3 @@ joinObjectFiles dflags o_files output_fn = do + -- disable --relax explicitly. +- ++ (if platformArch (targetPlatform dflags) +- `elem` [ArchSPARC, ArchSPARC64] +- && ldIsGnuLd ++ ++ (if ldIsGnuLd + then [SysTools.Option "-Wl,-no-relax"] diff --git a/dev-lang/ghc/files/ghc-8.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-8.4.2-allow-cross-bootstrap.patch b/dev-lang/ghc/files/ghc-8.4.2-allow-cross-bootstrap.patch new file mode 100644 index 000000000000..071d4970a25b --- /dev/null +++ b/dev-lang/ghc/files/ghc-8.4.2-allow-cross-bootstrap.patch @@ -0,0 +1,23 @@ +Allow using cross-compilers to bootstrap GHC. + +In my case I'm using "cross"-compiler from +x86_64-unknown-linux to x86_64-HEAD-linux. + +Those targets have the same ABI and can boot one another. +diff --git a/configure.ac b/configure.ac +index a8b8681a36..791367e8bf 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -228,11 +228,11 @@ FPTOOLS_SET_PLATFORM_VARS + if test "$BuildPlatform" != "$bootstrap_target" + then + echo "This GHC (${WithGhc}) does not generate code for the build platform" + echo " GHC target platform : $bootstrap_target" + echo " Desired build platform : $BuildPlatform" +- exit 1 ++ #exit 1 + fi + + # Testing if we shall enable shared libs support on Solaris. + # Anything older than SunOS 5.11 aka Solaris 11 (Express) is broken. + diff --git a/dev-lang/ghc/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..43a286feca83 --- /dev/null +++ b/dev-lang/ghc/ghc-7.10.3.ebuild @@ -0,0 +1,675 @@ +# Copyright 1999-2018 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? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-alpha.tbz2 )" +#arch_binaries="$arch_binaries arm? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-arm.tbz2 )" +arch_binaries="$arch_binaries amd64? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PVR}-amd64.tbz2 )" +arch_binaries="$arch_binaries ia64? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-ia64.tbz2 )" +arch_binaries="$arch_binaries ppc? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-ppc.tbz2 )" +arch_binaries="$arch_binaries ppc64? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-ppc64.tbz2 )" +arch_binaries="$arch_binaries sparc? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-sparc.tbz2 )" +arch_binaries="$arch_binaries x86? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PVR}-x86.tbz2 )" + +# various ports: +#arch_binaries="$arch_binaries x86-fbsd? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-x86-fbsd.tbz2 )" + +# 0 - yet +yet_binary() { + case "${ARCH}" in + alpha) return 0 ;; + #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 + 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..49995a58d35c --- /dev/null +++ b/dev-lang/ghc/ghc-7.8.4.ebuild @@ -0,0 +1,601 @@ +# Copyright 1999-2018 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? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-alpha.tbz2 )" +#arch_binaries="$arch_binaries arm? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-arm.tbz2 )" +arch_binaries="$arch_binaries amd64? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-amd64.tbz2 )" +arch_binaries="$arch_binaries ia64? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-ia64.tbz2 )" +arch_binaries="$arch_binaries ppc? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-ppc.tbz2 )" +arch_binaries="$arch_binaries ppc64? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-ppc64.tbz2 )" +arch_binaries="$arch_binaries sparc? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-sparc.tbz2 )" +arch_binaries="$arch_binaries x86? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-x86.tbz2 )" + +# various ports: +#arch_binaries="$arch_binaries x86-fbsd? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-x86-fbsd.tbz2 )" + +# 0 - yet +yet_binary() { + case "${ARCH}" in + alpha) return 0 ;; + #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" + + # 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..6e573c0fff30 --- /dev/null +++ b/dev-lang/ghc/ghc-8.0.2.ebuild @@ -0,0 +1,672 @@ +# Copyright 1999-2018 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? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-alpha.tbz2 )" +#arch_binaries="$arch_binaries arm? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-arm.tbz2 )" +arch_binaries="$arch_binaries arm64? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-arm64.tbz2 )" +arch_binaries="$arch_binaries amd64? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-x86_64-pc-linux-gnu.tbz2 )" +arch_binaries="$arch_binaries ia64? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-ia64-unknown-linux-gnu.tbz2 )" +arch_binaries="$arch_binaries ppc? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-ppc.tbz2 )" +arch_binaries="$arch_binaries ppc64? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-ppc64.tbz2 )" +#arch_binaries="$arch_binaries sparc? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-sparc.tbz2 )" +arch_binaries="$arch_binaries x86? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-i686-pc-linux-gnu.tbz2 )" + +# various ports: +#arch_binaries="$arch_binaries x86-fbsd? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-x86-fbsd.tbz2 )" + +# 0 - yet +yet_binary() { + case "${ARCH}" in + alpha) return 0 ;; + arm64) return 0 ;; + #arm) + # 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 ia64 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 + 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.2-no-relax-everywhere.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 + epatch "${FILESDIR}"/${PN}-8.0.2-binutils-2.30.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..61e2fdf5dd92 --- /dev/null +++ b/dev-lang/ghc/ghc-8.2.1.ebuild @@ -0,0 +1,755 @@ +# Copyright 1999-2018 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? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-alpha.tbz2 )" +#arch_binaries="$arch_binaries arm? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-armv7a-hardfloat-linux-gnueabi.tbz2 )" +#arch_binaries="$arch_binaries arm64? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-aarch64-unknown-linux-gnu.tbz2 )" +arch_binaries="$arch_binaries amd64? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-x86_64-pc-linux-gnu.tbz2 )" +#arch_binaries="$arch_binaries ia64? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-ia64-fixed-fiw.tbz2 )" +#arch_binaries="$arch_binaries ppc? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-ppc.tbz2 )" +#arch_binaries="$arch_binaries ppc64? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-ppc64.tbz2 )" +#arch_binaries="$arch_binaries sparc? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-sparc.tbz2 )" +arch_binaries="$arch_binaries x86? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-i686-pc-linux-gnu.tbz2 )" + +# various ports: +#arch_binaries="$arch_binaries x86-fbsd? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-x86-fbsd.tbz2 )" + +# 0 - yet +yet_binary() { + case "${ARCH}" in + #alpha) return 0 ;; + #arm64) return 0 ;; + #arm) return 0 ;; + amd64) return 0 ;; + #ia64) return 0 ;; + #ppc) return 0 ;; + #ppc64) return 0 ;; + #sparc) return 0 ;; + x86) return 0 ;; + *) return 1 ;; + esac +} + +GHC_PV=${PV} +#GHC_PV=8.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 + 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.0.2-no-relax-everywhere.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/ghc-8.2.2.ebuild b/dev-lang/ghc/ghc-8.2.2.ebuild new file mode 100644 index 000000000000..6e41de8bde93 --- /dev/null +++ b/dev-lang/ghc/ghc-8.2.2.ebuild @@ -0,0 +1,756 @@ +# Copyright 1999-2018 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +EAPI=6 + +# to make make a crosscompiler use crossdev and symlink ghc tree into +# cross overlay. result would look like 'cross-sparc-unknown-linux-gnu/ghc' +export CBUILD=${CBUILD:-${CHOST}} +export CTARGET=${CTARGET:-${CHOST}} +if [[ ${CTARGET} = ${CHOST} ]] ; then + if [[ ${CATEGORY/cross-} != ${CATEGORY} ]] ; then + export CTARGET=${CATEGORY/cross-} + fi +fi + +inherit autotools bash-completion-r1 eutils flag-o-matic ghc-package +inherit multilib pax-utils toolchain-funcs versionator prefix +inherit check-reqs +DESCRIPTION="The Glasgow Haskell Compiler" +HOMEPAGE="http://www.haskell.org/ghc/" + +# we don't have any binaries yet +arch_binaries="" + +# sorted! +#arch_binaries="$arch_binaries alpha? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-alpha.tbz2 )" +#arch_binaries="$arch_binaries arm? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-armv7a-hardfloat-linux-gnueabi.tbz2 )" +#arch_binaries="$arch_binaries arm64? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-aarch64-unknown-linux-gnu.tbz2 )" +arch_binaries="$arch_binaries amd64? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-x86_64-pc-linux-gnu.tbz2 )" +#arch_binaries="$arch_binaries ia64? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-ia64-fixed-fiw.tbz2 )" +#arch_binaries="$arch_binaries ppc? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-ppc.tbz2 )" +#arch_binaries="$arch_binaries ppc64? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-ppc64.tbz2 )" +#arch_binaries="$arch_binaries sparc? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-sparc.tbz2 )" +arch_binaries="$arch_binaries x86? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-i686-pc-linux-gnu.tbz2 )" + +# various ports: +#arch_binaries="$arch_binaries x86-fbsd? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-x86-fbsd.tbz2 )" + +# 0 - yet +yet_binary() { + case "${ARCH}" in + #alpha) return 0 ;; + #arm64) return 0 ;; + #arm) return 0 ;; + amd64) return 0 ;; + #ia64) return 0 ;; + #ppc) return 0 ;; + #ppc64) return 0 ;; + #sparc) return 0 ;; + x86) return 0 ;; + *) return 1 ;; + esac +} + +GHC_PV=${PV} +#GHC_PV=8.2.1.20171108 # 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 + hprefixify "${bin_libpath}"/${PN}*/settings + fi + + # regenerate the binary package cache + "$gp_back" recache || die "failed to update cache after relocation" + rm "$gp_back" +} + +ghc-check-reqs() { + # These are pessimistic values (slightly bigger than worst-case) + # Worst case is UNREG USE=profile ia64. See bug #611866 for some + # numbers on various arches. + CHECKREQS_DISK_BUILD=8G + CHECKREQS_DISK_USR=2G + # USE=binary roughly takes + use binary && CHECKREQS_DISK_BUILD=4G + + "$@" +} + +pkg_pretend() { + ghc-check-reqs check-reqs_pkg_pretend +} + +pkg_setup() { + ghc-check-reqs check-reqs_pkg_setup + + # quiet portage about prebuilt binaries + use binary && QA_PREBUILT="*" + + [[ ${MERGE_TYPE} == binary ]] && return + + if use ghcbootstrap; then + ewarn "You requested ghc bootstrapping, this is usually only used" + ewarn "by Gentoo developers to make binary .tbz2 packages." + + [[ -z $(type -P ghc) ]] && \ + die "Could not find a ghc to bootstrap with." + else + if ! yet_binary; then + eerror "Please try emerging with USE=ghcbootstrap and report build" + eerror "sucess or failure to the haskell team (haskell@gentoo.org)" + die "No binary available for '${ARCH}' arch yet, USE=ghcbootstrap" + fi + fi +} + +src_unpack() { + # Create the ${S} dir if we're using the binary version + use binary && mkdir "${S}" + + # the Solaris and Darwin binaries from ghc (maeder) need to be + # unpacked separately, so prevent them from being unpacked + local ONLYA=${A} + case ${CHOST} in + *-darwin* | *-solaris*) ONLYA=${GHC_P}-src.tar.xz ;; + esac + unpack ${ONLYA} +} + +src_prepare() { + ghc_setup_cflags + + if ! use ghcbootstrap && [[ ${CHOST} != *-darwin* && ${CHOST} != *-solaris* ]]; then + # Modify the wrapper script from the binary tarball to use GHC_PERSISTENT_FLAGS. + # See bug #313635. + sed -i -e "s|\"\$topdir\"|\"\$topdir\" ${GHC_PERSISTENT_FLAGS}|" \ + "${WORKDIR}/usr/bin/ghc-${GHC_PV}" + + # allow hardened users use vanilla binary to bootstrap ghc + # ghci uses mmap with rwx protection at it implements dynamic + # linking on it's own (bug #299709) + pax-mark -m "${WORKDIR}/usr/$(get_libdir)/${GHC_P}/bin/ghc" + fi + + if use binary; then + if use prefix; then + relocate_ghc "${EPREFIX}" + fi + + # Move unpacked files to the expected place + mv "${WORKDIR}/usr" "${S}" + eapply_user + else + if ! use ghcbootstrap; then + case ${CHOST} in + *-darwin* | *-solaris*) + # UPDATE ME for ghc-7 + mkdir "${WORKDIR}"/ghc-bin-installer || die + pushd "${WORKDIR}"/ghc-bin-installer > /dev/null || die + use sparc-solaris && unpack ghc-6.10.4-sparc-sun-solaris2.tar.bz2 + use x86-solaris && unpack ghc-7.0.3-i386-unknown-solaris2.tar.bz2 + use x86-macos && unpack ghc-7.4.1-i386-apple-darwin.tar.bz2 + use x64-macos && unpack ghc-7.4.1-x86_64-apple-darwin.tar.bz2 + popd > /dev/null + + pushd "${WORKDIR}"/ghc-bin-installer/ghc-[67].?*.? > /dev/null || die + # fix the binaries so they run, on Solaris we need an + # LD_LIBRARY_PATH which has our prefix libdirs, on + # Darwin we need to replace the frameworks with our libs + # from the prefix fix before installation, because some + # of the tools are actually used during configure/make + if [[ ${CHOST} == *-solaris* ]] ; then + export LD_LIBRARY_PATH="${EPREFIX}/$(get_libdir):${EPREFIX}/usr/$(get_libdir):${LD_LIBRARY_PATH}" + elif [[ ${CHOST} == *-darwin* ]] ; then + local readline_framework=GNUreadline.framework/GNUreadline + local gmp_framework=/opt/local/lib/libgmp.10.dylib + local ncurses_file=/opt/local/lib/libncurses.5.dylib + for binary in $(scanmacho -BRE MH_EXECUTE -F '%F' .) ; do + install_name_tool -change \ + ${readline_framework} \ + "${EPREFIX}"/lib/libreadline.dylib \ + ${binary} || die + install_name_tool -change \ + ${gmp_framework} \ + "${EPREFIX}"/usr/lib/libgmp.dylib \ + ${binary} || die + install_name_tool -change \ + ${ncurses_file} \ + "${EPREFIX}"/usr/lib/libncurses.dylib \ + ${binary} || die + done + # we don't do frameworks! + sed -i \ + -e 's/\(frameworks = \)\["GMP"\]/\1[]/g' \ + -e 's/\(extraLibraries = \)\["m"\]/\1["m","gmp"]/g' \ + rts/package.conf.in || die + fi + + # it is autoconf, but we really don't want to give it too + # much arguments, in fact we do the make in-place anyway + ./configure --prefix="${WORKDIR}"/usr || die + make install || die + popd > /dev/null + ;; + *) + relocate_ghc "${WORKDIR}" + ;; + esac + fi + + sed -i -e "s|\"\$topdir\"|\"\$topdir\" ${GHC_PERSISTENT_FLAGS}|" \ + "${S}/ghc/ghc.wrapper" + + cd "${S}" # otherwise eapply will break + + eapply "${FILESDIR}"/${PN}-7.0.4-CHOST-prefix.patch + eapply "${FILESDIR}"/${PN}-8.2.1-darwin.patch + + eapply "${FILESDIR}"/${PN}-8.2.1_rc1-cgen-constify.patch + eapply "${FILESDIR}"/${PN}-7.8.3-prim-lm.patch + eapply "${FILESDIR}"/${PN}-8.0.2-no-relax-everywhere.patch + + eapply "${FILESDIR}"/${PN}-8.2.1_rc2-O2-unreg.patch + eapply "${FILESDIR}"/${PN}-8.0.2-binutils-2.30.patch + + # a bunch of crosscompiler patches + eapply "${FILESDIR}"/${PN}-8.2.1_rc1-unphased-cross.patch + eapply "${FILESDIR}"/${PN}-8.2.1_rc1-staged-cross.patch + eapply "${FILESDIR}"/${PN}-8.2.1_rc1-ghci-cross.patch + eapply "${FILESDIR}"/${PN}-8.2.1_rc1-stage2-cross.patch + eapply "${FILESDIR}"/${PN}-8.2.1_rc1-hp2ps-cross.patch + + # needs a new libffi release + eapply "${FILESDIR}"/${PN}-8.0.2-libffi-alpha.patch + + # mingw32 target + pushd "${S}/libraries/Win32" + eapply "${FILESDIR}"/${PN}-8.2.1_rc1-win32-cross-1.patch # upstreamed, waits for merge to -HEAD + eapply "${FILESDIR}"/${PN}-8.2.1_rc1-win32-cross-2-hack.patch # bad workaround + popd + + bump_libs + + eapply_user + # as we have changed the build system + eautoreconf + fi +} + +src_configure() { + if ! use binary; then + # initialize build.mk + echo '# Gentoo changes' > mk/build.mk + + # Put docs into the right place, ie /usr/share/doc/ghc-${GHC_PV} + echo "docdir = ${EPREFIX}/usr/share/doc/$(cross)${P}" >> mk/build.mk + echo "htmldir = ${EPREFIX}/usr/share/doc/$(cross)${P}" >> mk/build.mk + + # We also need to use the GHC_FLAGS flags when building ghc itself + echo "SRC_HC_OPTS+=${HCFLAGS} ${GHC_FLAGS}" >> mk/build.mk + echo "SRC_CC_OPTS+=${CFLAGS}" >> mk/build.mk + echo "SRC_LD_OPTS+=${LDFLAGS}" >> mk/build.mk + # Speed up initial Cabal bootstrap + echo "utils/ghc-cabal_dist_EXTRA_HC_OPTS+=$(ghc-make-args)" >> mk/build.mk + + # We can't depend on haddock except when bootstrapping when we + # must build docs and include them into the binary .tbz2 package + # app-text/dblatex is not in portage, can not build PDF or PS + echo "BUILD_SPHINX_PDF = NO" >> mk/build.mk + echo "BUILD_SPHINX_HTML = $(usex doc YES NO)" >> mk/build.mk + echo "BUILD_MAN = $(usex doc YES NO)" >> mk/build.mk + + # this controls presence on 'xhtml' and 'haddock' in final install + echo "HADDOCK_DOCS = YES" >> mk/build.mk + + # not used outside of ghc's test + if [[ -n ${GHC_BUILD_DPH} ]]; then + echo "BUILD_DPH = YES" >> mk/build.mk + else + echo "BUILD_DPH = NO" >> mk/build.mk + fi + + # Any non-native build has to skip as it needs + # target haddock binary to be runnabine. + if ! is_native; then + # disable docs generation as it requires running stage2 + echo "HADDOCK_DOCS=NO" >> mk/build.mk + echo "BUILD_SPHINX_HTML=NO" >> mk/build.mk + echo "BUILD_SPHINX_PDF=NO" >> mk/build.mk + fi + + if is_crosscompile; then + # Install ghc-stage1 crosscompiler instead of + # ghc-stage2 cross-built compiler. + echo "Stage1Only=YES" >> mk/build.mk + fi + + # allows overriding build flavours for libraries: + # v - vanilla (static libs) + # p - profiled + # dyn - shared libraries + # example: GHC_LIBRARY_WAYS="v dyn" + if [[ -n ${GHC_LIBRARY_WAYS} ]]; then + echo "GhcLibWays=${GHC_LIBRARY_WAYS}" >> mk/build.mk + fi + echo "BUILD_PROF_LIBS = $(usex profile YES NO)" >> mk/build.mk + + # Get ghc from the unpacked binary .tbz2 + # except when bootstrapping we just pick ghc up off the path + if ! use ghcbootstrap; then + export PATH="${WORKDIR}/usr/bin:${PATH}" + fi + + echo "INTEGER_LIBRARY = $(usex gmp integer-gmp integer-simple)" >> mk/build.mk + + # don't strip anything. Very useful when stage2 SIGSEGVs on you + echo "STRIP_CMD = :" >> mk/build.mk + + local econf_args=() + + # GHC embeds toolchain it was built by and uses it later. + # Don't allow things like ccache or versioned binary slip. + # We use stable thing across gcc upgrades. + # User can use EXTRA_ECONF=CC=... to override this default. + econf_args+=( + AR=${CTARGET}-ar + CC=${CTARGET}-gcc + 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/ghc-8.4.1.ebuild b/dev-lang/ghc/ghc-8.4.1.ebuild new file mode 100644 index 000000000000..e23cc25aadde --- /dev/null +++ b/dev-lang/ghc/ghc-8.4.1.ebuild @@ -0,0 +1,756 @@ +# Copyright 1999-2018 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +EAPI=6 + +# to make make a crosscompiler use crossdev and symlink ghc tree into +# cross overlay. result would look like 'cross-sparc-unknown-linux-gnu/ghc' +export CBUILD=${CBUILD:-${CHOST}} +export CTARGET=${CTARGET:-${CHOST}} +if [[ ${CTARGET} = ${CHOST} ]] ; then + if [[ ${CATEGORY/cross-} != ${CATEGORY} ]] ; then + export CTARGET=${CATEGORY/cross-} + fi +fi + +inherit autotools bash-completion-r1 eutils flag-o-matic ghc-package +inherit multilib pax-utils toolchain-funcs versionator prefix +inherit check-reqs +DESCRIPTION="The Glasgow Haskell Compiler" +HOMEPAGE="http://www.haskell.org/ghc/" + +# we don't have any binaries yet +arch_binaries="" + +# sorted! +#arch_binaries="$arch_binaries alpha? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-alpha.tbz2 )" +#arch_binaries="$arch_binaries arm? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-armv7a-hardfloat-linux-gnueabi.tbz2 )" +#arch_binaries="$arch_binaries arm64? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-aarch64-unknown-linux-gnu.tbz2 )" +arch_binaries="$arch_binaries amd64? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-x86_64-pc-linux-gnu.tbz2 )" +#arch_binaries="$arch_binaries ia64? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-ia64-fixed-fiw.tbz2 )" +#arch_binaries="$arch_binaries ppc? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-ppc.tbz2 )" +#arch_binaries="$arch_binaries ppc64? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-ppc64.tbz2 )" +#arch_binaries="$arch_binaries sparc? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-sparc.tbz2 )" +arch_binaries="$arch_binaries x86? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-i686-pc-linux-gnu.tbz2 )" + +# various ports: +#arch_binaries="$arch_binaries x86-fbsd? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-x86-fbsd.tbz2 )" + +# 0 - yet +yet_binary() { + case "${ARCH}" in + #alpha) return 0 ;; + #arm64) return 0 ;; + #arm) return 0 ;; + amd64) return 0 ;; + #ia64) return 0 ;; + #ppc) return 0 ;; + #ppc64) return 0 ;; + #sparc) return 0 ;; + x86) return 0 ;; + *) return 1 ;; + esac +} + +GHC_PV=${PV} +#GHC_PV=8.4.0.20180224 # uncomment only for -alpha, -beta, -rc ebuilds +GHC_P=${PN}-${GHC_PV} # using ${P} is almost never correct + +SRC_URI="!binary? ( http://downloads.haskell.org/~ghc/${PV/_/-}/${GHC_P}-src.tar.xz )" +S="${WORKDIR}"/${GHC_P} + +[[ -n $arch_binaries ]] && SRC_URI+=" !ghcbootstrap? ( $arch_binaries )" + +BUMP_LIBRARIES=( + # "hackage-name hackage-version" +) + +LICENSE="BSD" +SLOT="0/${PV}" +#KEYWORDS="~alpha ~amd64 ~x86 ~amd64-linux ~x86-linux" +IUSE="doc ghcbootstrap ghcmakebinary +gmp profile" +IUSE+=" binary" + +RDEPEND=" + >=dev-lang/perl-5.6.1 + dev-libs/gmp:0= + sys-libs/ncurses:0=[unicode] + !ghcmakebinary? ( virtual/libffi:= ) +" + +# This set of dependencies is needed to run +# prebuilt ghc. We specifically avoid ncurses +# dependency with: +# utils/ghc-pkg_HC_OPTS += -DBOOTSTRAPPING +PREBUILT_BINARY_DEPENDS=" + !prefix? ( elibc_glibc? ( >=sys-libs/glibc-2.17 ) ) +" +# This set of dependencies is needed to install +# ghc[binary] in system. terminfo package is linked +# against ncurses. +PREBUILT_BINARY_RDEPENDS="${PREBUILT_BINARY_DEPENDS} + sys-libs/ncurses:0/6 +" + +RDEPEND+="binary? ( ${PREBUILT_BINARY_RDEPENDS} )" + +DEPEND="${RDEPEND} + doc? ( app-text/docbook-xml-dtd:4.2 + app-text/docbook-xml-dtd:4.5 + app-text/docbook-xsl-stylesheets + dev-python/sphinx + >=dev-libs/libxslt-1.1.2 ) + !ghcbootstrap? ( ${PREBUILT_BINARY_DEPENDS} )" + +PDEPEND="!ghcbootstrap? ( >=app-admin/haskell-updater-1.2 )" + +REQUIRED_USE="?? ( ghcbootstrap binary )" + +# haskell libraries built with cabal in configure mode, #515354 +QA_CONFIGURE_OPTIONS+=" --with-compiler --with-gcc" + +is_crosscompile() { + [[ ${CHOST} != ${CTARGET} ]] +} + +is_native() { + [[ ${CHOST} == ${CBUILD} ]] && [[ ${CHOST} == ${CTARGET} ]] +} + +# returns tool prefix for crosscompiler. +# Example: +# CTARGET=armv7a-unknown-linux-gnueabi +# CHOST=x86_64-pc-linux-gnu +# "armv7a-unknown-linux-gnueabi-" +# CTARGET=${CHOST} +# "" +# Used in tools and library prefix: +# "${ED}"/usr/bin/$(cross)haddock +# "${ED}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d" + +cross() { + if is_crosscompile; then + echo "${CTARGET}-" + else + echo "" + fi +} + +append-ghc-cflags() { + local persistent compile assemble link + local flag ghcflag + + for flag in $*; do + case ${flag} in + persistent) persistent="yes";; + compile) compile="yes";; + assemble) assemble="yes";; + link) link="yes";; + *) + [[ ${compile} ]] && ghcflag="-optc${flag}" CFLAGS+=" ${flag}" && GHC_FLAGS+=" ${ghcflag}" && + [[ ${persistent} ]] && GHC_PERSISTENT_FLAGS+=" ${ghcflag}" + [[ ${assemble} ]] && ghcflag="-opta${flag}" CFLAGS+=" ${flag}" && GHC_FLAGS+=" ${ghcflag}" && + [[ ${persistent} ]] && GHC_PERSISTENT_FLAGS+=" ${ghcflag}" + [[ ${link} ]] && ghcflag="-optl${flag}" LDFLAGS+=" ${flag}" && GHC_FLAGS+=" ${ghcflag}" && + [[ ${persistent} ]] && GHC_PERSISTENT_FLAGS+=" ${ghcflag}" + ;; + esac + done +} + +# $1 - lib name (under libraries/) +# $2 - lib version +# example: bump_lib "transformers" "0.4.2.0" +bump_lib() { + local pn=$1 pv=$2 + local p=${pn}-${pv} + local f + + einfo "Bumping ${pn} up to ${pv}" + + for f in ghc.mk GNUmakefile; do + mv libraries/"${pn}"/$f "${WORKDIR}"/"${p}"/$f || die + done + mv libraries/"${pn}" "${WORKDIR}"/"${pn}".old || die + mv "${WORKDIR}"/"${p}" libraries/"${pn}" || die +} + +update_SRC_URI() { + local p pn pv + for p in "${BUMP_LIBRARIES[@]}"; do + set -- $p + pn=$1 pv=$2 + + SRC_URI+=" mirror://hackage/package/${pn}/${pn}-${pv}.tar.gz" + done +} + +update_SRC_URI + +bump_libs() { + local p pn pv + for p in "${BUMP_LIBRARIES[@]}"; do + set -- $p + pn=$1 pv=$2 + + bump_lib "${pn}" "${pv}" + done +} + +ghc_setup_cflags() { + # TODO: plumb CFLAGS and BUILD_CFLAGS to respective CONF_CC_OPTS_STAGE<N> + if ! is_native; then + export CFLAGS=${GHC_CFLAGS-"-O2 -pipe"} + export LDFLAGS=${GHC_LDFLAGS-"-Wl,-O1"} + einfo "Crosscompiling mode:" + einfo " CHOST: ${CHOST}" + einfo " CTARGET: ${CTARGET}" + einfo " CFLAGS: ${CFLAGS}" + einfo " LDFLAGS: ${LDFLAGS}" + einfo " prefix: $(cross)" + return + fi + # We need to be very careful with the CFLAGS we ask ghc to pass through to + # gcc. There are plenty of flags which will make gcc produce output that + # breaks ghc in various ways. The main ones we want to pass through are + # -mcpu / -march flags. These are important for arches like alpha & sparc. + # We also use these CFLAGS for building the C parts of ghc, ie the rts. + strip-flags + strip-unsupported-flags + + # Cmm can't parse line numbers #482086 + replace-flags -ggdb[3-9] -ggdb2 + + GHC_FLAGS="" + GHC_PERSISTENT_FLAGS="" + for flag in ${CFLAGS}; do + case ${flag} in + + # Ignore extra optimisation (ghc passes -O to gcc anyway) + # -O2 and above break on too many systems + -O*) ;; + + # Arch and ABI flags are what we're really after + -m*) append-ghc-cflags compile assemble ${flag};; + + # Sometimes it's handy to see backtrace of RTS + # to get an idea what happens there + -g*) append-ghc-cflags compile ${flag};; + + # Ignore all other flags, including all -f* flags + esac + done + + for flag in ${LDFLAGS}; do + append-ghc-cflags link ${flag} + done + + # GHC uses ${CBUILD}-gcc, ${CHOST}-gcc and ${CTARGET}-gcc at a single build. + # Skip any gentoo-specific tweaks for cross-case to avoid passing unsupported + # options to gcc. + if is_native; then + # hardened-gcc needs to be disabled, because our prebuilt binaries/libraries + # are not built with fPIC, bug #606666 + gcc-specs-pie && append-ghc-cflags persistent compile link -nopie + tc-is-gcc && version_is_at_least 6.3 $(gcc-version) && if ! use ghcbootstrap; then + # gcc-6.3 has support for -no-pie upstream, but spelling differs from + # gentoo-specific '-nopie'. We enable it in non-bootstrap to allow + # hardened users try '-pie' in USE=ghcbootstrap mode. + append-ghc-cflags compile link -no-pie + fi + + # prevent from failing to build unregisterised ghc: + # http://www.mail-archive.com/debian-bugs-dist@lists.debian.org/msg171602.html + use ppc64 && append-ghc-cflags persistent compile -mminimal-toc + fi +} + +# substitutes string $1 to $2 in files $3 $4 ... +relocate_path() { + local from=$1 + local to=$2 + shift 2 + local file= + for file in "$@" + do + sed -i -e "s|$from|$to|g" \ + "$file" || die "path relocation failed for '$file'" + done +} + +# changes hardcoded ghc paths and updates package index +# $1 - new absolute root path +relocate_ghc() { + local to=$1 + + # libdir for prebuilt binary and for current system may mismatch + # It does for prefix installation for example: bug #476998 + local bin_ghc_prefix=${WORKDIR}/usr + local bin_libpath=$(echo "${bin_ghc_prefix}"/lib*) + local bin_libdir=${bin_libpath#${bin_ghc_prefix}/} + + # backup original script to use it later after relocation + local gp_back="${T}/ghc-pkg-${GHC_PV}-orig" + cp "${WORKDIR}/usr/bin/ghc-pkg-${GHC_PV}" "$gp_back" || die "unable to backup ghc-pkg wrapper" + + if [[ ${bin_libdir} != $(get_libdir) ]]; then + einfo "Relocating '${bin_libdir}' to '$(get_libdir)' (bug #476998)" + # moving the dir itself is not strictly needed + # but then USE=binary would result in installing + # in '${bin_libdir}' + mv "${bin_ghc_prefix}/${bin_libdir}" "${bin_ghc_prefix}/$(get_libdir)" || die + + relocate_path "/usr/${bin_libdir}" "/usr/$(get_libdir)" \ + "${WORKDIR}/usr/bin/ghc-${GHC_PV}" \ + "${WORKDIR}/usr/bin/ghci-${GHC_PV}" \ + "${WORKDIR}/usr/bin/ghc-pkg-${GHC_PV}" \ + "${WORKDIR}/usr/bin/hsc2hs" \ + "${WORKDIR}/usr/bin/runghc-${GHC_PV}" \ + "$gp_back" \ + "${WORKDIR}/usr/$(get_libdir)/${GHC_P}/package.conf.d/"* + fi + + # Relocate from /usr to ${EPREFIX}/usr + relocate_path "/usr" "${to}/usr" \ + "${WORKDIR}/usr/bin/ghc-${GHC_PV}" \ + "${WORKDIR}/usr/bin/ghci-${GHC_PV}" \ + "${WORKDIR}/usr/bin/ghc-pkg-${GHC_PV}" \ + "${WORKDIR}/usr/bin/hsc2hs" \ + "${WORKDIR}/usr/bin/runghc-${GHC_PV}" \ + "${WORKDIR}/usr/$(get_libdir)/${GHC_P}/package.conf.d/"* + + # this one we will use to regenerate cache + # so it should point to current tree location + relocate_path "/usr" "${WORKDIR}/usr" "$gp_back" + + if use prefix; then + hprefixify "${bin_libpath}"/${PN}*/settings + fi + + # regenerate the binary package cache + "$gp_back" recache || die "failed to update cache after relocation" + rm "$gp_back" +} + +ghc-check-reqs() { + # These are pessimistic values (slightly bigger than worst-case) + # Worst case is UNREG USE=profile ia64. See bug #611866 for some + # numbers on various arches. + CHECKREQS_DISK_BUILD=8G + CHECKREQS_DISK_USR=2G + # USE=binary roughly takes + use binary && CHECKREQS_DISK_BUILD=4G + + "$@" +} + +pkg_pretend() { + ghc-check-reqs check-reqs_pkg_pretend +} + +pkg_setup() { + ghc-check-reqs check-reqs_pkg_setup + + # quiet portage about prebuilt binaries + use binary && QA_PREBUILT="*" + + [[ ${MERGE_TYPE} == binary ]] && return + + if use ghcbootstrap; then + ewarn "You requested ghc bootstrapping, this is usually only used" + ewarn "by Gentoo developers to make binary .tbz2 packages." + + [[ -z $(type -P ghc) ]] && \ + die "Could not find a ghc to bootstrap with." + else + if ! yet_binary; then + eerror "Please try emerging with USE=ghcbootstrap and report build" + eerror "sucess or failure to the haskell team (haskell@gentoo.org)" + die "No binary available for '${ARCH}' arch yet, USE=ghcbootstrap" + fi + fi +} + +src_unpack() { + # Create the ${S} dir if we're using the binary version + use binary && mkdir "${S}" + + # the Solaris and Darwin binaries from ghc (maeder) need to be + # unpacked separately, so prevent them from being unpacked + local ONLYA=${A} + case ${CHOST} in + *-darwin* | *-solaris*) ONLYA=${GHC_P}-src.tar.xz ;; + esac + unpack ${ONLYA} +} + +src_prepare() { + ghc_setup_cflags + + if ! use ghcbootstrap && [[ ${CHOST} != *-darwin* && ${CHOST} != *-solaris* ]]; then + # Modify the wrapper script from the binary tarball to use GHC_PERSISTENT_FLAGS. + # See bug #313635. + sed -i -e "s|\"\$topdir\"|\"\$topdir\" ${GHC_PERSISTENT_FLAGS}|" \ + "${WORKDIR}/usr/bin/ghc-${GHC_PV}" + + # allow hardened users use vanilla binary to bootstrap ghc + # ghci uses mmap with rwx protection at it implements dynamic + # linking on it's own (bug #299709) + pax-mark -m "${WORKDIR}/usr/$(get_libdir)/${GHC_P}/bin/ghc" + fi + + if use binary; then + if use prefix; then + relocate_ghc "${EPREFIX}" + fi + + # Move unpacked files to the expected place + mv "${WORKDIR}/usr" "${S}" + eapply_user + else + if ! use ghcbootstrap; then + case ${CHOST} in + *-darwin* | *-solaris*) + # UPDATE ME for ghc-7 + mkdir "${WORKDIR}"/ghc-bin-installer || die + pushd "${WORKDIR}"/ghc-bin-installer > /dev/null || die + use sparc-solaris && unpack ghc-6.10.4-sparc-sun-solaris2.tar.bz2 + use x86-solaris && unpack ghc-7.0.3-i386-unknown-solaris2.tar.bz2 + use x86-macos && unpack ghc-7.4.1-i386-apple-darwin.tar.bz2 + use x64-macos && unpack ghc-7.4.1-x86_64-apple-darwin.tar.bz2 + popd > /dev/null + + pushd "${WORKDIR}"/ghc-bin-installer/ghc-[67].?*.? > /dev/null || die + # fix the binaries so they run, on Solaris we need an + # LD_LIBRARY_PATH which has our prefix libdirs, on + # Darwin we need to replace the frameworks with our libs + # from the prefix fix before installation, because some + # of the tools are actually used during configure/make + if [[ ${CHOST} == *-solaris* ]] ; then + export LD_LIBRARY_PATH="${EPREFIX}/$(get_libdir):${EPREFIX}/usr/$(get_libdir):${LD_LIBRARY_PATH}" + elif [[ ${CHOST} == *-darwin* ]] ; then + local readline_framework=GNUreadline.framework/GNUreadline + local gmp_framework=/opt/local/lib/libgmp.10.dylib + local ncurses_file=/opt/local/lib/libncurses.5.dylib + for binary in $(scanmacho -BRE MH_EXECUTE -F '%F' .) ; do + install_name_tool -change \ + ${readline_framework} \ + "${EPREFIX}"/lib/libreadline.dylib \ + ${binary} || die + install_name_tool -change \ + ${gmp_framework} \ + "${EPREFIX}"/usr/lib/libgmp.dylib \ + ${binary} || die + install_name_tool -change \ + ${ncurses_file} \ + "${EPREFIX}"/usr/lib/libncurses.dylib \ + ${binary} || die + done + # we don't do frameworks! + sed -i \ + -e 's/\(frameworks = \)\["GMP"\]/\1[]/g' \ + -e 's/\(extraLibraries = \)\["m"\]/\1["m","gmp"]/g' \ + rts/package.conf.in || die + fi + + # it is autoconf, but we really don't want to give it too + # much arguments, in fact we do the make in-place anyway + ./configure --prefix="${WORKDIR}"/usr || die + make install || die + popd > /dev/null + ;; + *) + relocate_ghc "${WORKDIR}" + ;; + esac + fi + + sed -i -e "s|\"\$topdir\"|\"\$topdir\" ${GHC_PERSISTENT_FLAGS}|" \ + "${S}/ghc/ghc.wrapper" + + cd "${S}" # otherwise eapply will break + + eapply "${FILESDIR}"/${PN}-7.0.4-CHOST-prefix.patch + eapply "${FILESDIR}"/${PN}-8.2.1-darwin.patch + eapply "${FILESDIR}"/${PN}-7.8.3-prim-lm.patch + eapply "${FILESDIR}"/${PN}-8.0.2-no-relax-everywhere.patch + + # a bunch of crosscompiler patches + # needs newer version: + #eapply "${FILESDIR}"/${PN}-8.2.1_rc1-hp2ps-cross.patch + + # mingw32 target + pushd "${S}/libraries/Win32" + eapply "${FILESDIR}"/${PN}-8.2.1_rc1-win32-cross-2-hack.patch # bad workaround + popd + + bump_libs + + eapply_user + # as we have changed the build system + eautoreconf + fi +} + +src_configure() { + if ! use binary; then + # initialize build.mk + echo '# Gentoo changes' > mk/build.mk + + # Put docs into the right place, ie /usr/share/doc/ghc-${GHC_PV} + echo "docdir = ${EPREFIX}/usr/share/doc/$(cross)${P}" >> mk/build.mk + echo "htmldir = ${EPREFIX}/usr/share/doc/$(cross)${P}" >> mk/build.mk + + # We also need to use the GHC_FLAGS flags when building ghc itself + echo "SRC_HC_OPTS+=${HCFLAGS} ${GHC_FLAGS}" >> mk/build.mk + echo "SRC_CC_OPTS+=${CFLAGS}" >> mk/build.mk + echo "SRC_LD_OPTS+=${LDFLAGS}" >> mk/build.mk + # Speed up initial Cabal bootstrap + echo "utils/ghc-cabal_dist_EXTRA_HC_OPTS+=$(ghc-make-args)" >> mk/build.mk + + # We can't depend on haddock except when bootstrapping when we + # must build docs and include them into the binary .tbz2 package + # app-text/dblatex is not in portage, can not build PDF or PS + echo "BUILD_SPHINX_PDF = NO" >> mk/build.mk + echo "BUILD_SPHINX_HTML = $(usex doc YES NO)" >> mk/build.mk + echo "BUILD_MAN = $(usex doc YES NO)" >> mk/build.mk + + # this controls presence on 'xhtml' and 'haddock' in final install + echo "HADDOCK_DOCS = YES" >> mk/build.mk + + # not used outside of ghc's test + if [[ -n ${GHC_BUILD_DPH} ]]; then + echo "BUILD_DPH = YES" >> mk/build.mk + else + echo "BUILD_DPH = NO" >> mk/build.mk + fi + + # Any non-native build has to skip as it needs + # target haddock binary to be runnabine. + if ! is_native; then + # disable docs generation as it requires running stage2 + echo "HADDOCK_DOCS=NO" >> mk/build.mk + echo "BUILD_SPHINX_HTML=NO" >> mk/build.mk + echo "BUILD_SPHINX_PDF=NO" >> mk/build.mk + fi + + if is_crosscompile; then + # Install ghc-stage1 crosscompiler instead of + # ghc-stage2 cross-built compiler. + echo "Stage1Only=YES" >> mk/build.mk + fi + + # allows overriding build flavours for libraries: + # v - vanilla (static libs) + # p - profiled + # dyn - shared libraries + # example: GHC_LIBRARY_WAYS="v dyn" + if [[ -n ${GHC_LIBRARY_WAYS} ]]; then + echo "GhcLibWays=${GHC_LIBRARY_WAYS}" >> mk/build.mk + fi + echo "BUILD_PROF_LIBS = $(usex profile YES NO)" >> mk/build.mk + + # Get ghc from the unpacked binary .tbz2 + # except when bootstrapping we just pick ghc up off the path + if ! use ghcbootstrap; then + export PATH="${WORKDIR}/usr/bin:${PATH}" + fi + + echo "INTEGER_LIBRARY = $(usex gmp integer-gmp integer-simple)" >> mk/build.mk + + # don't strip anything. Very useful when stage2 SIGSEGVs on you + echo "STRIP_CMD = :" >> mk/build.mk + + local econf_args=() + + # GHC embeds toolchain it was built by and uses it later. + # Don't allow things like ccache or versioned binary slip. + # We use stable thing across gcc upgrades. + # User can use EXTRA_ECONF=CC=... to override this default. + econf_args+=( + AR=${CTARGET}-ar + CC=${CTARGET}-gcc + # these should be inferred by GHC but ghc defaults + # to using bundled tools on windows. + Windres=${CTARGET}-windres + DllWrap=${CTARGET}-dllwrap + # we set the linker explicitly below + --disable-ld-override + ) + case ${CTARGET} in + arm*) + # ld.bfd-2.28 does not work for ghc. Force ld.gold + # instead. This should be removed once gentoo gets + # a fix for R_ARM_COPY bug: https://sourceware.org/PR16177 + econf_args+=(LD=${CTARGET}-ld.gold) + ;; + sparc*) + # ld.gold-2.28 does not work for ghc. Force ld.bfd + # instead. This should be removed once gentoo gets + # a fix for missing --no-relax support bug: + # https://sourceware.org/ml/binutils/2017-07/msg00183.html + econf_args+=(LD=${CTARGET}-ld.bfd) + ;; + *) + econf_args+=(LD=${CTARGET}-ld) + esac + + if [[ ${CBUILD} != ${CHOST} ]]; then + # GHC bug: ghc claims not to support cross-building. + # It does, but does not distinct --host= value + # for stage1 and stage2 compiler. + econf_args+=(--host=${CBUILD}) + fi + + if use ghcmakebinary; then + # When building booting libary we are trying to + # bundle or restrict most of external depends + # with unstable ABI: + # - embed libffi (default GHC behaviour) + # - disable ncurses support for ghci (via haskeline) + # https://bugs.gentoo.org/557478 + # - disable ncurses support for ghc-pkg + echo "libraries/haskeline_CONFIGURE_OPTS += --flag=-terminfo" >> mk/build.mk + echo "utils/ghc-pkg_HC_OPTS += -DBOOTSTRAPPING" >> mk/build.mk + elif is_native; then + # using ${GTARGET}'s libffi is not supported yet: + # GHC embeds full path for ffi includes without /usr/${CTARGET} account. + econf_args+=(--with-system-libffi) + econf_args+=(--with-ffi-includes=$(pkg-config libffi --cflags-only-I | sed -e 's@^-I@@')) + fi + + einfo "Final mk/build.mk:" + cat mk/build.mk || die + + econf ${econf_args[@]} --enable-bootstrap-with-devel-snapshot + + if [[ ${PV} == *9999* ]]; then + GHC_PV="$(grep 'S\[\"PACKAGE_VERSION\"\]' config.status | sed -e 's@^.*=\"\(.*\)\"@\1@')" + GHC_P=${PN}-${GHC_PV} + fi + fi # ! use binary +} + +src_compile() { + if ! use binary; then + # Stage1Only crosscompiler does not build stage2 + if ! is_crosscompile; then + # 1. build/pax-mark compiler binary first + emake ghc/stage2/build/tmp/ghc-stage2 + # 2. pax-mark (bug #516430) + pax-mark -m ghc/stage2/build/tmp/ghc-stage2 + # 2. build/pax-mark haddock using ghc-stage2 + if is_native; then + # non-native build does not build haddock + # due to HADDOCK_DOCS=NO, but it could. + emake utils/haddock/dist/build/tmp/haddock + pax-mark -m utils/haddock/dist/build/tmp/haddock + fi + fi + # 3. and then all the rest + emake all + fi # ! use binary +} + +src_install() { + if use binary; then + use prefix && mkdir -p "${ED}" + mv "${S}/usr" "${ED}" + else + [[ -f VERSION ]] || emake VERSION + + # -j1 due to a rare race in install script: + # make --no-print-directory -f ghc.mk phase=final install + # /usr/lib/portage/python3.4/ebuild-helpers/xattr/install -c -m 755 \ + # -d "/tmp/portage-tmpdir/portage/cross-armv7a-unknown-linux-gnueabi/ghc-9999/image/usr/lib64/armv7a-unknown-linux-gnueabi-ghc-8.3.20170404/include" + # /usr/lib/portage/python3.4/ebuild-helpers/xattr/install -c -m 644 utils/hsc2hs/template-hsc.h \ + # "/tmp/portage-tmpdir/portage/cross-armv7a-unknown-linux-gnueabi/ghc-9999/image/usr/lib64/armv7a-unknown-linux-gnueabi-ghc-8.3.20170404" + # /usr/bin/install: cannot create regular file \ + # '/tmp/portage-tmpdir/portage/cross-armv7a-unknown-linux-gnueabi/ghc-9999/image/usr/lib64/armv7a-unknown-linux-gnueabi-ghc-8.3.20170404': No such file or directory + emake -j1 install DESTDIR="${D}" + + # Skip for cross-targets as they all share target location: + # /usr/share/doc/ghc-9999/ + if ! is_crosscompile; then + dodoc "distrib/README" "ANNOUNCE" "LICENSE" "VERSION" + fi + + # rename ghc-shipped files to avoid collision + # of external packages. Motivating example: + # user had installed: + # dev-lang/ghc-7.8.4-r0 (with transformers-0.3.0.0) + # dev-haskell/transformers-0.4.2.0 + # then user tried to update to + # dev-lang/ghc-7.8.4-r1 (with transformers-0.4.2.0) + # this will lead to single .conf file collision. + local shipped_conf renamed_conf + local package_confdir="${ED}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d" + for shipped_conf in "${package_confdir}"/*.conf; do + # rename 'pkg-ver-id.conf' to 'pkg-ver-id-gentoo-${PF}.conf' + renamed_conf=${shipped_conf%.conf}-gentoo-${PF}.conf + mv "${shipped_conf}" "${renamed_conf}" || die + done + + # remove link, but leave 'haddock-${GHC_P}' + rm -f "${ED}"/usr/bin/$(cross)haddock + + if ! is_crosscompile; then + newbashcomp "${FILESDIR}"/ghc-bash-completion ghc-pkg + newbashcomp utils/completion/ghc.bash ghc + fi + fi + + # path to the package.cache + local package_confdir="${ED}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d" + PKGCACHE="${package_confdir}"/package.cache + # copy the package.conf.d, including timestamp, save it so we can help + # users that have a broken package.conf.d + cp -pR "${package_confdir}"{,.initial} || die "failed to backup intial package.conf.d" + + # copy the package.conf, including timestamp, save it so we later can put it + # back before uninstalling, or when upgrading. + cp -p "${PKGCACHE}"{,.shipped} \ + || die "failed to copy package.conf.d/package.cache" +} + +pkg_preinst() { + # have we got an earlier version of ghc installed? + if has_version "<${CATEGORY}/${PF}"; then + haskell_updater_warn="1" + fi +} + +pkg_postinst() { + ghc-reregister + + # path to the package.cache + PKGCACHE="${EROOT}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d/package.cache" + + # give the cache a new timestamp, it must be as recent as + # the package.conf.d directory. + touch "${PKGCACHE}" + + if [[ "${haskell_updater_warn}" == "1" ]]; then + ewarn + ewarn "\e[1;31m************************************************************************\e[0m" + ewarn + ewarn "You have just upgraded from an older version of GHC." + ewarn "You may have to run" + ewarn " 'haskell-updater'" + ewarn "to rebuild all ghc-based Haskell libraries." + ewarn + ewarn "\e[1;31m************************************************************************\e[0m" + ewarn + fi +} + +pkg_prerm() { + PKGCACHE="${EROOT}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d/package.cache" + rm -rf "${PKGCACHE}" + + cp -p "${PKGCACHE}"{.shipped,} +} + +pkg_postrm() { + ghc-package_pkg_postrm +} diff --git a/dev-lang/ghc/ghc-8.4.2.ebuild b/dev-lang/ghc/ghc-8.4.2.ebuild new file mode 100644 index 000000000000..2b6dbd92fe91 --- /dev/null +++ b/dev-lang/ghc/ghc-8.4.2.ebuild @@ -0,0 +1,761 @@ +# Copyright 1999-2018 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +EAPI=6 + +# to make make a crosscompiler use crossdev and symlink ghc tree into +# cross overlay. result would look like 'cross-sparc-unknown-linux-gnu/ghc' +export CBUILD=${CBUILD:-${CHOST}} +export CTARGET=${CTARGET:-${CHOST}} +if [[ ${CTARGET} = ${CHOST} ]] ; then + if [[ ${CATEGORY/cross-} != ${CATEGORY} ]] ; then + export CTARGET=${CATEGORY/cross-} + fi +fi + +inherit autotools bash-completion-r1 eutils flag-o-matic ghc-package +inherit multilib pax-utils toolchain-funcs versionator prefix +inherit check-reqs +DESCRIPTION="The Glasgow Haskell Compiler" +HOMEPAGE="http://www.haskell.org/ghc/" + +# we don't have any binaries yet +arch_binaries="" + +# sorted! +#arch_binaries="$arch_binaries alpha? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-alpha.tbz2 )" +#arch_binaries="$arch_binaries arm? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-armv7a-hardfloat-linux-gnueabi.tbz2 )" +#arch_binaries="$arch_binaries arm64? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-aarch64-unknown-linux-gnu.tbz2 )" +arch_binaries="$arch_binaries amd64? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-x86_64-pc-linux-gnu.tbz2 )" +#arch_binaries="$arch_binaries ia64? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-ia64-fixed-fiw.tbz2 )" +#arch_binaries="$arch_binaries ppc? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-ppc.tbz2 )" +#arch_binaries="$arch_binaries ppc64? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-ppc64.tbz2 )" +#arch_binaries="$arch_binaries sparc? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-sparc.tbz2 )" +arch_binaries="$arch_binaries x86? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-i686-pc-linux-gnu.tbz2 )" + +# various ports: +#arch_binaries="$arch_binaries x86-fbsd? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-x86-fbsd.tbz2 )" + +# 0 - yet +yet_binary() { + case "${ARCH}" in + #alpha) return 0 ;; + #arm64) return 0 ;; + #arm) return 0 ;; + amd64) return 0 ;; + #ia64) return 0 ;; + #ppc) return 0 ;; + #ppc64) return 0 ;; + #sparc) return 0 ;; + x86) return 0 ;; + *) return 1 ;; + esac +} + +GHC_PV=${PV} +#GHC_PV=8.4.1.20180329 # uncomment only for -alpha, -beta, -rc ebuilds +GHC_P=${PN}-${GHC_PV} # using ${P} is almost never correct + +SRC_URI="!binary? ( http://downloads.haskell.org/~ghc/${PV/_/-}/${GHC_P}-src.tar.xz )" +S="${WORKDIR}"/${GHC_P} + +[[ -n $arch_binaries ]] && SRC_URI+=" !ghcbootstrap? ( $arch_binaries )" + +BUMP_LIBRARIES=( + # "hackage-name hackage-version" +) + +LICENSE="BSD" +SLOT="0/${PV}" +#KEYWORDS="~alpha ~amd64 ~x86 ~amd64-linux ~x86-linux" +IUSE="doc ghcbootstrap ghcmakebinary +gmp profile" +IUSE+=" binary" + +RDEPEND=" + >=dev-lang/perl-5.6.1 + dev-libs/gmp:0= + sys-libs/ncurses:0=[unicode] + !ghcmakebinary? ( virtual/libffi:= ) +" + +# This set of dependencies is needed to run +# prebuilt ghc. We specifically avoid ncurses +# dependency with: +# utils/ghc-pkg_HC_OPTS += -DBOOTSTRAPPING +PREBUILT_BINARY_DEPENDS=" + !prefix? ( elibc_glibc? ( >=sys-libs/glibc-2.17 ) ) +" +# This set of dependencies is needed to install +# ghc[binary] in system. terminfo package is linked +# against ncurses. +PREBUILT_BINARY_RDEPENDS="${PREBUILT_BINARY_DEPENDS} + sys-libs/ncurses:0/6 +" + +RDEPEND+="binary? ( ${PREBUILT_BINARY_RDEPENDS} )" + +DEPEND="${RDEPEND} + doc? ( app-text/docbook-xml-dtd:4.2 + app-text/docbook-xml-dtd:4.5 + app-text/docbook-xsl-stylesheets + dev-python/sphinx + >=dev-libs/libxslt-1.1.2 ) + !ghcbootstrap? ( ${PREBUILT_BINARY_DEPENDS} )" + +PDEPEND="!ghcbootstrap? ( >=app-admin/haskell-updater-1.2 )" + +REQUIRED_USE="?? ( ghcbootstrap binary )" + +# haskell libraries built with cabal in configure mode, #515354 +QA_CONFIGURE_OPTIONS+=" --with-compiler --with-gcc" + +is_crosscompile() { + [[ ${CHOST} != ${CTARGET} ]] +} + +is_native() { + [[ ${CHOST} == ${CBUILD} ]] && [[ ${CHOST} == ${CTARGET} ]] +} + +# returns tool prefix for crosscompiler. +# Example: +# CTARGET=armv7a-unknown-linux-gnueabi +# CHOST=x86_64-pc-linux-gnu +# "armv7a-unknown-linux-gnueabi-" +# CTARGET=${CHOST} +# "" +# Used in tools and library prefix: +# "${ED}"/usr/bin/$(cross)haddock +# "${ED}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d" + +cross() { + if is_crosscompile; then + echo "${CTARGET}-" + else + echo "" + fi +} + +append-ghc-cflags() { + local persistent compile assemble link + local flag ghcflag + + for flag in $*; do + case ${flag} in + persistent) persistent="yes";; + compile) compile="yes";; + assemble) assemble="yes";; + link) link="yes";; + *) + [[ ${compile} ]] && ghcflag="-optc${flag}" CFLAGS+=" ${flag}" && GHC_FLAGS+=" ${ghcflag}" && + [[ ${persistent} ]] && GHC_PERSISTENT_FLAGS+=" ${ghcflag}" + [[ ${assemble} ]] && ghcflag="-opta${flag}" CFLAGS+=" ${flag}" && GHC_FLAGS+=" ${ghcflag}" && + [[ ${persistent} ]] && GHC_PERSISTENT_FLAGS+=" ${ghcflag}" + [[ ${link} ]] && ghcflag="-optl${flag}" LDFLAGS+=" ${flag}" && GHC_FLAGS+=" ${ghcflag}" && + [[ ${persistent} ]] && GHC_PERSISTENT_FLAGS+=" ${ghcflag}" + ;; + esac + done +} + +# $1 - lib name (under libraries/) +# $2 - lib version +# example: bump_lib "transformers" "0.4.2.0" +bump_lib() { + local pn=$1 pv=$2 + local p=${pn}-${pv} + local f + + einfo "Bumping ${pn} up to ${pv}" + + for f in ghc.mk GNUmakefile; do + mv libraries/"${pn}"/$f "${WORKDIR}"/"${p}"/$f || die + done + mv libraries/"${pn}" "${WORKDIR}"/"${pn}".old || die + mv "${WORKDIR}"/"${p}" libraries/"${pn}" || die +} + +update_SRC_URI() { + local p pn pv + for p in "${BUMP_LIBRARIES[@]}"; do + set -- $p + pn=$1 pv=$2 + + SRC_URI+=" mirror://hackage/package/${pn}/${pn}-${pv}.tar.gz" + done +} + +update_SRC_URI + +bump_libs() { + local p pn pv + for p in "${BUMP_LIBRARIES[@]}"; do + set -- $p + pn=$1 pv=$2 + + bump_lib "${pn}" "${pv}" + done +} + +ghc_setup_cflags() { + # TODO: plumb CFLAGS and BUILD_CFLAGS to respective CONF_CC_OPTS_STAGE<N> + if ! is_native; then + export CFLAGS=${GHC_CFLAGS-"-O2 -pipe"} + export LDFLAGS=${GHC_LDFLAGS-"-Wl,-O1"} + einfo "Crosscompiling mode:" + einfo " CHOST: ${CHOST}" + einfo " CTARGET: ${CTARGET}" + einfo " CFLAGS: ${CFLAGS}" + einfo " LDFLAGS: ${LDFLAGS}" + einfo " prefix: $(cross)" + return + fi + # We need to be very careful with the CFLAGS we ask ghc to pass through to + # gcc. There are plenty of flags which will make gcc produce output that + # breaks ghc in various ways. The main ones we want to pass through are + # -mcpu / -march flags. These are important for arches like alpha & sparc. + # We also use these CFLAGS for building the C parts of ghc, ie the rts. + strip-flags + strip-unsupported-flags + + # Cmm can't parse line numbers #482086 + replace-flags -ggdb[3-9] -ggdb2 + + GHC_FLAGS="" + GHC_PERSISTENT_FLAGS="" + for flag in ${CFLAGS}; do + case ${flag} in + + # Ignore extra optimisation (ghc passes -O to gcc anyway) + # -O2 and above break on too many systems + -O*) ;; + + # Arch and ABI flags are what we're really after + -m*) append-ghc-cflags compile assemble ${flag};; + + # Sometimes it's handy to see backtrace of RTS + # to get an idea what happens there + -g*) append-ghc-cflags compile ${flag};; + + # Ignore all other flags, including all -f* flags + esac + done + + for flag in ${LDFLAGS}; do + append-ghc-cflags link ${flag} + done + + # GHC uses ${CBUILD}-gcc, ${CHOST}-gcc and ${CTARGET}-gcc at a single build. + # Skip any gentoo-specific tweaks for cross-case to avoid passing unsupported + # options to gcc. + if is_native; then + # hardened-gcc needs to be disabled, because our prebuilt binaries/libraries + # are not built with fPIC, bug #606666 + gcc-specs-pie && append-ghc-cflags persistent compile link -nopie + tc-is-gcc && version_is_at_least 6.3 $(gcc-version) && if ! use ghcbootstrap; then + # gcc-6.3 has support for -no-pie upstream, but spelling differs from + # gentoo-specific '-nopie'. We enable it in non-bootstrap to allow + # hardened users try '-pie' in USE=ghcbootstrap mode. + append-ghc-cflags compile link -no-pie + fi + + # prevent from failing to build unregisterised ghc: + # http://www.mail-archive.com/debian-bugs-dist@lists.debian.org/msg171602.html + use ppc64 && append-ghc-cflags persistent compile -mminimal-toc + fi +} + +# substitutes string $1 to $2 in files $3 $4 ... +relocate_path() { + local from=$1 + local to=$2 + shift 2 + local file= + for file in "$@" + do + sed -i -e "s|$from|$to|g" \ + "$file" || die "path relocation failed for '$file'" + done +} + +# changes hardcoded ghc paths and updates package index +# $1 - new absolute root path +relocate_ghc() { + local to=$1 + + # libdir for prebuilt binary and for current system may mismatch + # It does for prefix installation for example: bug #476998 + local bin_ghc_prefix=${WORKDIR}/usr + local bin_libpath=$(echo "${bin_ghc_prefix}"/lib*) + local bin_libdir=${bin_libpath#${bin_ghc_prefix}/} + + # backup original script to use it later after relocation + local gp_back="${T}/ghc-pkg-${GHC_PV}-orig" + cp "${WORKDIR}/usr/bin/ghc-pkg-${GHC_PV}" "$gp_back" || die "unable to backup ghc-pkg wrapper" + + if [[ ${bin_libdir} != $(get_libdir) ]]; then + einfo "Relocating '${bin_libdir}' to '$(get_libdir)' (bug #476998)" + # moving the dir itself is not strictly needed + # but then USE=binary would result in installing + # in '${bin_libdir}' + mv "${bin_ghc_prefix}/${bin_libdir}" "${bin_ghc_prefix}/$(get_libdir)" || die + + relocate_path "/usr/${bin_libdir}" "/usr/$(get_libdir)" \ + "${WORKDIR}/usr/bin/ghc-${GHC_PV}" \ + "${WORKDIR}/usr/bin/ghci-${GHC_PV}" \ + "${WORKDIR}/usr/bin/ghc-pkg-${GHC_PV}" \ + "${WORKDIR}/usr/bin/hsc2hs" \ + "${WORKDIR}/usr/bin/runghc-${GHC_PV}" \ + "$gp_back" \ + "${WORKDIR}/usr/$(get_libdir)/${GHC_P}/package.conf.d/"* + fi + + # Relocate from /usr to ${EPREFIX}/usr + relocate_path "/usr" "${to}/usr" \ + "${WORKDIR}/usr/bin/ghc-${GHC_PV}" \ + "${WORKDIR}/usr/bin/ghci-${GHC_PV}" \ + "${WORKDIR}/usr/bin/ghc-pkg-${GHC_PV}" \ + "${WORKDIR}/usr/bin/haddock-ghc-${GHC_PV}" \ + "${WORKDIR}/usr/bin/hp2ps" \ + "${WORKDIR}/usr/bin/hpc" \ + "${WORKDIR}/usr/bin/hsc2hs" \ + "${WORKDIR}/usr/bin/runghc-${GHC_PV}" \ + "${WORKDIR}/usr/$(get_libdir)/${GHC_P}/package.conf.d/"* + + # this one we will use to regenerate cache + # so it should point to current tree location + relocate_path "/usr" "${WORKDIR}/usr" "$gp_back" + + if use prefix; then + hprefixify "${bin_libpath}"/${PN}*/settings + fi + + # regenerate the binary package cache + "$gp_back" recache || die "failed to update cache after relocation" + rm "$gp_back" +} + +ghc-check-reqs() { + # These are pessimistic values (slightly bigger than worst-case) + # Worst case is UNREG USE=profile ia64. See bug #611866 for some + # numbers on various arches. + CHECKREQS_DISK_BUILD=8G + CHECKREQS_DISK_USR=2G + # USE=binary roughly takes + use binary && CHECKREQS_DISK_BUILD=4G + + "$@" +} + +pkg_pretend() { + ghc-check-reqs check-reqs_pkg_pretend +} + +pkg_setup() { + ghc-check-reqs check-reqs_pkg_setup + + # quiet portage about prebuilt binaries + use binary && QA_PREBUILT="*" + + [[ ${MERGE_TYPE} == binary ]] && return + + if use ghcbootstrap; then + ewarn "You requested ghc bootstrapping, this is usually only used" + ewarn "by Gentoo developers to make binary .tbz2 packages." + + [[ -z $(type -P ghc) ]] && \ + die "Could not find a ghc to bootstrap with." + else + if ! yet_binary; then + eerror "Please try emerging with USE=ghcbootstrap and report build" + eerror "sucess or failure to the haskell team (haskell@gentoo.org)" + die "No binary available for '${ARCH}' arch yet, USE=ghcbootstrap" + fi + fi +} + +src_unpack() { + # Create the ${S} dir if we're using the binary version + use binary && mkdir "${S}" + + # the Solaris and Darwin binaries from ghc (maeder) need to be + # unpacked separately, so prevent them from being unpacked + local ONLYA=${A} + case ${CHOST} in + *-darwin* | *-solaris*) ONLYA=${GHC_P}-src.tar.xz ;; + esac + unpack ${ONLYA} +} + +src_prepare() { + ghc_setup_cflags + + if ! use ghcbootstrap && [[ ${CHOST} != *-darwin* && ${CHOST} != *-solaris* ]]; then + # Modify the wrapper script from the binary tarball to use GHC_PERSISTENT_FLAGS. + # See bug #313635. + sed -i -e "s|\"\$topdir\"|\"\$topdir\" ${GHC_PERSISTENT_FLAGS}|" \ + "${WORKDIR}/usr/bin/ghc-${GHC_PV}" + + # allow hardened users use vanilla binary to bootstrap ghc + # ghci uses mmap with rwx protection at it implements dynamic + # linking on it's own (bug #299709) + pax-mark -m "${WORKDIR}/usr/$(get_libdir)/${GHC_P}/bin/ghc" + fi + + if use binary; then + if use prefix; then + relocate_ghc "${EPREFIX}" + fi + + # Move unpacked files to the expected place + mv "${WORKDIR}/usr" "${S}" + eapply_user + else + if ! use ghcbootstrap; then + case ${CHOST} in + *-darwin* | *-solaris*) + # UPDATE ME for ghc-7 + mkdir "${WORKDIR}"/ghc-bin-installer || die + pushd "${WORKDIR}"/ghc-bin-installer > /dev/null || die + use sparc-solaris && unpack ghc-6.10.4-sparc-sun-solaris2.tar.bz2 + use x86-solaris && unpack ghc-7.0.3-i386-unknown-solaris2.tar.bz2 + use x86-macos && unpack ghc-7.4.1-i386-apple-darwin.tar.bz2 + use x64-macos && unpack ghc-7.4.1-x86_64-apple-darwin.tar.bz2 + popd > /dev/null + + pushd "${WORKDIR}"/ghc-bin-installer/ghc-[67].?*.? > /dev/null || die + # fix the binaries so they run, on Solaris we need an + # LD_LIBRARY_PATH which has our prefix libdirs, on + # Darwin we need to replace the frameworks with our libs + # from the prefix fix before installation, because some + # of the tools are actually used during configure/make + if [[ ${CHOST} == *-solaris* ]] ; then + export LD_LIBRARY_PATH="${EPREFIX}/$(get_libdir):${EPREFIX}/usr/$(get_libdir):${LD_LIBRARY_PATH}" + elif [[ ${CHOST} == *-darwin* ]] ; then + local readline_framework=GNUreadline.framework/GNUreadline + local gmp_framework=/opt/local/lib/libgmp.10.dylib + local ncurses_file=/opt/local/lib/libncurses.5.dylib + for binary in $(scanmacho -BRE MH_EXECUTE -F '%F' .) ; do + install_name_tool -change \ + ${readline_framework} \ + "${EPREFIX}"/lib/libreadline.dylib \ + ${binary} || die + install_name_tool -change \ + ${gmp_framework} \ + "${EPREFIX}"/usr/lib/libgmp.dylib \ + ${binary} || die + install_name_tool -change \ + ${ncurses_file} \ + "${EPREFIX}"/usr/lib/libncurses.dylib \ + ${binary} || die + done + # we don't do frameworks! + sed -i \ + -e 's/\(frameworks = \)\["GMP"\]/\1[]/g' \ + -e 's/\(extraLibraries = \)\["m"\]/\1["m","gmp"]/g' \ + rts/package.conf.in || die + fi + + # it is autoconf, but we really don't want to give it too + # much arguments, in fact we do the make in-place anyway + ./configure --prefix="${WORKDIR}"/usr || die + make install || die + popd > /dev/null + ;; + *) + relocate_ghc "${WORKDIR}" + ;; + esac + fi + + sed -i -e "s|\"\$topdir\"|\"\$topdir\" ${GHC_PERSISTENT_FLAGS}|" \ + "${S}/ghc/ghc.wrapper" + + cd "${S}" # otherwise eapply will break + + eapply "${FILESDIR}"/${PN}-7.0.4-CHOST-prefix.patch + eapply "${FILESDIR}"/${PN}-8.2.1-darwin.patch + eapply "${FILESDIR}"/${PN}-7.8.3-prim-lm.patch + eapply "${FILESDIR}"/${PN}-8.0.2-no-relax-everywhere.patch + eapply "${FILESDIR}"/${PN}-8.0.2-binutils-2.30.patch + eapply "${FILESDIR}"/${PN}-8.4.2-allow-cross-bootstrap.patch + + # a bunch of crosscompiler patches + # needs newer version: + #eapply "${FILESDIR}"/${PN}-8.2.1_rc1-hp2ps-cross.patch + + # mingw32 target + pushd "${S}/libraries/Win32" + eapply "${FILESDIR}"/${PN}-8.2.1_rc1-win32-cross-2-hack.patch # bad workaround + popd + + bump_libs + + eapply_user + # as we have changed the build system + eautoreconf + fi +} + +src_configure() { + if ! use binary; then + # initialize build.mk + echo '# Gentoo changes' > mk/build.mk + + # Put docs into the right place, ie /usr/share/doc/ghc-${GHC_PV} + echo "docdir = ${EPREFIX}/usr/share/doc/$(cross)${P}" >> mk/build.mk + echo "htmldir = ${EPREFIX}/usr/share/doc/$(cross)${P}" >> mk/build.mk + + # We also need to use the GHC_FLAGS flags when building ghc itself + echo "SRC_HC_OPTS+=${HCFLAGS} ${GHC_FLAGS}" >> mk/build.mk + echo "SRC_CC_OPTS+=${CFLAGS}" >> mk/build.mk + echo "SRC_LD_OPTS+=${LDFLAGS}" >> mk/build.mk + # Speed up initial Cabal bootstrap + echo "utils/ghc-cabal_dist_EXTRA_HC_OPTS+=$(ghc-make-args)" >> mk/build.mk + + # We can't depend on haddock except when bootstrapping when we + # must build docs and include them into the binary .tbz2 package + # app-text/dblatex is not in portage, can not build PDF or PS + echo "BUILD_SPHINX_PDF = NO" >> mk/build.mk + echo "BUILD_SPHINX_HTML = $(usex doc YES NO)" >> mk/build.mk + echo "BUILD_MAN = $(usex doc YES NO)" >> mk/build.mk + + # this controls presence on 'xhtml' and 'haddock' in final install + echo "HADDOCK_DOCS = YES" >> mk/build.mk + + # not used outside of ghc's test + if [[ -n ${GHC_BUILD_DPH} ]]; then + echo "BUILD_DPH = YES" >> mk/build.mk + else + echo "BUILD_DPH = NO" >> mk/build.mk + fi + + # Any non-native build has to skip as it needs + # target haddock binary to be runnabine. + if ! is_native; then + # disable docs generation as it requires running stage2 + echo "HADDOCK_DOCS=NO" >> mk/build.mk + echo "BUILD_SPHINX_HTML=NO" >> mk/build.mk + echo "BUILD_SPHINX_PDF=NO" >> mk/build.mk + fi + + if is_crosscompile; then + # Install ghc-stage1 crosscompiler instead of + # ghc-stage2 cross-built compiler. + echo "Stage1Only=YES" >> mk/build.mk + fi + + # allows overriding build flavours for libraries: + # v - vanilla (static libs) + # p - profiled + # dyn - shared libraries + # example: GHC_LIBRARY_WAYS="v dyn" + if [[ -n ${GHC_LIBRARY_WAYS} ]]; then + echo "GhcLibWays=${GHC_LIBRARY_WAYS}" >> mk/build.mk + fi + echo "BUILD_PROF_LIBS = $(usex profile YES NO)" >> mk/build.mk + + # Get ghc from the unpacked binary .tbz2 + # except when bootstrapping we just pick ghc up off the path + if ! use ghcbootstrap; then + export PATH="${WORKDIR}/usr/bin:${PATH}" + fi + + echo "INTEGER_LIBRARY = $(usex gmp integer-gmp integer-simple)" >> mk/build.mk + + # don't strip anything. Very useful when stage2 SIGSEGVs on you + echo "STRIP_CMD = :" >> mk/build.mk + + local econf_args=() + + # GHC embeds toolchain it was built by and uses it later. + # Don't allow things like ccache or versioned binary slip. + # We use stable thing across gcc upgrades. + # User can use EXTRA_ECONF=CC=... to override this default. + econf_args+=( + AR=${CTARGET}-ar + CC=${CTARGET}-gcc + # these should be inferred by GHC but ghc defaults + # to using bundled tools on windows. + Windres=${CTARGET}-windres + DllWrap=${CTARGET}-dllwrap + # we set the linker explicitly below + --disable-ld-override + ) + case ${CTARGET} in + arm*) + # ld.bfd-2.28 does not work for ghc. Force ld.gold + # instead. This should be removed once gentoo gets + # a fix for R_ARM_COPY bug: https://sourceware.org/PR16177 + econf_args+=(LD=${CTARGET}-ld.gold) + ;; + sparc*) + # ld.gold-2.28 does not work for ghc. Force ld.bfd + # instead. This should be removed once gentoo gets + # a fix for missing --no-relax support bug: + # https://sourceware.org/ml/binutils/2017-07/msg00183.html + econf_args+=(LD=${CTARGET}-ld.bfd) + ;; + *) + econf_args+=(LD=${CTARGET}-ld) + esac + + if [[ ${CBUILD} != ${CHOST} ]]; then + # GHC bug: ghc claims not to support cross-building. + # It does, but does not distinct --host= value + # for stage1 and stage2 compiler. + econf_args+=(--host=${CBUILD}) + fi + + if use ghcmakebinary; then + # When building booting libary we are trying to + # bundle or restrict most of external depends + # with unstable ABI: + # - embed libffi (default GHC behaviour) + # - disable ncurses support for ghci (via haskeline) + # https://bugs.gentoo.org/557478 + # - disable ncurses support for ghc-pkg + echo "libraries/haskeline_CONFIGURE_OPTS += --flag=-terminfo" >> mk/build.mk + echo "utils/ghc-pkg_HC_OPTS += -DBOOTSTRAPPING" >> mk/build.mk + elif is_native; then + # using ${GTARGET}'s libffi is not supported yet: + # GHC embeds full path for ffi includes without /usr/${CTARGET} account. + econf_args+=(--with-system-libffi) + econf_args+=(--with-ffi-includes=$(pkg-config libffi --cflags-only-I | sed -e 's@^-I@@')) + fi + + einfo "Final mk/build.mk:" + cat mk/build.mk || die + + econf ${econf_args[@]} --enable-bootstrap-with-devel-snapshot + + if [[ ${PV} == *9999* ]]; then + GHC_PV="$(grep 'S\[\"PACKAGE_VERSION\"\]' config.status | sed -e 's@^.*=\"\(.*\)\"@\1@')" + GHC_P=${PN}-${GHC_PV} + fi + fi # ! use binary +} + +src_compile() { + if ! use binary; then + # Stage1Only crosscompiler does not build stage2 + if ! is_crosscompile; then + # 1. build/pax-mark compiler binary first + emake ghc/stage2/build/tmp/ghc-stage2 + # 2. pax-mark (bug #516430) + pax-mark -m ghc/stage2/build/tmp/ghc-stage2 + # 2. build/pax-mark haddock using ghc-stage2 + if is_native; then + # non-native build does not build haddock + # due to HADDOCK_DOCS=NO, but it could. + emake utils/haddock/dist/build/tmp/haddock + pax-mark -m utils/haddock/dist/build/tmp/haddock + fi + fi + # 3. and then all the rest + emake all + fi # ! use binary +} + +src_install() { + if use binary; then + use prefix && mkdir -p "${ED}" + mv "${S}/usr" "${ED}" + else + [[ -f VERSION ]] || emake VERSION + + # -j1 due to a rare race in install script: + # make --no-print-directory -f ghc.mk phase=final install + # /usr/lib/portage/python3.4/ebuild-helpers/xattr/install -c -m 755 \ + # -d "/tmp/portage-tmpdir/portage/cross-armv7a-unknown-linux-gnueabi/ghc-9999/image/usr/lib64/armv7a-unknown-linux-gnueabi-ghc-8.3.20170404/include" + # /usr/lib/portage/python3.4/ebuild-helpers/xattr/install -c -m 644 utils/hsc2hs/template-hsc.h \ + # "/tmp/portage-tmpdir/portage/cross-armv7a-unknown-linux-gnueabi/ghc-9999/image/usr/lib64/armv7a-unknown-linux-gnueabi-ghc-8.3.20170404" + # /usr/bin/install: cannot create regular file \ + # '/tmp/portage-tmpdir/portage/cross-armv7a-unknown-linux-gnueabi/ghc-9999/image/usr/lib64/armv7a-unknown-linux-gnueabi-ghc-8.3.20170404': No such file or directory + emake -j1 install DESTDIR="${D}" + + # Skip for cross-targets as they all share target location: + # /usr/share/doc/ghc-9999/ + if ! is_crosscompile; then + dodoc "distrib/README" "ANNOUNCE" "LICENSE" "VERSION" + fi + + # rename ghc-shipped files to avoid collision + # of external packages. Motivating example: + # user had installed: + # dev-lang/ghc-7.8.4-r0 (with transformers-0.3.0.0) + # dev-haskell/transformers-0.4.2.0 + # then user tried to update to + # dev-lang/ghc-7.8.4-r1 (with transformers-0.4.2.0) + # this will lead to single .conf file collision. + local shipped_conf renamed_conf + local package_confdir="${ED}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d" + for shipped_conf in "${package_confdir}"/*.conf; do + # rename 'pkg-ver-id.conf' to 'pkg-ver-id-gentoo-${PF}.conf' + renamed_conf=${shipped_conf%.conf}-gentoo-${PF}.conf + mv "${shipped_conf}" "${renamed_conf}" || die + done + + # remove link, but leave 'haddock-${GHC_P}' + rm -f "${ED}"/usr/bin/$(cross)haddock + + if ! is_crosscompile; then + newbashcomp "${FILESDIR}"/ghc-bash-completion ghc-pkg + newbashcomp utils/completion/ghc.bash ghc + fi + fi + + # path to the package.cache + local package_confdir="${ED}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d" + PKGCACHE="${package_confdir}"/package.cache + # copy the package.conf.d, including timestamp, save it so we can help + # users that have a broken package.conf.d + cp -pR "${package_confdir}"{,.initial} || die "failed to backup intial package.conf.d" + + # copy the package.conf, including timestamp, save it so we later can put it + # back before uninstalling, or when upgrading. + cp -p "${PKGCACHE}"{,.shipped} \ + || die "failed to copy package.conf.d/package.cache" +} + +pkg_preinst() { + # have we got an earlier version of ghc installed? + if has_version "<${CATEGORY}/${PF}"; then + haskell_updater_warn="1" + fi +} + +pkg_postinst() { + ghc-reregister + + # path to the package.cache + PKGCACHE="${EROOT}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d/package.cache" + + # give the cache a new timestamp, it must be as recent as + # the package.conf.d directory. + touch "${PKGCACHE}" + + if [[ "${haskell_updater_warn}" == "1" ]]; then + ewarn + ewarn "\e[1;31m************************************************************************\e[0m" + ewarn + ewarn "You have just upgraded from an older version of GHC." + ewarn "You may have to run" + ewarn " 'haskell-updater'" + ewarn "to rebuild all ghc-based Haskell libraries." + ewarn + ewarn "\e[1;31m************************************************************************\e[0m" + ewarn + fi +} + +pkg_prerm() { + PKGCACHE="${EROOT}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d/package.cache" + rm -rf "${PKGCACHE}" + + cp -p "${PKGCACHE}"{.shipped,} +} + +pkg_postrm() { + ghc-package_pkg_postrm +} diff --git a/dev-lang/ghc/ghc-8.4.3.ebuild b/dev-lang/ghc/ghc-8.4.3.ebuild new file mode 100644 index 000000000000..f7908959c942 --- /dev/null +++ b/dev-lang/ghc/ghc-8.4.3.ebuild @@ -0,0 +1,760 @@ +# Copyright 1999-2018 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +EAPI=6 + +# to make make a crosscompiler use crossdev and symlink ghc tree into +# cross overlay. result would look like 'cross-sparc-unknown-linux-gnu/ghc' +export CBUILD=${CBUILD:-${CHOST}} +export CTARGET=${CTARGET:-${CHOST}} +if [[ ${CTARGET} = ${CHOST} ]] ; then + if [[ ${CATEGORY/cross-} != ${CATEGORY} ]] ; then + export CTARGET=${CATEGORY/cross-} + fi +fi + +inherit autotools bash-completion-r1 eutils flag-o-matic ghc-package +inherit multilib pax-utils toolchain-funcs versionator prefix +inherit check-reqs +DESCRIPTION="The Glasgow Haskell Compiler" +HOMEPAGE="http://www.haskell.org/ghc/" + +# we don't have any binaries yet +arch_binaries="" + +# sorted! +#arch_binaries="$arch_binaries alpha? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-alpha.tbz2 )" +#arch_binaries="$arch_binaries arm? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-armv7a-hardfloat-linux-gnueabi.tbz2 )" +#arch_binaries="$arch_binaries arm64? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-aarch64-unknown-linux-gnu.tbz2 )" +arch_binaries="$arch_binaries amd64? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-x86_64-pc-linux-gnu.tbz2 )" +#arch_binaries="$arch_binaries ia64? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-ia64-fixed-fiw.tbz2 )" +#arch_binaries="$arch_binaries ppc? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-ppc.tbz2 )" +#arch_binaries="$arch_binaries ppc64? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-ppc64.tbz2 )" +#arch_binaries="$arch_binaries sparc? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-sparc.tbz2 )" +arch_binaries="$arch_binaries x86? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-i686-pc-linux-gnu.tbz2 )" + +# various ports: +#arch_binaries="$arch_binaries x86-fbsd? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-x86-fbsd.tbz2 )" + +# 0 - yet +yet_binary() { + case "${ARCH}" in + #alpha) return 0 ;; + #arm64) return 0 ;; + #arm) return 0 ;; + amd64) return 0 ;; + #ia64) return 0 ;; + #ppc) return 0 ;; + #ppc64) return 0 ;; + #sparc) return 0 ;; + x86) return 0 ;; + *) return 1 ;; + esac +} + +GHC_PV=${PV} +#GHC_PV=8.4.1.20180329 # uncomment only for -alpha, -beta, -rc ebuilds +GHC_P=${PN}-${GHC_PV} # using ${P} is almost never correct + +SRC_URI="!binary? ( http://downloads.haskell.org/~ghc/${PV/_/-}/${GHC_P}-src.tar.xz )" +S="${WORKDIR}"/${GHC_P} + +[[ -n $arch_binaries ]] && SRC_URI+=" !ghcbootstrap? ( $arch_binaries )" + +BUMP_LIBRARIES=( + # "hackage-name hackage-version" +) + +LICENSE="BSD" +SLOT="0/${PV}" +#KEYWORDS="~alpha ~amd64 ~x86 ~amd64-linux ~x86-linux" +IUSE="doc ghcbootstrap ghcmakebinary +gmp profile" +IUSE+=" binary" + +RDEPEND=" + >=dev-lang/perl-5.6.1 + dev-libs/gmp:0= + sys-libs/ncurses:0=[unicode] + !ghcmakebinary? ( virtual/libffi:= ) +" + +# This set of dependencies is needed to run +# prebuilt ghc. We specifically avoid ncurses +# dependency with: +# utils/ghc-pkg_HC_OPTS += -DBOOTSTRAPPING +PREBUILT_BINARY_DEPENDS=" + !prefix? ( elibc_glibc? ( >=sys-libs/glibc-2.17 ) ) +" +# This set of dependencies is needed to install +# ghc[binary] in system. terminfo package is linked +# against ncurses. +PREBUILT_BINARY_RDEPENDS="${PREBUILT_BINARY_DEPENDS} + sys-libs/ncurses:0/6 +" + +RDEPEND+="binary? ( ${PREBUILT_BINARY_RDEPENDS} )" + +DEPEND="${RDEPEND} + doc? ( app-text/docbook-xml-dtd:4.2 + app-text/docbook-xml-dtd:4.5 + app-text/docbook-xsl-stylesheets + dev-python/sphinx + >=dev-libs/libxslt-1.1.2 ) + !ghcbootstrap? ( ${PREBUILT_BINARY_DEPENDS} )" + +PDEPEND="!ghcbootstrap? ( >=app-admin/haskell-updater-1.2 )" + +REQUIRED_USE="?? ( ghcbootstrap binary )" + +# haskell libraries built with cabal in configure mode, #515354 +QA_CONFIGURE_OPTIONS+=" --with-compiler --with-gcc" + +is_crosscompile() { + [[ ${CHOST} != ${CTARGET} ]] +} + +is_native() { + [[ ${CHOST} == ${CBUILD} ]] && [[ ${CHOST} == ${CTARGET} ]] +} + +# returns tool prefix for crosscompiler. +# Example: +# CTARGET=armv7a-unknown-linux-gnueabi +# CHOST=x86_64-pc-linux-gnu +# "armv7a-unknown-linux-gnueabi-" +# CTARGET=${CHOST} +# "" +# Used in tools and library prefix: +# "${ED}"/usr/bin/$(cross)haddock +# "${ED}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d" + +cross() { + if is_crosscompile; then + echo "${CTARGET}-" + else + echo "" + fi +} + +append-ghc-cflags() { + local persistent compile assemble link + local flag ghcflag + + for flag in $*; do + case ${flag} in + persistent) persistent="yes";; + compile) compile="yes";; + assemble) assemble="yes";; + link) link="yes";; + *) + [[ ${compile} ]] && ghcflag="-optc${flag}" CFLAGS+=" ${flag}" && GHC_FLAGS+=" ${ghcflag}" && + [[ ${persistent} ]] && GHC_PERSISTENT_FLAGS+=" ${ghcflag}" + [[ ${assemble} ]] && ghcflag="-opta${flag}" CFLAGS+=" ${flag}" && GHC_FLAGS+=" ${ghcflag}" && + [[ ${persistent} ]] && GHC_PERSISTENT_FLAGS+=" ${ghcflag}" + [[ ${link} ]] && ghcflag="-optl${flag}" LDFLAGS+=" ${flag}" && GHC_FLAGS+=" ${ghcflag}" && + [[ ${persistent} ]] && GHC_PERSISTENT_FLAGS+=" ${ghcflag}" + ;; + esac + done +} + +# $1 - lib name (under libraries/) +# $2 - lib version +# example: bump_lib "transformers" "0.4.2.0" +bump_lib() { + local pn=$1 pv=$2 + local p=${pn}-${pv} + local f + + einfo "Bumping ${pn} up to ${pv}" + + for f in ghc.mk GNUmakefile; do + mv libraries/"${pn}"/$f "${WORKDIR}"/"${p}"/$f || die + done + mv libraries/"${pn}" "${WORKDIR}"/"${pn}".old || die + mv "${WORKDIR}"/"${p}" libraries/"${pn}" || die +} + +update_SRC_URI() { + local p pn pv + for p in "${BUMP_LIBRARIES[@]}"; do + set -- $p + pn=$1 pv=$2 + + SRC_URI+=" mirror://hackage/package/${pn}/${pn}-${pv}.tar.gz" + done +} + +update_SRC_URI + +bump_libs() { + local p pn pv + for p in "${BUMP_LIBRARIES[@]}"; do + set -- $p + pn=$1 pv=$2 + + bump_lib "${pn}" "${pv}" + done +} + +ghc_setup_cflags() { + # TODO: plumb CFLAGS and BUILD_CFLAGS to respective CONF_CC_OPTS_STAGE<N> + if ! is_native; then + export CFLAGS=${GHC_CFLAGS-"-O2 -pipe"} + export LDFLAGS=${GHC_LDFLAGS-"-Wl,-O1"} + einfo "Crosscompiling mode:" + einfo " CHOST: ${CHOST}" + einfo " CTARGET: ${CTARGET}" + einfo " CFLAGS: ${CFLAGS}" + einfo " LDFLAGS: ${LDFLAGS}" + einfo " prefix: $(cross)" + return + fi + # We need to be very careful with the CFLAGS we ask ghc to pass through to + # gcc. There are plenty of flags which will make gcc produce output that + # breaks ghc in various ways. The main ones we want to pass through are + # -mcpu / -march flags. These are important for arches like alpha & sparc. + # We also use these CFLAGS for building the C parts of ghc, ie the rts. + strip-flags + strip-unsupported-flags + + # Cmm can't parse line numbers #482086 + replace-flags -ggdb[3-9] -ggdb2 + + GHC_FLAGS="" + GHC_PERSISTENT_FLAGS="" + for flag in ${CFLAGS}; do + case ${flag} in + + # Ignore extra optimisation (ghc passes -O to gcc anyway) + # -O2 and above break on too many systems + -O*) ;; + + # Arch and ABI flags are what we're really after + -m*) append-ghc-cflags compile assemble ${flag};; + + # Sometimes it's handy to see backtrace of RTS + # to get an idea what happens there + -g*) append-ghc-cflags compile ${flag};; + + # Ignore all other flags, including all -f* flags + esac + done + + for flag in ${LDFLAGS}; do + append-ghc-cflags link ${flag} + done + + # GHC uses ${CBUILD}-gcc, ${CHOST}-gcc and ${CTARGET}-gcc at a single build. + # Skip any gentoo-specific tweaks for cross-case to avoid passing unsupported + # options to gcc. + if is_native; then + # hardened-gcc needs to be disabled, because our prebuilt binaries/libraries + # are not built with fPIC, bug #606666 + gcc-specs-pie && append-ghc-cflags persistent compile link -nopie + tc-is-gcc && version_is_at_least 6.3 $(gcc-version) && if ! use ghcbootstrap; then + # gcc-6.3 has support for -no-pie upstream, but spelling differs from + # gentoo-specific '-nopie'. We enable it in non-bootstrap to allow + # hardened users try '-pie' in USE=ghcbootstrap mode. + append-ghc-cflags compile link -no-pie + fi + + # prevent from failing to build unregisterised ghc: + # http://www.mail-archive.com/debian-bugs-dist@lists.debian.org/msg171602.html + use ppc64 && append-ghc-cflags persistent compile -mminimal-toc + fi +} + +# substitutes string $1 to $2 in files $3 $4 ... +relocate_path() { + local from=$1 + local to=$2 + shift 2 + local file= + for file in "$@" + do + sed -i -e "s|$from|$to|g" \ + "$file" || die "path relocation failed for '$file'" + done +} + +# changes hardcoded ghc paths and updates package index +# $1 - new absolute root path +relocate_ghc() { + local to=$1 + + # libdir for prebuilt binary and for current system may mismatch + # It does for prefix installation for example: bug #476998 + local bin_ghc_prefix=${WORKDIR}/usr + local bin_libpath=$(echo "${bin_ghc_prefix}"/lib*) + local bin_libdir=${bin_libpath#${bin_ghc_prefix}/} + + # backup original script to use it later after relocation + local gp_back="${T}/ghc-pkg-${GHC_PV}-orig" + cp "${WORKDIR}/usr/bin/ghc-pkg-${GHC_PV}" "$gp_back" || die "unable to backup ghc-pkg wrapper" + + if [[ ${bin_libdir} != $(get_libdir) ]]; then + einfo "Relocating '${bin_libdir}' to '$(get_libdir)' (bug #476998)" + # moving the dir itself is not strictly needed + # but then USE=binary would result in installing + # in '${bin_libdir}' + mv "${bin_ghc_prefix}/${bin_libdir}" "${bin_ghc_prefix}/$(get_libdir)" || die + + relocate_path "/usr/${bin_libdir}" "/usr/$(get_libdir)" \ + "${WORKDIR}/usr/bin/ghc-${GHC_PV}" \ + "${WORKDIR}/usr/bin/ghci-${GHC_PV}" \ + "${WORKDIR}/usr/bin/ghc-pkg-${GHC_PV}" \ + "${WORKDIR}/usr/bin/hsc2hs" \ + "${WORKDIR}/usr/bin/runghc-${GHC_PV}" \ + "$gp_back" \ + "${WORKDIR}/usr/$(get_libdir)/${GHC_P}/package.conf.d/"* + fi + + # Relocate from /usr to ${EPREFIX}/usr + relocate_path "/usr" "${to}/usr" \ + "${WORKDIR}/usr/bin/ghc-${GHC_PV}" \ + "${WORKDIR}/usr/bin/ghci-${GHC_PV}" \ + "${WORKDIR}/usr/bin/ghc-pkg-${GHC_PV}" \ + "${WORKDIR}/usr/bin/haddock-ghc-${GHC_PV}" \ + "${WORKDIR}/usr/bin/hp2ps" \ + "${WORKDIR}/usr/bin/hpc" \ + "${WORKDIR}/usr/bin/hsc2hs" \ + "${WORKDIR}/usr/bin/runghc-${GHC_PV}" \ + "${WORKDIR}/usr/$(get_libdir)/${GHC_P}/package.conf.d/"* + + # this one we will use to regenerate cache + # so it should point to current tree location + relocate_path "/usr" "${WORKDIR}/usr" "$gp_back" + + if use prefix; then + hprefixify "${bin_libpath}"/${PN}*/settings + fi + + # regenerate the binary package cache + "$gp_back" recache || die "failed to update cache after relocation" + rm "$gp_back" +} + +ghc-check-reqs() { + # These are pessimistic values (slightly bigger than worst-case) + # Worst case is UNREG USE=profile ia64. See bug #611866 for some + # numbers on various arches. + CHECKREQS_DISK_BUILD=8G + CHECKREQS_DISK_USR=2G + # USE=binary roughly takes + use binary && CHECKREQS_DISK_BUILD=4G + + "$@" +} + +pkg_pretend() { + ghc-check-reqs check-reqs_pkg_pretend +} + +pkg_setup() { + ghc-check-reqs check-reqs_pkg_setup + + # quiet portage about prebuilt binaries + use binary && QA_PREBUILT="*" + + [[ ${MERGE_TYPE} == binary ]] && return + + if use ghcbootstrap; then + ewarn "You requested ghc bootstrapping, this is usually only used" + ewarn "by Gentoo developers to make binary .tbz2 packages." + + [[ -z $(type -P ghc) ]] && \ + die "Could not find a ghc to bootstrap with." + else + if ! yet_binary; then + eerror "Please try emerging with USE=ghcbootstrap and report build" + eerror "sucess or failure to the haskell team (haskell@gentoo.org)" + die "No binary available for '${ARCH}' arch yet, USE=ghcbootstrap" + fi + fi +} + +src_unpack() { + # Create the ${S} dir if we're using the binary version + use binary && mkdir "${S}" + + # the Solaris and Darwin binaries from ghc (maeder) need to be + # unpacked separately, so prevent them from being unpacked + local ONLYA=${A} + case ${CHOST} in + *-darwin* | *-solaris*) ONLYA=${GHC_P}-src.tar.xz ;; + esac + unpack ${ONLYA} +} + +src_prepare() { + ghc_setup_cflags + + if ! use ghcbootstrap && [[ ${CHOST} != *-darwin* && ${CHOST} != *-solaris* ]]; then + # Modify the wrapper script from the binary tarball to use GHC_PERSISTENT_FLAGS. + # See bug #313635. + sed -i -e "s|\"\$topdir\"|\"\$topdir\" ${GHC_PERSISTENT_FLAGS}|" \ + "${WORKDIR}/usr/bin/ghc-${GHC_PV}" + + # allow hardened users use vanilla binary to bootstrap ghc + # ghci uses mmap with rwx protection at it implements dynamic + # linking on it's own (bug #299709) + pax-mark -m "${WORKDIR}/usr/$(get_libdir)/${GHC_P}/bin/ghc" + fi + + if use binary; then + if use prefix; then + relocate_ghc "${EPREFIX}" + fi + + # Move unpacked files to the expected place + mv "${WORKDIR}/usr" "${S}" + eapply_user + else + if ! use ghcbootstrap; then + case ${CHOST} in + *-darwin* | *-solaris*) + # UPDATE ME for ghc-7 + mkdir "${WORKDIR}"/ghc-bin-installer || die + pushd "${WORKDIR}"/ghc-bin-installer > /dev/null || die + use sparc-solaris && unpack ghc-6.10.4-sparc-sun-solaris2.tar.bz2 + use x86-solaris && unpack ghc-7.0.3-i386-unknown-solaris2.tar.bz2 + use x86-macos && unpack ghc-7.4.1-i386-apple-darwin.tar.bz2 + use x64-macos && unpack ghc-7.4.1-x86_64-apple-darwin.tar.bz2 + popd > /dev/null + + pushd "${WORKDIR}"/ghc-bin-installer/ghc-[67].?*.? > /dev/null || die + # fix the binaries so they run, on Solaris we need an + # LD_LIBRARY_PATH which has our prefix libdirs, on + # Darwin we need to replace the frameworks with our libs + # from the prefix fix before installation, because some + # of the tools are actually used during configure/make + if [[ ${CHOST} == *-solaris* ]] ; then + export LD_LIBRARY_PATH="${EPREFIX}/$(get_libdir):${EPREFIX}/usr/$(get_libdir):${LD_LIBRARY_PATH}" + elif [[ ${CHOST} == *-darwin* ]] ; then + local readline_framework=GNUreadline.framework/GNUreadline + local gmp_framework=/opt/local/lib/libgmp.10.dylib + local ncurses_file=/opt/local/lib/libncurses.5.dylib + for binary in $(scanmacho -BRE MH_EXECUTE -F '%F' .) ; do + install_name_tool -change \ + ${readline_framework} \ + "${EPREFIX}"/lib/libreadline.dylib \ + ${binary} || die + install_name_tool -change \ + ${gmp_framework} \ + "${EPREFIX}"/usr/lib/libgmp.dylib \ + ${binary} || die + install_name_tool -change \ + ${ncurses_file} \ + "${EPREFIX}"/usr/lib/libncurses.dylib \ + ${binary} || die + done + # we don't do frameworks! + sed -i \ + -e 's/\(frameworks = \)\["GMP"\]/\1[]/g' \ + -e 's/\(extraLibraries = \)\["m"\]/\1["m","gmp"]/g' \ + rts/package.conf.in || die + fi + + # it is autoconf, but we really don't want to give it too + # much arguments, in fact we do the make in-place anyway + ./configure --prefix="${WORKDIR}"/usr || die + make install || die + popd > /dev/null + ;; + *) + relocate_ghc "${WORKDIR}" + ;; + esac + fi + + sed -i -e "s|\"\$topdir\"|\"\$topdir\" ${GHC_PERSISTENT_FLAGS}|" \ + "${S}/ghc/ghc.wrapper" + + cd "${S}" # otherwise eapply will break + + eapply "${FILESDIR}"/${PN}-7.0.4-CHOST-prefix.patch + eapply "${FILESDIR}"/${PN}-8.2.1-darwin.patch + eapply "${FILESDIR}"/${PN}-7.8.3-prim-lm.patch + eapply "${FILESDIR}"/${PN}-8.0.2-no-relax-everywhere.patch + eapply "${FILESDIR}"/${PN}-8.4.2-allow-cross-bootstrap.patch + + # a bunch of crosscompiler patches + # needs newer version: + #eapply "${FILESDIR}"/${PN}-8.2.1_rc1-hp2ps-cross.patch + + # mingw32 target + pushd "${S}/libraries/Win32" + eapply "${FILESDIR}"/${PN}-8.2.1_rc1-win32-cross-2-hack.patch # bad workaround + popd + + bump_libs + + eapply_user + # as we have changed the build system + eautoreconf + fi +} + +src_configure() { + if ! use binary; then + # initialize build.mk + echo '# Gentoo changes' > mk/build.mk + + # Put docs into the right place, ie /usr/share/doc/ghc-${GHC_PV} + echo "docdir = ${EPREFIX}/usr/share/doc/$(cross)${P}" >> mk/build.mk + echo "htmldir = ${EPREFIX}/usr/share/doc/$(cross)${P}" >> mk/build.mk + + # We also need to use the GHC_FLAGS flags when building ghc itself + echo "SRC_HC_OPTS+=${HCFLAGS} ${GHC_FLAGS}" >> mk/build.mk + echo "SRC_CC_OPTS+=${CFLAGS}" >> mk/build.mk + echo "SRC_LD_OPTS+=${LDFLAGS}" >> mk/build.mk + # Speed up initial Cabal bootstrap + echo "utils/ghc-cabal_dist_EXTRA_HC_OPTS+=$(ghc-make-args)" >> mk/build.mk + + # We can't depend on haddock except when bootstrapping when we + # must build docs and include them into the binary .tbz2 package + # app-text/dblatex is not in portage, can not build PDF or PS + echo "BUILD_SPHINX_PDF = NO" >> mk/build.mk + echo "BUILD_SPHINX_HTML = $(usex doc YES NO)" >> mk/build.mk + echo "BUILD_MAN = $(usex doc YES NO)" >> mk/build.mk + + # this controls presence on 'xhtml' and 'haddock' in final install + echo "HADDOCK_DOCS = YES" >> mk/build.mk + + # not used outside of ghc's test + if [[ -n ${GHC_BUILD_DPH} ]]; then + echo "BUILD_DPH = YES" >> mk/build.mk + else + echo "BUILD_DPH = NO" >> mk/build.mk + fi + + # Any non-native build has to skip as it needs + # target haddock binary to be runnabine. + if ! is_native; then + # disable docs generation as it requires running stage2 + echo "HADDOCK_DOCS=NO" >> mk/build.mk + echo "BUILD_SPHINX_HTML=NO" >> mk/build.mk + echo "BUILD_SPHINX_PDF=NO" >> mk/build.mk + fi + + if is_crosscompile; then + # Install ghc-stage1 crosscompiler instead of + # ghc-stage2 cross-built compiler. + echo "Stage1Only=YES" >> mk/build.mk + fi + + # allows overriding build flavours for libraries: + # v - vanilla (static libs) + # p - profiled + # dyn - shared libraries + # example: GHC_LIBRARY_WAYS="v dyn" + if [[ -n ${GHC_LIBRARY_WAYS} ]]; then + echo "GhcLibWays=${GHC_LIBRARY_WAYS}" >> mk/build.mk + fi + echo "BUILD_PROF_LIBS = $(usex profile YES NO)" >> mk/build.mk + + # Get ghc from the unpacked binary .tbz2 + # except when bootstrapping we just pick ghc up off the path + if ! use ghcbootstrap; then + export PATH="${WORKDIR}/usr/bin:${PATH}" + fi + + echo "INTEGER_LIBRARY = $(usex gmp integer-gmp integer-simple)" >> mk/build.mk + + # don't strip anything. Very useful when stage2 SIGSEGVs on you + echo "STRIP_CMD = :" >> mk/build.mk + + local econf_args=() + + # GHC embeds toolchain it was built by and uses it later. + # Don't allow things like ccache or versioned binary slip. + # We use stable thing across gcc upgrades. + # User can use EXTRA_ECONF=CC=... to override this default. + econf_args+=( + AR=${CTARGET}-ar + CC=${CTARGET}-gcc + # these should be inferred by GHC but ghc defaults + # to using bundled tools on windows. + Windres=${CTARGET}-windres + DllWrap=${CTARGET}-dllwrap + # we set the linker explicitly below + --disable-ld-override + ) + case ${CTARGET} in + arm*) + # ld.bfd-2.28 does not work for ghc. Force ld.gold + # instead. This should be removed once gentoo gets + # a fix for R_ARM_COPY bug: https://sourceware.org/PR16177 + econf_args+=(LD=${CTARGET}-ld.gold) + ;; + sparc*) + # ld.gold-2.28 does not work for ghc. Force ld.bfd + # instead. This should be removed once gentoo gets + # a fix for missing --no-relax support bug: + # https://sourceware.org/ml/binutils/2017-07/msg00183.html + econf_args+=(LD=${CTARGET}-ld.bfd) + ;; + *) + econf_args+=(LD=${CTARGET}-ld) + esac + + if [[ ${CBUILD} != ${CHOST} ]]; then + # GHC bug: ghc claims not to support cross-building. + # It does, but does not distinct --host= value + # for stage1 and stage2 compiler. + econf_args+=(--host=${CBUILD}) + fi + + if use ghcmakebinary; then + # When building booting libary we are trying to + # bundle or restrict most of external depends + # with unstable ABI: + # - embed libffi (default GHC behaviour) + # - disable ncurses support for ghci (via haskeline) + # https://bugs.gentoo.org/557478 + # - disable ncurses support for ghc-pkg + echo "libraries/haskeline_CONFIGURE_OPTS += --flag=-terminfo" >> mk/build.mk + echo "utils/ghc-pkg_HC_OPTS += -DBOOTSTRAPPING" >> mk/build.mk + elif is_native; then + # using ${GTARGET}'s libffi is not supported yet: + # GHC embeds full path for ffi includes without /usr/${CTARGET} account. + econf_args+=(--with-system-libffi) + econf_args+=(--with-ffi-includes=$(pkg-config libffi --cflags-only-I | sed -e 's@^-I@@')) + fi + + einfo "Final mk/build.mk:" + cat mk/build.mk || die + + econf ${econf_args[@]} --enable-bootstrap-with-devel-snapshot + + if [[ ${PV} == *9999* ]]; then + GHC_PV="$(grep 'S\[\"PACKAGE_VERSION\"\]' config.status | sed -e 's@^.*=\"\(.*\)\"@\1@')" + GHC_P=${PN}-${GHC_PV} + fi + fi # ! use binary +} + +src_compile() { + if ! use binary; then + # Stage1Only crosscompiler does not build stage2 + if ! is_crosscompile; then + # 1. build/pax-mark compiler binary first + emake ghc/stage2/build/tmp/ghc-stage2 + # 2. pax-mark (bug #516430) + pax-mark -m ghc/stage2/build/tmp/ghc-stage2 + # 2. build/pax-mark haddock using ghc-stage2 + if is_native; then + # non-native build does not build haddock + # due to HADDOCK_DOCS=NO, but it could. + emake utils/haddock/dist/build/tmp/haddock + pax-mark -m utils/haddock/dist/build/tmp/haddock + fi + fi + # 3. and then all the rest + emake all + fi # ! use binary +} + +src_install() { + if use binary; then + use prefix && mkdir -p "${ED}" + mv "${S}/usr" "${ED}" + else + [[ -f VERSION ]] || emake VERSION + + # -j1 due to a rare race in install script: + # make --no-print-directory -f ghc.mk phase=final install + # /usr/lib/portage/python3.4/ebuild-helpers/xattr/install -c -m 755 \ + # -d "/tmp/portage-tmpdir/portage/cross-armv7a-unknown-linux-gnueabi/ghc-9999/image/usr/lib64/armv7a-unknown-linux-gnueabi-ghc-8.3.20170404/include" + # /usr/lib/portage/python3.4/ebuild-helpers/xattr/install -c -m 644 utils/hsc2hs/template-hsc.h \ + # "/tmp/portage-tmpdir/portage/cross-armv7a-unknown-linux-gnueabi/ghc-9999/image/usr/lib64/armv7a-unknown-linux-gnueabi-ghc-8.3.20170404" + # /usr/bin/install: cannot create regular file \ + # '/tmp/portage-tmpdir/portage/cross-armv7a-unknown-linux-gnueabi/ghc-9999/image/usr/lib64/armv7a-unknown-linux-gnueabi-ghc-8.3.20170404': No such file or directory + emake -j1 install DESTDIR="${D}" + + # Skip for cross-targets as they all share target location: + # /usr/share/doc/ghc-9999/ + if ! is_crosscompile; then + dodoc "distrib/README" "ANNOUNCE" "LICENSE" "VERSION" + fi + + # rename ghc-shipped files to avoid collision + # of external packages. Motivating example: + # user had installed: + # dev-lang/ghc-7.8.4-r0 (with transformers-0.3.0.0) + # dev-haskell/transformers-0.4.2.0 + # then user tried to update to + # dev-lang/ghc-7.8.4-r1 (with transformers-0.4.2.0) + # this will lead to single .conf file collision. + local shipped_conf renamed_conf + local package_confdir="${ED}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d" + for shipped_conf in "${package_confdir}"/*.conf; do + # rename 'pkg-ver-id.conf' to 'pkg-ver-id-gentoo-${PF}.conf' + renamed_conf=${shipped_conf%.conf}-gentoo-${PF}.conf + mv "${shipped_conf}" "${renamed_conf}" || die + done + + # remove link, but leave 'haddock-${GHC_P}' + rm -f "${ED}"/usr/bin/$(cross)haddock + + if ! is_crosscompile; then + newbashcomp "${FILESDIR}"/ghc-bash-completion ghc-pkg + newbashcomp utils/completion/ghc.bash ghc + fi + fi + + # path to the package.cache + local package_confdir="${ED}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d" + PKGCACHE="${package_confdir}"/package.cache + # copy the package.conf.d, including timestamp, save it so we can help + # users that have a broken package.conf.d + cp -pR "${package_confdir}"{,.initial} || die "failed to backup intial package.conf.d" + + # copy the package.conf, including timestamp, save it so we later can put it + # back before uninstalling, or when upgrading. + cp -p "${PKGCACHE}"{,.shipped} \ + || die "failed to copy package.conf.d/package.cache" +} + +pkg_preinst() { + # have we got an earlier version of ghc installed? + if has_version "<${CATEGORY}/${PF}"; then + haskell_updater_warn="1" + fi +} + +pkg_postinst() { + ghc-reregister + + # path to the package.cache + PKGCACHE="${EROOT}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d/package.cache" + + # give the cache a new timestamp, it must be as recent as + # the package.conf.d directory. + touch "${PKGCACHE}" + + if [[ "${haskell_updater_warn}" == "1" ]]; then + ewarn + ewarn "\e[1;31m************************************************************************\e[0m" + ewarn + ewarn "You have just upgraded from an older version of GHC." + ewarn "You may have to run" + ewarn " 'haskell-updater'" + ewarn "to rebuild all ghc-based Haskell libraries." + ewarn + ewarn "\e[1;31m************************************************************************\e[0m" + ewarn + fi +} + +pkg_prerm() { + PKGCACHE="${EROOT}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d/package.cache" + rm -rf "${PKGCACHE}" + + cp -p "${PKGCACHE}"{.shipped,} +} + +pkg_postrm() { + ghc-package_pkg_postrm +} diff --git a/dev-lang/ghc/metadata.xml b/dev-lang/ghc/metadata.xml new file mode 100644 index 000000000000..494e169583d3 --- /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">Internal: Bootstrap GHC from an existing GHC installation.</flag> + <flag name="ghcmakebinary">Internal: Build binary friendly for redistribution.</flag> + </use> +</pkgmetadata> |