summaryrefslogtreecommitdiff
path: root/sys-devel/binutils-apple
diff options
context:
space:
mode:
authorV3n3RiX <venerix@redcorelinux.org>2017-10-09 18:53:29 +0100
committerV3n3RiX <venerix@redcorelinux.org>2017-10-09 18:53:29 +0100
commit4f2d7949f03e1c198bc888f2d05f421d35c57e21 (patch)
treeba5f07bf3f9d22d82e54a462313f5d244036c768 /sys-devel/binutils-apple
reinit the tree, so we can have metadata
Diffstat (limited to 'sys-devel/binutils-apple')
-rw-r--r--sys-devel/binutils-apple/Manifest55
-rw-r--r--sys-devel/binutils-apple/binutils-apple-4.3-r2.ebuild337
-rw-r--r--sys-devel/binutils-apple/binutils-apple-5.1-r1.ebuild384
-rw-r--r--sys-devel/binutils-apple/binutils-apple-6.1-r1.ebuild385
-rw-r--r--sys-devel/binutils-apple/binutils-apple-6.3-r1.ebuild378
-rw-r--r--sys-devel/binutils-apple/binutils-apple-7.0-r1.ebuild369
-rw-r--r--sys-devel/binutils-apple/binutils-apple-7.0.ebuild366
-rw-r--r--sys-devel/binutils-apple/binutils-apple-7.1-r1.ebuild369
-rw-r--r--sys-devel/binutils-apple/binutils-apple-7.1.ebuild366
-rw-r--r--sys-devel/binutils-apple/binutils-apple-7.2-r1.ebuild370
-rw-r--r--sys-devel/binutils-apple/binutils-apple-7.2.ebuild366
-rw-r--r--sys-devel/binutils-apple/binutils-apple-7.3.1.ebuild393
-rw-r--r--sys-devel/binutils-apple/binutils-apple-7.3.ebuild386
-rw-r--r--sys-devel/binutils-apple/binutils-apple-8.1.ebuild334
-rw-r--r--sys-devel/binutils-apple/binutils-apple-8.2.1.ebuild334
-rw-r--r--sys-devel/binutils-apple/metadata.xml18
16 files changed, 5210 insertions, 0 deletions
diff --git a/sys-devel/binutils-apple/Manifest b/sys-devel/binutils-apple/Manifest
new file mode 100644
index 000000000000..e357731f44b9
--- /dev/null
+++ b/sys-devel/binutils-apple/Manifest
@@ -0,0 +1,55 @@
+DIST binutils-apple-patches-4.3-r1.tar.bz2 37363 SHA256 0abb41301034903452084f13566d912976a8d8845dfe37564e727c9dba9bb130 SHA512 f5d64ad182891c3af971e6aabd3c0c1b717b6a1cb471632339cba61b41a998d15880d18de09aafa1c3d059e528c888d6e8b914025c79bc21897d90a6d0e2ebf5 WHIRLPOOL eca7f9c2cd0e0c35978824c7ae591844ee5f88522db0747ed7d4e37e73bec076dadb3a2e017de7ee6cf2564a8363f4848b0cac36117a6dfd918b4514ad14e843
+DIST binutils-apple-patches-5.1-r2.tar.bz2 51642 SHA256 fa179acf848b3cb4f888d8f8154dffec2737e06bb7002daa8d317ad0bdf02f49 SHA512 37ba0dcae6c10b54a07c6208f6893ab80b0de1bd1c2f677902f707c8290629f7671a481e256b57a18bf304b95e41e4d59519bc1c88f15de488c0ef7e142f5cd8 WHIRLPOOL 8cd1b1730b7df31d2324c8c5f23d9b7e11ffb85284cbc1f6f6ee0290304789c405b878d207821dae997420382dd39aa943fcd1fe78ae8135fc238589f429b55f
+DIST binutils-apple-patches-6.1-r1.tar.bz2 42189 SHA256 8efc006a59a589d498cd0a745e3096f6e0387031a69b0583b94f8ff943bdd10a SHA512 be8ee5af5c8c9f9228cf6980f032aa101058ac1a414bec89401dbc4ff32ea96d6ebf96b7b79285fa1e7b4037a9ed68b285dbe59ff8e3d3e62bfc0145199e72f3 WHIRLPOOL 80fa76ed8c8f60908ac12b4a2d252d8ec1ae6d418f3e20faa6e1905f6d6284dae74d9d82190d02fdd2690ce572c7e97cf38e9e4b88089beaf8962b6162616b20
+DIST binutils-apple-patches-6.3-r1.tar.bz2 37951 SHA256 3a5f647eea58f37c091fc7358ee8b8a36de75a5ea826b50e4de1507d31540c79 SHA512 07262f4cb621d7afa240c4d81f80eb1a2adf486b60eb480fe283235eac12167f8efa0a462bf9d0036226aa5e6a5382f9f74420ba3269bc260d0a48d0e4442578 WHIRLPOOL 37429146254f62bb3b67b63551ae7c759131d117ee98a3a9e465b2765550378487d425c435ac7e37f20a0259a536dec7b66851bae1c680c9c25a117a4921ced9
+DIST binutils-apple-patches-7.0-r1.tar.bz2 43705 SHA256 e016615294167a539c716094ee595c37d7e11a44e76c6aeadb4d9e6bd14622fb SHA512 a25570062628979e23d73ce9dfd0a9bbb4237fdac472a30f2ec564a9bc9afa7d91d8d8b5bf460d16344677f817b55154394608d74c937f0b1fc6dda64f538266 WHIRLPOOL 2b9b2db3c5e81c26bc6857e2b9b38ae487e3c34e58e2180d84e26762bea287f82d290633efe0d9c4b531b4167782487e260963ff8bc4f2775c23a36c9fe3a0ba
+DIST binutils-apple-patches-7.0-r2.tar.bz2 50934 SHA256 5be8cf3ed268bb413ffd05aff91a74a138c5ee92f3cad7c1bcafb4abd957ce8d SHA512 c7c8f50fad0507228336b6144b8be3e70df07d64f1df617bfd9cd717a095c49cd9555c441cde7d24bbe2d179ab8763e4f6ab1074dd6c5532b80a1bbb4f13a244 WHIRLPOOL 35e735356ee72161b0f69ea12ca3ae6745dcea18f8bcba62adbe8c189da9ddf0595bbd837c21acecf0a32a6a50a998c80a2cc3088e63b64655c6f0d0949e05c8
+DIST binutils-apple-patches-7.2-r0.tar.bz2 2917 SHA256 8fa3c64c840aefb71c32fc0294ce6c2b0cf058a5e7f624d736dac6b8c1f44287 SHA512 ca2fc2da88144fbf01f34f1664e6177105a5d1bff956e83f6c7cd530b8e80dcd59b0c921ad95d3c4554e02909bcd846d3a2a4535bf47569b343c85e765619821 WHIRLPOOL 9ba63b8407f6015dd8cca48bea474c375cf90047a138fac8aef800622a780bfcc98910cc46781aea72a2b9803e7cd86c3ea35cfe9fa33bba8813499cc8b91c2c
+DIST binutils-apple-patches-7.3-r0.tar.bz2 44576 SHA256 18a9484b53225004ccd37d34d0e208e3a716f73831f4a433be211f233d855fb1 SHA512 6b092c586ac4c3a3c65229a7490f93b0f0d38348e5a2db4f73d6062c737007ee0a5b6bdb5948b7aac1d74d32442fa501ba92161a9ffe13151288432c6a706c43 WHIRLPOOL ef159c24cd1e53538f73aac805e06d14775f82921b1e8a10919981dbec0017d0c70ada0e80ea6135cca5551ccfb38f229df666bcb2e692880d6a23d380d39801
+DIST binutils-apple-patches-7.3-r1.tar.bz2 44737 SHA256 215da3068451640cf25dbe7beb0c8d704a6fbc6d3d988675ae17b9ebbd9d1ee2 SHA512 ce4b3a725e19cb632b0c101a32488ce09a8bb89aed08339d5518d834cb68c525b2e0c8b66564a945c077915e92cc6be3f7028c5baacb870b3ca9b9422b4fb0da WHIRLPOOL 1c8a2b251e385eff5de435f9c72c8244329f55de5a61549371214ddab1cfe687491571d68d0a2c7cee4da2529f24005d1d0a7429daa5c6a1ef3a68ea8af0da20
+DIST binutils-apple-patches-8.2-r0.tar.bz2 5771 SHA256 839dba0eb6314e15bfa43b50479359adfc695c8b65b6c7176abc0983c41c6dbb SHA512 92d04396630a31b752a24845c27fe8da2e37eb176117c9b31193e8f48af7ade707cda4060289b848965310afd05b2f121c740b0e5baa56b79c5481273a88c84e WHIRLPOOL 5706ab6aee04670b4fbbf5cca62109c3f69beba834729280dc636d8c5c4017f321d0402db080032219ccf025899a9bf1daf48a7ac6805faf01e10ed6faf73242
+DIST cctools-822.tar.gz 2024412 SHA256 dfaa9bdbd023524d47429674f64d2d5ea393123dabf90868be0aa17f61f45289 SHA512 8b02cc837d5e0520f35da445f25ba86b5042d5caa27b49a599e829ed89428cf78dbd1831bcf6c18301f941fbfb31ac2114e248041d98008a466e1574f4fe1586 WHIRLPOOL 81191ab46e8a9e47e4267146f978438ff64314b0363296b973a02f361918a5cd69057753a1b40766b93d3d4a3ed10585a27f6da2953992a406be61d1dcc1d06c
+DIST cctools-855.tar.gz 1699635 SHA256 751748ddf32c8ea84c175f32792721fa44424dad6acbf163f84f41e9617dbc58 SHA512 50f5d015ce807aa5ca274dd2deea810b8b375110e60b5e334ca4b2170526b738ea5f86a5436caebbdb748badc3b89601d0f450f5b867d8393c89e336a3db4b3f WHIRLPOOL fa493a29e32583f60c3553794bbb6d01a7b5ef797d8e8ba8161c9cbf237906ebbfaff560366da2d5b852bfcbdd55e874c00edf5b3169b16b357a54fcf3c07c4c
+DIST cctools-862.tar.gz 1702345 SHA256 1bf29f620b91c901ad3116b47738ab5076c1aed75d13869cd3bc7f067b4aaadb SHA512 faa401c1dc55bfb9cd2a9a9cc7bc9d473ee63b019607967c8b0da325514d6a1f7b1f52404370bcc018e86d30d75a4b01183f49b793f577110663efe43871360a WHIRLPOOL 371307f3264361f5e2e48d83177aff1a8f435cf2bdc1f4998cc5780c5b3760048a29a7620d2390db8f0c9378cd2f3b2f130b6aca9d402e3d428c4f4d353db097
+DIST cctools-870.tar.gz 1702965 SHA256 b83f4b4696414b814cc1781ec4b68ff9c7bb97920a68f308351a74e75f41d961 SHA512 8cd16350bc2eea576e3922f44de3d15cfcf492a5561215a3a9160f2045284a2fd0fa28e030686868bae8619993fc8901649d7576c56d86a423f9955b27f65138 WHIRLPOOL 9c99188b0e6e71fc3beef674b977f5f59310410b004c26e85e83b7fe7d48f4499a31b982935c695effaa9130781dc10b9a20633800df361a550cf53fb52ba352
+DIST cctools-877.5.tar.gz 1717664 SHA256 5e7525c86581d9dead8a8508a9e824101765d05a3e14d612de1aa38def9adde9 SHA512 cec8520450c3b1ffe77bd841ad6b8f6b0d28657e7c39ae1525bfe7ec1460c0f4bb394da316e6ed5b08cb5df26b757b9d94a9923cc7eaf9b14315d045ea891062 WHIRLPOOL 30b8c8fad772804a449318b08b7e3362e9a73345a4fe43758216d41f533189dac6a2bee37f1884fc049702f2705fda250767cf3a776956796c270147197920b7
+DIST cctools-877.7.tar.gz 1720523 SHA256 c3809b7604a27db0c0b418fcccd5cad49f002e2a750ec611f92f806521f7ed9e SHA512 5c381fe8b85d1254f660eb3c3510d9e0a49792ae5bb0e69a4dfb5a18e7f1706ee1411589f20583a9d7f12126ef616f66f1ad5c1c4ff405f66b52759c0a4272b5 WHIRLPOOL 2c8e85fd33f183bd074abf90237301eff252ca05aa48a59aea713d263b10e0710d261a5ac01185e9a17d1a391fa025fb91d60df0f3b426140defdbd5536e4bbb
+DIST cctools-877.8.tar.gz 1720708 SHA256 88be2788adf461f1d8278324b0078f6003b2328b6f95a54b16ec6ed1ba651dc2 SHA512 3f75fbe4eacd89f2e6372a3167ed197e2b8bda9faa10fe6bce0cf9d3d3eca536f0af5fc4ce1e4bc6a24eb68db36f5d0b1d0bc3f9807e285e67cfaa2d336d81ef WHIRLPOOL eea67bacd8037b19ba3efcc2fecfcc74ec3e785ce92628fdeccbeca6e17dee4d1926719a02ca7f68fc2045f9b37571cb044cc29a3a8fe6a5bd704a3446f44945
+DIST cctools-886.tar.gz 1731850 SHA256 f3a4fa7dad4a54d862b1d9f48e3dfb25fc532c9cf46a041cf8134694328a8878 SHA512 49f14e165da3a9fcf16614a810b8a2a68907348bd27a60b268b330e416a0bc070fb6445e1e6b80d849026bd6ce7de4459623ab86168e2d63bb492d1ba6680c5b WHIRLPOOL 91a09d3c773f0aede36de548310879a1ad4158f39e9d4d91b4e1a9460d31acdcab5c658113381742512861c6281661dea7fd8273d7146ac6838088d1435ebe2f
+DIST cctools-895.tar.gz 1716126 SHA256 ce66034fa35117f9ae76bbb7dd72d8068c405778fa42e877e8a13237a10c5cb7 SHA512 4ef9db870385cc2c4263bcbe42ff0de80386771f5acbc7082a1818ecd6b8d7bb1bfa02a7fcfecd3e7281481aeaaac4c331359aca3564bfe7a4c7dea1e0d06126 WHIRLPOOL 36f6814cfe25fd5e257720560db18ceaed7cc5504f9fcb20cd00f48e9295797067d1538fd172406b7c68d771df1059d46261b33fc4fb293afe8b28a7580e90c4
+DIST dyld-195.6.tar.gz 412518 SHA256 69296e9b4192bdac778ea899fffc18b02be62b51b5e8474b4cf85ae5f2b08aa4 SHA512 58a9ea27efc02e66f9d99bfa250af1d90326385385431e5279386bbd9ab53366bf7e8236543296908b7214c33523c8f60098a6298a7393b3180e2a6bce18e7c5 WHIRLPOOL e37b11d3996559f8a1843577a5fa42f96e4d42419f205276600f0ed79fcd2490da1f8a77eecf29f111b3db62a65e8e9cd77a154e3b389d633a7ac1525273b9b5
+DIST dyld-353.2.1.tar.gz 510036 SHA256 051089e284c5a4d671b21b73866abd01d54e5ea1912cadf3a9b916890fb31540 SHA512 a9488620499f682e245b55b7e0e4ec02fc0bcf03bd8a70d4a4ee0ba762067ade2f41c188990c101727476d41c19368b4cc89cccf2df40231da1c777742c7391f WHIRLPOOL 3164746ed8c866df993f08e405e7e329db427af8eeded681d5fb88031ef2c025363d5bfb647e9315738024adf9f48efacf49226f86f27def584ec7f538da292e
+DIST dyld-360.14.tar.gz 518873 SHA256 c4e011241d75e3fac4dbdfc0049ccf26fb939fea6c0256b6f16036b2e4690c6e SHA512 cfe536ea1f0ad8fbc2846417289e3e36704bf69388e083e0ece0ffa6eeee501e7e9b2ba47eed7be0e5120b5cc72f33b2fc0d2d39ba7a16beaf98db94dfb4ae40 WHIRLPOOL 6ed42fa38f60a84deab0bc9b128f5de232df487613726978be29783ede7eee9b5899472a984d50f44a20c87c1772aeede9b81706000fa66713df34d6e956c88e
+DIST dyld-360.17.tar.gz 518876 SHA256 e137f54d5f7af7512e2e2337248caa0580743db212471de71fd45d3e3e92c68d SHA512 aae2a0ea1f4130de51aa920ce1affa579993b3b58a7d398ec998c0d7ac4919907ba4e508b9bfc15080b1f4f4cf15e4615bc416b6ec32b52a4b5d8fbbad1dc9ab WHIRLPOOL 2c3cc5fe0063b0a6ad1cc77e5ae1204e8bcd23ba732ad775910fe6340a5d908b77d2623fb7fa4eccff20e0e2176405d8d6734b7d60dbba61ccfc58f37009aca7
+DIST dyld-360.18.tar.gz 518957 SHA256 a5bec8c2e3bded111aec7e447b35c110038e822f95e11e55b9a4d331fbaeff08 SHA512 1299bd2dd5cd663917ec4a03ed0f875e0bf07d6680d3d095af12f4b11960c02a52e361bde27ff88843f80832fc6d36654e2556ee0a3ca2259fcded5b568ab2f9 WHIRLPOOL 5b42ea6de3f08b7e0fbad7ea9df512c74fd4bceecf859683297d0cb8998d642ea3a0597ef488dcbf42a75064a07a528baf63c957d36174fddff34d6e6c7502d8
+DIST dyld-421.2.tar.gz 625173 SHA256 e922c4e78af8f7af14dd158f1db986f8eb260403e7a0dc67fa35279d2cfdceb7 SHA512 75f2fb840da980d44649aa3e045f50c4e37d4403fbdb1e2e5f1a85bf6d8859e1130053c3806f7ef992fdfc6573f7f18146263c690144bdd3df31452c6bdd8bd8 WHIRLPOOL cf7093f68ecaf41db2bd8ed5d456183007e5b87b1296f182ffa007464c65248188127c60e2f937faa6fdaba771b9995673bedf22e9b81826c74cf1c50d39360e
+DIST ld64-128.2.tar.gz 494361 SHA256 96a912464e2d4d3d7cdaab0744003b0fa93d139f203c82867f659ee94b4ae9f7 SHA512 f50a3c396e6f4fddc685bb3f59f9a260bd2f47060535d24259b2b411e4f759e48daa35819da682ad9bceaa1b9a1981eb34716387d988cdc4b7eec9ab2169726e WHIRLPOOL 78dec40124ae11c80483b362860b01c833fcaff67bae6b6cb3b72371daffdf3be809186f5daca4bb6ace77441cb43168939eb60eedf9f8c05ae3ec644c2a0502
+DIST ld64-236.3.tar.gz 624400 SHA256 8ef36729b643201081ab45ebd8586ede8f9968bc17614b679a940faa82875ca6 SHA512 e103fc5efd4d4161c7dc55b1ad53aebd455cfcd72de7873ebfdf5ba896b7b0da9c9aeb12e1e1a76425768ac1dc85d864a4ce33b5b841ba115eeab96a2e2965aa WHIRLPOOL d122e325518860c810b9efde7016ebecb6b59c56bb40ae1f041a840be764a5d9b90c7db1922fd9037c18f4caae7ace0d395591ffb3db704c87b92837ef997a17
+DIST ld64-241.9.tar.gz 639944 SHA256 3594e87c626c3b5abab6470cac6f27b367f1efcee60eb3d0f6b6d4ecf9b24230 SHA512 6958e7064f4fd8b47501225fc4cbc6292e5da63d7f4103ad79add177ef7382c8de3c732f14d19a9c11356b8070f578392383caccc3795e2ab8ef7b7ddbde88da WHIRLPOOL 5b07a336efde52b00b2601866907513517593a113583f05a9c45b98b4d6f394d87add887a7e44a95f462b6c2b5617ce497376b94a523e5cdf0f69d4d10ef3407
+DIST ld64-242.tar.gz 641597 SHA256 bec1a5e20b599d108be0017736833c1f6212ea26c67f20d8437abc5d23433c36 SHA512 bde2eee69ada7f81d5e97762c371661f304372d5461da4bd843c76d0abcab518193fa71b917850af2022e586a756a3624a0ad28debfa8de6777e3c255d83dd34 WHIRLPOOL d4c54f2a145386fd90a8a12f08010e31a84912c5f11e4a48e08497f282449cc9eb053855f302cf0353035bb2a6513aaed92737ab60c8b3a6bb3a1af626adf475
+DIST ld64-253.3.tar.gz 671087 SHA256 76c02f6f297c251b66504e1115946bda6e1618640bc6cf03d0ad99b17bd8a5d6 SHA512 ce2c86f2f37ee37bd417315ba51815707b0ca6f24da06819fd1b2d0b4fe0762e45a08c3faf2c0c980e4913c9cbfbf6c8185f9a6810cfa1d9dad231b5bb276081 WHIRLPOOL 7e168bb6dc1474d26da77ca6afde1b591781eb5c0a7a50530b334e4ed6dc0206a2d047375d7d924aa05ccc0912ec8ee966874a9324c66820c454ebd173d1520e
+DIST ld64-253.6.tar.gz 671838 SHA256 7fbae5e88ac1420480de8a495dcd3b876d399278bfce9ffbef7d54334dd80b4a SHA512 40b29e273ed3d69e4f92593cadea831fd618452d3f05e30c0b836ffc05db61fd345cb2f6d63271563c786ecabd47f19f8369456cbe6422800117a53c654a98c6 WHIRLPOOL b687166038f0ad3dd65a623c91aa7204025ab371b90d5be57fff3bf8f8d89df93aaf8d781fd3a950ced4deab667917a379ad5ac479d25fb00644a02950c118cd
+DIST ld64-253.9.tar.gz 673388 SHA256 8fa3a1b65f665824ac129c02e2fab8926a06e503ec277ea32cd8bc27c8de11c3 SHA512 a52b081295c19f28858f8ee47c05249bba3e15cc8bb6f7017d9f6dcf7509cdacef7a4b16b3940cd0b1f72b3b67efb503ab2e3801b31e50cda1d34c6bc8df8dcf WHIRLPOOL 07e850984d2ff24637a64d76860799136e63af56dc2740f8d1e1bd3311ae3f33eac902e7850f94555407002d0d16f44d4a276470f54e60a0633169b884b7dfc1
+DIST ld64-264.3.101.tar.gz 681491 SHA256 2882f0c104334bdba8eb64cd3a9f9059ceca4d4e0c08473506a926d53c9ef218 SHA512 ffa37af95f1a6e76829d0ac8badfd0236d93dc2f9988c7f4b88fe271b7b02a4b5553402a1e9a49feed9da4d04a50e2a2cacdb1bd4c04ecbef09d68b85a2e8a6a WHIRLPOOL cdc466a24fdbc2bf3756d73f89f91d26fec21d8004a2e77804e2b678a9da08afe83bb5aa9fb4548496feb3d9180c3d2521a8d5329b875ed76d4e3a0ea231d5be
+DIST ld64-264.3.102.tar.gz 681509 SHA256 307f73678a3e5c9ed4d1bcf77da7399d84efac32916c5df6cd477c3b5c36f953 SHA512 ec221de3624dcce3db694ec2d7b05f3c939cd1ba79c97437ba9f2d4e5d9c37369bb5df82cc37bc158bf5c4e2128cc2b96ca1a7477f98538850092bffa4601da0 WHIRLPOOL 509774429d498c4a070a54798715776eddf2b8ef70a99dd4250d60144efa2d4a6a324914112556435709beb614172dd45b860f3963b0da9a0825cb0756bcd719
+DIST ld64-274.1.tar.gz 670493 SHA256 6cbe886717de833789fa562ec4889ebf9136ae5f7573d17d39836d3f5755b7ab SHA512 ef5d6802f759e09aa2dfab7eb84e9cd2a57b28da3f150833cf1a922c395dd696e501b1bcb10385cbe995f4945fc6c99c2d2d8c50c42f369186bdc1ac3e30ad99 WHIRLPOOL 5b98613419f304cca05d7e626a33a93b08e991cbdf5a9b76891656e8b5757937e930bdc047ceb60a345a11ee195c641af5d2ec7b3d731530050be160c82d6a93
+DIST ld64-274.2.tar.gz 671652 SHA256 175d89c419e99d49a7a5f7e4196d3cef4c9e19cc17a425c332e86df6b516f7d7 SHA512 7b4e17f199909450b697bf719564c6841d46f5116c48dd47ff483ae7ddfe2965db1b7c024ed8ebeeaf90cd983ed353b95f7f23c93c8971536977dc892e6d6a9d WHIRLPOOL 30f935d1f49769a851871f6fc4d7210409122d910651835c3568c0fb22111bdc4c2419413a5808aa95dc6a840f856eefe7c5a3d8215470cf8f1b4b4432c40494
+DIST libunwind-30.tar.gz 82811 SHA256 6ac97d18cc2b05e6de1269bf5af03b81948bd2200dae827527f3dc618b82bd41 SHA512 57106eafa1516791b4e0db2de6c6336bc0c1cbd8bf098a6d3a809fafa457802c95a7aeae9137f4ca5922a3018dfd8f597907ea4187b0afbbf267500eae00041f WHIRLPOOL c3caf5ba593cffa2f0a9cdb256f518524e9500eaf0a013c4973dc9881b16efa0c388e70407bbed1fd331f100af2da01ddeee12d33b3afc1213d69c32ab5e1d0b
+DIST libunwind-35.3.tar.gz 90002 SHA256 2bcc95553a44fa3edca41993ccfac65ba267830cb37c85dca760b34094722e56 SHA512 b7d9a86ef24f1fe9ca14517471e03a910219a229af9f0d4cf94435115971360640451107ba20c93fb1aab788f8b6eb5ed580ee08fdaa990b9fa43e9ae360c6b4 WHIRLPOOL 838912e46031b3a6796bfe854f0244991ce5bc3b59b95855224c9e84639e57b69f541b7993658360721423533dca75037248ea90f5e274b332f27319fdd85a9a
+EBUILD binutils-apple-4.3-r2.ebuild 10300 SHA256 e0354ffd23ac9c92c0a10214dc0c65aab687f74ac91c4b0510bc54ee3b2e6ba1 SHA512 7709d446c90b3c7dd3131c952249b85817b65613182ba47411a41213951e46dd080c2559e552bdb386f388bcc2306b333963c6489cab8fc24248eb5b7c95ef74 WHIRLPOOL d90b36b3a1e0538277c24d9486863ba69970181cbc1ac80de5ae24df184e08602f9082576b39463c2b47076ce50d07087bea95490eca0d26fd80c29426163007
+EBUILD binutils-apple-5.1-r1.ebuild 12194 SHA256 eee6cf99d127c0e0b8b63c52c9915c7c2cfd61705b1daf7049c85a91213cde35 SHA512 d50b50c71822bb9d341790318133ddaf6d5342be77dd3649c1af1cd4d9c223e119fad46b87ef0465d2ebf3e768e5b4c6425b73100b94d78f0595fcf2ea4c7240 WHIRLPOOL 1c018ad8c6d100dcae48807d6de1bd941c894f92d91e03c59798a0137ddbd1a7b8f5f0df1bdc5f59b804adda888a0983346936123ac796e9197000ecd0f20431
+EBUILD binutils-apple-6.1-r1.ebuild 12268 SHA256 e5caa4a596f2d7befec95bc391f816a2b1e63bc6af512e2c09d465fb53e23539 SHA512 1b6ab3f9ec1892b73ceab616b0ccc6de778ce008989bb28864943bad416dd8fa8654b01e7613cc35852df616a999f04acda4cfe3e6945ae021a9df8454894a8b WHIRLPOOL dbb8daf769676ca43f8c47887e3e0232a73f4ab8ab7aed450658eaa9f9983a166c8cbac129dc2d4d55c6657eaaca734f4e68f1c426d4378920d631909df3f440
+EBUILD binutils-apple-6.3-r1.ebuild 11973 SHA256 268e7a2d9ea1a49eecea3dae98f6fb88b2f1b3cb6975b9cecdc2c8483f8bd875 SHA512 1b47c66c969d91372f1e919c091548e7f3b2dae8de97afb2fc86b0e49cf5091ac935fbbebb264a362e351e3497f6816d51b046557c8530620aeba89a72872ddb WHIRLPOOL 9a11e9e3d8a6af4a454119b69de1d0222e3b6c3b232fdf9a6c0d74bbd15b6a5fe48009e903f8f10a203717fbd83fb56bdbaa30bf73a2863d53eb0012fbb6c7f3
+EBUILD binutils-apple-7.0-r1.ebuild 11966 SHA256 d2342e0d0b004b2876c733599414a33e1d5e27234d57c09d90dc20b35c3bfd1e SHA512 48e7cf9eef8228e6c7968c4d82c5bf6aab3591f4920481a1704a9979d1210b0993ae54d9877c0c1fc7c4a4bfb92854feaa0a42f485bc55e4b0aea3b47c694f71 WHIRLPOOL 0c4d24e7fbb34361b774a7c1b5bdd45d0439e7c84d67d3b2cb08c10ddefcf19547287756a01ac56464af5251d1265d72ac6979272209086d9f08efb64a070bef
+EBUILD binutils-apple-7.0.ebuild 12071 SHA256 f23c9166ad1a5ab6ddaca488cf1c04e65622347bfa14c1f008711af167a6e60e SHA512 e0c106f0972211f33500e5de2ba0cb48bc0119a4cf581c146ca5e7453d2ecc0102c5a1c82a835555ea87179c9eafd3d82aa078e91338a2364d0fb8c70dbb07c2 WHIRLPOOL f4b4078395b6776397a1c6016687d01f9cae003edb4df8d9a4d3b97a8834e2d1054da49b1b7dfc7ed40f1cff7262f0b2901c31de6910bb17865d29bde24a489d
+EBUILD binutils-apple-7.1-r1.ebuild 11966 SHA256 d7e5c3ef29321fc5b7a48ebb69d6f94001ec5449f3eaea5fbd9a095e908b638b SHA512 bc66d390a90d5ab79b80d7e3416816595e2be783dc2b597ea378b77137d2d1958f2292c755e2f2895cfb73c86118f4a200497c8e4b17a71aac66628fcae6937e WHIRLPOOL 79769e322722bc7771b06954fefdecdd31c894a765a2bcee68f73f88c710063bd437a9802fab74c2b913c7c483c175cccd69d7735f2b7f9b4f0bfe2fe556dc04
+EBUILD binutils-apple-7.1.ebuild 12071 SHA256 91931389eaf76ddb3e06f1804825eaba393060b8c782453ba9f90ff5a356f669 SHA512 9f78728988f1c002751790bd4228d3540d56e1998a18b610cba0ec2a1af197f18df3ccd630ccdafb3be5ae4bed938219e420a15576b61af50d3d500ad1c9ad68 WHIRLPOOL bbb053bd6b0ddcfc6661ae375ced4247b34fcf724f79d292fb998a9ba4149856166b6d8138dac258157ab50b119c600bda53c8f4122cb2eec9c9d8343be50b65
+EBUILD binutils-apple-7.2-r1.ebuild 12038 SHA256 84638377d89b6ed3a78f11c585adcc9049c43d715b91f3d8099e1ca1d458d7a8 SHA512 f45fa298c8bf1c3fdd208db195e97331f8f3e84b3d675f450a812563a96dfb49de6b369ab75e393b6ce43e9ba8d4dd47a9d860ee9dc722ed591b41e63dc1ce0a WHIRLPOOL 425e7228eac7dd3a289c558a344f40646ac502baa1b2f1ec029686425a602521d5bee9b0406d65ae4cf654a725f5f1d8481965427eedd029fe3808c8e57ca20f
+EBUILD binutils-apple-7.2.ebuild 12071 SHA256 c7ca7d5614661e9c38b0dbc6777eea39ab123eef0e2e48db79557399c5a5b6c3 SHA512 c73b4a136143bdb379e762575af1c1db057527b6d2fe05bf1e971297b0057a04fa7e75bc0fe4629030046a9d28ef1a7a664101800318704768d3038117aca219 WHIRLPOOL c1691eca53161787ce6f8ada0a77b157ee3ab3d8bc0c33da6cd32f35fd4dc67cebe7c22764b700def680007d8de59db895f4e8eb8a205c74fa7c0650486f656c
+EBUILD binutils-apple-7.3.1.ebuild 13250 SHA256 6b1492d69edc8854005751ed7db06c1afb1fed8d34c844b7194bf6239920e1e5 SHA512 8fd675d434a9522b3d2a0bca532ce788070ee3dc828eb0bdcb03e4d33391864846996d0c7d4432f52aae946ac0cabdd44edf9dc6ce9913aefc95ca01a2c04fd3 WHIRLPOOL aca1c3d20a704121f6341b8eeceb6b6cbe33a36d7513f9b2a62f94b2e2273864f4f09ae01d0519d2f28febe2fd55c8c409b0fc9c9564fd323521bd71919861ad
+EBUILD binutils-apple-7.3.ebuild 12902 SHA256 4f2f8c77d62f1338b829ce2f1028d0c17a5fd429975fcd7c137fa0c251809729 SHA512 12dfdbf609eba1d7225cd5dbbcbe18d0355d438f94cddf7616bb21a60d780cff2a13df678784ea97c3631948d6a73c1453cc59e069e4fd6e9bcfae598ee1bb87 WHIRLPOOL 283f2b68a26dcee3c88d02e1e1e75d534dd508ecb042143eb91f6ac35b140708f39da96b83693e09578907a968a7eeb411ee71e4f1875adaa8773b909195a6b0
+EBUILD binutils-apple-8.1.ebuild 10435 SHA256 1cbf1c4b457b0f164edc219f03e7de58d22bd22edb19feba24d7931b10fb2da7 SHA512 f27d9a19b2fd903cb888d64e481400d48919745c4f9b40953cd4188de25fe5d9f338735dfcfa5fc4b9d5bf20662425aa3a0f4a3b2c2de04f8faba0af5d1c044b WHIRLPOOL 2669f18344580bd711a14c3d93503489acc5eb7a9c1dda85f89a676dbf40ca089cd3fe1192b52cd296e67b7f4be6b41f283da1d7781df1fdfdf934671a642627
+EBUILD binutils-apple-8.2.1.ebuild 10435 SHA256 3a861945f5eeccb766e8692ea233971d48548f226d51cdcf18d106e444339b87 SHA512 92b8176fb8ad383833a25c6b49e57a8bd41b3a9615fb4bd84d32ce1a00f269410f6e2306b2664f713f4ec399288d383a9e5358718257fce2da6574652f41ab0d WHIRLPOOL 84aee3828d169e97be1ad02a4b25eacb5f7a348c41e4d04408b783654b5d68ea0374013b33e6f6880f583f25be75104702198b58ee1f73ac4ca819098e6d0d67
+MISC ChangeLog 12708 SHA256 9523a1b7308bea60f60e0ed1b417e41ffbd36b777d4d18edebd61451f1db2ef3 SHA512 b7d49532a5e74787a969121b493db1afa059f6b71c8545810e3dbf2c89c7b3753d7974e0b2e3021ead9ca9f130cf473802a45916b0ecb56ed342e001f91cbc01 WHIRLPOOL a978b12d8955ab8ab19870482a0a8999056ef23e049137fc3ca45f4f52df1dd91e48d54e2b528becb96f2a683bc38fb3defff17bfc2334cf2ef867956e3774c9
+MISC ChangeLog-2015 14762 SHA256 00a025a8653554e0d3d6f2fbb3f45531faafeda0f222c792c428134df2c36d42 SHA512 aee75b6f20ca20b565afc8f701a131691b24238669c1abfdd82dbfd536ceb6f59ccb83f7b88be89e174550516d7790fc58964233250620c86c1ed94785b098a4 WHIRLPOOL c310ac0be33a5fffe79029881fdc154f5f5050d2cc9629da516e41c7fef2247fc5de54d3307867e45273d85052224e88e5c9453485dc8bc31cef5843c2510d79
+MISC metadata.xml 684 SHA256 b4b5e9590a82f115301dcfbd3874c53c52029d3a7b14e67670e82dd81e7b0b0f SHA512 e588cb802b2b22ee656b9dcf45d9d372a3b306fa3574a7d859e2df9032eeeab63219a9d9b69249a5a67733dff4c484da17621f00d2b0775935f2cfa5a6f91977 WHIRLPOOL 0fa0a4f4202f4a8d91e76ac99cd6ca477e0dd4c74a524a7069d603dcb6f5603b29c5ea0174c35f1db7275374f8844e0a76e0c0c860c0cdf041aee92223a55ccc
diff --git a/sys-devel/binutils-apple/binutils-apple-4.3-r2.ebuild b/sys-devel/binutils-apple/binutils-apple-4.3-r2.ebuild
new file mode 100644
index 000000000000..5131c4f35b99
--- /dev/null
+++ b/sys-devel/binutils-apple/binutils-apple-4.3-r2.ebuild
@@ -0,0 +1,337 @@
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI="5"
+
+inherit eutils flag-o-matic toolchain-funcs
+
+LD64=ld64-128.2
+CCTOOLS_VERSION=822
+CCTOOLS=cctools-${CCTOOLS_VERSION}
+CCTOOLS_HEADERS=cctools-855
+LIBUNWIND=libunwind-30
+DYLD=dyld-195.6
+
+DESCRIPTION="Darwin assembler as(1) and static linker ld(1), Xcode Tools ${PV}"
+HOMEPAGE="http://www.opensource.apple.com/darwinsource/"
+SRC_URI="http://www.opensource.apple.com/tarballs/ld64/${LD64}.tar.gz
+ http://www.opensource.apple.com/tarballs/cctools/${CCTOOLS}.tar.gz
+ http://www.opensource.apple.com/tarballs/cctools/${CCTOOLS_HEADERS}.tar.gz
+ http://www.opensource.apple.com/tarballs/libunwind/${LIBUNWIND}.tar.gz
+ http://www.opensource.apple.com/tarballs/dyld/${DYLD}.tar.gz
+ https://dev.gentoo.org/~grobian/distfiles/${PN}-patches-4.3-r1.tar.bz2"
+
+LICENSE="APSL-2"
+KEYWORDS="~ppc-macos ~x64-macos ~x86-macos"
+IUSE="lto test multitarget"
+
+RDEPEND="sys-devel/binutils-config
+ lto? ( sys-devel/llvm )"
+DEPEND="${RDEPEND}
+ test? ( >=dev-lang/perl-5.8.8 )
+ || ( >=sys-devel/gcc-apple-4.2.1 sys-devel/llvm )"
+
+SLOT="4"
+
+S=${WORKDIR}
+
+is_cross() { [[ ${CHOST} != ${CTARGET} ]] ; }
+
+src_prepare() {
+ if use multitarget ; then
+ ewarn "You have enabled support for non-standard target architectures"
+ ewarn "using USE=multitarget. This includes experimental support for"
+ ewarn "ppc and ppc64 which is a community forward-port from the last"
+ ewarn "version of ld64 to officially support PPC."
+
+ if [[ ${CHOST} == powerpc*-darwin* ]] ; then
+ ewarn "HERE BE DRAGONS! Your system seems to be PPC which means that"
+ ewarn "the actual usability of your Gentoo programs will depend on the"
+ ewarn "above-mentioned experimental PPC support in the linker. Be"
+ ewarn "sure to keep a known-to-work version like ${PN}-3.2.6 around!"
+ fi
+ fi
+
+ cd "${S}"/${LD64}/src
+ cp "${S}"/ld64-128.2-Makefile-3 Makefile
+ epatch "${S}"/ld64-127.2-lto.patch
+ epatch "${S}"/ld64-128.2-stdlib.patch
+ epatch "${S}"/ld64-241.9-register-names.patch
+ epatch "${S}"/ld64-241.9-get-comm-align.patch
+ epatch "${S}"/ld64-241.9-cc_md5.patch
+ epatch "${S}"/ld64-128.2-1010.patch
+ epatch "${S}"/ld64-128.2-ppc.patch
+
+ # We used to use our own copy of lto.h, which doesn't require llvm
+ # build-env. Current versions of llvm provide
+ # $EPREFIX/usr/include/llvm-c/lto.h as well as
+ # $EPREFIX/usr/lib/libLTO.{so,dylib}, so we just use these.
+
+ # provide missing headers from libunwind and dyld
+ mkdir -p include/{mach,mach-o/arm} || die
+ # never present because it's private
+ cp ../../${DYLD}/include/mach-o/dyld_priv.h include/mach-o || die
+ # missing on <= 10.5
+ cp ../../${LIBUNWIND}/include/libunwind.h include/ || die
+ cp ../../${LIBUNWIND}/include/mach-o/compact_unwind_encoding.h include/mach-o || die
+ # missing on <= 10.4
+ cp ../../${DYLD}/include/mach-o/dyld_images.h include/mach-o || die
+ cp ../../${CCTOOLS}/include/mach-o/loader.h include/mach-o || die
+ # use copies from cctools because they're otherwise hidden in some SDK
+ cp ../../${CCTOOLS}/include/mach-o/arm/reloc.h include/mach-o/arm || die
+ # provide all required CPU_TYPEs on all platforms
+ cp ../../${CCTOOLS}/include/mach/machine.h include/mach/machine.h
+ # add alias for newer identifiers, because ld64 uses both but cctools
+ # header only defines the older
+ epatch "${S}"/ld64-236.3-missing-cputypes.patch
+
+ # mimic OS X Leopard-style Availability.h macros for libunwind.h on
+ # older systems
+ [[ ${CHOST} == *darwin* && ${CHOST#*-darwin} -le 8 ]] && \
+ echo "#define __OSX_AVAILABLE_STARTING(x,y) " > include/Availability.h
+
+ local VER_STR="\"@(#)PROGRAM:ld PROJECT:${LD64} (Gentoo ${PN}-${PVR})\\n\""
+ echo "char ldVersionString[] = ${VER_STR};" > version.cpp
+
+ epatch "${S}"/ld64-123.2-debug-backtrace.patch
+ if [[ ${CHOST} == powerpc*-darwin* ]] ; then
+ epatch "${S}"/ld64-123.2-darwin8-no-mlong-branch-warning.patch
+ epatch "${S}"/ld64-127.2-thread_state.patch
+ fi
+
+ cd "${S}"/${CCTOOLS}
+ epatch "${S}"/${PN}-4.0-as.patch
+ epatch "${S}"/${PN}-4.2-as-dir.patch
+ epatch "${S}"/${PN}-3.2.3-ranlib.patch
+ epatch "${S}"/${PN}-3.1.1-libtool-ranlib.patch
+ epatch "${S}"/${PN}-3.1.1-nmedit.patch
+ epatch "${S}"/${PN}-3.1.1-no-headers.patch
+ epatch "${S}"/${PN}-4.0-no-oss-dir.patch
+ epatch "${S}"/${PN}-4.2-lto.patch
+ epatch "${S}"/${PN}-5.1-extraneous-includes.patch
+ epatch "${S}"/${PN}-5.1-thread-state-redefined.patch
+ epatch "${S}"/${PN}-4.3-makefile-target-warning.patch
+ epatch "${S}"/${PN}-4.3-lto-prefix.patch
+ cp ../${LD64}/src/other/prune_trie.h include/mach-o/ || die
+ # __darwin_i386_float_state missing on <= 10.4
+ cp -a ../${CCTOOLS_HEADERS}/include/mach/i386 include/mach
+
+ # do not build profileable libstuff to save compile time
+ sed -i -e "/^all:/s, profile , ," libstuff/Makefile
+
+ # cctools version is provided to make via RC_ProjectSourceVersion which
+ # generates and compiles it as apple_version[] into libstuff. From
+ # there it's picked up by the individual tools. Since
+ # RC_ProjectSourceVersion is also used as library version, we can't
+ # just append our local version info. So we hack the libstuff Makefile
+ # to include our Gentoo version.
+ sed -i -e "/cctools-.*(RC_ProjectSourceVersion).*OFILE_DIR/s,Version),Version) (Gentoo ${PN}-${PVR})," \
+ libstuff/Makefile
+
+ # clean up test suite
+ cd "${S}"/${LD64}/unit-tests/test-cases
+ local c
+
+ # we don't have llvm
+ ((++c)); rm -rf llvm-integration;
+
+ # we don't have dtrace
+ ((++c)); rm -rf dtrace-static-probes-coalescing;
+ ((++c)); rm -rf dtrace-static-probes;
+
+ # a file is missing
+ ((++c)); rm -rf eh-coalescing-r
+
+ # we don't do universal binaries
+ ((++c)); rm -rf blank-stubs;
+
+ # looks like a problem with apple's result-filter.pl
+ ((++c)); rm -rf implicit-common3;
+ ((++c)); rm -rf order_file-ans;
+
+ # TODO no idea what goes wrong here
+ ((++c)); rm -rf dwarf-debug-notes;
+
+ einfo "Deleted $c tests that were bound to fail"
+
+ cd "${S}"
+ ebegin "cleaning Makefiles from unwanted CFLAGS"
+ find . -name "Makefile" -print0 | xargs -0 sed \
+ -i \
+ -e 's/ -g / /g' \
+ -e 's/^G =.*$/G =/' \
+ -e 's/^OFLAG =.*$/OFLAG =/' \
+ -e 's/install -c -s/install/g'
+ eend $?
+}
+
+src_configure() {
+ ENABLE_LTO=0
+ use lto && ENABLE_LTO=1
+
+ export CTARGET=${CTARGET:-${CHOST}}
+ if [[ ${CTARGET} == ${CHOST} ]] ; then
+ if [[ ${CATEGORY} == cross-* ]] ; then
+ export CTARGET=${CATEGORY#cross-}
+ fi
+ fi
+
+ LIBPATH=/usr/$(get_libdir)/binutils/${CTARGET}/${PV}
+ INCPATH=${LIBPATH}/include
+ DATAPATH=/usr/share/binutils-data/${CTARGET}/${PV}
+ if is_cross ; then
+ BINPATH=/usr/${CHOST}/${CTARGET}/binutils-bin/${PV}
+ else
+ BINPATH=/usr/${CTARGET}/binutils-bin/${PV}
+ fi
+
+ # CPPFLAGS only affects ld64, cctools don't use 'em (which currently is
+ # what we want)
+ append-cppflags -DNDEBUG
+
+ CCTOOLS_OFLAG=
+ if [[ ${CHOST} == *darwin* && ${CHOST#*-darwin} -le 8 ]] ; then
+ # cctools expect to use UNIX03 struct member names.
+ # This is default on > 10.4. Activate it on <= 10.4 by defining
+ # __DARWIN_UNIX03 explicitly.
+ CCTOOLS_OFLAG="-D__DARWIN_UNIX03=1"
+ fi
+
+ cat <<EOF > ${LD64}/src/configure.h
+#define DEFAULT_MACOSX_MIN_VERSION "${MACOSX_DEPLOYMENT_TARGET}"
+#define SUPPORT_ARCH_arm_any 1
+EOF
+
+ use multitarget && cat <<EOF >> ${LD64}/src/configure.h
+#define SUPPORT_ARCH_ppc 1
+EOF
+#define SUPPORT_ARCH_ppc64 1
+}
+
+compile_ld64() {
+ einfo "building ${LD64}"
+ cd "${S}"/${LD64}/src
+ emake \
+ LTO=${ENABLE_LTO} \
+ || die "emake failed for ld64"
+ use test && emake build_test
+}
+
+compile_cctools() {
+ einfo "building ${CCTOOLS}"
+ cd "${S}"/${CCTOOLS}
+ # -j1 because it fails too often with weird errors
+ emake \
+ LIB_PRUNETRIE="-L../../${LD64}/src -lprunetrie" \
+ EFITOOLS= \
+ ENABLE_LTO="${ENABLE_LTO}" \
+ COMMON_SUBDIRS='libstuff ar misc otool' \
+ SUBDIRS_32= \
+ LEGACY= \
+ RC_ProjectSourceVersion=${CCTOOLS_VERSION} \
+ RC_CFLAGS="${CFLAGS}" \
+ OFLAG="${CCTOOLS_OFLAG}" \
+ -j1 \
+ || die "emake failed for the cctools"
+ cd "${S}"/${CCTOOLS}/as
+ emake \
+ BUILD_OBSOLETE_ARCH= \
+ RC_ProjectSourceVersion=${CCTOOLS_VERSION} \
+ RC_CFLAGS="-DASLIBEXECDIR=\"\\\"${EPREFIX}${LIBPATH}/\\\"\" ${CFLAGS}" \
+ OFLAG="${CCTOOLS_OFLAG}" \
+ || die "emake failed for as"
+}
+
+src_compile() {
+ compile_ld64
+ compile_cctools
+}
+
+install_ld64() {
+ exeinto ${BINPATH}
+ doexe "${S}"/${LD64}/src/{ld64,rebase,dyldinfo,unwinddump,ObjectDump}
+ dosym ld64 ${BINPATH}/ld
+ insinto ${DATAPATH}/man/man1
+ doins "${S}"/${LD64}/doc/man/man1/{ld,ld64,rebase}.1
+}
+
+install_cctools() {
+ cd "${S}"/${CCTOOLS}
+ emake install_all_but_headers \
+ EFITOOLS= \
+ COMMON_SUBDIRS='ar misc otool' \
+ SUBDIRS_32= \
+ DSTROOT=\"${D}\" \
+ BINDIR=\"${EPREFIX}\"${BINPATH} \
+ LOCBINDIR=\"${EPREFIX}\"${BINPATH} \
+ USRBINDIR=\"${EPREFIX}\"${BINPATH} \
+ LOCLIBDIR=\"${EPREFIX}\"${LIBPATH} \
+ MANDIR=\"${EPREFIX}\"${DATAPATH}/man/
+ cd "${S}"/${CCTOOLS}/as
+ emake install \
+ BUILD_OBSOLETE_ARCH= \
+ DSTROOT=\"${D}\" \
+ USRBINDIR=\"${EPREFIX}\"${BINPATH} \
+ LIBDIR=\"${EPREFIX}\"${LIBPATH} \
+ LOCLIBDIR=\"${EPREFIX}\"${LIBPATH}
+
+ cd "${ED}"${BINPATH}
+ insinto ${DATAPATH}/man/man1
+ local skips manpage
+ # ar brings an up-to-date manpage with it
+ skips=( ar )
+ for bin in *; do
+ for skip in ${skips[@]}; do
+ if [[ ${bin} == ${skip} ]]; then
+ continue 2;
+ fi
+ done
+ manpage=${S}/${CCTOOLS}/man/${bin}.1
+ if [[ -f "${manpage}" ]]; then
+ doins "${manpage}"
+ fi
+ done
+ insinto ${DATAPATH}/man/man5
+ doins "${S}"/${CCTOOLS}/man/*.5
+}
+
+src_test() {
+ if ! [ "${EPREFIX}"/usr/bin/clang ] ; then
+ einfo "Test suite only works properly with clang - please install"
+ return
+ fi
+
+ einfo "Running unit tests"
+ cd "${S}"/${LD64}/unit-tests/test-cases
+ # provide the new ld as a symlink to clang so that -ccc-install-dir
+ # will pick it up
+ ln -sfn ../../src/ld64 ld
+ # use our arch command because the System's will report i386 even for an
+ # x86_64 prefix
+ perl ../bin/make-recursive.pl \
+ BUILT_PRODUCTS_DIR="${S}"/${LD64}/src \
+ ARCH="$(arch)" \
+ LD="${S}"/${LD64}/src/ld64 \
+ CC="clang -ccc-install-dir $PWD" \
+ CXX="clang++ -ccc-install-dir $PWD" \
+ OTOOL="${S}"/${CCTOOLS}/otool/otool.NEW \
+ | perl ../bin/result-filter.pl
+}
+
+src_install() {
+ install_ld64
+ install_cctools
+
+ cd "${S}"
+ insinto /etc/env.d/binutils
+ cat <<-EOF > env.d
+ TARGET="${CHOST}"
+ VER="${PV}"
+ FAKE_TARGETS="${CHOST}"
+ EOF
+ newins env.d ${CHOST}-${PV}
+}
+
+pkg_postinst() {
+ binutils-config ${CHOST}-${PV}
+}
diff --git a/sys-devel/binutils-apple/binutils-apple-5.1-r1.ebuild b/sys-devel/binutils-apple/binutils-apple-5.1-r1.ebuild
new file mode 100644
index 000000000000..507c8b54be16
--- /dev/null
+++ b/sys-devel/binutils-apple/binutils-apple-5.1-r1.ebuild
@@ -0,0 +1,384 @@
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI="5"
+
+inherit eutils flag-o-matic toolchain-funcs
+
+LD64=ld64-236.3
+CCTOOLS_VERSION=855
+CCTOOLS=cctools-${CCTOOLS_VERSION}
+LIBUNWIND=libunwind-35.3
+DYLD=dyld-353.2.1
+
+DESCRIPTION="Darwin assembler as(1) and static linker ld(1), Xcode Tools ${PV}"
+HOMEPAGE="http://www.opensource.apple.com/darwinsource/"
+SRC_URI="http://www.opensource.apple.com/tarballs/ld64/${LD64}.tar.gz
+ http://www.opensource.apple.com/tarballs/cctools/${CCTOOLS}.tar.gz
+ http://www.opensource.apple.com/tarballs/dyld/${DYLD}.tar.gz
+ http://www.opensource.apple.com/tarballs/libunwind/${LIBUNWIND}.tar.gz
+ https://dev.gentoo.org/~grobian/distfiles/${PN}-patches-4.3-r1.tar.bz2
+ https://dev.gentoo.org/~grobian/distfiles/${PN}-patches-5.1-r2.tar.bz2"
+
+LICENSE="APSL-2"
+KEYWORDS="~ppc-macos ~x64-macos ~x86-macos"
+IUSE="lto test libcxx multitarget"
+
+RDEPEND="sys-devel/binutils-config
+ lto? ( sys-devel/llvm )
+ libcxx? ( sys-libs/libcxx )"
+DEPEND="${RDEPEND}
+ test? ( >=dev-lang/perl-5.8.8 )
+ || ( >=sys-devel/gcc-apple-4.2.1 sys-devel/llvm )
+ libcxx? ( sys-devel/llvm )"
+
+SLOT="5"
+
+S=${WORKDIR}
+
+is_cross() { [[ ${CHOST} != ${CTARGET} ]] ; }
+
+src_prepare() {
+ if use multitarget ; then
+ ewarn "You have enabled support for non-standard target architectures"
+ ewarn "using USE=multitarget. This includes experimental support for"
+ ewarn "ppc and ppc64 which is a community forward-port from the last"
+ ewarn "version of ld64 to officially support PPC."
+
+ if [[ ${CHOST} == powerpc*-darwin* ]] ; then
+ ewarn "HERE BE DRAGONS! Your system seems to be PPC which means that"
+ ewarn "the actual usability of your Gentoo programs will depend on the"
+ ewarn "above-mentioned experimental PPC support in the linker. Be"
+ ewarn "sure to keep a known-to-work version like ${PN}-3.2.6 around!"
+ fi
+ fi
+
+ cd "${S}"/${LD64}/src
+ cp "${S}"/ld64-136-compile_stubs.h ld/compile_stubs.h
+ cp "${S}"/ld64-236.3-Makefile-2 Makefile
+
+ epatch "${S}"/ld64-236.3-nolto.patch
+ epatch "${S}"/ld64-241.9-extraneous-includes.patch
+ epatch "${S}"/ld64-241.9-osatomic.patch
+ epatch "${S}"/ld64-236.3-arm64-fixup.patch
+ epatch "${S}"/ld64-241.9-arm64-cputype.patch
+ epatch "${S}"/ld64-236.3-crashreporter.patch
+ epatch "${S}"/ld64-236.3-nosnapshots.patch
+ epatch "${S}"/ld64-236.3-ppc.patch
+ epatch "${S}"/ld64-236.3-constant-types-2.patch
+ epatch "${S}"/ld64-236.3-gcc-2.patch
+ epatch "${S}"/ld64-241.9-register-names.patch
+ epatch "${S}"/ld64-241.9-get-comm-align.patch
+ epatch "${S}"/ld64-241.9-cc_md5.patch
+ epatch "${S}"/ld64-253.3-delete-warning.patch
+
+ # We used to use our own copy of lto.h, which doesn't require llvm
+ # build-env. Current versions of llvm provide
+ # $EPREFIX/usr/include/llvm-c/lto.h as well as
+ # $EPREFIX/usr/lib/libLTO.{so,dylib}, so we just use these.
+
+ # provide missing headers from libunwind and dyld
+ mkdir -p include/{mach,mach-o/arm} || die
+ # never present because it's private
+ cp ../../${DYLD}/include/mach-o/dyld_priv.h include/mach-o || die
+ # missing on <= 10.5
+ cp ../../${LIBUNWIND}/include/libunwind.h include/ || die
+ cp ../../${LIBUNWIND}/include/mach-o/compact_unwind_encoding.h include/mach-o || die
+ # missing on <= 10.4
+ cp ../../${DYLD}/include/mach-o/dyld_images.h include/mach-o || die
+ cp ../../${CCTOOLS}/include/mach-o/loader.h include/mach-o || die
+ # use copies from cctools because they're otherwise hidden in some SDK
+ cp ../../${CCTOOLS}/include/mach-o/arm/reloc.h include/mach-o/arm || die
+ # provide all required CPU_TYPEs on all platforms
+ cp ../../${CCTOOLS}/include/mach/machine.h include/mach/machine.h
+ # add alias for newer identifiers, because ld64 uses both but cctools
+ # header only defines the older
+ epatch "${S}"/ld64-236.3-missing-cputypes.patch
+
+ # mimic OS X Leopard-style Availability.h macros for libunwind.h on
+ # older systems
+ [[ ${CHOST} == *darwin* && ${CHOST#*-darwin} -le 8 ]] && \
+ echo "#define __OSX_AVAILABLE_STARTING(x,y) " > include/Availability.h
+
+ local VER_STR="\"@(#)PROGRAM:ld PROJECT:${LD64} (Gentoo ${PN}-${PVR})\\n\""
+ echo "char ldVersionString[] = ${VER_STR};" > version.cpp
+
+ epatch "${S}"/ld64-123.2-debug-backtrace.patch
+ if [[ ${CHOST} == powerpc*-darwin* ]] ; then
+ epatch "${S}"/ld64-123.2-darwin8-no-mlong-branch-warning.patch
+ epatch "${S}"/ld64-127.2-thread_state.patch
+ fi
+
+ cd "${S}"/${CCTOOLS}
+ epatch "${S}"/${PN}-4.5-as.patch
+ epatch "${S}"/${PN}-5.1-as-dir.patch
+ epatch "${S}"/${PN}-5.1-ranlib.patch
+ epatch "${S}"/${PN}-3.1.1-libtool-ranlib.patch
+ epatch "${S}"/${PN}-3.1.1-no-headers.patch
+ epatch "${S}"/${PN}-4.0-no-oss-dir.patch
+ epatch "${S}"/${PN}-5.1-nolto.patch
+ epatch "${S}"/cctools-839-intel-retf.patch
+ epatch "${S}"/${PN}-5.1-extraneous-includes.patch
+ epatch "${S}"/${PN}-5.1-otool-stdc.patch
+ epatch "${S}"/${PN}-5.1-constant-types.patch
+ epatch "${S}"/${PN}-5.1-strnlen.patch
+ epatch "${S}"/${PN}-5.1-ppc.patch
+ epatch "${S}"/${PN}-5.1-thread-state-redefined.patch
+ epatch "${S}"/${PN}-5.1-makefile-target-warning.patch
+ epatch "${S}"/${PN}-5.1-lto-prefix.patch
+ cp ../${LD64}/src/other/prune_trie.h include/mach-o/ || die
+
+ # do not build profileable libstuff to save compile time
+ sed -i -e "/^all:/s, profile , ," libstuff/Makefile
+
+ # cctools version is provided to make via RC_ProjectSourceVersion which
+ # generates and compiles it as apple_version[] into libstuff. From
+ # there it's picked up by the individual tools. Since
+ # RC_ProjectSourceVersion is also used as library version, we can't
+ # just append our local version info. So we hack the libstuff Makefile
+ # to include our Gentoo version.
+ sed -i -e "/cctools-.*(RC_ProjectSourceVersion).*OFILE_DIR/s,Version),Version) (Gentoo ${PN}-${PVR})," \
+ libstuff/Makefile
+
+ # clean up test suite
+ cd "${S}"/${LD64}/unit-tests/test-cases
+ local c
+
+ # we don't have llvm
+ ((++c)); rm -rf llvm-integration;
+
+ # we don't have dtrace
+ ((++c)); rm -rf dtrace-static-probes-coalescing;
+ ((++c)); rm -rf dtrace-static-probes;
+
+ # a file is missing
+ ((++c)); rm -rf eh-coalescing-r
+
+ # we don't do universal binaries
+ ((++c)); rm -rf blank-stubs;
+
+ # looks like a problem with apple's result-filter.pl
+ ((++c)); rm -rf implicit-common3;
+ ((++c)); rm -rf order_file-ans;
+
+ # TODO no idea what goes wrong here
+ ((++c)); rm -rf dwarf-debug-notes;
+
+ einfo "Deleted $c tests that were bound to fail"
+
+ cd "${S}"
+ ebegin "cleaning Makefiles from unwanted CFLAGS"
+ find . -name "Makefile" -print0 | xargs -0 sed \
+ -i \
+ -e 's/ -g / /g' \
+ -e 's/^G =.*$/G =/' \
+ -e 's/^OFLAG =.*$/OFLAG =/' \
+ -e 's/install -c -s/install/g'
+ eend $?
+}
+
+src_configure() {
+ ENABLE_LTO=0
+ use lto && ENABLE_LTO=1
+
+ export CTARGET=${CTARGET:-${CHOST}}
+ if [[ ${CTARGET} == ${CHOST} ]] ; then
+ if [[ ${CATEGORY} == cross-* ]] ; then
+ export CTARGET=${CATEGORY#cross-}
+ fi
+ fi
+
+ LIBPATH=/usr/$(get_libdir)/binutils/${CTARGET}/${PV}
+ INCPATH=${LIBPATH}/include
+ DATAPATH=/usr/share/binutils-data/${CTARGET}/${PV}
+ if is_cross ; then
+ BINPATH=/usr/${CHOST}/${CTARGET}/binutils-bin/${PV}
+ else
+ BINPATH=/usr/${CTARGET}/binutils-bin/${PV}
+ fi
+
+ if [ "${CXX/*clang*/yes}" = "yes" ] ; then
+ if use libcxx ; then
+ append-cxxflags -stdlib=libc++
+ CXXLIB=-stdlib=libc++
+ else
+ # force libstdc++ for systems where libc++ is default (OS X 10.9+?)
+ append-cxxflags -stdlib=libstdc++
+ CXXLIB=-stdlib=libstdc++
+ fi
+ else
+ use libcxx && \
+ ewarn "libcxx only available with clang and your C++ compiler ($CXX) does not seem to be clang"
+ fi
+
+ # CPPFLAGS only affects ld64, cctools don't use 'em (which currently is
+ # what we want)
+ append-cppflags -DNDEBUG
+
+ # Block API and thus snapshots supported on >= 10.6
+ [[ ${CHOST} == *darwin* && ${CHOST#*-darwin} -ge 10 ]] && \
+ append-cppflags -DSUPPORT_SNAPSHOTS
+
+ CCTOOLS_OFLAG=
+ if [[ ${CHOST} == *darwin* && ${CHOST#*-darwin} -le 8 ]] ; then
+ # cctools expect to use UNIX03 struct member names.
+ # This is default on > 10.4. Activate it on <= 10.4 by defining
+ # __DARWIN_UNIX03 explicitly.
+ CCTOOLS_OFLAG="-D__DARWIN_UNIX03=1"
+ fi
+
+ # if compiling with USE multitarget, extract all the known arches from
+ # create_configure and pass them back to it
+ creco=${LD64}/src/create_configure
+ ARCHS_TO_SUPPORT=""
+ if use multitarget ; then
+ ARCHS_TO_SUPPORT="$(grep KNOWN_ARCHS= $creco | \
+ cut -d\" -f2 | tr ',' ' ')"
+ fi
+
+ # Create configure.h for ld64 with SUPPORT_ARCH_<arch> defines in it.
+ DERIVED_FILE_DIR=${LD64}/src \
+ RC_SUPPORTED_ARCHS="$ARCHS_TO_SUPPORT" \
+ $creco
+
+ # do not depend on MachOFileAbstraction.hpp to define
+ # SUPPORT_ARCH_arm_any because that's not included by every file where
+ # our ppc/arm-optional patch uses it, ld.hpp in particular
+ grep "SUPPORT_ARCH_armv[0-9]" ${LD64}/src/configure.h >/dev/null && \
+ echo "#define SUPPORT_ARCH_arm_any 1" >> ${LD64}/src/configure.h
+}
+
+compile_ld64() {
+ einfo "building ${LD64}"
+ cd "${S}"/${LD64}/src
+ emake \
+ LTO=${ENABLE_LTO} \
+ || die "emake failed for ld64"
+ use test && emake build_test
+}
+
+compile_cctools() {
+ einfo "building ${CCTOOLS}"
+ cd "${S}"/${CCTOOLS}
+ # -j1 because it fails too often with weird errors
+ # Suppress running dsymutil because it will warn about missing debug
+ # info which is expected when compiling without -g as we normally do.
+ # This might need some more thought if anyone ever wanted to build us
+ # for debugging with Apple's tools.
+ emake \
+ LIB_PRUNETRIE="-L../../${LD64}/src -lprunetrie" \
+ EFITOOLS= \
+ ENABLE_LTO=${ENABLE_LTO} \
+ COMMON_SUBDIRS='libstuff ar misc otool' \
+ SUBDIRS_32= \
+ LEGACY= \
+ RC_ProjectSourceVersion=${CCTOOLS_VERSION} \
+ RC_CFLAGS="${CFLAGS}" \
+ OFLAG="${CCTOOLS_OFLAG}" \
+ CXXLIB="${CXXLIB}" \
+ DSYMUTIL=": disabled: dsymutil" \
+ -j1 \
+ || die "emake failed for the cctools"
+ cd "${S}"/${CCTOOLS}/as
+ emake \
+ BUILD_OBSOLETE_ARCH= \
+ RC_ProjectSourceVersion=${CCTOOLS_VERSION} \
+ RC_CFLAGS="-DASLIBEXECDIR=\"\\\"${EPREFIX}${LIBPATH}/\\\"\" ${CFLAGS}" \
+ OFLAG="${CCTOOLS_OFLAG}" \
+ DSYMUTIL=": disabled: dsymutil" \
+ || die "emake failed for as"
+}
+
+src_compile() {
+ compile_ld64
+ compile_cctools
+}
+
+install_ld64() {
+ exeinto ${BINPATH}
+ doexe "${S}"/${LD64}/src/{ld64,rebase,dyldinfo,unwinddump,ObjectDump}
+ dosym ld64 ${BINPATH}/ld
+ insinto ${DATAPATH}/man/man1
+ doins "${S}"/${LD64}/doc/man/man1/{ld,ld64,rebase}.1
+}
+
+install_cctools() {
+ cd "${S}"/${CCTOOLS}
+ emake install_all_but_headers \
+ EFITOOLS= \
+ COMMON_SUBDIRS='ar misc otool' \
+ SUBDIRS_32= \
+ DSTROOT=\"${D}\" \
+ BINDIR=\"${EPREFIX}\"${BINPATH} \
+ LOCBINDIR=\"${EPREFIX}\"${BINPATH} \
+ USRBINDIR=\"${EPREFIX}\"${BINPATH} \
+ LOCLIBDIR=\"${EPREFIX}\"${LIBPATH} \
+ MANDIR=\"${EPREFIX}\"${DATAPATH}/man/
+ cd "${S}"/${CCTOOLS}/as
+ emake install \
+ BUILD_OBSOLETE_ARCH= \
+ DSTROOT=\"${D}\" \
+ USRBINDIR=\"${EPREFIX}\"${BINPATH} \
+ LIBDIR=\"${EPREFIX}\"${LIBPATH} \
+ LOCLIBDIR=\"${EPREFIX}\"${LIBPATH}
+
+ cd "${ED}"${BINPATH}
+ insinto ${DATAPATH}/man/man1
+ local skips manpage
+ # ar brings an up-to-date manpage with it
+ skips=( ar )
+ for bin in *; do
+ for skip in ${skips[@]}; do
+ if [[ ${bin} == ${skip} ]]; then
+ continue 2;
+ fi
+ done
+ manpage=${S}/${CCTOOLS}/man/${bin}.1
+ if [[ -f "${manpage}" ]]; then
+ doins "${manpage}"
+ fi
+ done
+ insinto ${DATAPATH}/man/man5
+ doins "${S}"/${CCTOOLS}/man/*.5
+}
+
+src_test() {
+ if ! [ "${EPREFIX}"/usr/bin/clang ] ; then
+ einfo "Test suite only works properly with clang - please install"
+ return
+ fi
+
+ einfo "Running unit tests"
+ cd "${S}"/${LD64}/unit-tests/test-cases
+ # provide the new ld as a symlink to clang so that -ccc-install-dir
+ # will pick it up
+ ln -sfn ../../src/ld64 ld
+ # use our arch command because the System's will report i386 even for an
+ # x86_64 prefix
+ perl ../bin/make-recursive.pl \
+ BUILT_PRODUCTS_DIR="${S}"/${LD64}/src \
+ ARCH="$(arch)" \
+ LD="${S}"/${LD64}/src/ld64 \
+ CC="clang -ccc-install-dir $PWD" \
+ CXX="clang++ -ccc-install-dir $PWD" \
+ OTOOL="${S}"/${CCTOOLS}/otool/otool.NEW \
+ | perl ../bin/result-filter.pl
+}
+
+src_install() {
+ install_ld64
+ install_cctools
+
+ cd "${S}"
+ insinto /etc/env.d/binutils
+ cat <<-EOF > env.d
+ TARGET="${CHOST}"
+ VER="${PV}"
+ FAKE_TARGETS="${CHOST}"
+ EOF
+ newins env.d ${CHOST}-${PV}
+}
+
+pkg_postinst() {
+ binutils-config ${CHOST}-${PV}
+}
diff --git a/sys-devel/binutils-apple/binutils-apple-6.1-r1.ebuild b/sys-devel/binutils-apple/binutils-apple-6.1-r1.ebuild
new file mode 100644
index 000000000000..984b31319824
--- /dev/null
+++ b/sys-devel/binutils-apple/binutils-apple-6.1-r1.ebuild
@@ -0,0 +1,385 @@
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI="5"
+
+inherit eutils flag-o-matic toolchain-funcs
+
+LD64=ld64-241.9
+CCTOOLS_VERSION=862
+CCTOOLS=cctools-${CCTOOLS_VERSION}
+LIBUNWIND=libunwind-35.3
+DYLD=dyld-353.2.1
+
+DESCRIPTION="Darwin assembler as(1) and static linker ld(1), Xcode Tools ${PV}"
+HOMEPAGE="http://www.opensource.apple.com/darwinsource/"
+SRC_URI="http://www.opensource.apple.com/tarballs/ld64/${LD64}.tar.gz
+ http://www.opensource.apple.com/tarballs/cctools/${CCTOOLS}.tar.gz
+ http://www.opensource.apple.com/tarballs/dyld/${DYLD}.tar.gz
+ http://www.opensource.apple.com/tarballs/libunwind/${LIBUNWIND}.tar.gz
+ https://dev.gentoo.org/~grobian/distfiles/${PN}-patches-4.3-r1.tar.bz2
+ https://dev.gentoo.org/~grobian/distfiles/${PN}-patches-5.1-r2.tar.bz2
+ https://dev.gentoo.org/~grobian/distfiles/${PN}-patches-6.1-r1.tar.bz2"
+
+LICENSE="APSL-2"
+KEYWORDS="~ppc-macos ~x64-macos ~x86-macos"
+IUSE="lto test libcxx multitarget"
+
+RDEPEND="sys-devel/binutils-config
+ lto? ( sys-devel/llvm )
+ libcxx? ( sys-libs/libcxx )"
+DEPEND="${RDEPEND}
+ test? ( >=dev-lang/perl-5.8.8 )
+ || ( >=sys-devel/gcc-apple-4.2.1 sys-devel/llvm )
+ libcxx? ( sys-devel/llvm )"
+
+SLOT="6"
+
+S=${WORKDIR}
+
+is_cross() { [[ ${CHOST} != ${CTARGET} ]] ; }
+
+src_prepare() {
+ if use multitarget ; then
+ ewarn "You have enabled support for non-standard target architectures"
+ ewarn "using USE=multitarget. This includes experimental support for"
+ ewarn "ppc and ppc64 which is a community forward-port from the last"
+ ewarn "version of ld64 to officially support PPC."
+
+ if [[ ${CHOST} == powerpc*-darwin* ]] ; then
+ ewarn "HERE BE DRAGONS! Your system seems to be PPC which means that"
+ ewarn "the actual usability of your Gentoo programs will depend on the"
+ ewarn "above-mentioned experimental PPC support in the linker. Be"
+ ewarn "sure to keep a known-to-work version like ${PN}-3.2.6 around!"
+ fi
+ fi
+
+ cd "${S}"/${LD64}/src
+ cp "${S}"/ld64-136-compile_stubs.h ld/compile_stubs.h
+ cp "${S}"/ld64-236.3-Makefile-2 Makefile
+
+ epatch "${S}"/ld64-236.3-nolto.patch
+ epatch "${S}"/ld64-241.9-extraneous-includes.patch
+ epatch "${S}"/ld64-241.9-osatomic.patch
+ epatch "${S}"/ld64-241.9-arm64-cputype.patch
+ epatch "${S}"/ld64-236.3-crashreporter.patch
+ epatch "${S}"/ld64-241.9-nosnapshots.patch
+ epatch "${S}"/ld64-241.9-ppc.patch
+ epatch "${S}"/ld64-236.3-constant-types-2.patch
+ epatch "${S}"/ld64-241.9-gcc-2.patch
+ epatch "${S}"/ld64-241.9-register-names.patch
+ epatch "${S}"/ld64-241.9-get-comm-align.patch
+ epatch "${S}"/ld64-241.9-cc_md5.patch
+ epatch "${S}"/ld64-241.9-lto-noremarks.patch
+ epatch "${S}"/ld64-253.3-delete-warning.patch
+
+ # We used to use our own copy of lto.h, which doesn't require llvm
+ # build-env. Current versions of llvm provide
+ # $EPREFIX/usr/include/llvm-c/lto.h as well as
+ # $EPREFIX/usr/lib/libLTO.{so,dylib}, so we just use these.
+
+ # provide missing headers from libunwind and dyld
+ mkdir -p include/{mach,mach-o/arm} || die
+ # never present because it's private
+ cp ../../${DYLD}/include/mach-o/dyld_priv.h include/mach-o || die
+ # missing on <= 10.5
+ cp ../../${LIBUNWIND}/include/libunwind.h include/ || die
+ cp ../../${LIBUNWIND}/include/mach-o/compact_unwind_encoding.h include/mach-o || die
+ # missing on <= 10.4
+ cp ../../${DYLD}/include/mach-o/dyld_images.h include/mach-o || die
+ cp ../../${CCTOOLS}/include/mach-o/loader.h include/mach-o || die
+ # use copies from cctools because they're otherwise hidden in some SDK
+ cp ../../${CCTOOLS}/include/mach-o/arm/reloc.h include/mach-o/arm || die
+ # provide all required CPU_TYPEs on all platforms
+ cp ../../${CCTOOLS}/include/mach/machine.h include/mach/machine.h
+ # add alias for newer identifiers, because ld64 uses both but cctools
+ # header only defines the older
+ epatch "${S}"/ld64-236.3-missing-cputypes.patch
+
+ # mimic OS X Leopard-style Availability.h macros for libunwind.h on
+ # older systems
+ [[ ${CHOST} == *darwin* && ${CHOST#*-darwin} -le 8 ]] && \
+ echo "#define __OSX_AVAILABLE_STARTING(x,y) " > include/Availability.h
+
+ local VER_STR="\"@(#)PROGRAM:ld PROJECT:${LD64} (Gentoo ${PN}-${PVR})\\n\""
+ echo "char ldVersionString[] = ${VER_STR};" > version.cpp
+
+ epatch "${S}"/ld64-123.2-debug-backtrace.patch
+ if [[ ${CHOST} == powerpc*-darwin* ]] ; then
+ epatch "${S}"/ld64-123.2-darwin8-no-mlong-branch-warning.patch
+ epatch "${S}"/ld64-127.2-thread_state.patch
+ fi
+
+ cd "${S}"/${CCTOOLS}
+ epatch "${S}"/${PN}-4.5-as.patch
+ epatch "${S}"/${PN}-5.1-as-dir.patch
+ epatch "${S}"/${PN}-5.1-ranlib.patch
+ epatch "${S}"/${PN}-3.1.1-libtool-ranlib.patch
+ epatch "${S}"/${PN}-3.1.1-no-headers.patch
+ epatch "${S}"/${PN}-4.0-no-oss-dir.patch
+ epatch "${S}"/${PN}-5.1-nolto.patch
+ epatch "${S}"/cctools-839-intel-retf.patch
+ epatch "${S}"/${PN}-5.1-extraneous-includes.patch
+ epatch "${S}"/${PN}-5.1-otool-stdc.patch
+ epatch "${S}"/${PN}-5.1-constant-types.patch
+ epatch "${S}"/${PN}-5.1-strnlen.patch
+ epatch "${S}"/${PN}-5.1-ppc.patch
+ epatch "${S}"/${PN}-5.1-thread-state-redefined.patch
+ epatch "${S}"/${PN}-5.1-makefile-target-warning.patch
+ epatch "${S}"/${PN}-6.3-lto-prefix.patch
+ cp ../${LD64}/src/other/prune_trie.h include/mach-o/ || die
+
+ # do not build profileable libstuff to save compile time
+ sed -i -e "/^all:/s, profile , ," libstuff/Makefile
+
+ # cctools version is provided to make via RC_ProjectSourceVersion which
+ # generates and compiles it as apple_version[] into libstuff. From
+ # there it's picked up by the individual tools. Since
+ # RC_ProjectSourceVersion is also used as library version, we can't
+ # just append our local version info. So we hack the libstuff Makefile
+ # to include our Gentoo version.
+ sed -i -e "/cctools-.*(RC_ProjectSourceVersion).*OFILE_DIR/s,Version),Version) (Gentoo ${PN}-${PVR})," \
+ libstuff/Makefile
+
+ # clean up test suite
+ cd "${S}"/${LD64}/unit-tests/test-cases
+ local c
+
+ # we don't have llvm
+ ((++c)); rm -rf llvm-integration;
+
+ # we don't have dtrace
+ ((++c)); rm -rf dtrace-static-probes-coalescing;
+ ((++c)); rm -rf dtrace-static-probes;
+
+ # a file is missing
+ ((++c)); rm -rf eh-coalescing-r
+
+ # we don't do universal binaries
+ ((++c)); rm -rf blank-stubs;
+
+ # looks like a problem with apple's result-filter.pl
+ ((++c)); rm -rf implicit-common3;
+ ((++c)); rm -rf order_file-ans;
+
+ # TODO no idea what goes wrong here
+ ((++c)); rm -rf dwarf-debug-notes;
+
+ einfo "Deleted $c tests that were bound to fail"
+
+ cd "${S}"
+ ebegin "cleaning Makefiles from unwanted CFLAGS"
+ find . -name "Makefile" -print0 | xargs -0 sed \
+ -i \
+ -e 's/ -g / /g' \
+ -e 's/^G =.*$/G =/' \
+ -e 's/^OFLAG =.*$/OFLAG =/' \
+ -e 's/install -c -s/install/g'
+ eend $?
+}
+
+src_configure() {
+ ENABLE_LTO=0
+ use lto && ENABLE_LTO=1
+
+ export CTARGET=${CTARGET:-${CHOST}}
+ if [[ ${CTARGET} == ${CHOST} ]] ; then
+ if [[ ${CATEGORY} == cross-* ]] ; then
+ export CTARGET=${CATEGORY#cross-}
+ fi
+ fi
+
+ LIBPATH=/usr/$(get_libdir)/binutils/${CTARGET}/${PV}
+ INCPATH=${LIBPATH}/include
+ DATAPATH=/usr/share/binutils-data/${CTARGET}/${PV}
+ if is_cross ; then
+ BINPATH=/usr/${CHOST}/${CTARGET}/binutils-bin/${PV}
+ else
+ BINPATH=/usr/${CTARGET}/binutils-bin/${PV}
+ fi
+
+ if [ "${CXX/*clang*/yes}" = "yes" ] ; then
+ if use libcxx ; then
+ append-cxxflags -stdlib=libc++
+ CXXLIB=-stdlib=libc++
+ else
+ # force libstdc++ for systems where libc++ is default (OS X 10.9+?)
+ append-cxxflags -stdlib=libstdc++
+ CXXLIB=-stdlib=libstdc++
+ fi
+ else
+ use libcxx && \
+ ewarn "libcxx only available with clang and your C++ compiler ($CXX) does not seem to be clang"
+ fi
+
+ # CPPFLAGS only affects ld64, cctools don't use 'em (which currently is
+ # what we want)
+ append-cppflags -DNDEBUG
+
+ # Block API and thus snapshots supported on >= 10.6
+ [[ ${CHOST} == *darwin* && ${CHOST#*-darwin} -ge 10 ]] && \
+ append-cppflags -DSUPPORT_SNAPSHOTS
+
+ CCTOOLS_OFLAG=
+ if [[ ${CHOST} == *darwin* && ${CHOST#*-darwin} -le 8 ]] ; then
+ # cctools expect to use UNIX03 struct member names.
+ # This is default on > 10.4. Activate it on <= 10.4 by defining
+ # __DARWIN_UNIX03 explicitly.
+ CCTOOLS_OFLAG="-D__DARWIN_UNIX03=1"
+ fi
+
+ # if compiling with USE multitarget, extract all the known arches from
+ # create_configure and pass them back to it
+ creco=${LD64}/src/create_configure
+ ARCHS_TO_SUPPORT=""
+ if use multitarget ; then
+ ARCHS_TO_SUPPORT="$(grep KNOWN_ARCHS= $creco | \
+ cut -d\" -f2 | tr ',' ' ')"
+ fi
+
+ # Create configure.h for ld64 with SUPPORT_ARCH_<arch> defines in it.
+ DERIVED_FILE_DIR=${LD64}/src \
+ RC_SUPPORTED_ARCHS="$ARCHS_TO_SUPPORT" \
+ $creco
+
+ # do not depend on MachOFileAbstraction.hpp to define
+ # SUPPORT_ARCH_arm_any because that's not included by every file where
+ # our ppc/arm-optional patch uses it, ld.hpp in particular
+ grep "SUPPORT_ARCH_armv[0-9]" ${LD64}/src/configure.h >/dev/null && \
+ echo "#define SUPPORT_ARCH_arm_any 1" >> ${LD64}/src/configure.h
+}
+
+compile_ld64() {
+ einfo "building ${LD64}"
+ cd "${S}"/${LD64}/src
+ emake \
+ LTO=${ENABLE_LTO} \
+ || die "emake failed for ld64"
+ use test && emake build_test
+}
+
+compile_cctools() {
+ einfo "building ${CCTOOLS}"
+ cd "${S}"/${CCTOOLS}
+ # -j1 because it fails too often with weird errors
+ # Suppress running dsymutil because it will warn about missing debug
+ # info which is expected when compiling without -g as we normally do.
+ # This might need some more thought if anyone ever wanted to build us
+ # for debugging with Apple's tools.
+ emake \
+ LIB_PRUNETRIE="-L../../${LD64}/src -lprunetrie" \
+ EFITOOLS= \
+ ENABLE_LTO=${ENABLE_LTO} \
+ COMMON_SUBDIRS='libstuff ar misc otool' \
+ SUBDIRS_32= \
+ LEGACY= \
+ RC_ProjectSourceVersion=${CCTOOLS_VERSION} \
+ RC_CFLAGS="${CFLAGS}" \
+ OFLAG="${CCTOOLS_OFLAG}" \
+ CXXLIB="${CXXLIB}" \
+ DSYMUTIL=": disabled: dsymutil" \
+ -j1 \
+ || die "emake failed for the cctools"
+ cd "${S}"/${CCTOOLS}/as
+ emake \
+ BUILD_OBSOLETE_ARCH= \
+ RC_ProjectSourceVersion=${CCTOOLS_VERSION} \
+ RC_CFLAGS="-DASLIBEXECDIR=\"\\\"${EPREFIX}${LIBPATH}/\\\"\" ${CFLAGS}" \
+ OFLAG="${CCTOOLS_OFLAG}" \
+ DSYMUTIL=": disabled: dsymutil" \
+ || die "emake failed for as"
+}
+
+src_compile() {
+ compile_ld64
+ compile_cctools
+}
+
+install_ld64() {
+ exeinto ${BINPATH}
+ doexe "${S}"/${LD64}/src/{ld64,rebase,dyldinfo,unwinddump,ObjectDump}
+ dosym ld64 ${BINPATH}/ld
+ insinto ${DATAPATH}/man/man1
+ doins "${S}"/${LD64}/doc/man/man1/{ld,ld64,rebase}.1
+}
+
+install_cctools() {
+ cd "${S}"/${CCTOOLS}
+ emake install_all_but_headers \
+ EFITOOLS= \
+ COMMON_SUBDIRS='ar misc otool' \
+ SUBDIRS_32= \
+ DSTROOT=\"${D}\" \
+ BINDIR=\"${EPREFIX}\"${BINPATH} \
+ LOCBINDIR=\"${EPREFIX}\"${BINPATH} \
+ USRBINDIR=\"${EPREFIX}\"${BINPATH} \
+ LOCLIBDIR=\"${EPREFIX}\"${LIBPATH} \
+ MANDIR=\"${EPREFIX}\"${DATAPATH}/man/
+ cd "${S}"/${CCTOOLS}/as
+ emake install \
+ BUILD_OBSOLETE_ARCH= \
+ DSTROOT=\"${D}\" \
+ USRBINDIR=\"${EPREFIX}\"${BINPATH} \
+ LIBDIR=\"${EPREFIX}\"${LIBPATH} \
+ LOCLIBDIR=\"${EPREFIX}\"${LIBPATH}
+
+ cd "${ED}"${BINPATH}
+ insinto ${DATAPATH}/man/man1
+ local skips manpage
+ # ar brings an up-to-date manpage with it
+ skips=( ar )
+ for bin in *; do
+ for skip in ${skips[@]}; do
+ if [[ ${bin} == ${skip} ]]; then
+ continue 2;
+ fi
+ done
+ manpage=${S}/${CCTOOLS}/man/${bin}.1
+ if [[ -f "${manpage}" ]]; then
+ doins "${manpage}"
+ fi
+ done
+ insinto ${DATAPATH}/man/man5
+ doins "${S}"/${CCTOOLS}/man/*.5
+}
+
+src_test() {
+ if ! [ "${EPREFIX}"/usr/bin/clang ] ; then
+ einfo "Test suite only works properly with clang - please install"
+ return
+ fi
+
+ einfo "Running unit tests"
+ cd "${S}"/${LD64}/unit-tests/test-cases
+ # provide the new ld as a symlink to clang so that -ccc-install-dir
+ # will pick it up
+ ln -sfn ../../src/ld64 ld
+ # use our arch command because the System's will report i386 even for an
+ # x86_64 prefix
+ perl ../bin/make-recursive.pl \
+ BUILT_PRODUCTS_DIR="${S}"/${LD64}/src \
+ ARCH="$(arch)" \
+ LD="${S}"/${LD64}/src/ld64 \
+ CC="clang -ccc-install-dir $PWD" \
+ CXX="clang++ -ccc-install-dir $PWD" \
+ OTOOL="${S}"/${CCTOOLS}/otool/otool.NEW \
+ | perl ../bin/result-filter.pl
+}
+
+src_install() {
+ install_ld64
+ install_cctools
+
+ cd "${S}"
+ insinto /etc/env.d/binutils
+ cat <<-EOF > env.d
+ TARGET="${CHOST}"
+ VER="${PV}"
+ FAKE_TARGETS="${CHOST}"
+ EOF
+ newins env.d ${CHOST}-${PV}
+}
+
+pkg_postinst() {
+ binutils-config ${CHOST}-${PV}
+}
diff --git a/sys-devel/binutils-apple/binutils-apple-6.3-r1.ebuild b/sys-devel/binutils-apple/binutils-apple-6.3-r1.ebuild
new file mode 100644
index 000000000000..371c6a2b6c6b
--- /dev/null
+++ b/sys-devel/binutils-apple/binutils-apple-6.3-r1.ebuild
@@ -0,0 +1,378 @@
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI="5"
+
+inherit eutils flag-o-matic toolchain-funcs
+
+LD64=ld64-242
+CCTOOLS_VERSION=870
+CCTOOLS=cctools-${CCTOOLS_VERSION}
+LIBUNWIND=libunwind-35.3
+DYLD=dyld-353.2.1
+
+DESCRIPTION="Darwin assembler as(1) and static linker ld(1), Xcode Tools ${PV}"
+HOMEPAGE="http://www.opensource.apple.com/darwinsource/"
+SRC_URI="http://www.opensource.apple.com/tarballs/ld64/${LD64}.tar.gz
+ http://www.opensource.apple.com/tarballs/cctools/${CCTOOLS}.tar.gz
+ http://www.opensource.apple.com/tarballs/dyld/${DYLD}.tar.gz
+ http://www.opensource.apple.com/tarballs/libunwind/${LIBUNWIND}.tar.gz
+ https://dev.gentoo.org/~grobian/distfiles/${PN}-patches-4.3-r1.tar.bz2
+ https://dev.gentoo.org/~grobian/distfiles/${PN}-patches-5.1-r2.tar.bz2
+ https://dev.gentoo.org/~grobian/distfiles/${PN}-patches-6.1-r1.tar.bz2
+ https://dev.gentoo.org/~grobian/distfiles/${PN}-patches-6.3-r1.tar.bz2"
+
+LICENSE="APSL-2"
+KEYWORDS="~ppc-macos ~x64-macos ~x86-macos"
+IUSE="lto test libcxx multitarget"
+
+RDEPEND="sys-devel/binutils-config
+ lto? ( sys-devel/llvm )
+ libcxx? ( sys-libs/libcxx )"
+DEPEND="${RDEPEND}
+ test? ( >=dev-lang/perl-5.8.8 )
+ || ( >=sys-devel/gcc-apple-4.2.1 sys-devel/llvm )
+ libcxx? ( sys-devel/llvm )"
+
+SLOT="6"
+
+S=${WORKDIR}
+
+is_cross() { [[ ${CHOST} != ${CTARGET} ]] ; }
+
+src_prepare() {
+ if use multitarget ; then
+ ewarn "You have enabled support for non-standard target architectures"
+ ewarn "using USE=multitarget. This includes experimental support for"
+ ewarn "ppc and ppc64 which is a community forward-port from the last"
+ ewarn "version of ld64 to officially support PPC."
+
+ if [[ ${CHOST} == powerpc*-darwin* ]] ; then
+ ewarn "HERE BE DRAGONS! Your system seems to be PPC which means that"
+ ewarn "the actual usability of your Gentoo programs will depend on the"
+ ewarn "above-mentioned experimental PPC support in the linker. Be"
+ ewarn "sure to keep a known-to-work version like ${PN}-3.2.6 around!"
+ fi
+ fi
+
+ cd "${S}"/${LD64}/src
+ cp "${S}"/ld64-136-compile_stubs.h ld/compile_stubs.h
+ cp "${S}"/ld64-236.3-Makefile-2 Makefile
+
+ epatch "${S}"/ld64-236.3-nolto.patch
+ epatch "${S}"/ld64-241.9-extraneous-includes.patch
+ epatch "${S}"/ld64-241.9-osatomic.patch
+ epatch "${S}"/ld64-236.3-crashreporter.patch
+ epatch "${S}"/ld64-241.9-nosnapshots.patch
+ epatch "${S}"/ld64-242-ppc.patch
+ epatch "${S}"/ld64-236.3-constant-types-2.patch
+ epatch "${S}"/ld64-242-gcc-2.patch
+ epatch "${S}"/ld64-241.9-register-names.patch
+ epatch "${S}"/ld64-241.9-get-comm-align.patch
+ epatch "${S}"/ld64-241.9-cc_md5.patch
+ epatch "${S}"/ld64-253.3-delete-warning.patch
+
+ # provide missing headers from libunwind and dyld
+ mkdir -p include/{mach,mach-o/arm} || die
+ # never present because it's private
+ cp ../../${DYLD}/include/mach-o/dyld_priv.h include/mach-o || die
+ # missing on <= 10.5
+ cp ../../${LIBUNWIND}/include/libunwind.h include/ || die
+ cp ../../${LIBUNWIND}/include/mach-o/compact_unwind_encoding.h include/mach-o || die
+ # missing on <= 10.4
+ cp ../../${DYLD}/include/mach-o/dyld_images.h include/mach-o || die
+ cp ../../${CCTOOLS}/include/mach-o/loader.h include/mach-o || die
+ # use copies from cctools because they're otherwise hidden in some SDK
+ cp ../../${CCTOOLS}/include/mach-o/arm/reloc.h include/mach-o/arm || die
+ # provide all required CPU_TYPEs on all platforms
+ cp ../../${CCTOOLS}/include/mach/machine.h include/mach/machine.h
+ # add alias for newer identifiers, because ld64 uses both but cctools
+ # header only defines the older
+ epatch "${S}"/ld64-236.3-missing-cputypes.patch
+
+ # mimic OS X Leopard-style Availability.h macros for libunwind.h on
+ # older systems
+ [[ ${CHOST} == *darwin* && ${CHOST#*-darwin} -le 8 ]] && \
+ echo "#define __OSX_AVAILABLE_STARTING(x,y) " > include/Availability.h
+
+ local VER_STR="\"@(#)PROGRAM:ld PROJECT:${LD64} (Gentoo ${PN}-${PVR})\\n\""
+ echo "char ldVersionString[] = ${VER_STR};" > version.cpp
+
+ epatch "${S}"/ld64-123.2-debug-backtrace.patch
+ if [[ ${CHOST} == powerpc*-darwin* ]] ; then
+ epatch "${S}"/ld64-123.2-darwin8-no-mlong-branch-warning.patch
+ epatch "${S}"/ld64-127.2-thread_state.patch
+ fi
+
+ cd "${S}"/${CCTOOLS}
+ epatch "${S}"/${PN}-4.5-as.patch
+ epatch "${S}"/${PN}-5.1-as-dir.patch
+ epatch "${S}"/${PN}-5.1-ranlib.patch
+ epatch "${S}"/${PN}-3.1.1-libtool-ranlib.patch
+ epatch "${S}"/${PN}-3.1.1-no-headers.patch
+ epatch "${S}"/${PN}-4.0-no-oss-dir.patch
+ epatch "${S}"/cctools-839-intel-retf.patch
+ epatch "${S}"/${PN}-5.1-extraneous-includes.patch
+ epatch "${S}"/${PN}-5.1-otool-stdc.patch
+ epatch "${S}"/${PN}-5.1-constant-types.patch
+ epatch "${S}"/${PN}-5.1-strnlen.patch
+ epatch "${S}"/${PN}-5.1-ppc.patch
+ epatch "${S}"/${PN}-5.1-thread-state-redefined.patch
+ epatch "${S}"/${PN}-5.1-makefile-target-warning.patch
+ epatch "${S}"/${PN}-6.3-lto-prefix.patch
+ cp ../${LD64}/src/other/prune_trie.h include/mach-o/ || die
+
+ # do not build profileable libstuff to save compile time
+ sed -i -e "/^all:/s, profile , ," libstuff/Makefile
+
+ # cctools version is provided to make via RC_ProjectSourceVersion which
+ # generates and compiles it as apple_version[] into libstuff. From
+ # there it's picked up by the individual tools. Since
+ # RC_ProjectSourceVersion is also used as library version, we can't
+ # just append our local version info. So we hack the libstuff Makefile
+ # to include our Gentoo version.
+ sed -i -e "/cctools-.*(RC_ProjectSourceVersion).*OFILE_DIR/s,Version),Version) (Gentoo ${PN}-${PVR})," \
+ libstuff/Makefile
+
+ # clean up test suite
+ cd "${S}"/${LD64}/unit-tests/test-cases
+ local c
+
+ # we don't have llvm
+ ((++c)); rm -rf llvm-integration;
+
+ # we don't have dtrace
+ ((++c)); rm -rf dtrace-static-probes-coalescing;
+ ((++c)); rm -rf dtrace-static-probes;
+
+ # a file is missing
+ ((++c)); rm -rf eh-coalescing-r
+
+ # we don't do universal binaries
+ ((++c)); rm -rf blank-stubs;
+
+ # looks like a problem with apple's result-filter.pl
+ ((++c)); rm -rf implicit-common3;
+ ((++c)); rm -rf order_file-ans;
+
+ # TODO no idea what goes wrong here
+ ((++c)); rm -rf dwarf-debug-notes;
+
+ einfo "Deleted $c tests that were bound to fail"
+
+ cd "${S}"
+ ebegin "cleaning Makefiles from unwanted CFLAGS"
+ find . -name "Makefile" -print0 | xargs -0 sed \
+ -i \
+ -e 's/ -g / /g' \
+ -e 's/^G =.*$/G =/' \
+ -e 's/^OFLAG =.*$/OFLAG =/' \
+ -e 's/install -c -s/install/g'
+ eend $?
+}
+
+src_configure() {
+ ENABLE_LTO=0
+ use lto && ENABLE_LTO=1
+
+ export CTARGET=${CTARGET:-${CHOST}}
+ if [[ ${CTARGET} == ${CHOST} ]] ; then
+ if [[ ${CATEGORY} == cross-* ]] ; then
+ export CTARGET=${CATEGORY#cross-}
+ fi
+ fi
+
+ LIBPATH=/usr/$(get_libdir)/binutils/${CTARGET}/${PV}
+ INCPATH=${LIBPATH}/include
+ DATAPATH=/usr/share/binutils-data/${CTARGET}/${PV}
+ if is_cross ; then
+ BINPATH=/usr/${CHOST}/${CTARGET}/binutils-bin/${PV}
+ else
+ BINPATH=/usr/${CTARGET}/binutils-bin/${PV}
+ fi
+
+ if [[ ${CXX} == *clang* ]] ; then
+ if use libcxx ; then
+ append-cxxflags -stdlib=libc++
+ CXXLIB=-stdlib=libc++
+ else
+ # force libstdc++ for systems where libc++ is default (OS X 10.9+?)
+ append-cxxflags -stdlib=libstdc++
+ CXXLIB=-stdlib=libstdc++
+ fi
+ else
+ use libcxx && \
+ ewarn "libcxx only available with clang and your C++ compiler ($CXX) does not seem to be clang"
+ fi
+
+ # CPPFLAGS only affects ld64, cctools don't use 'em (which currently is
+ # what we want)
+ append-cppflags -DNDEBUG
+
+ # Block API and thus snapshots supported on >= 10.6
+ [[ ${CHOST} == *darwin* && ${CHOST#*-darwin} -ge 10 ]] && \
+ append-cppflags -DSUPPORT_SNAPSHOTS
+
+ CCTOOLS_OFLAG=
+ if [[ ${CHOST} == *darwin* && ${CHOST#*-darwin} -le 8 ]] ; then
+ # cctools expect to use UNIX03 struct member names.
+ # This is default on > 10.4. Activate it on <= 10.4 by defining
+ # __DARWIN_UNIX03 explicitly.
+ CCTOOLS_OFLAG="-D__DARWIN_UNIX03=1"
+ fi
+
+ # if compiling with USE multitarget, extract all the known arches from
+ # create_configure and pass them back to it
+ creco=${LD64}/src/create_configure
+ ARCHS_TO_SUPPORT=""
+ if use multitarget ; then
+ ARCHS_TO_SUPPORT="$(grep KNOWN_ARCHS= $creco | \
+ cut -d\" -f2 | tr ',' ' ')"
+ fi
+
+ # Create configure.h for ld64 with SUPPORT_ARCH_<arch> defines in it.
+ DERIVED_FILE_DIR=${LD64}/src \
+ RC_SUPPORTED_ARCHS="$ARCHS_TO_SUPPORT" \
+ $creco
+
+ # do not depend on MachOFileAbstraction.hpp to define
+ # SUPPORT_ARCH_arm_any because that's not included by every file where
+ # our ppc/arm-optional patch uses it, ld.hpp in particular
+ grep "SUPPORT_ARCH_armv[0-9]" ${LD64}/src/configure.h >/dev/null && \
+ echo "#define SUPPORT_ARCH_arm_any 1" >> ${LD64}/src/configure.h
+}
+
+compile_ld64() {
+ einfo "building ${LD64}"
+ cd "${S}"/${LD64}/src
+ emake \
+ LTO=${ENABLE_LTO} \
+ || die "emake failed for ld64"
+ use test && emake build_test
+}
+
+compile_cctools() {
+ einfo "building ${CCTOOLS}"
+ cd "${S}"/${CCTOOLS}
+ # -j1 because it fails too often with weird errors
+ # Suppress running dsymutil because it will warn about missing debug
+ # info which is expected when compiling without -g as we normally do.
+ # This might need some more thought if anyone ever wanted to build us
+ # for debugging with Apple's tools.
+ emake \
+ LIB_PRUNETRIE="-L../../${LD64}/src -lprunetrie" \
+ EFITOOLS= \
+ ENABLE_LTO="${ENABLE_LTO}" \
+ COMMON_SUBDIRS='libstuff ar misc otool' \
+ SUBDIRS_32= \
+ LEGACY= \
+ RC_ProjectSourceVersion=${CCTOOLS_VERSION} \
+ RC_CFLAGS="${CFLAGS}" \
+ OFLAG="${CCTOOLS_OFLAG}" \
+ CXXLIB="${CXXLIB}" \
+ DSYMUTIL=": disabled: dsymutil" \
+ -j1 \
+ || die "emake failed for the cctools"
+ cd "${S}"/${CCTOOLS}/as
+ emake \
+ BUILD_OBSOLETE_ARCH= \
+ RC_ProjectSourceVersion=${CCTOOLS_VERSION} \
+ RC_CFLAGS="-DASLIBEXECDIR=\"\\\"${EPREFIX}${LIBPATH}/\\\"\" ${CFLAGS}" \
+ OFLAG="${CCTOOLS_OFLAG}" \
+ DSYMUTIL=": disabled: dsymutil" \
+ || die "emake failed for as"
+}
+
+src_compile() {
+ compile_ld64
+ compile_cctools
+}
+
+install_ld64() {
+ exeinto ${BINPATH}
+ doexe "${S}"/${LD64}/src/{ld64,rebase,dyldinfo,unwinddump,ObjectDump}
+ dosym ld64 ${BINPATH}/ld
+ insinto ${DATAPATH}/man/man1
+ doins "${S}"/${LD64}/doc/man/man1/{ld,ld64,rebase}.1
+}
+
+install_cctools() {
+ cd "${S}"/${CCTOOLS}
+ emake install_all_but_headers \
+ EFITOOLS= \
+ COMMON_SUBDIRS='ar misc otool' \
+ SUBDIRS_32= \
+ DSTROOT=\"${D}\" \
+ BINDIR=\"${EPREFIX}\"${BINPATH} \
+ LOCBINDIR=\"${EPREFIX}\"${BINPATH} \
+ USRBINDIR=\"${EPREFIX}\"${BINPATH} \
+ LOCLIBDIR=\"${EPREFIX}\"${LIBPATH} \
+ MANDIR=\"${EPREFIX}\"${DATAPATH}/man/
+ cd "${S}"/${CCTOOLS}/as
+ emake install \
+ BUILD_OBSOLETE_ARCH= \
+ DSTROOT=\"${D}\" \
+ USRBINDIR=\"${EPREFIX}\"${BINPATH} \
+ LIBDIR=\"${EPREFIX}\"${LIBPATH} \
+ LOCLIBDIR=\"${EPREFIX}\"${LIBPATH}
+
+ cd "${ED}"${BINPATH}
+ insinto ${DATAPATH}/man/man1
+ local skips manpage
+ # ar brings an up-to-date manpage with it
+ skips=( ar )
+ for bin in *; do
+ for skip in ${skips[@]}; do
+ if [[ ${bin} == ${skip} ]]; then
+ continue 2;
+ fi
+ done
+ manpage=${S}/${CCTOOLS}/man/${bin}.1
+ if [[ -f "${manpage}" ]]; then
+ doins "${manpage}"
+ fi
+ done
+ insinto ${DATAPATH}/man/man5
+ doins "${S}"/${CCTOOLS}/man/*.5
+}
+
+src_test() {
+ if ! [ "${EPREFIX}"/usr/bin/clang ] ; then
+ einfo "Test suite only works properly with clang - please install"
+ return
+ fi
+
+ einfo "Running unit tests"
+ cd "${S}"/${LD64}/unit-tests/test-cases
+ # provide the new ld as a symlink to clang so that -ccc-install-dir
+ # will pick it up
+ ln -sfn ../../src/ld64 ld
+ # use our arch command because the System's will report i386 even for an
+ # x86_64 prefix
+ perl ../bin/make-recursive.pl \
+ BUILT_PRODUCTS_DIR="${S}"/${LD64}/src \
+ ARCH="$(arch)" \
+ LD="${S}"/${LD64}/src/ld64 \
+ CC="clang -ccc-install-dir $PWD" \
+ CXX="clang++ -ccc-install-dir $PWD" \
+ OTOOL="${S}"/${CCTOOLS}/otool/otool.NEW \
+ | perl ../bin/result-filter.pl
+}
+
+src_install() {
+ install_ld64
+ install_cctools
+
+ cd "${S}"
+ insinto /etc/env.d/binutils
+ cat <<-EOF > env.d
+ TARGET="${CHOST}"
+ VER="${PV}"
+ FAKE_TARGETS="${CHOST}"
+ EOF
+ newins env.d ${CHOST}-${PV}
+}
+
+pkg_postinst() {
+ binutils-config ${CHOST}-${PV}
+}
diff --git a/sys-devel/binutils-apple/binutils-apple-7.0-r1.ebuild b/sys-devel/binutils-apple/binutils-apple-7.0-r1.ebuild
new file mode 100644
index 000000000000..2eab5e95aabf
--- /dev/null
+++ b/sys-devel/binutils-apple/binutils-apple-7.0-r1.ebuild
@@ -0,0 +1,369 @@
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI="5"
+
+inherit eutils flag-o-matic toolchain-funcs
+
+LD64=ld64-253.3
+CCTOOLS_VERSION=877.5
+CCTOOLS=cctools-${CCTOOLS_VERSION}
+LIBUNWIND=libunwind-35.3
+DYLD=dyld-360.14
+
+DESCRIPTION="Darwin assembler as(1) and static linker ld(1), Xcode Tools ${PV}"
+HOMEPAGE="http://www.opensource.apple.com/darwinsource/"
+SRC_URI="http://www.opensource.apple.com/tarballs/ld64/${LD64}.tar.gz
+ http://www.opensource.apple.com/tarballs/cctools/${CCTOOLS}.tar.gz
+ http://www.opensource.apple.com/tarballs/dyld/${DYLD}.tar.gz
+ http://www.opensource.apple.com/tarballs/libunwind/${LIBUNWIND}.tar.gz
+ https://dev.gentoo.org/~grobian/distfiles/${PN}-patches-4.3-r1.tar.bz2
+ https://dev.gentoo.org/~grobian/distfiles/${PN}-patches-5.1-r2.tar.bz2
+ https://dev.gentoo.org/~grobian/distfiles/${PN}-patches-6.1-r1.tar.bz2
+ https://dev.gentoo.org/~grobian/distfiles/${PN}-patches-6.3-r1.tar.bz2
+ https://dev.gentoo.org/~grobian/distfiles/${PN}-patches-7.0-r2.tar.bz2"
+
+LICENSE="APSL-2"
+KEYWORDS="~ppc-macos ~x64-macos ~x86-macos"
+IUSE="lto test multitarget"
+
+# ld64 can now only be compiled using llvm and libc++ since it massivley uses
+# C++11 language fatures. *But additionally* the as driver now defaults to
+# calling clang as the assembler on many platforms. This can be disabled using
+# -Wa,-Q but since it's default we make llvm a static runtime dependency.
+RDEPEND="sys-devel/binutils-config
+ lto? ( app-arch/xar )
+ sys-devel/llvm
+ sys-libs/libcxx"
+DEPEND="${RDEPEND}
+ test? ( >=dev-lang/perl-5.8.8 )"
+
+SLOT="7"
+
+S=${WORKDIR}
+
+is_cross() { [[ ${CHOST} != ${CTARGET} ]] ; }
+
+src_prepare() {
+ if use multitarget ; then
+ ewarn "You have enabled support for non-standard target architectures"
+ ewarn "using USE=multitarget. This includes experimental support for"
+ ewarn "ppc and ppc64 which is a community forward-port from the last"
+ ewarn "version of ld64 to officially support PPC."
+
+ if [[ ${CHOST} == powerpc*-darwin* ]] ; then
+ ewarn "HERE BE DRAGONS! Your system seems to be PPC which means that"
+ ewarn "the actual usability of your Gentoo programs will depend on the"
+ ewarn "above-mentioned experimental PPC support in the linker. Be"
+ ewarn "sure to keep a known-to-work version like ${PN}-3.2.6 around!"
+ fi
+ fi
+
+ cd "${S}"/${LD64}/src
+ cp "${S}"/ld64-136-compile_stubs.h ld/compile_stubs.h
+ cp "${S}"/ld64-253.3-Makefile-3 Makefile
+
+ epatch "${S}"/ld64-253.3-nolto.patch
+ epatch "${S}"/ld64-241.9-extraneous-includes.patch
+ epatch "${S}"/ld64-241.9-osatomic.patch
+ epatch "${S}"/ld64-236.3-crashreporter.patch
+ epatch "${S}"/ld64-253.3-nosnapshots.patch
+ epatch "${S}"/ld64-253.3-ppc.patch
+ epatch "${S}"/ld64-236.3-constant-types-2.patch
+ epatch "${S}"/ld64-241.9-register-names.patch
+ epatch "${S}"/ld64-241.9-get-comm-align.patch
+ epatch "${S}"/ld64-241.9-cc_md5.patch
+ epatch "${S}"/ld64-253.3-make_pair.patch
+ epatch "${S}"/ld64-253.3-delete-warning.patch
+
+ # provide missing headers from libunwind and dyld
+ mkdir -p include/{mach,mach-o/arm} || die
+ # never present because it's private
+ cp ../../${DYLD}/include/mach-o/dyld_priv.h include/mach-o || die
+ # missing on <= 10.5
+ cp ../../${LIBUNWIND}/include/libunwind.h include/ || die
+ cp ../../${LIBUNWIND}/include/mach-o/compact_unwind_encoding.h include/mach-o || die
+ # missing on <= 10.4
+ cp ../../${DYLD}/include/mach-o/dyld_images.h include/mach-o || die
+ cp ../../${CCTOOLS}/include/mach-o/loader.h include/mach-o || die
+ # use copies from cctools because they're otherwise hidden in some SDK
+ cp ../../${CCTOOLS}/include/mach-o/arm/reloc.h include/mach-o/arm || die
+ # provide all required CPU_TYPEs on all platforms
+ cp ../../${CCTOOLS}/include/mach/machine.h include/mach/machine.h
+ # add alias for newer identifiers, because ld64 uses both but cctools
+ # header only defines the older
+ epatch "${S}"/ld64-236.3-missing-cputypes.patch
+
+ # mimic OS X Leopard-style Availability.h macros for libunwind.h on
+ # older systems
+ [[ ${CHOST} == *darwin* && ${CHOST#*-darwin} -le 8 ]] && \
+ echo "#define __OSX_AVAILABLE_STARTING(x,y) " > include/Availability.h
+
+ local VER_STR="\"@(#)PROGRAM:ld PROJECT:${LD64} (Gentoo ${PN}-${PVR})\\n\""
+ echo "char ldVersionString[] = ${VER_STR};" > version.cpp
+
+ epatch "${S}"/ld64-123.2-debug-backtrace.patch
+ if [[ ${CHOST} == powerpc*-darwin* ]] ; then
+ epatch "${S}"/ld64-123.2-darwin8-no-mlong-branch-warning.patch
+ epatch "${S}"/ld64-127.2-thread_state.patch
+ fi
+
+ cd "${S}"/${CCTOOLS}
+ epatch "${S}"/${PN}-4.5-as.patch
+ epatch "${S}"/${PN}-5.1-as-dir.patch
+ epatch "${S}"/${PN}-5.1-ranlib.patch
+ epatch "${S}"/${PN}-3.1.1-libtool-ranlib.patch
+ epatch "${S}"/${PN}-3.1.1-no-headers.patch
+ epatch "${S}"/${PN}-4.0-no-oss-dir.patch
+ epatch "${S}"/cctools-839-intel-retf.patch
+ epatch "${S}"/${PN}-5.1-extraneous-includes.patch
+ #epatch "${S}"/${PN}-5.1-otool-stdc.patch
+ epatch "${S}"/${PN}-5.1-constant-types.patch
+ epatch "${S}"/${PN}-5.1-strnlen.patch
+ epatch "${S}"/${PN}-5.1-ppc.patch
+ epatch "${S}"/${PN}-5.1-thread-state-redefined.patch
+ epatch "${S}"/${PN}-7.0-make-j.patch
+ epatch "${S}"/${PN}-7.0-lto-prefix-2.patch
+ epatch "${S}"/${PN}-7.0-clang-as.patch
+ epatch "${S}"/${PN}-7.0-nolto.patch
+ epatch "${S}"/${PN}-7.0-nollvm.patch
+ cp ../${LD64}/src/other/prune_trie.h include/mach-o/ || die
+
+ # do not build profileable libstuff to save compile time
+ sed -i -e "/^all:/s, profile , ," libstuff/Makefile
+
+ # cctools version is provided to make via RC_ProjectSourceVersion which
+ # generates and compiles it as apple_version[] into libstuff. From
+ # there it's picked up by the individual tools. Since
+ # RC_ProjectSourceVersion is also used as library version, we can't
+ # just append our local version info. So we hack the libstuff Makefile
+ # to include our Gentoo version.
+ sed -i -e "/cctools-.*(RC_ProjectSourceVersion).*OFILE_DIR/s,Version),Version) (Gentoo ${PN}-${PVR})," \
+ libstuff/Makefile
+
+ # clean up test suite
+ cd "${S}"/${LD64}/unit-tests/test-cases
+ local c
+
+ # we don't have llvm
+ ((++c)); rm -rf llvm-integration;
+
+ # we don't have dtrace
+ ((++c)); rm -rf dtrace-static-probes-coalescing;
+ ((++c)); rm -rf dtrace-static-probes;
+
+ # a file is missing
+ ((++c)); rm -rf eh-coalescing-r
+
+ # we don't do universal binaries
+ ((++c)); rm -rf blank-stubs;
+
+ # looks like a problem with apple's result-filter.pl
+ ((++c)); rm -rf implicit-common3;
+ ((++c)); rm -rf order_file-ans;
+
+ # TODO no idea what goes wrong here
+ ((++c)); rm -rf dwarf-debug-notes;
+
+ einfo "Deleted $c tests that were bound to fail"
+
+ cd "${S}"
+ ebegin "cleaning Makefiles from unwanted CFLAGS"
+ find . -name "Makefile" -print0 | xargs -0 sed \
+ -i \
+ -e 's/ -g / /g' \
+ -e 's/^G =.*$/G =/' \
+ -e 's/^OFLAG =.*$/OFLAG =/' \
+ -e 's/install -c -s/install/g'
+ eend $?
+}
+
+src_configure() {
+ ENABLE_LTO=0
+ use lto && ENABLE_LTO=1
+
+ export CTARGET=${CTARGET:-${CHOST}}
+ if [[ ${CTARGET} == ${CHOST} ]] ; then
+ if [[ ${CATEGORY} == cross-* ]] ; then
+ export CTARGET=${CATEGORY#cross-}
+ fi
+ fi
+
+ LIBPATH=/usr/$(get_libdir)/binutils/${CTARGET}/${PV}
+ INCPATH=${LIBPATH}/include
+ DATAPATH=/usr/share/binutils-data/${CTARGET}/${PV}
+ if is_cross ; then
+ BINPATH=/usr/${CHOST}/${CTARGET}/binutils-bin/${PV}
+ else
+ BINPATH=/usr/${CTARGET}/binutils-bin/${PV}
+ fi
+
+ # CPPFLAGS only affects ld64, cctools don't use 'em (which currently is
+ # what we want)
+ append-cppflags -DNDEBUG
+
+ # Block API and thus snapshots supported on >= 10.6
+ [[ ${CHOST} == *darwin* && ${CHOST#*-darwin} -ge 10 ]] && \
+ append-cppflags -DSUPPORT_SNAPSHOTS
+
+ CCTOOLS_OFLAG=
+ if [[ ${CHOST} == *darwin* && ${CHOST#*-darwin} -le 8 ]] ; then
+ # cctools expect to use UNIX03 struct member names.
+ # This is default on > 10.4. Activate it on <= 10.4 by defining
+ # __DARWIN_UNIX03 explicitly.
+ CCTOOLS_OFLAG="-D__DARWIN_UNIX03=1"
+ fi
+
+ # if compiling with USE multitarget, extract all the known arches from
+ # create_configure and pass them back to it
+ creco=${LD64}/src/create_configure
+ ARCHS_TO_SUPPORT=""
+ if use multitarget ; then
+ ARCHS_TO_SUPPORT="$(grep KNOWN_ARCHS= $creco | \
+ cut -d\" -f2 | tr ',' ' ')"
+ fi
+
+ # Create configure.h for ld64 with SUPPORT_ARCH_<arch> defines in it.
+ DERIVED_FILE_DIR=${LD64}/src \
+ RC_SUPPORTED_ARCHS="$ARCHS_TO_SUPPORT" \
+ $creco
+
+ # do not depend on MachOFileAbstraction.hpp to define
+ # SUPPORT_ARCH_arm_any because that's not included by every file where
+ # our ppc/arm-optional patch uses it, ld.hpp in particular
+ grep "SUPPORT_ARCH_armv[0-9]" ${LD64}/src/configure.h >/dev/null && \
+ echo "#define SUPPORT_ARCH_arm_any 1" >> ${LD64}/src/configure.h
+}
+
+compile_ld64() {
+ einfo "building ${LD64}"
+ cd "${S}"/${LD64}/src
+ emake \
+ LTO=${ENABLE_LTO} \
+ || die "emake failed for ld64"
+ use test && emake build_test
+}
+
+compile_cctools() {
+ einfo "building ${CCTOOLS}"
+ cd "${S}"/${CCTOOLS}
+ # Suppress running dsymutil because it will warn about missing debug
+ # info which is expected when compiling without -g as we normally do.
+ # This might need some more thought if anyone ever wanted to build us
+ # for debugging with Apple's tools.
+ emake \
+ LIB_PRUNETRIE="-L../../${LD64}/src -lprunetrie" \
+ EFITOOLS= \
+ LTO="${ENABLE_LTO}" \
+ LTO_LIBDIR=../../../lib \
+ COMMON_SUBDIRS='libstuff ar misc otool' \
+ SUBDIRS_32= \
+ LEGACY= \
+ RC_ProjectSourceVersion=${CCTOOLS_VERSION} \
+ RC_CFLAGS="${CFLAGS}" \
+ OFLAG="${CCTOOLS_OFLAG}" \
+ DSYMUTIL=": disabled: dsymutil" \
+ || die "emake failed for the cctools"
+ cd "${S}"/${CCTOOLS}/as
+ emake \
+ BUILD_OBSOLETE_ARCH= \
+ RC_ProjectSourceVersion=${CCTOOLS_VERSION} \
+ RC_CFLAGS="-DASLIBEXECDIR=\"\\\"${EPREFIX}${LIBPATH}/\\\"\" -DCLANGDIR=\"\\\"${EPREFIX}/usr/bin/\\\"\" ${CFLAGS}" \
+ OFLAG="${CCTOOLS_OFLAG}" \
+ DSYMUTIL=": disabled: dsymutil" \
+ || die "emake failed for as"
+}
+
+src_compile() {
+ compile_ld64
+ compile_cctools
+}
+
+install_ld64() {
+ exeinto ${BINPATH}
+ doexe "${S}"/${LD64}/src/{ld64,rebase,dyldinfo,unwinddump,ObjectDump}
+ dosym ld64 ${BINPATH}/ld
+ insinto ${DATAPATH}/man/man1
+ doins "${S}"/${LD64}/doc/man/man1/{ld,ld64,rebase}.1
+}
+
+install_cctools() {
+ cd "${S}"/${CCTOOLS}
+ emake install_all_but_headers \
+ EFITOOLS= \
+ COMMON_SUBDIRS='ar misc otool' \
+ SUBDIRS_32= \
+ DSTROOT=\"${D}\" \
+ BINDIR=\"${EPREFIX}\"${BINPATH} \
+ LOCBINDIR=\"${EPREFIX}\"${BINPATH} \
+ USRBINDIR=\"${EPREFIX}\"${BINPATH} \
+ LOCLIBDIR=\"${EPREFIX}\"${LIBPATH} \
+ MANDIR=\"${EPREFIX}\"${DATAPATH}/man/
+ cd "${S}"/${CCTOOLS}/as
+ emake install \
+ BUILD_OBSOLETE_ARCH= \
+ DSTROOT=\"${D}\" \
+ USRBINDIR=\"${EPREFIX}\"${BINPATH} \
+ LIBDIR=\"${EPREFIX}\"${LIBPATH} \
+ LOCLIBDIR=\"${EPREFIX}\"${LIBPATH}
+
+ cd "${ED}"${BINPATH}
+ insinto ${DATAPATH}/man/man1
+ local skips manpage
+ # ar brings an up-to-date manpage with it
+ skips=( ar )
+ for bin in *; do
+ for skip in ${skips[@]}; do
+ if [[ ${bin} == ${skip} ]]; then
+ continue 2;
+ fi
+ done
+ manpage=${S}/${CCTOOLS}/man/${bin}.1
+ if [[ -f "${manpage}" ]]; then
+ doins "${manpage}"
+ fi
+ done
+ insinto ${DATAPATH}/man/man5
+ doins "${S}"/${CCTOOLS}/man/*.5
+}
+
+src_test() {
+ if ! [ "${EPREFIX}"/usr/bin/clang ] ; then
+ einfo "Test suite only works properly with clang - please install"
+ return
+ fi
+
+ einfo "Running unit tests"
+ cd "${S}"/${LD64}/unit-tests/test-cases
+ # provide the new ld as a symlink to clang so that -ccc-install-dir
+ # will pick it up
+ ln -sfn ../../src/ld64 ld
+ # use our arch command because the System's will report i386 even for an
+ # x86_64 prefix
+ perl ../bin/make-recursive.pl \
+ BUILT_PRODUCTS_DIR="${S}"/${LD64}/src \
+ ARCH="$(arch)" \
+ LD="${S}"/${LD64}/src/ld64 \
+ CC="${CC} -ccc-install-dir $PWD" \
+ CXX="${CXX} -ccc-install-dir $PWD" \
+ OTOOL="${S}"/${CCTOOLS}/otool/otool.NEW \
+ | perl ../bin/result-filter.pl
+}
+
+src_install() {
+ install_ld64
+ install_cctools
+
+ cd "${S}"
+ insinto /etc/env.d/binutils
+ cat <<-EOF > env.d
+ TARGET="${CHOST}"
+ VER="${PV}"
+ FAKE_TARGETS="${CHOST}"
+ EOF
+ newins env.d ${CHOST}-${PV}
+}
+
+pkg_postinst() {
+ binutils-config ${CHOST}-${PV}
+}
diff --git a/sys-devel/binutils-apple/binutils-apple-7.0.ebuild b/sys-devel/binutils-apple/binutils-apple-7.0.ebuild
new file mode 100644
index 000000000000..c81eb3fe54e0
--- /dev/null
+++ b/sys-devel/binutils-apple/binutils-apple-7.0.ebuild
@@ -0,0 +1,366 @@
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI="5"
+
+inherit eutils flag-o-matic toolchain-funcs
+
+LD64=ld64-253.3
+CCTOOLS_VERSION=877.5
+CCTOOLS=cctools-${CCTOOLS_VERSION}
+LIBUNWIND=libunwind-35.3
+DYLD=dyld-360.14
+
+DESCRIPTION="Darwin assembler as(1) and static linker ld(1), Xcode Tools ${PV}"
+HOMEPAGE="http://www.opensource.apple.com/darwinsource/"
+SRC_URI="http://www.opensource.apple.com/tarballs/ld64/${LD64}.tar.gz
+ http://www.opensource.apple.com/tarballs/cctools/${CCTOOLS}.tar.gz
+ http://www.opensource.apple.com/tarballs/dyld/${DYLD}.tar.gz
+ http://www.opensource.apple.com/tarballs/libunwind/${LIBUNWIND}.tar.gz
+ https://dev.gentoo.org/~grobian/distfiles/${PN}-patches-4.3-r1.tar.bz2
+ https://dev.gentoo.org/~grobian/distfiles/${PN}-patches-5.1-r2.tar.bz2
+ https://dev.gentoo.org/~grobian/distfiles/${PN}-patches-6.1-r1.tar.bz2
+ https://dev.gentoo.org/~grobian/distfiles/${PN}-patches-6.3-r1.tar.bz2
+ https://dev.gentoo.org/~grobian/distfiles/${PN}-patches-7.0-r1.tar.bz2"
+
+LICENSE="APSL-2"
+KEYWORDS="~ppc-macos ~x64-macos ~x86-macos"
+IUSE="test multitarget"
+
+# ld64 can now only be compiled using llvm and libc++ since it massivley uses
+# C++11 language fatures. *But additionally* the as driver now defaults to
+# calling clang as the assembler on many platforms. This can be disabled using
+# -Wa,-Q but since it's default we make llvm a static runtime dependency.
+
+# Also, llvm lto and disassembler interfaces are now widely used in cctools.
+# Since we cannot compile with gcc any more and every llvm since 3.4 has
+# provided those interfaces, we no longer support disabling them. That
+# indirectly makes xar a static runtime dependency.
+RDEPEND="sys-devel/binutils-config
+ app-arch/xar
+ sys-devel/llvm
+ sys-libs/libcxx"
+DEPEND="${RDEPEND}
+ test? ( >=dev-lang/perl-5.8.8 )"
+
+SLOT="7"
+
+S=${WORKDIR}
+
+is_cross() { [[ ${CHOST} != ${CTARGET} ]] ; }
+
+src_prepare() {
+ if use multitarget ; then
+ ewarn "You have enabled support for non-standard target architectures"
+ ewarn "using USE=multitarget. This includes experimental support for"
+ ewarn "ppc and ppc64 which is a community forward-port from the last"
+ ewarn "version of ld64 to officially support PPC."
+
+ if [[ ${CHOST} == powerpc*-darwin* ]] ; then
+ ewarn "HERE BE DRAGONS! Your system seems to be PPC which means that"
+ ewarn "the actual usability of your Gentoo programs will depend on the"
+ ewarn "above-mentioned experimental PPC support in the linker. Be"
+ ewarn "sure to keep a known-to-work version like ${PN}-3.2.6 around!"
+ fi
+ fi
+
+ cd "${S}"/${LD64}/src
+ cp "${S}"/ld64-136-compile_stubs.h ld/compile_stubs.h
+ cp "${S}"/ld64-253.3-Makefile-2 Makefile
+
+ epatch "${S}"/ld64-241.9-extraneous-includes.patch
+ epatch "${S}"/ld64-241.9-osatomic.patch
+ epatch "${S}"/ld64-236.3-crashreporter.patch
+ epatch "${S}"/ld64-253.3-nosnapshots.patch
+ epatch "${S}"/ld64-253.3-ppc.patch
+ epatch "${S}"/ld64-236.3-constant-types-2.patch
+ epatch "${S}"/ld64-241.9-register-names.patch
+ epatch "${S}"/ld64-241.9-get-comm-align.patch
+ epatch "${S}"/ld64-241.9-cc_md5.patch
+ epatch "${S}"/ld64-253.3-make_pair.patch
+ epatch "${S}"/ld64-253.3-delete-warning.patch
+
+ # provide missing headers from libunwind and dyld
+ mkdir -p include/{mach,mach-o/arm} || die
+ # never present because it's private
+ cp ../../${DYLD}/include/mach-o/dyld_priv.h include/mach-o || die
+ # missing on <= 10.5
+ cp ../../${LIBUNWIND}/include/libunwind.h include/ || die
+ cp ../../${LIBUNWIND}/include/mach-o/compact_unwind_encoding.h include/mach-o || die
+ # missing on <= 10.4
+ cp ../../${DYLD}/include/mach-o/dyld_images.h include/mach-o || die
+ cp ../../${CCTOOLS}/include/mach-o/loader.h include/mach-o || die
+ # use copies from cctools because they're otherwise hidden in some SDK
+ cp ../../${CCTOOLS}/include/mach-o/arm/reloc.h include/mach-o/arm || die
+ # provide all required CPU_TYPEs on all platforms
+ cp ../../${CCTOOLS}/include/mach/machine.h include/mach/machine.h
+ # add alias for newer identifiers, because ld64 uses both but cctools
+ # header only defines the older
+ epatch "${S}"/ld64-236.3-missing-cputypes.patch
+
+ # mimic OS X Leopard-style Availability.h macros for libunwind.h on
+ # older systems
+ [[ ${CHOST} == *darwin* && ${CHOST#*-darwin} -le 8 ]] && \
+ echo "#define __OSX_AVAILABLE_STARTING(x,y) " > include/Availability.h
+
+ local VER_STR="\"@(#)PROGRAM:ld PROJECT:${LD64} (Gentoo ${PN}-${PVR})\\n\""
+ echo "char ldVersionString[] = ${VER_STR};" > version.cpp
+
+ epatch "${S}"/ld64-123.2-debug-backtrace.patch
+ if [[ ${CHOST} == powerpc*-darwin* ]] ; then
+ epatch "${S}"/ld64-123.2-darwin8-no-mlong-branch-warning.patch
+ epatch "${S}"/ld64-127.2-thread_state.patch
+ fi
+
+ cd "${S}"/${CCTOOLS}
+ epatch "${S}"/${PN}-4.5-as.patch
+ epatch "${S}"/${PN}-5.1-as-dir.patch
+ epatch "${S}"/${PN}-5.1-ranlib.patch
+ epatch "${S}"/${PN}-3.1.1-libtool-ranlib.patch
+ epatch "${S}"/${PN}-3.1.1-no-headers.patch
+ epatch "${S}"/${PN}-4.0-no-oss-dir.patch
+ epatch "${S}"/cctools-839-intel-retf.patch
+ epatch "${S}"/${PN}-5.1-extraneous-includes.patch
+ #epatch "${S}"/${PN}-5.1-otool-stdc.patch
+ epatch "${S}"/${PN}-5.1-constant-types.patch
+ epatch "${S}"/${PN}-5.1-strnlen.patch
+ epatch "${S}"/${PN}-5.1-ppc.patch
+ epatch "${S}"/${PN}-5.1-thread-state-redefined.patch
+ epatch "${S}"/${PN}-5.1-makefile-target-warning.patch
+ epatch "${S}"/${PN}-7.0-lto-prefix.patch
+ epatch "${S}"/${PN}-7.0-clang-as.patch
+ cp ../${LD64}/src/other/prune_trie.h include/mach-o/ || die
+
+ # do not build profileable libstuff to save compile time
+ sed -i -e "/^all:/s, profile , ," libstuff/Makefile
+
+ # cctools version is provided to make via RC_ProjectSourceVersion which
+ # generates and compiles it as apple_version[] into libstuff. From
+ # there it's picked up by the individual tools. Since
+ # RC_ProjectSourceVersion is also used as library version, we can't
+ # just append our local version info. So we hack the libstuff Makefile
+ # to include our Gentoo version.
+ sed -i -e "/cctools-.*(RC_ProjectSourceVersion).*OFILE_DIR/s,Version),Version) (Gentoo ${PN}-${PVR})," \
+ libstuff/Makefile
+
+ # clean up test suite
+ cd "${S}"/${LD64}/unit-tests/test-cases
+ local c
+
+ # we don't have llvm
+ ((++c)); rm -rf llvm-integration;
+
+ # we don't have dtrace
+ ((++c)); rm -rf dtrace-static-probes-coalescing;
+ ((++c)); rm -rf dtrace-static-probes;
+
+ # a file is missing
+ ((++c)); rm -rf eh-coalescing-r
+
+ # we don't do universal binaries
+ ((++c)); rm -rf blank-stubs;
+
+ # looks like a problem with apple's result-filter.pl
+ ((++c)); rm -rf implicit-common3;
+ ((++c)); rm -rf order_file-ans;
+
+ # TODO no idea what goes wrong here
+ ((++c)); rm -rf dwarf-debug-notes;
+
+ einfo "Deleted $c tests that were bound to fail"
+
+ cd "${S}"
+ ebegin "cleaning Makefiles from unwanted CFLAGS"
+ find . -name "Makefile" -print0 | xargs -0 sed \
+ -i \
+ -e 's/ -g / /g' \
+ -e 's/^G =.*$/G =/' \
+ -e 's/^OFLAG =.*$/OFLAG =/' \
+ -e 's/install -c -s/install/g'
+ eend $?
+}
+
+src_configure() {
+ export CTARGET=${CTARGET:-${CHOST}}
+ if [[ ${CTARGET} == ${CHOST} ]] ; then
+ if [[ ${CATEGORY} == cross-* ]] ; then
+ export CTARGET=${CATEGORY#cross-}
+ fi
+ fi
+
+ LIBPATH=/usr/$(get_libdir)/binutils/${CTARGET}/${PV}
+ INCPATH=${LIBPATH}/include
+ DATAPATH=/usr/share/binutils-data/${CTARGET}/${PV}
+ if is_cross ; then
+ BINPATH=/usr/${CHOST}/${CTARGET}/binutils-bin/${PV}
+ else
+ BINPATH=/usr/${CTARGET}/binutils-bin/${PV}
+ fi
+
+ # CPPFLAGS only affects ld64, cctools don't use 'em (which currently is
+ # what we want)
+ append-cppflags -DNDEBUG
+
+ # Block API and thus snapshots supported on >= 10.6
+ [[ ${CHOST} == *darwin* && ${CHOST#*-darwin} -ge 10 ]] && \
+ append-cppflags -DSUPPORT_SNAPSHOTS
+
+ CCTOOLS_OFLAG=
+ if [[ ${CHOST} == *darwin* && ${CHOST#*-darwin} -le 8 ]] ; then
+ # cctools expect to use UNIX03 struct member names.
+ # This is default on > 10.4. Activate it on <= 10.4 by defining
+ # __DARWIN_UNIX03 explicitly.
+ CCTOOLS_OFLAG="-D__DARWIN_UNIX03=1"
+ fi
+
+ # if compiling with USE multitarget, extract all the known arches from
+ # create_configure and pass them back to it
+ creco=${LD64}/src/create_configure
+ ARCHS_TO_SUPPORT=""
+ if use multitarget ; then
+ ARCHS_TO_SUPPORT="$(grep KNOWN_ARCHS= $creco | \
+ cut -d\" -f2 | tr ',' ' ')"
+ fi
+
+ # Create configure.h for ld64 with SUPPORT_ARCH_<arch> defines in it.
+ DERIVED_FILE_DIR=${LD64}/src \
+ RC_SUPPORTED_ARCHS="$ARCHS_TO_SUPPORT" \
+ $creco
+
+ # do not depend on MachOFileAbstraction.hpp to define
+ # SUPPORT_ARCH_arm_any because that's not included by every file where
+ # our ppc/arm-optional patch uses it, ld.hpp in particular
+ grep "SUPPORT_ARCH_armv[0-9]" ${LD64}/src/configure.h >/dev/null && \
+ echo "#define SUPPORT_ARCH_arm_any 1" >> ${LD64}/src/configure.h
+}
+
+compile_ld64() {
+ einfo "building ${LD64}"
+ cd "${S}"/${LD64}/src
+ emake || die "emake failed for ld64"
+ use test && emake build_test
+}
+
+compile_cctools() {
+ einfo "building ${CCTOOLS}"
+ cd "${S}"/${CCTOOLS}
+ # -j1 because it fails too often with weird errors
+ # Suppress running dsymutil because it will warn about missing debug
+ # info which is expected when compiling without -g as we normally do.
+ # This might need some more thought if anyone ever wanted to build us
+ # for debugging with Apple's tools.
+ emake \
+ LIB_PRUNETRIE="-L../../${LD64}/src -lprunetrie" \
+ EFITOOLS= \
+ COMMON_SUBDIRS='libstuff ar misc otool' \
+ SUBDIRS_32= \
+ LEGACY= \
+ RC_ProjectSourceVersion=${CCTOOLS_VERSION} \
+ RC_CFLAGS="${CFLAGS}" \
+ OFLAG="${CCTOOLS_OFLAG}" \
+ DSYMUTIL=": disabled: dsymutil" \
+ -j1 \
+ || die "emake failed for the cctools"
+ cd "${S}"/${CCTOOLS}/as
+ emake \
+ BUILD_OBSOLETE_ARCH= \
+ RC_ProjectSourceVersion=${CCTOOLS_VERSION} \
+ RC_CFLAGS="-DASLIBEXECDIR=\"\\\"${EPREFIX}${LIBPATH}/\\\"\" -DCLANGDIR=\"\\\"${EPREFIX}/usr/bin/\\\"\" ${CFLAGS}" \
+ OFLAG="${CCTOOLS_OFLAG}" \
+ DSYMUTIL=": disabled: dsymutil" \
+ || die "emake failed for as"
+}
+
+src_compile() {
+ compile_ld64
+ compile_cctools
+}
+
+install_ld64() {
+ exeinto ${BINPATH}
+ doexe "${S}"/${LD64}/src/{ld64,rebase,dyldinfo,unwinddump,ObjectDump}
+ dosym ld64 ${BINPATH}/ld
+ insinto ${DATAPATH}/man/man1
+ doins "${S}"/${LD64}/doc/man/man1/{ld,ld64,rebase}.1
+}
+
+install_cctools() {
+ cd "${S}"/${CCTOOLS}
+ emake install_all_but_headers \
+ EFITOOLS= \
+ COMMON_SUBDIRS='ar misc otool' \
+ SUBDIRS_32= \
+ DSTROOT=\"${D}\" \
+ BINDIR=\"${EPREFIX}\"${BINPATH} \
+ LOCBINDIR=\"${EPREFIX}\"${BINPATH} \
+ USRBINDIR=\"${EPREFIX}\"${BINPATH} \
+ LOCLIBDIR=\"${EPREFIX}\"${LIBPATH} \
+ MANDIR=\"${EPREFIX}\"${DATAPATH}/man/
+ cd "${S}"/${CCTOOLS}/as
+ emake install \
+ BUILD_OBSOLETE_ARCH= \
+ DSTROOT=\"${D}\" \
+ USRBINDIR=\"${EPREFIX}\"${BINPATH} \
+ LIBDIR=\"${EPREFIX}\"${LIBPATH} \
+ LOCLIBDIR=\"${EPREFIX}\"${LIBPATH}
+
+ cd "${ED}"${BINPATH}
+ insinto ${DATAPATH}/man/man1
+ local skips manpage
+ # ar brings an up-to-date manpage with it
+ skips=( ar )
+ for bin in *; do
+ for skip in ${skips[@]}; do
+ if [[ ${bin} == ${skip} ]]; then
+ continue 2;
+ fi
+ done
+ manpage=${S}/${CCTOOLS}/man/${bin}.1
+ if [[ -f "${manpage}" ]]; then
+ doins "${manpage}"
+ fi
+ done
+ insinto ${DATAPATH}/man/man5
+ doins "${S}"/${CCTOOLS}/man/*.5
+}
+
+src_test() {
+ if ! [ "${EPREFIX}"/usr/bin/clang ] ; then
+ einfo "Test suite only works properly with clang - please install"
+ return
+ fi
+
+ einfo "Running unit tests"
+ cd "${S}"/${LD64}/unit-tests/test-cases
+ # provide the new ld as a symlink to clang so that -ccc-install-dir
+ # will pick it up
+ ln -sfn ../../src/ld64 ld
+ # use our arch command because the System's will report i386 even for an
+ # x86_64 prefix
+ perl ../bin/make-recursive.pl \
+ BUILT_PRODUCTS_DIR="${S}"/${LD64}/src \
+ ARCH="$(arch)" \
+ LD="${S}"/${LD64}/src/ld64 \
+ CC="${CC} -ccc-install-dir $PWD" \
+ CXX="${CXX} -ccc-install-dir $PWD" \
+ OTOOL="${S}"/${CCTOOLS}/otool/otool.NEW \
+ | perl ../bin/result-filter.pl
+}
+
+src_install() {
+ install_ld64
+ install_cctools
+
+ cd "${S}"
+ insinto /etc/env.d/binutils
+ cat <<-EOF > env.d
+ TARGET="${CHOST}"
+ VER="${PV}"
+ FAKE_TARGETS="${CHOST}"
+ EOF
+ newins env.d ${CHOST}-${PV}
+}
+
+pkg_postinst() {
+ binutils-config ${CHOST}-${PV}
+}
diff --git a/sys-devel/binutils-apple/binutils-apple-7.1-r1.ebuild b/sys-devel/binutils-apple/binutils-apple-7.1-r1.ebuild
new file mode 100644
index 000000000000..6b57a7444fd8
--- /dev/null
+++ b/sys-devel/binutils-apple/binutils-apple-7.1-r1.ebuild
@@ -0,0 +1,369 @@
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI="5"
+
+inherit eutils flag-o-matic toolchain-funcs
+
+LD64=ld64-253.6
+CCTOOLS_VERSION=877.7
+CCTOOLS=cctools-${CCTOOLS_VERSION}
+LIBUNWIND=libunwind-35.3
+DYLD=dyld-360.17
+
+DESCRIPTION="Darwin assembler as(1) and static linker ld(1), Xcode Tools ${PV}"
+HOMEPAGE="http://www.opensource.apple.com/darwinsource/"
+SRC_URI="http://www.opensource.apple.com/tarballs/ld64/${LD64}.tar.gz
+ http://www.opensource.apple.com/tarballs/cctools/${CCTOOLS}.tar.gz
+ http://www.opensource.apple.com/tarballs/dyld/${DYLD}.tar.gz
+ http://www.opensource.apple.com/tarballs/libunwind/${LIBUNWIND}.tar.gz
+ https://dev.gentoo.org/~grobian/distfiles/${PN}-patches-4.3-r1.tar.bz2
+ https://dev.gentoo.org/~grobian/distfiles/${PN}-patches-5.1-r2.tar.bz2
+ https://dev.gentoo.org/~grobian/distfiles/${PN}-patches-6.1-r1.tar.bz2
+ https://dev.gentoo.org/~grobian/distfiles/${PN}-patches-6.3-r1.tar.bz2
+ https://dev.gentoo.org/~grobian/distfiles/${PN}-patches-7.0-r2.tar.bz2"
+
+LICENSE="APSL-2"
+KEYWORDS="~ppc-macos ~x64-macos ~x86-macos"
+IUSE="lto test multitarget"
+
+# ld64 can now only be compiled using llvm and libc++ since it massivley uses
+# C++11 language fatures. *But additionally* the as driver now defaults to
+# calling clang as the assembler on many platforms. This can be disabled using
+# -Wa,-Q but since it's default we make llvm a static runtime dependency.
+RDEPEND="sys-devel/binutils-config
+ lto? ( app-arch/xar )
+ sys-devel/llvm
+ sys-libs/libcxx"
+DEPEND="${RDEPEND}
+ test? ( >=dev-lang/perl-5.8.8 )"
+
+SLOT="7"
+
+S=${WORKDIR}
+
+is_cross() { [[ ${CHOST} != ${CTARGET} ]] ; }
+
+src_prepare() {
+ if use multitarget ; then
+ ewarn "You have enabled support for non-standard target architectures"
+ ewarn "using USE=multitarget. This includes experimental support for"
+ ewarn "ppc and ppc64 which is a community forward-port from the last"
+ ewarn "version of ld64 to officially support PPC."
+
+ if [[ ${CHOST} == powerpc*-darwin* ]] ; then
+ ewarn "HERE BE DRAGONS! Your system seems to be PPC which means that"
+ ewarn "the actual usability of your Gentoo programs will depend on the"
+ ewarn "above-mentioned experimental PPC support in the linker. Be"
+ ewarn "sure to keep a known-to-work version like ${PN}-3.2.6 around!"
+ fi
+ fi
+
+ cd "${S}"/${LD64}/src
+ cp "${S}"/ld64-136-compile_stubs.h ld/compile_stubs.h
+ cp "${S}"/ld64-253.3-Makefile-3 Makefile
+
+ epatch "${S}"/ld64-253.3-nolto.patch
+ epatch "${S}"/ld64-241.9-extraneous-includes.patch
+ epatch "${S}"/ld64-241.9-osatomic.patch
+ epatch "${S}"/ld64-236.3-crashreporter.patch
+ epatch "${S}"/ld64-253.3-nosnapshots.patch
+ epatch "${S}"/ld64-253.3-ppc.patch
+ epatch "${S}"/ld64-236.3-constant-types-2.patch
+ epatch "${S}"/ld64-241.9-register-names.patch
+ epatch "${S}"/ld64-241.9-get-comm-align.patch
+ epatch "${S}"/ld64-241.9-cc_md5.patch
+ epatch "${S}"/ld64-253.3-make_pair.patch
+ epatch "${S}"/ld64-253.3-delete-warning.patch
+
+ # provide missing headers from libunwind and dyld
+ mkdir -p include/{mach,mach-o/arm} || die
+ # never present because it's private
+ cp ../../${DYLD}/include/mach-o/dyld_priv.h include/mach-o || die
+ # missing on <= 10.5
+ cp ../../${LIBUNWIND}/include/libunwind.h include/ || die
+ cp ../../${LIBUNWIND}/include/mach-o/compact_unwind_encoding.h include/mach-o || die
+ # missing on <= 10.4
+ cp ../../${DYLD}/include/mach-o/dyld_images.h include/mach-o || die
+ cp ../../${CCTOOLS}/include/mach-o/loader.h include/mach-o || die
+ # use copies from cctools because they're otherwise hidden in some SDK
+ cp ../../${CCTOOLS}/include/mach-o/arm/reloc.h include/mach-o/arm || die
+ # provide all required CPU_TYPEs on all platforms
+ cp ../../${CCTOOLS}/include/mach/machine.h include/mach/machine.h
+ # add alias for newer identifiers, because ld64 uses both but cctools
+ # header only defines the older
+ epatch "${S}"/ld64-236.3-missing-cputypes.patch
+
+ # mimic OS X Leopard-style Availability.h macros for libunwind.h on
+ # older systems
+ [[ ${CHOST} == *darwin* && ${CHOST#*-darwin} -le 8 ]] && \
+ echo "#define __OSX_AVAILABLE_STARTING(x,y) " > include/Availability.h
+
+ local VER_STR="\"@(#)PROGRAM:ld PROJECT:${LD64} (Gentoo ${PN}-${PVR})\\n\""
+ echo "char ldVersionString[] = ${VER_STR};" > version.cpp
+
+ epatch "${S}"/ld64-123.2-debug-backtrace.patch
+ if [[ ${CHOST} == powerpc*-darwin* ]] ; then
+ epatch "${S}"/ld64-123.2-darwin8-no-mlong-branch-warning.patch
+ epatch "${S}"/ld64-127.2-thread_state.patch
+ fi
+
+ cd "${S}"/${CCTOOLS}
+ epatch "${S}"/${PN}-4.5-as.patch
+ epatch "${S}"/${PN}-5.1-as-dir.patch
+ epatch "${S}"/${PN}-5.1-ranlib.patch
+ epatch "${S}"/${PN}-3.1.1-libtool-ranlib.patch
+ epatch "${S}"/${PN}-3.1.1-no-headers.patch
+ epatch "${S}"/${PN}-4.0-no-oss-dir.patch
+ epatch "${S}"/cctools-839-intel-retf.patch
+ epatch "${S}"/${PN}-5.1-extraneous-includes.patch
+ #epatch "${S}"/${PN}-5.1-otool-stdc.patch
+ epatch "${S}"/${PN}-5.1-constant-types.patch
+ epatch "${S}"/${PN}-5.1-strnlen.patch
+ epatch "${S}"/${PN}-5.1-ppc.patch
+ epatch "${S}"/${PN}-5.1-thread-state-redefined.patch
+ epatch "${S}"/${PN}-7.0-make-j.patch
+ epatch "${S}"/${PN}-7.0-lto-prefix-2.patch
+ epatch "${S}"/${PN}-7.0-clang-as.patch
+ epatch "${S}"/${PN}-7.0-nolto.patch
+ epatch "${S}"/${PN}-7.0-nollvm.patch
+ cp ../${LD64}/src/other/prune_trie.h include/mach-o/ || die
+
+ # do not build profileable libstuff to save compile time
+ sed -i -e "/^all:/s, profile , ," libstuff/Makefile
+
+ # cctools version is provided to make via RC_ProjectSourceVersion which
+ # generates and compiles it as apple_version[] into libstuff. From
+ # there it's picked up by the individual tools. Since
+ # RC_ProjectSourceVersion is also used as library version, we can't
+ # just append our local version info. So we hack the libstuff Makefile
+ # to include our Gentoo version.
+ sed -i -e "/cctools-.*(RC_ProjectSourceVersion).*OFILE_DIR/s,Version),Version) (Gentoo ${PN}-${PVR})," \
+ libstuff/Makefile
+
+ # clean up test suite
+ cd "${S}"/${LD64}/unit-tests/test-cases
+ local c
+
+ # we don't have llvm
+ ((++c)); rm -rf llvm-integration;
+
+ # we don't have dtrace
+ ((++c)); rm -rf dtrace-static-probes-coalescing;
+ ((++c)); rm -rf dtrace-static-probes;
+
+ # a file is missing
+ ((++c)); rm -rf eh-coalescing-r
+
+ # we don't do universal binaries
+ ((++c)); rm -rf blank-stubs;
+
+ # looks like a problem with apple's result-filter.pl
+ ((++c)); rm -rf implicit-common3;
+ ((++c)); rm -rf order_file-ans;
+
+ # TODO no idea what goes wrong here
+ ((++c)); rm -rf dwarf-debug-notes;
+
+ einfo "Deleted $c tests that were bound to fail"
+
+ cd "${S}"
+ ebegin "cleaning Makefiles from unwanted CFLAGS"
+ find . -name "Makefile" -print0 | xargs -0 sed \
+ -i \
+ -e 's/ -g / /g' \
+ -e 's/^G =.*$/G =/' \
+ -e 's/^OFLAG =.*$/OFLAG =/' \
+ -e 's/install -c -s/install/g'
+ eend $?
+}
+
+src_configure() {
+ ENABLE_LTO=0
+ use lto && ENABLE_LTO=1
+
+ export CTARGET=${CTARGET:-${CHOST}}
+ if [[ ${CTARGET} == ${CHOST} ]] ; then
+ if [[ ${CATEGORY} == cross-* ]] ; then
+ export CTARGET=${CATEGORY#cross-}
+ fi
+ fi
+
+ LIBPATH=/usr/$(get_libdir)/binutils/${CTARGET}/${PV}
+ INCPATH=${LIBPATH}/include
+ DATAPATH=/usr/share/binutils-data/${CTARGET}/${PV}
+ if is_cross ; then
+ BINPATH=/usr/${CHOST}/${CTARGET}/binutils-bin/${PV}
+ else
+ BINPATH=/usr/${CTARGET}/binutils-bin/${PV}
+ fi
+
+ # CPPFLAGS only affects ld64, cctools don't use 'em (which currently is
+ # what we want)
+ append-cppflags -DNDEBUG
+
+ # Block API and thus snapshots supported on >= 10.6
+ [[ ${CHOST} == *darwin* && ${CHOST#*-darwin} -ge 10 ]] && \
+ append-cppflags -DSUPPORT_SNAPSHOTS
+
+ CCTOOLS_OFLAG=
+ if [[ ${CHOST} == *darwin* && ${CHOST#*-darwin} -le 8 ]] ; then
+ # cctools expect to use UNIX03 struct member names.
+ # This is default on > 10.4. Activate it on <= 10.4 by defining
+ # __DARWIN_UNIX03 explicitly.
+ CCTOOLS_OFLAG="-D__DARWIN_UNIX03=1"
+ fi
+
+ # if compiling with USE multitarget, extract all the known arches from
+ # create_configure and pass them back to it
+ creco=${LD64}/src/create_configure
+ ARCHS_TO_SUPPORT=""
+ if use multitarget ; then
+ ARCHS_TO_SUPPORT="$(grep KNOWN_ARCHS= $creco | \
+ cut -d\" -f2 | tr ',' ' ')"
+ fi
+
+ # Create configure.h for ld64 with SUPPORT_ARCH_<arch> defines in it.
+ DERIVED_FILE_DIR=${LD64}/src \
+ RC_SUPPORTED_ARCHS="$ARCHS_TO_SUPPORT" \
+ $creco
+
+ # do not depend on MachOFileAbstraction.hpp to define
+ # SUPPORT_ARCH_arm_any because that's not included by every file where
+ # our ppc/arm-optional patch uses it, ld.hpp in particular
+ grep "SUPPORT_ARCH_armv[0-9]" ${LD64}/src/configure.h >/dev/null && \
+ echo "#define SUPPORT_ARCH_arm_any 1" >> ${LD64}/src/configure.h
+}
+
+compile_ld64() {
+ einfo "building ${LD64}"
+ cd "${S}"/${LD64}/src
+ emake \
+ LTO=${ENABLE_LTO} \
+ || die "emake failed for ld64"
+ use test && emake build_test
+}
+
+compile_cctools() {
+ einfo "building ${CCTOOLS}"
+ cd "${S}"/${CCTOOLS}
+ # Suppress running dsymutil because it will warn about missing debug
+ # info which is expected when compiling without -g as we normally do.
+ # This might need some more thought if anyone ever wanted to build us
+ # for debugging with Apple's tools.
+ emake \
+ LIB_PRUNETRIE="-L../../${LD64}/src -lprunetrie" \
+ EFITOOLS= \
+ LTO="${ENABLE_LTO}" \
+ LTO_LIBDIR=../../../lib \
+ COMMON_SUBDIRS='libstuff ar misc otool' \
+ SUBDIRS_32= \
+ LEGACY= \
+ RC_ProjectSourceVersion=${CCTOOLS_VERSION} \
+ RC_CFLAGS="${CFLAGS}" \
+ OFLAG="${CCTOOLS_OFLAG}" \
+ DSYMUTIL=": disabled: dsymutil" \
+ || die "emake failed for the cctools"
+ cd "${S}"/${CCTOOLS}/as
+ emake \
+ BUILD_OBSOLETE_ARCH= \
+ RC_ProjectSourceVersion=${CCTOOLS_VERSION} \
+ RC_CFLAGS="-DASLIBEXECDIR=\"\\\"${EPREFIX}${LIBPATH}/\\\"\" -DCLANGDIR=\"\\\"${EPREFIX}/usr/bin/\\\"\" ${CFLAGS}" \
+ OFLAG="${CCTOOLS_OFLAG}" \
+ DSYMUTIL=": disabled: dsymutil" \
+ || die "emake failed for as"
+}
+
+src_compile() {
+ compile_ld64
+ compile_cctools
+}
+
+install_ld64() {
+ exeinto ${BINPATH}
+ doexe "${S}"/${LD64}/src/{ld64,rebase,dyldinfo,unwinddump,ObjectDump}
+ dosym ld64 ${BINPATH}/ld
+ insinto ${DATAPATH}/man/man1
+ doins "${S}"/${LD64}/doc/man/man1/{ld,ld64,rebase}.1
+}
+
+install_cctools() {
+ cd "${S}"/${CCTOOLS}
+ emake install_all_but_headers \
+ EFITOOLS= \
+ COMMON_SUBDIRS='ar misc otool' \
+ SUBDIRS_32= \
+ DSTROOT=\"${D}\" \
+ BINDIR=\"${EPREFIX}\"${BINPATH} \
+ LOCBINDIR=\"${EPREFIX}\"${BINPATH} \
+ USRBINDIR=\"${EPREFIX}\"${BINPATH} \
+ LOCLIBDIR=\"${EPREFIX}\"${LIBPATH} \
+ MANDIR=\"${EPREFIX}\"${DATAPATH}/man/
+ cd "${S}"/${CCTOOLS}/as
+ emake install \
+ BUILD_OBSOLETE_ARCH= \
+ DSTROOT=\"${D}\" \
+ USRBINDIR=\"${EPREFIX}\"${BINPATH} \
+ LIBDIR=\"${EPREFIX}\"${LIBPATH} \
+ LOCLIBDIR=\"${EPREFIX}\"${LIBPATH}
+
+ cd "${ED}"${BINPATH}
+ insinto ${DATAPATH}/man/man1
+ local skips manpage
+ # ar brings an up-to-date manpage with it
+ skips=( ar )
+ for bin in *; do
+ for skip in ${skips[@]}; do
+ if [[ ${bin} == ${skip} ]]; then
+ continue 2;
+ fi
+ done
+ manpage=${S}/${CCTOOLS}/man/${bin}.1
+ if [[ -f "${manpage}" ]]; then
+ doins "${manpage}"
+ fi
+ done
+ insinto ${DATAPATH}/man/man5
+ doins "${S}"/${CCTOOLS}/man/*.5
+}
+
+src_test() {
+ if ! [ "${EPREFIX}"/usr/bin/clang ] ; then
+ einfo "Test suite only works properly with clang - please install"
+ return
+ fi
+
+ einfo "Running unit tests"
+ cd "${S}"/${LD64}/unit-tests/test-cases
+ # provide the new ld as a symlink to clang so that -ccc-install-dir
+ # will pick it up
+ ln -sfn ../../src/ld64 ld
+ # use our arch command because the System's will report i386 even for an
+ # x86_64 prefix
+ perl ../bin/make-recursive.pl \
+ BUILT_PRODUCTS_DIR="${S}"/${LD64}/src \
+ ARCH="$(arch)" \
+ LD="${S}"/${LD64}/src/ld64 \
+ CC="${CC} -ccc-install-dir $PWD" \
+ CXX="${CXX} -ccc-install-dir $PWD" \
+ OTOOL="${S}"/${CCTOOLS}/otool/otool.NEW \
+ | perl ../bin/result-filter.pl
+}
+
+src_install() {
+ install_ld64
+ install_cctools
+
+ cd "${S}"
+ insinto /etc/env.d/binutils
+ cat <<-EOF > env.d
+ TARGET="${CHOST}"
+ VER="${PV}"
+ FAKE_TARGETS="${CHOST}"
+ EOF
+ newins env.d ${CHOST}-${PV}
+}
+
+pkg_postinst() {
+ binutils-config ${CHOST}-${PV}
+}
diff --git a/sys-devel/binutils-apple/binutils-apple-7.1.ebuild b/sys-devel/binutils-apple/binutils-apple-7.1.ebuild
new file mode 100644
index 000000000000..9dfebf05d008
--- /dev/null
+++ b/sys-devel/binutils-apple/binutils-apple-7.1.ebuild
@@ -0,0 +1,366 @@
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI="5"
+
+inherit eutils flag-o-matic toolchain-funcs
+
+LD64=ld64-253.6
+CCTOOLS_VERSION=877.7
+CCTOOLS=cctools-${CCTOOLS_VERSION}
+LIBUNWIND=libunwind-35.3
+DYLD=dyld-360.17
+
+DESCRIPTION="Darwin assembler as(1) and static linker ld(1), Xcode Tools ${PV}"
+HOMEPAGE="http://www.opensource.apple.com/darwinsource/"
+SRC_URI="http://www.opensource.apple.com/tarballs/ld64/${LD64}.tar.gz
+ http://www.opensource.apple.com/tarballs/cctools/${CCTOOLS}.tar.gz
+ http://www.opensource.apple.com/tarballs/dyld/${DYLD}.tar.gz
+ http://www.opensource.apple.com/tarballs/libunwind/${LIBUNWIND}.tar.gz
+ https://dev.gentoo.org/~grobian/distfiles/${PN}-patches-4.3-r1.tar.bz2
+ https://dev.gentoo.org/~grobian/distfiles/${PN}-patches-5.1-r2.tar.bz2
+ https://dev.gentoo.org/~grobian/distfiles/${PN}-patches-6.1-r1.tar.bz2
+ https://dev.gentoo.org/~grobian/distfiles/${PN}-patches-6.3-r1.tar.bz2
+ https://dev.gentoo.org/~grobian/distfiles/${PN}-patches-7.0-r1.tar.bz2"
+
+LICENSE="APSL-2"
+KEYWORDS="~ppc-macos ~x64-macos ~x86-macos"
+IUSE="test multitarget"
+
+# ld64 can now only be compiled using llvm and libc++ since it massivley uses
+# C++11 language fatures. *But additionally* the as driver now defaults to
+# calling clang as the assembler on many platforms. This can be disabled using
+# -Wa,-Q but since it's default we make llvm a static runtime dependency.
+
+# Also, llvm lto and disassembler interfaces are now widely used in cctools.
+# Since we cannot compile with gcc any more and every llvm since 3.4 has
+# provided those interfaces, we no longer support disabling them. That
+# indirectly makes xar a static runtime dependency.
+RDEPEND="sys-devel/binutils-config
+ app-arch/xar
+ sys-devel/llvm
+ sys-libs/libcxx"
+DEPEND="${RDEPEND}
+ test? ( >=dev-lang/perl-5.8.8 )"
+
+SLOT="7"
+
+S=${WORKDIR}
+
+is_cross() { [[ ${CHOST} != ${CTARGET} ]] ; }
+
+src_prepare() {
+ if use multitarget ; then
+ ewarn "You have enabled support for non-standard target architectures"
+ ewarn "using USE=multitarget. This includes experimental support for"
+ ewarn "ppc and ppc64 which is a community forward-port from the last"
+ ewarn "version of ld64 to officially support PPC."
+
+ if [[ ${CHOST} == powerpc*-darwin* ]] ; then
+ ewarn "HERE BE DRAGONS! Your system seems to be PPC which means that"
+ ewarn "the actual usability of your Gentoo programs will depend on the"
+ ewarn "above-mentioned experimental PPC support in the linker. Be"
+ ewarn "sure to keep a known-to-work version like ${PN}-3.2.6 around!"
+ fi
+ fi
+
+ cd "${S}"/${LD64}/src
+ cp "${S}"/ld64-136-compile_stubs.h ld/compile_stubs.h
+ cp "${S}"/ld64-253.3-Makefile-2 Makefile
+
+ epatch "${S}"/ld64-241.9-extraneous-includes.patch
+ epatch "${S}"/ld64-241.9-osatomic.patch
+ epatch "${S}"/ld64-236.3-crashreporter.patch
+ epatch "${S}"/ld64-253.3-nosnapshots.patch
+ epatch "${S}"/ld64-253.3-ppc.patch
+ epatch "${S}"/ld64-236.3-constant-types-2.patch
+ epatch "${S}"/ld64-241.9-register-names.patch
+ epatch "${S}"/ld64-241.9-get-comm-align.patch
+ epatch "${S}"/ld64-241.9-cc_md5.patch
+ epatch "${S}"/ld64-253.3-make_pair.patch
+ epatch "${S}"/ld64-253.3-delete-warning.patch
+
+ # provide missing headers from libunwind and dyld
+ mkdir -p include/{mach,mach-o/arm} || die
+ # never present because it's private
+ cp ../../${DYLD}/include/mach-o/dyld_priv.h include/mach-o || die
+ # missing on <= 10.5
+ cp ../../${LIBUNWIND}/include/libunwind.h include/ || die
+ cp ../../${LIBUNWIND}/include/mach-o/compact_unwind_encoding.h include/mach-o || die
+ # missing on <= 10.4
+ cp ../../${DYLD}/include/mach-o/dyld_images.h include/mach-o || die
+ cp ../../${CCTOOLS}/include/mach-o/loader.h include/mach-o || die
+ # use copies from cctools because they're otherwise hidden in some SDK
+ cp ../../${CCTOOLS}/include/mach-o/arm/reloc.h include/mach-o/arm || die
+ # provide all required CPU_TYPEs on all platforms
+ cp ../../${CCTOOLS}/include/mach/machine.h include/mach/machine.h
+ # add alias for newer identifiers, because ld64 uses both but cctools
+ # header only defines the older
+ epatch "${S}"/ld64-236.3-missing-cputypes.patch
+
+ # mimic OS X Leopard-style Availability.h macros for libunwind.h on
+ # older systems
+ [[ ${CHOST} == *darwin* && ${CHOST#*-darwin} -le 8 ]] && \
+ echo "#define __OSX_AVAILABLE_STARTING(x,y) " > include/Availability.h
+
+ local VER_STR="\"@(#)PROGRAM:ld PROJECT:${LD64} (Gentoo ${PN}-${PVR})\\n\""
+ echo "char ldVersionString[] = ${VER_STR};" > version.cpp
+
+ epatch "${S}"/ld64-123.2-debug-backtrace.patch
+ if [[ ${CHOST} == powerpc*-darwin* ]] ; then
+ epatch "${S}"/ld64-123.2-darwin8-no-mlong-branch-warning.patch
+ epatch "${S}"/ld64-127.2-thread_state.patch
+ fi
+
+ cd "${S}"/${CCTOOLS}
+ epatch "${S}"/${PN}-4.5-as.patch
+ epatch "${S}"/${PN}-5.1-as-dir.patch
+ epatch "${S}"/${PN}-5.1-ranlib.patch
+ epatch "${S}"/${PN}-3.1.1-libtool-ranlib.patch
+ epatch "${S}"/${PN}-3.1.1-no-headers.patch
+ epatch "${S}"/${PN}-4.0-no-oss-dir.patch
+ epatch "${S}"/cctools-839-intel-retf.patch
+ epatch "${S}"/${PN}-5.1-extraneous-includes.patch
+ #epatch "${S}"/${PN}-5.1-otool-stdc.patch
+ epatch "${S}"/${PN}-5.1-constant-types.patch
+ epatch "${S}"/${PN}-5.1-strnlen.patch
+ epatch "${S}"/${PN}-5.1-ppc.patch
+ epatch "${S}"/${PN}-5.1-thread-state-redefined.patch
+ epatch "${S}"/${PN}-5.1-makefile-target-warning.patch
+ epatch "${S}"/${PN}-7.0-lto-prefix.patch
+ epatch "${S}"/${PN}-7.0-clang-as.patch
+ cp ../${LD64}/src/other/prune_trie.h include/mach-o/ || die
+
+ # do not build profileable libstuff to save compile time
+ sed -i -e "/^all:/s, profile , ," libstuff/Makefile
+
+ # cctools version is provided to make via RC_ProjectSourceVersion which
+ # generates and compiles it as apple_version[] into libstuff. From
+ # there it's picked up by the individual tools. Since
+ # RC_ProjectSourceVersion is also used as library version, we can't
+ # just append our local version info. So we hack the libstuff Makefile
+ # to include our Gentoo version.
+ sed -i -e "/cctools-.*(RC_ProjectSourceVersion).*OFILE_DIR/s,Version),Version) (Gentoo ${PN}-${PVR})," \
+ libstuff/Makefile
+
+ # clean up test suite
+ cd "${S}"/${LD64}/unit-tests/test-cases
+ local c
+
+ # we don't have llvm
+ ((++c)); rm -rf llvm-integration;
+
+ # we don't have dtrace
+ ((++c)); rm -rf dtrace-static-probes-coalescing;
+ ((++c)); rm -rf dtrace-static-probes;
+
+ # a file is missing
+ ((++c)); rm -rf eh-coalescing-r
+
+ # we don't do universal binaries
+ ((++c)); rm -rf blank-stubs;
+
+ # looks like a problem with apple's result-filter.pl
+ ((++c)); rm -rf implicit-common3;
+ ((++c)); rm -rf order_file-ans;
+
+ # TODO no idea what goes wrong here
+ ((++c)); rm -rf dwarf-debug-notes;
+
+ einfo "Deleted $c tests that were bound to fail"
+
+ cd "${S}"
+ ebegin "cleaning Makefiles from unwanted CFLAGS"
+ find . -name "Makefile" -print0 | xargs -0 sed \
+ -i \
+ -e 's/ -g / /g' \
+ -e 's/^G =.*$/G =/' \
+ -e 's/^OFLAG =.*$/OFLAG =/' \
+ -e 's/install -c -s/install/g'
+ eend $?
+}
+
+src_configure() {
+ # CPPFLAGS only affects ld64, cctools don't use 'em (which currently is
+ # what we want)
+ append-cppflags -DNDEBUG
+
+ export CTARGET=${CTARGET:-${CHOST}}
+ if [[ ${CTARGET} == ${CHOST} ]] ; then
+ if [[ ${CATEGORY} == cross-* ]] ; then
+ export CTARGET=${CATEGORY#cross-}
+ fi
+ fi
+
+ LIBPATH=/usr/$(get_libdir)/binutils/${CTARGET}/${PV}
+ INCPATH=${LIBPATH}/include
+ DATAPATH=/usr/share/binutils-data/${CTARGET}/${PV}
+ if is_cross ; then
+ BINPATH=/usr/${CHOST}/${CTARGET}/binutils-bin/${PV}
+ else
+ BINPATH=/usr/${CTARGET}/binutils-bin/${PV}
+ fi
+
+ # Block API and thus snapshots supported on >= 10.6
+ [[ ${CHOST} == *darwin* && ${CHOST#*-darwin} -ge 10 ]] && \
+ append-cppflags -DSUPPORT_SNAPSHOTS
+
+ CCTOOLS_OFLAG=
+ if [[ ${CHOST} == *darwin* && ${CHOST#*-darwin} -le 8 ]] ; then
+ # cctools expect to use UNIX03 struct member names.
+ # This is default on > 10.4. Activate it on <= 10.4 by defining
+ # __DARWIN_UNIX03 explicitly.
+ CCTOOLS_OFLAG="-D__DARWIN_UNIX03=1"
+ fi
+
+ # if compiling with USE multitarget, extract all the known arches from
+ # create_configure and pass them back to it
+ creco=${LD64}/src/create_configure
+ ARCHS_TO_SUPPORT=""
+ if use multitarget ; then
+ ARCHS_TO_SUPPORT="$(grep KNOWN_ARCHS= $creco | \
+ cut -d\" -f2 | tr ',' ' ')"
+ fi
+
+ # Create configure.h for ld64 with SUPPORT_ARCH_<arch> defines in it.
+ DERIVED_FILE_DIR=${LD64}/src \
+ RC_SUPPORTED_ARCHS="$ARCHS_TO_SUPPORT" \
+ $creco
+
+ # do not depend on MachOFileAbstraction.hpp to define
+ # SUPPORT_ARCH_arm_any because that's not included by every file where
+ # our ppc/arm-optional patch uses it, ld.hpp in particular
+ grep "SUPPORT_ARCH_armv[0-9]" ${LD64}/src/configure.h >/dev/null && \
+ echo "#define SUPPORT_ARCH_arm_any 1" >> ${LD64}/src/configure.h
+}
+
+compile_ld64() {
+ einfo "building ${LD64}"
+ cd "${S}"/${LD64}/src
+ emake || die "emake failed for ld64"
+ use test && emake build_test
+}
+
+compile_cctools() {
+ einfo "building ${CCTOOLS}"
+ cd "${S}"/${CCTOOLS}
+ # -j1 because it fails too often with weird errors
+ # Suppress running dsymutil because it will warn about missing debug
+ # info which is expected when compiling without -g as we normally do.
+ # This might need some more thought if anyone ever wanted to build us
+ # for debugging with Apple's tools.
+ emake \
+ LIB_PRUNETRIE="-L../../${LD64}/src -lprunetrie" \
+ EFITOOLS= \
+ COMMON_SUBDIRS='libstuff ar misc otool' \
+ SUBDIRS_32= \
+ LEGACY= \
+ RC_ProjectSourceVersion=${CCTOOLS_VERSION} \
+ RC_CFLAGS="${CFLAGS}" \
+ OFLAG="${CCTOOLS_OFLAG}" \
+ DSYMUTIL=": disabled: dsymutil" \
+ -j1 \
+ || die "emake failed for the cctools"
+ cd "${S}"/${CCTOOLS}/as
+ emake \
+ BUILD_OBSOLETE_ARCH= \
+ RC_ProjectSourceVersion=${CCTOOLS_VERSION} \
+ RC_CFLAGS="-DASLIBEXECDIR=\"\\\"${EPREFIX}${LIBPATH}/\\\"\" -DCLANGDIR=\"\\\"${EPREFIX}/usr/bin/\\\"\" ${CFLAGS}" \
+ OFLAG="${CCTOOLS_OFLAG}" \
+ DSYMUTIL=": disabled: dsymutil" \
+ || die "emake failed for as"
+}
+
+src_compile() {
+ compile_ld64
+ compile_cctools
+}
+
+install_ld64() {
+ exeinto ${BINPATH}
+ doexe "${S}"/${LD64}/src/{ld64,rebase,dyldinfo,unwinddump,ObjectDump}
+ dosym ld64 ${BINPATH}/ld
+ insinto ${DATAPATH}/man/man1
+ doins "${S}"/${LD64}/doc/man/man1/{ld,ld64,rebase}.1
+}
+
+install_cctools() {
+ cd "${S}"/${CCTOOLS}
+ emake install_all_but_headers \
+ EFITOOLS= \
+ COMMON_SUBDIRS='ar misc otool' \
+ SUBDIRS_32= \
+ DSTROOT=\"${D}\" \
+ BINDIR=\"${EPREFIX}\"${BINPATH} \
+ LOCBINDIR=\"${EPREFIX}\"${BINPATH} \
+ USRBINDIR=\"${EPREFIX}\"${BINPATH} \
+ LOCLIBDIR=\"${EPREFIX}\"${LIBPATH} \
+ MANDIR=\"${EPREFIX}\"${DATAPATH}/man/
+ cd "${S}"/${CCTOOLS}/as
+ emake install \
+ BUILD_OBSOLETE_ARCH= \
+ DSTROOT=\"${D}\" \
+ USRBINDIR=\"${EPREFIX}\"${BINPATH} \
+ LIBDIR=\"${EPREFIX}\"${LIBPATH} \
+ LOCLIBDIR=\"${EPREFIX}\"${LIBPATH}
+
+ cd "${ED}"${BINPATH}
+ insinto ${DATAPATH}/man/man1
+ local skips manpage
+ # ar brings an up-to-date manpage with it
+ skips=( ar )
+ for bin in *; do
+ for skip in ${skips[@]}; do
+ if [[ ${bin} == ${skip} ]]; then
+ continue 2;
+ fi
+ done
+ manpage=${S}/${CCTOOLS}/man/${bin}.1
+ if [[ -f "${manpage}" ]]; then
+ doins "${manpage}"
+ fi
+ done
+ insinto ${DATAPATH}/man/man5
+ doins "${S}"/${CCTOOLS}/man/*.5
+}
+
+src_test() {
+ if ! [ "${EPREFIX}"/usr/bin/clang ] ; then
+ einfo "Test suite only works properly with clang - please install"
+ return
+ fi
+
+ einfo "Running unit tests"
+ cd "${S}"/${LD64}/unit-tests/test-cases
+ # provide the new ld as a symlink to clang so that -ccc-install-dir
+ # will pick it up
+ ln -sfn ../../src/ld64 ld
+ # use our arch command because the System's will report i386 even for an
+ # x86_64 prefix
+ perl ../bin/make-recursive.pl \
+ BUILT_PRODUCTS_DIR="${S}"/${LD64}/src \
+ ARCH="$(arch)" \
+ LD="${S}"/${LD64}/src/ld64 \
+ CC="${CC} -ccc-install-dir $PWD" \
+ CXX="${CXX} -ccc-install-dir $PWD" \
+ OTOOL="${S}"/${CCTOOLS}/otool/otool.NEW \
+ | perl ../bin/result-filter.pl
+}
+
+src_install() {
+ install_ld64
+ install_cctools
+
+ cd "${S}"
+ insinto /etc/env.d/binutils
+ cat <<-EOF > env.d
+ TARGET="${CHOST}"
+ VER="${PV}"
+ FAKE_TARGETS="${CHOST}"
+ EOF
+ newins env.d ${CHOST}-${PV}
+}
+
+pkg_postinst() {
+ binutils-config ${CHOST}-${PV}
+}
diff --git a/sys-devel/binutils-apple/binutils-apple-7.2-r1.ebuild b/sys-devel/binutils-apple/binutils-apple-7.2-r1.ebuild
new file mode 100644
index 000000000000..e5de0f0f7867
--- /dev/null
+++ b/sys-devel/binutils-apple/binutils-apple-7.2-r1.ebuild
@@ -0,0 +1,370 @@
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI="5"
+
+inherit eutils flag-o-matic toolchain-funcs
+
+LD64=ld64-253.9
+CCTOOLS_VERSION=877.8
+CCTOOLS=cctools-${CCTOOLS_VERSION}
+LIBUNWIND=libunwind-35.3
+DYLD=dyld-360.18
+
+DESCRIPTION="Darwin assembler as(1) and static linker ld(1), Xcode Tools ${PV}"
+HOMEPAGE="http://www.opensource.apple.com/darwinsource/"
+SRC_URI="http://www.opensource.apple.com/tarballs/ld64/${LD64}.tar.gz
+ http://www.opensource.apple.com/tarballs/cctools/${CCTOOLS}.tar.gz
+ http://www.opensource.apple.com/tarballs/dyld/${DYLD}.tar.gz
+ http://www.opensource.apple.com/tarballs/libunwind/${LIBUNWIND}.tar.gz
+ https://dev.gentoo.org/~grobian/distfiles/${PN}-patches-4.3-r1.tar.bz2
+ https://dev.gentoo.org/~grobian/distfiles/${PN}-patches-5.1-r2.tar.bz2
+ https://dev.gentoo.org/~grobian/distfiles/${PN}-patches-6.1-r1.tar.bz2
+ https://dev.gentoo.org/~grobian/distfiles/${PN}-patches-6.3-r1.tar.bz2
+ https://dev.gentoo.org/~grobian/distfiles/${PN}-patches-7.0-r2.tar.bz2
+ https://dev.gentoo.org/~grobian/distfiles/${PN}-patches-7.2-r0.tar.bz2"
+
+LICENSE="APSL-2"
+KEYWORDS="~ppc-macos ~x64-macos ~x86-macos"
+IUSE="lto test multitarget"
+
+# ld64 can now only be compiled using llvm and libc++ since it massivley uses
+# C++11 language fatures. *But additionally* the as driver now defaults to
+# calling clang as the assembler on many platforms. This can be disabled using
+# -Wa,-Q but since it's default we make llvm a static runtime dependency.
+RDEPEND="sys-devel/binutils-config
+ lto? ( app-arch/xar )
+ sys-devel/llvm
+ sys-libs/libcxx"
+DEPEND="${RDEPEND}
+ test? ( >=dev-lang/perl-5.8.8 )"
+
+SLOT="7"
+
+S=${WORKDIR}
+
+is_cross() { [[ ${CHOST} != ${CTARGET} ]] ; }
+
+src_prepare() {
+ if use multitarget ; then
+ ewarn "You have enabled support for non-standard target architectures"
+ ewarn "using USE=multitarget. This includes experimental support for"
+ ewarn "ppc and ppc64 which is a community forward-port from the last"
+ ewarn "version of ld64 to officially support PPC."
+
+ if [[ ${CHOST} == powerpc*-darwin* ]] ; then
+ ewarn "HERE BE DRAGONS! Your system seems to be PPC which means that"
+ ewarn "the actual usability of your Gentoo programs will depend on the"
+ ewarn "above-mentioned experimental PPC support in the linker. Be"
+ ewarn "sure to keep a known-to-work version like ${PN}-3.2.6 around!"
+ fi
+ fi
+
+ cd "${S}"/${LD64}/src
+ cp "${S}"/ld64-136-compile_stubs.h ld/compile_stubs.h
+ cp "${S}"/ld64-253.3-Makefile-3 Makefile
+
+ epatch "${S}"/ld64-253.9-nolto.patch
+ epatch "${S}"/ld64-241.9-extraneous-includes.patch
+ epatch "${S}"/ld64-241.9-osatomic.patch
+ epatch "${S}"/ld64-236.3-crashreporter.patch
+ epatch "${S}"/ld64-253.3-nosnapshots.patch
+ epatch "${S}"/ld64-253.3-ppc.patch
+ epatch "${S}"/ld64-236.3-constant-types-2.patch
+ epatch "${S}"/ld64-241.9-register-names.patch
+ epatch "${S}"/ld64-241.9-get-comm-align.patch
+ epatch "${S}"/ld64-241.9-cc_md5.patch
+ epatch "${S}"/ld64-253.3-make_pair.patch
+ epatch "${S}"/ld64-253.3-delete-warning.patch
+
+ # provide missing headers from libunwind and dyld
+ mkdir -p include/{mach,mach-o/arm} || die
+ # never present because it's private
+ cp ../../${DYLD}/include/mach-o/dyld_priv.h include/mach-o || die
+ # missing on <= 10.5
+ cp ../../${LIBUNWIND}/include/libunwind.h include/ || die
+ cp ../../${LIBUNWIND}/include/mach-o/compact_unwind_encoding.h include/mach-o || die
+ # missing on <= 10.4
+ cp ../../${DYLD}/include/mach-o/dyld_images.h include/mach-o || die
+ cp ../../${CCTOOLS}/include/mach-o/loader.h include/mach-o || die
+ # use copies from cctools because they're otherwise hidden in some SDK
+ cp ../../${CCTOOLS}/include/mach-o/arm/reloc.h include/mach-o/arm || die
+ # provide all required CPU_TYPEs on all platforms
+ cp ../../${CCTOOLS}/include/mach/machine.h include/mach/machine.h
+ # add alias for newer identifiers, because ld64 uses both but cctools
+ # header only defines the older
+ epatch "${S}"/ld64-236.3-missing-cputypes.patch
+
+ # mimic OS X Leopard-style Availability.h macros for libunwind.h on
+ # older systems
+ [[ ${CHOST} == *darwin* && ${CHOST#*-darwin} -le 8 ]] && \
+ echo "#define __OSX_AVAILABLE_STARTING(x,y) " > include/Availability.h
+
+ local VER_STR="\"@(#)PROGRAM:ld PROJECT:${LD64} (Gentoo ${PN}-${PVR})\\n\""
+ echo "char ldVersionString[] = ${VER_STR};" > version.cpp
+
+ epatch "${S}"/ld64-123.2-debug-backtrace.patch
+ if [[ ${CHOST} == powerpc*-darwin* ]] ; then
+ epatch "${S}"/ld64-123.2-darwin8-no-mlong-branch-warning.patch
+ epatch "${S}"/ld64-127.2-thread_state.patch
+ fi
+
+ cd "${S}"/${CCTOOLS}
+ epatch "${S}"/${PN}-4.5-as.patch
+ epatch "${S}"/${PN}-5.1-as-dir.patch
+ epatch "${S}"/${PN}-5.1-ranlib.patch
+ epatch "${S}"/${PN}-3.1.1-libtool-ranlib.patch
+ epatch "${S}"/${PN}-3.1.1-no-headers.patch
+ epatch "${S}"/${PN}-4.0-no-oss-dir.patch
+ epatch "${S}"/cctools-839-intel-retf.patch
+ epatch "${S}"/${PN}-5.1-extraneous-includes.patch
+ #epatch "${S}"/${PN}-5.1-otool-stdc.patch
+ epatch "${S}"/${PN}-5.1-constant-types.patch
+ epatch "${S}"/${PN}-5.1-strnlen.patch
+ epatch "${S}"/${PN}-5.1-ppc.patch
+ epatch "${S}"/${PN}-5.1-thread-state-redefined.patch
+ epatch "${S}"/${PN}-7.0-make-j.patch
+ epatch "${S}"/${PN}-7.0-lto-prefix-2.patch
+ epatch "${S}"/${PN}-7.0-clang-as.patch
+ epatch "${S}"/${PN}-7.0-nolto.patch
+ epatch "${S}"/${PN}-7.0-nollvm.patch
+ cp ../${LD64}/src/other/prune_trie.h include/mach-o/ || die
+
+ # do not build profileable libstuff to save compile time
+ sed -i -e "/^all:/s, profile , ," libstuff/Makefile
+
+ # cctools version is provided to make via RC_ProjectSourceVersion which
+ # generates and compiles it as apple_version[] into libstuff. From
+ # there it's picked up by the individual tools. Since
+ # RC_ProjectSourceVersion is also used as library version, we can't
+ # just append our local version info. So we hack the libstuff Makefile
+ # to include our Gentoo version.
+ sed -i -e "/cctools-.*(RC_ProjectSourceVersion).*OFILE_DIR/s,Version),Version) (Gentoo ${PN}-${PVR})," \
+ libstuff/Makefile
+
+ # clean up test suite
+ cd "${S}"/${LD64}/unit-tests/test-cases
+ local c
+
+ # we don't have llvm
+ ((++c)); rm -rf llvm-integration;
+
+ # we don't have dtrace
+ ((++c)); rm -rf dtrace-static-probes-coalescing;
+ ((++c)); rm -rf dtrace-static-probes;
+
+ # a file is missing
+ ((++c)); rm -rf eh-coalescing-r
+
+ # we don't do universal binaries
+ ((++c)); rm -rf blank-stubs;
+
+ # looks like a problem with apple's result-filter.pl
+ ((++c)); rm -rf implicit-common3;
+ ((++c)); rm -rf order_file-ans;
+
+ # TODO no idea what goes wrong here
+ ((++c)); rm -rf dwarf-debug-notes;
+
+ einfo "Deleted $c tests that were bound to fail"
+
+ cd "${S}"
+ ebegin "cleaning Makefiles from unwanted CFLAGS"
+ find . -name "Makefile" -print0 | xargs -0 sed \
+ -i \
+ -e 's/ -g / /g' \
+ -e 's/^G =.*$/G =/' \
+ -e 's/^OFLAG =.*$/OFLAG =/' \
+ -e 's/install -c -s/install/g'
+ eend $?
+}
+
+src_configure() {
+ ENABLE_LTO=0
+ use lto && ENABLE_LTO=1
+
+ export CTARGET=${CTARGET:-${CHOST}}
+ if [[ ${CTARGET} == ${CHOST} ]] ; then
+ if [[ ${CATEGORY} == cross-* ]] ; then
+ export CTARGET=${CATEGORY#cross-}
+ fi
+ fi
+
+ LIBPATH=/usr/$(get_libdir)/binutils/${CTARGET}/${PV}
+ INCPATH=${LIBPATH}/include
+ DATAPATH=/usr/share/binutils-data/${CTARGET}/${PV}
+ if is_cross ; then
+ BINPATH=/usr/${CHOST}/${CTARGET}/binutils-bin/${PV}
+ else
+ BINPATH=/usr/${CTARGET}/binutils-bin/${PV}
+ fi
+
+ # CPPFLAGS only affects ld64, cctools don't use 'em (which currently is
+ # what we want)
+ append-cppflags -DNDEBUG
+
+ # Block API and thus snapshots supported on >= 10.6
+ [[ ${CHOST} == *darwin* && ${CHOST#*-darwin} -ge 10 ]] && \
+ append-cppflags -DSUPPORT_SNAPSHOTS
+
+ CCTOOLS_OFLAG=
+ if [[ ${CHOST} == *darwin* && ${CHOST#*-darwin} -le 8 ]] ; then
+ # cctools expect to use UNIX03 struct member names.
+ # This is default on > 10.4. Activate it on <= 10.4 by defining
+ # __DARWIN_UNIX03 explicitly.
+ CCTOOLS_OFLAG="-D__DARWIN_UNIX03=1"
+ fi
+
+ # if compiling with USE multitarget, extract all the known arches from
+ # create_configure and pass them back to it
+ creco=${LD64}/src/create_configure
+ ARCHS_TO_SUPPORT=""
+ if use multitarget ; then
+ ARCHS_TO_SUPPORT="$(grep KNOWN_ARCHS= $creco | \
+ cut -d\" -f2 | tr ',' ' ')"
+ fi
+
+ # Create configure.h for ld64 with SUPPORT_ARCH_<arch> defines in it.
+ DERIVED_FILE_DIR=${LD64}/src \
+ RC_SUPPORTED_ARCHS="$ARCHS_TO_SUPPORT" \
+ $creco
+
+ # do not depend on MachOFileAbstraction.hpp to define
+ # SUPPORT_ARCH_arm_any because that's not included by every file where
+ # our ppc/arm-optional patch uses it, ld.hpp in particular
+ grep "SUPPORT_ARCH_armv[0-9]" ${LD64}/src/configure.h >/dev/null && \
+ echo "#define SUPPORT_ARCH_arm_any 1" >> ${LD64}/src/configure.h
+}
+
+compile_ld64() {
+ einfo "building ${LD64}"
+ cd "${S}"/${LD64}/src
+ emake \
+ LTO=${ENABLE_LTO} \
+ || die "emake failed for ld64"
+ use test && emake build_test
+}
+
+compile_cctools() {
+ einfo "building ${CCTOOLS}"
+ cd "${S}"/${CCTOOLS}
+ # Suppress running dsymutil because it will warn about missing debug
+ # info which is expected when compiling without -g as we normally do.
+ # This might need some more thought if anyone ever wanted to build us
+ # for debugging with Apple's tools.
+ emake \
+ LIB_PRUNETRIE="-L../../${LD64}/src -lprunetrie" \
+ EFITOOLS= \
+ LTO="${ENABLE_LTO}" \
+ LTO_LIBDIR=../../../lib \
+ COMMON_SUBDIRS='libstuff ar misc otool' \
+ SUBDIRS_32= \
+ LEGACY= \
+ RC_ProjectSourceVersion=${CCTOOLS_VERSION} \
+ RC_CFLAGS="${CFLAGS}" \
+ OFLAG="${CCTOOLS_OFLAG}" \
+ DSYMUTIL=": disabled: dsymutil" \
+ || die "emake failed for the cctools"
+ cd "${S}"/${CCTOOLS}/as
+ emake \
+ BUILD_OBSOLETE_ARCH= \
+ RC_ProjectSourceVersion=${CCTOOLS_VERSION} \
+ RC_CFLAGS="-DASLIBEXECDIR=\"\\\"${EPREFIX}${LIBPATH}/\\\"\" -DCLANGDIR=\"\\\"${EPREFIX}/usr/bin/\\\"\" ${CFLAGS}" \
+ OFLAG="${CCTOOLS_OFLAG}" \
+ DSYMUTIL=": disabled: dsymutil" \
+ || die "emake failed for as"
+}
+
+src_compile() {
+ compile_ld64
+ compile_cctools
+}
+
+install_ld64() {
+ exeinto ${BINPATH}
+ doexe "${S}"/${LD64}/src/{ld64,rebase,dyldinfo,unwinddump,ObjectDump}
+ dosym ld64 ${BINPATH}/ld
+ insinto ${DATAPATH}/man/man1
+ doins "${S}"/${LD64}/doc/man/man1/{ld,ld64,rebase}.1
+}
+
+install_cctools() {
+ cd "${S}"/${CCTOOLS}
+ emake install_all_but_headers \
+ EFITOOLS= \
+ COMMON_SUBDIRS='ar misc otool' \
+ SUBDIRS_32= \
+ DSTROOT=\"${D}\" \
+ BINDIR=\"${EPREFIX}\"${BINPATH} \
+ LOCBINDIR=\"${EPREFIX}\"${BINPATH} \
+ USRBINDIR=\"${EPREFIX}\"${BINPATH} \
+ LOCLIBDIR=\"${EPREFIX}\"${LIBPATH} \
+ MANDIR=\"${EPREFIX}\"${DATAPATH}/man/
+ cd "${S}"/${CCTOOLS}/as
+ emake install \
+ BUILD_OBSOLETE_ARCH= \
+ DSTROOT=\"${D}\" \
+ USRBINDIR=\"${EPREFIX}\"${BINPATH} \
+ LIBDIR=\"${EPREFIX}\"${LIBPATH} \
+ LOCLIBDIR=\"${EPREFIX}\"${LIBPATH}
+
+ cd "${ED}"${BINPATH}
+ insinto ${DATAPATH}/man/man1
+ local skips manpage
+ # ar brings an up-to-date manpage with it
+ skips=( ar )
+ for bin in *; do
+ for skip in ${skips[@]}; do
+ if [[ ${bin} == ${skip} ]]; then
+ continue 2;
+ fi
+ done
+ manpage=${S}/${CCTOOLS}/man/${bin}.1
+ if [[ -f "${manpage}" ]]; then
+ doins "${manpage}"
+ fi
+ done
+ insinto ${DATAPATH}/man/man5
+ doins "${S}"/${CCTOOLS}/man/*.5
+}
+
+src_test() {
+ if ! [ "${EPREFIX}"/usr/bin/clang ] ; then
+ einfo "Test suite only works properly with clang - please install"
+ return
+ fi
+
+ einfo "Running unit tests"
+ cd "${S}"/${LD64}/unit-tests/test-cases
+ # provide the new ld as a symlink to clang so that -ccc-install-dir
+ # will pick it up
+ ln -sfn ../../src/ld64 ld
+ # use our arch command because the System's will report i386 even for an
+ # x86_64 prefix
+ perl ../bin/make-recursive.pl \
+ BUILT_PRODUCTS_DIR="${S}"/${LD64}/src \
+ ARCH="$(arch)" \
+ LD="${S}"/${LD64}/src/ld64 \
+ CC="${CC} -ccc-install-dir $PWD" \
+ CXX="${CXX} -ccc-install-dir $PWD" \
+ OTOOL="${S}"/${CCTOOLS}/otool/otool.NEW \
+ | perl ../bin/result-filter.pl
+}
+
+src_install() {
+ install_ld64
+ install_cctools
+
+ cd "${S}"
+ insinto /etc/env.d/binutils
+ cat <<-EOF > env.d
+ TARGET="${CHOST}"
+ VER="${PV}"
+ FAKE_TARGETS="${CHOST}"
+ EOF
+ newins env.d ${CHOST}-${PV}
+}
+
+pkg_postinst() {
+ binutils-config ${CHOST}-${PV}
+}
diff --git a/sys-devel/binutils-apple/binutils-apple-7.2.ebuild b/sys-devel/binutils-apple/binutils-apple-7.2.ebuild
new file mode 100644
index 000000000000..0f608625bcae
--- /dev/null
+++ b/sys-devel/binutils-apple/binutils-apple-7.2.ebuild
@@ -0,0 +1,366 @@
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI="5"
+
+inherit eutils flag-o-matic toolchain-funcs
+
+LD64=ld64-253.9
+CCTOOLS_VERSION=877.8
+CCTOOLS=cctools-${CCTOOLS_VERSION}
+LIBUNWIND=libunwind-35.3
+DYLD=dyld-360.18
+
+DESCRIPTION="Darwin assembler as(1) and static linker ld(1), Xcode Tools ${PV}"
+HOMEPAGE="http://www.opensource.apple.com/darwinsource/"
+SRC_URI="http://www.opensource.apple.com/tarballs/ld64/${LD64}.tar.gz
+ http://www.opensource.apple.com/tarballs/cctools/${CCTOOLS}.tar.gz
+ http://www.opensource.apple.com/tarballs/dyld/${DYLD}.tar.gz
+ http://www.opensource.apple.com/tarballs/libunwind/${LIBUNWIND}.tar.gz
+ https://dev.gentoo.org/~grobian/distfiles/${PN}-patches-4.3-r1.tar.bz2
+ https://dev.gentoo.org/~grobian/distfiles/${PN}-patches-5.1-r2.tar.bz2
+ https://dev.gentoo.org/~grobian/distfiles/${PN}-patches-6.1-r1.tar.bz2
+ https://dev.gentoo.org/~grobian/distfiles/${PN}-patches-6.3-r1.tar.bz2
+ https://dev.gentoo.org/~grobian/distfiles/${PN}-patches-7.0-r1.tar.bz2"
+
+LICENSE="APSL-2"
+KEYWORDS="~ppc-macos ~x64-macos ~x86-macos"
+IUSE="test multitarget"
+
+# ld64 can now only be compiled using llvm and libc++ since it massivley uses
+# C++11 language fatures. *But additionally* the as driver now defaults to
+# calling clang as the assembler on many platforms. This can be disabled using
+# -Wa,-Q but since it's default we make llvm a static runtime dependency.
+
+# Also, llvm lto and disassembler interfaces are now widely used in cctools.
+# Since we cannot compile with gcc any more and every llvm since 3.4 has
+# provided those interfaces, we no longer support disabling them. That
+# indirectly makes xar a static runtime dependency.
+RDEPEND="sys-devel/binutils-config
+ app-arch/xar
+ sys-devel/llvm
+ sys-libs/libcxx"
+DEPEND="${RDEPEND}
+ test? ( >=dev-lang/perl-5.8.8 )"
+
+SLOT="7"
+
+S=${WORKDIR}
+
+is_cross() { [[ ${CHOST} != ${CTARGET} ]] ; }
+
+src_prepare() {
+ if use multitarget ; then
+ ewarn "You have enabled support for non-standard target architectures"
+ ewarn "using USE=multitarget. This includes experimental support for"
+ ewarn "ppc and ppc64 which is a community forward-port from the last"
+ ewarn "version of ld64 to officially support PPC."
+
+ if [[ ${CHOST} == powerpc*-darwin* ]] ; then
+ ewarn "HERE BE DRAGONS! Your system seems to be PPC which means that"
+ ewarn "the actual usability of your Gentoo programs will depend on the"
+ ewarn "above-mentioned experimental PPC support in the linker. Be"
+ ewarn "sure to keep a known-to-work version like ${PN}-3.2.6 around!"
+ fi
+ fi
+
+ cd "${S}"/${LD64}/src
+ cp "${S}"/ld64-136-compile_stubs.h ld/compile_stubs.h
+ cp "${S}"/ld64-253.3-Makefile-2 Makefile
+
+ epatch "${S}"/ld64-241.9-extraneous-includes.patch
+ epatch "${S}"/ld64-241.9-osatomic.patch
+ epatch "${S}"/ld64-236.3-crashreporter.patch
+ epatch "${S}"/ld64-253.3-nosnapshots.patch
+ epatch "${S}"/ld64-253.3-ppc.patch
+ epatch "${S}"/ld64-236.3-constant-types-2.patch
+ epatch "${S}"/ld64-241.9-register-names.patch
+ epatch "${S}"/ld64-241.9-get-comm-align.patch
+ epatch "${S}"/ld64-241.9-cc_md5.patch
+ epatch "${S}"/ld64-253.3-make_pair.patch
+ epatch "${S}"/ld64-253.3-delete-warning.patch
+
+ # provide missing headers from libunwind and dyld
+ mkdir -p include/{mach,mach-o/arm} || die
+ # never present because it's private
+ cp ../../${DYLD}/include/mach-o/dyld_priv.h include/mach-o || die
+ # missing on <= 10.5
+ cp ../../${LIBUNWIND}/include/libunwind.h include/ || die
+ cp ../../${LIBUNWIND}/include/mach-o/compact_unwind_encoding.h include/mach-o || die
+ # missing on <= 10.4
+ cp ../../${DYLD}/include/mach-o/dyld_images.h include/mach-o || die
+ cp ../../${CCTOOLS}/include/mach-o/loader.h include/mach-o || die
+ # use copies from cctools because they're otherwise hidden in some SDK
+ cp ../../${CCTOOLS}/include/mach-o/arm/reloc.h include/mach-o/arm || die
+ # provide all required CPU_TYPEs on all platforms
+ cp ../../${CCTOOLS}/include/mach/machine.h include/mach/machine.h
+ # add alias for newer identifiers, because ld64 uses both but cctools
+ # header only defines the older
+ epatch "${S}"/ld64-236.3-missing-cputypes.patch
+
+ # mimic OS X Leopard-style Availability.h macros for libunwind.h on
+ # older systems
+ [[ ${CHOST} == *darwin* && ${CHOST#*-darwin} -le 8 ]] && \
+ echo "#define __OSX_AVAILABLE_STARTING(x,y) " > include/Availability.h
+
+ local VER_STR="\"@(#)PROGRAM:ld PROJECT:${LD64} (Gentoo ${PN}-${PVR})\\n\""
+ echo "char ldVersionString[] = ${VER_STR};" > version.cpp
+
+ epatch "${S}"/ld64-123.2-debug-backtrace.patch
+ if [[ ${CHOST} == powerpc*-darwin* ]] ; then
+ epatch "${S}"/ld64-123.2-darwin8-no-mlong-branch-warning.patch
+ epatch "${S}"/ld64-127.2-thread_state.patch
+ fi
+
+ cd "${S}"/${CCTOOLS}
+ epatch "${S}"/${PN}-4.5-as.patch
+ epatch "${S}"/${PN}-5.1-as-dir.patch
+ epatch "${S}"/${PN}-5.1-ranlib.patch
+ epatch "${S}"/${PN}-3.1.1-libtool-ranlib.patch
+ epatch "${S}"/${PN}-3.1.1-no-headers.patch
+ epatch "${S}"/${PN}-4.0-no-oss-dir.patch
+ epatch "${S}"/cctools-839-intel-retf.patch
+ epatch "${S}"/${PN}-5.1-extraneous-includes.patch
+ #epatch "${S}"/${PN}-5.1-otool-stdc.patch
+ epatch "${S}"/${PN}-5.1-constant-types.patch
+ epatch "${S}"/${PN}-5.1-strnlen.patch
+ epatch "${S}"/${PN}-5.1-ppc.patch
+ epatch "${S}"/${PN}-5.1-thread-state-redefined.patch
+ epatch "${S}"/${PN}-5.1-makefile-target-warning.patch
+ epatch "${S}"/${PN}-7.0-lto-prefix.patch
+ epatch "${S}"/${PN}-7.0-clang-as.patch
+ cp ../${LD64}/src/other/prune_trie.h include/mach-o/ || die
+
+ # do not build profileable libstuff to save compile time
+ sed -i -e "/^all:/s, profile , ," libstuff/Makefile
+
+ # cctools version is provided to make via RC_ProjectSourceVersion which
+ # generates and compiles it as apple_version[] into libstuff. From
+ # there it's picked up by the individual tools. Since
+ # RC_ProjectSourceVersion is also used as library version, we can't
+ # just append our local version info. So we hack the libstuff Makefile
+ # to include our Gentoo version.
+ sed -i -e "/cctools-.*(RC_ProjectSourceVersion).*OFILE_DIR/s,Version),Version) (Gentoo ${PN}-${PVR})," \
+ libstuff/Makefile
+
+ # clean up test suite
+ cd "${S}"/${LD64}/unit-tests/test-cases
+ local c
+
+ # we don't have llvm
+ ((++c)); rm -rf llvm-integration;
+
+ # we don't have dtrace
+ ((++c)); rm -rf dtrace-static-probes-coalescing;
+ ((++c)); rm -rf dtrace-static-probes;
+
+ # a file is missing
+ ((++c)); rm -rf eh-coalescing-r
+
+ # we don't do universal binaries
+ ((++c)); rm -rf blank-stubs;
+
+ # looks like a problem with apple's result-filter.pl
+ ((++c)); rm -rf implicit-common3;
+ ((++c)); rm -rf order_file-ans;
+
+ # TODO no idea what goes wrong here
+ ((++c)); rm -rf dwarf-debug-notes;
+
+ einfo "Deleted $c tests that were bound to fail"
+
+ cd "${S}"
+ ebegin "cleaning Makefiles from unwanted CFLAGS"
+ find . -name "Makefile" -print0 | xargs -0 sed \
+ -i \
+ -e 's/ -g / /g' \
+ -e 's/^G =.*$/G =/' \
+ -e 's/^OFLAG =.*$/OFLAG =/' \
+ -e 's/install -c -s/install/g'
+ eend $?
+}
+
+src_configure() {
+ # CPPFLAGS only affects ld64, cctools don't use 'em (which currently is
+ # what we want)
+ append-cppflags -DNDEBUG
+
+ export CTARGET=${CTARGET:-${CHOST}}
+ if [[ ${CTARGET} == ${CHOST} ]] ; then
+ if [[ ${CATEGORY} == cross-* ]] ; then
+ export CTARGET=${CATEGORY#cross-}
+ fi
+ fi
+
+ LIBPATH=/usr/$(get_libdir)/binutils/${CTARGET}/${PV}
+ INCPATH=${LIBPATH}/include
+ DATAPATH=/usr/share/binutils-data/${CTARGET}/${PV}
+ if is_cross ; then
+ BINPATH=/usr/${CHOST}/${CTARGET}/binutils-bin/${PV}
+ else
+ BINPATH=/usr/${CTARGET}/binutils-bin/${PV}
+ fi
+
+ # Block API and thus snapshots supported on >= 10.6
+ [[ ${CHOST} == *darwin* && ${CHOST#*-darwin} -ge 10 ]] && \
+ append-cppflags -DSUPPORT_SNAPSHOTS
+
+ CCTOOLS_OFLAG=
+ if [[ ${CHOST} == *darwin* && ${CHOST#*-darwin} -le 8 ]] ; then
+ # cctools expect to use UNIX03 struct member names.
+ # This is default on > 10.4. Activate it on <= 10.4 by defining
+ # __DARWIN_UNIX03 explicitly.
+ CCTOOLS_OFLAG="-D__DARWIN_UNIX03=1"
+ fi
+
+ # if compiling with USE multitarget, extract all the known arches from
+ # create_configure and pass them back to it
+ creco=${LD64}/src/create_configure
+ ARCHS_TO_SUPPORT=""
+ if use multitarget ; then
+ ARCHS_TO_SUPPORT="$(grep KNOWN_ARCHS= $creco | \
+ cut -d\" -f2 | tr ',' ' ')"
+ fi
+
+ # Create configure.h for ld64 with SUPPORT_ARCH_<arch> defines in it.
+ DERIVED_FILE_DIR=${LD64}/src \
+ RC_SUPPORTED_ARCHS="$ARCHS_TO_SUPPORT" \
+ $creco
+
+ # do not depend on MachOFileAbstraction.hpp to define
+ # SUPPORT_ARCH_arm_any because that's not included by every file where
+ # our ppc/arm-optional patch uses it, ld.hpp in particular
+ grep "SUPPORT_ARCH_armv[0-9]" ${LD64}/src/configure.h >/dev/null && \
+ echo "#define SUPPORT_ARCH_arm_any 1" >> ${LD64}/src/configure.h
+}
+
+compile_ld64() {
+ einfo "building ${LD64}"
+ cd "${S}"/${LD64}/src
+ emake || die "emake failed for ld64"
+ use test && emake build_test
+}
+
+compile_cctools() {
+ einfo "building ${CCTOOLS}"
+ cd "${S}"/${CCTOOLS}
+ # -j1 because it fails too often with weird errors
+ # Suppress running dsymutil because it will warn about missing debug
+ # info which is expected when compiling without -g as we normally do.
+ # This might need some more thought if anyone ever wanted to build us
+ # for debugging with Apple's tools.
+ emake \
+ LIB_PRUNETRIE="-L../../${LD64}/src -lprunetrie" \
+ EFITOOLS= \
+ COMMON_SUBDIRS='libstuff ar misc otool' \
+ SUBDIRS_32= \
+ LEGACY= \
+ RC_ProjectSourceVersion=${CCTOOLS_VERSION} \
+ RC_CFLAGS="${CFLAGS}" \
+ OFLAG="${CCTOOLS_OFLAG}" \
+ DSYMUTIL=": disabled: dsymutil" \
+ -j1 \
+ || die "emake failed for the cctools"
+ cd "${S}"/${CCTOOLS}/as
+ emake \
+ BUILD_OBSOLETE_ARCH= \
+ RC_ProjectSourceVersion=${CCTOOLS_VERSION} \
+ RC_CFLAGS="-DASLIBEXECDIR=\"\\\"${EPREFIX}${LIBPATH}/\\\"\" -DCLANGDIR=\"\\\"${EPREFIX}/usr/bin/\\\"\" ${CFLAGS}" \
+ OFLAG="${CCTOOLS_OFLAG}" \
+ DSYMUTIL=": disabled: dsymutil" \
+ || die "emake failed for as"
+}
+
+src_compile() {
+ compile_ld64
+ compile_cctools
+}
+
+install_ld64() {
+ exeinto ${BINPATH}
+ doexe "${S}"/${LD64}/src/{ld64,rebase,dyldinfo,unwinddump,ObjectDump}
+ dosym ld64 ${BINPATH}/ld
+ insinto ${DATAPATH}/man/man1
+ doins "${S}"/${LD64}/doc/man/man1/{ld,ld64,rebase}.1
+}
+
+install_cctools() {
+ cd "${S}"/${CCTOOLS}
+ emake install_all_but_headers \
+ EFITOOLS= \
+ COMMON_SUBDIRS='ar misc otool' \
+ SUBDIRS_32= \
+ DSTROOT=\"${D}\" \
+ BINDIR=\"${EPREFIX}\"${BINPATH} \
+ LOCBINDIR=\"${EPREFIX}\"${BINPATH} \
+ USRBINDIR=\"${EPREFIX}\"${BINPATH} \
+ LOCLIBDIR=\"${EPREFIX}\"${LIBPATH} \
+ MANDIR=\"${EPREFIX}\"${DATAPATH}/man/
+ cd "${S}"/${CCTOOLS}/as
+ emake install \
+ BUILD_OBSOLETE_ARCH= \
+ DSTROOT=\"${D}\" \
+ USRBINDIR=\"${EPREFIX}\"${BINPATH} \
+ LIBDIR=\"${EPREFIX}\"${LIBPATH} \
+ LOCLIBDIR=\"${EPREFIX}\"${LIBPATH}
+
+ cd "${ED}"${BINPATH}
+ insinto ${DATAPATH}/man/man1
+ local skips manpage
+ # ar brings an up-to-date manpage with it
+ skips=( ar )
+ for bin in *; do
+ for skip in ${skips[@]}; do
+ if [[ ${bin} == ${skip} ]]; then
+ continue 2;
+ fi
+ done
+ manpage=${S}/${CCTOOLS}/man/${bin}.1
+ if [[ -f "${manpage}" ]]; then
+ doins "${manpage}"
+ fi
+ done
+ insinto ${DATAPATH}/man/man5
+ doins "${S}"/${CCTOOLS}/man/*.5
+}
+
+src_test() {
+ if ! [ "${EPREFIX}"/usr/bin/clang ] ; then
+ einfo "Test suite only works properly with clang - please install"
+ return
+ fi
+
+ einfo "Running unit tests"
+ cd "${S}"/${LD64}/unit-tests/test-cases
+ # provide the new ld as a symlink to clang so that -ccc-install-dir
+ # will pick it up
+ ln -sfn ../../src/ld64 ld
+ # use our arch command because the System's will report i386 even for an
+ # x86_64 prefix
+ perl ../bin/make-recursive.pl \
+ BUILT_PRODUCTS_DIR="${S}"/${LD64}/src \
+ ARCH="$(arch)" \
+ LD="${S}"/${LD64}/src/ld64 \
+ CC="${CC} -ccc-install-dir $PWD" \
+ CXX="${CXX} -ccc-install-dir $PWD" \
+ OTOOL="${S}"/${CCTOOLS}/otool/otool.NEW \
+ | perl ../bin/result-filter.pl
+}
+
+src_install() {
+ install_ld64
+ install_cctools
+
+ cd "${S}"
+ insinto /etc/env.d/binutils
+ cat <<-EOF > env.d
+ TARGET="${CHOST}"
+ VER="${PV}"
+ FAKE_TARGETS="${CHOST}"
+ EOF
+ newins env.d ${CHOST}-${PV}
+}
+
+pkg_postinst() {
+ binutils-config ${CHOST}-${PV}
+}
diff --git a/sys-devel/binutils-apple/binutils-apple-7.3.1.ebuild b/sys-devel/binutils-apple/binutils-apple-7.3.1.ebuild
new file mode 100644
index 000000000000..e56d422a78c8
--- /dev/null
+++ b/sys-devel/binutils-apple/binutils-apple-7.3.1.ebuild
@@ -0,0 +1,393 @@
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI="5"
+
+inherit eutils flag-o-matic toolchain-funcs
+
+LD64=ld64-264.3.102
+CCTOOLS_VERSION=886
+CCTOOLS=cctools-${CCTOOLS_VERSION}
+LIBUNWIND=libunwind-35.3
+DYLD=dyld-360.18
+
+DESCRIPTION="Darwin assembler as(1) and static linker ld(1), Xcode Tools ${PV}"
+HOMEPAGE="http://www.opensource.apple.com/darwinsource/"
+SRC_URI="http://www.opensource.apple.com/tarballs/ld64/${LD64}.tar.gz
+ http://www.opensource.apple.com/tarballs/cctools/${CCTOOLS}.tar.gz
+ http://www.opensource.apple.com/tarballs/dyld/${DYLD}.tar.gz
+ http://www.opensource.apple.com/tarballs/libunwind/${LIBUNWIND}.tar.gz
+ https://dev.gentoo.org/~grobian/distfiles/${PN}-patches-4.3-r1.tar.bz2
+ https://dev.gentoo.org/~grobian/distfiles/${PN}-patches-5.1-r2.tar.bz2
+ https://dev.gentoo.org/~grobian/distfiles/${PN}-patches-6.1-r1.tar.bz2
+ https://dev.gentoo.org/~grobian/distfiles/${PN}-patches-6.3-r1.tar.bz2
+ https://dev.gentoo.org/~grobian/distfiles/${PN}-patches-7.0-r2.tar.bz2
+ https://dev.gentoo.org/~grobian/distfiles/${PN}-patches-7.2-r0.tar.bz2
+ https://dev.gentoo.org/~grobian/distfiles/${PN}-patches-7.3-r1.tar.bz2"
+
+LICENSE="APSL-2"
+KEYWORDS="~ppc-macos ~x64-macos ~x86-macos"
+IUSE="lto test multitarget"
+
+# ld64 can now only be compiled using llvm and libc++ since it massively uses
+# C++11 language features. *But additionally* the as driver now defaults to
+# calling clang as the assembler on many platforms. This can be disabled using
+# -Wa,-Q but since it's default we make llvm a static runtime dependency.
+RDEPEND="sys-devel/binutils-config
+ lto? ( app-arch/xar )
+ sys-devel/llvm
+ sys-libs/libcxx"
+DEPEND="${RDEPEND}
+ test? ( >=dev-lang/perl-5.8.8 )"
+
+SLOT="7"
+
+S=${WORKDIR}
+
+is_cross() { [[ ${CHOST} != ${CTARGET} ]] ; }
+
+src_prepare() {
+ if use multitarget ; then
+ ewarn "You have enabled support for non-standard target architectures"
+ ewarn "using USE=multitarget. This includes experimental support for"
+ ewarn "ppc and ppc64 which is a community forward-port from the last"
+ ewarn "version of ld64 to officially support PPC."
+
+ if [[ ${CHOST} == powerpc*-darwin* ]] ; then
+ ewarn "HERE BE DRAGONS! Your system seems to be PPC which means that"
+ ewarn "the actual usability of your Gentoo programs will depend on the"
+ ewarn "above-mentioned experimental PPC support in the linker. Be"
+ ewarn "sure to keep a known-to-work version like ${PN}-3.2.6 around!"
+ fi
+ fi
+
+ cd "${S}"/${LD64}/src
+ cp "${S}"/ld64-136-compile_stubs.h ld/compile_stubs.h
+ cp "${S}"/ld64-264.3.101-Makefile Makefile
+
+ epatch "${S}"/ld64-264.3.101-nolto.patch
+ epatch "${S}"/ld64-241.9-extraneous-includes.patch
+ epatch "${S}"/ld64-241.9-osatomic.patch
+ epatch "${S}"/ld64-236.3-crashreporter.patch
+ epatch "${S}"/ld64-264.3.101-nosnapshots.patch
+ epatch "${S}"/ld64-264.3.101-ppc.patch
+ epatch "${S}"/ld64-264.3.101-constant-types.patch
+ epatch "${S}"/ld64-241.9-register-names.patch
+ epatch "${S}"/ld64-241.9-get-comm-align.patch
+ epatch "${S}"/ld64-241.9-cc_md5.patch
+ epatch "${S}"/ld64-264.3.102-bitcode-case.patch
+
+ # workound llvm-3.9.{0,1} issue
+ # https://bugs.gentoo.org/show_bug.cgi?id=603580
+ # https://groups.google.com/forum/#!topic/llvm-dev/JY6nuKE__sU
+ # http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20160829/169553.html
+ sed -i -e '/COMPILE_TIME_ASSERT/d' ld/parsers/libunwind/*.hpp || die
+
+ # provide missing headers from libunwind and dyld
+ mkdir -p include/{mach,mach-o/arm} || die
+ # never present because it's private
+ cp ../../${DYLD}/include/mach-o/dyld_priv.h include/mach-o || die
+ # missing on <= 10.5
+ cp ../../${LIBUNWIND}/include/libunwind.h include/ || die
+ cp ../../${LIBUNWIND}/include/mach-o/compact_unwind_encoding.h include/mach-o || die
+ # missing on <= 10.4
+ cp ../../${DYLD}/include/mach-o/dyld_images.h include/mach-o || die
+ cp ../../${CCTOOLS}/include/mach-o/loader.h include/mach-o || die
+ # use copies from cctools because they're otherwise hidden in some SDK
+ cp ../../${CCTOOLS}/include/mach-o/arm/reloc.h include/mach-o/arm || die
+ # provide all required CPU_TYPEs on all platforms
+ cp ../../${CCTOOLS}/include/mach/machine.h include/mach/machine.h
+ # add alias for newer identifiers, because ld64 uses both but cctools
+ # header only defines the older
+ epatch "${S}"/ld64-236.3-missing-cputypes.patch
+
+ # mimic OS X Leopard-style Availability.h macros for libunwind.h on
+ # older systems
+ [[ ${CHOST} == *darwin* && ${CHOST#*-darwin} -le 8 ]] && \
+ echo "#define __OSX_AVAILABLE_STARTING(x,y) " > include/Availability.h
+
+ local VER_STR="\"@(#)PROGRAM:ld PROJECT:${LD64} (Gentoo ${PN}-${PVR})\\n\""
+ echo "char ldVersionString[] = ${VER_STR};" > version.cpp
+
+ epatch "${S}"/ld64-123.2-debug-backtrace.patch
+ if [[ ${CHOST} == powerpc*-darwin* ]] ; then
+ epatch "${S}"/ld64-123.2-darwin8-no-mlong-branch-warning.patch
+ epatch "${S}"/ld64-127.2-thread_state.patch
+ fi
+
+ cd "${S}"/${CCTOOLS}
+ epatch "${S}"/${PN}-4.5-as.patch
+ epatch "${S}"/${PN}-5.1-as-dir.patch
+ epatch "${S}"/${PN}-5.1-ranlib.patch
+ epatch "${S}"/${PN}-3.1.1-libtool-ranlib.patch
+ epatch "${S}"/${PN}-3.1.1-no-headers.patch
+ epatch "${S}"/${PN}-4.0-no-oss-dir.patch
+ epatch "${S}"/cctools-839-intel-retf.patch
+ epatch "${S}"/${PN}-5.1-extraneous-includes.patch
+ #epatch "${S}"/${PN}-5.1-otool-stdc.patch
+ epatch "${S}"/${PN}-5.1-constant-types.patch
+ epatch "${S}"/${PN}-5.1-strnlen.patch
+ epatch "${S}"/${PN}-5.1-ppc.patch
+ epatch "${S}"/${PN}-5.1-thread-state-redefined.patch
+ epatch "${S}"/${PN}-7.3-make-j.patch
+ epatch "${S}"/${PN}-7.0-lto-prefix-2.patch
+ epatch "${S}"/${PN}-7.0-clang-as.patch
+ epatch "${S}"/${PN}-7.3-nolto.patch
+ epatch "${S}"/${PN}-7.3-nollvm.patch
+ epatch "${S}"/${PN}-7.3-no-developertools-dir.patch
+ cp ../${LD64}/src/other/prune_trie.h include/mach-o/ || die
+
+ # do not build profileable libstuff to save compile time
+ sed -i -e "/^all:/s, profile , ," libstuff/Makefile
+
+ # cctools version is provided to make via RC_ProjectSourceVersion which
+ # generates and compiles it as apple_version[] into libstuff. From
+ # there it's picked up by the individual tools. Since
+ # RC_ProjectSourceVersion is also used as library version, we can't
+ # just append our local version info. So we hack the libstuff Makefile
+ # to include our Gentoo version.
+ sed -i -e "/cctools-.*(RC_ProjectSourceVersion).*OFILE_DIR/s,Version),Version) (Gentoo ${PN}-${PVR})," \
+ libstuff/Makefile
+
+ # clean up test suite
+ cd "${S}"/${LD64}/unit-tests/test-cases
+ local c
+
+ # we don't have llvm
+ ((++c)); rm -rf llvm-integration;
+
+ # we don't have dtrace
+ ((++c)); rm -rf dtrace-static-probes-coalescing;
+ ((++c)); rm -rf dtrace-static-probes;
+
+ # a file is missing
+ ((++c)); rm -rf eh-coalescing-r
+
+ # we don't do universal binaries
+ ((++c)); rm -rf blank-stubs;
+
+ # looks like a problem with apple's result-filter.pl
+ ((++c)); rm -rf implicit-common3;
+ ((++c)); rm -rf order_file-ans;
+
+ # TODO no idea what goes wrong here
+ ((++c)); rm -rf dwarf-debug-notes;
+
+ einfo "Deleted $c tests that were bound to fail"
+
+ cd "${S}"
+ ebegin "cleaning Makefiles from unwanted CFLAGS"
+ find . -name "Makefile" -print0 | xargs -0 sed \
+ -i \
+ -e 's/ -g / /g' \
+ -e 's/^G =.*$/G =/' \
+ -e 's/^OFLAG =.*$/OFLAG =/' \
+ -e 's/install -c -s/install/g'
+ eend $?
+}
+
+src_configure() {
+ ENABLE_LTO=0
+ use lto && ENABLE_LTO=1
+
+ export CTARGET=${CTARGET:-${CHOST}}
+ if [[ ${CTARGET} == ${CHOST} ]] ; then
+ if [[ ${CATEGORY} == cross-* ]] ; then
+ export CTARGET=${CATEGORY#cross-}
+ fi
+ fi
+
+ LIBPATH=/usr/$(get_libdir)/binutils/${CTARGET}/${PV}
+ INCPATH=${LIBPATH}/include
+ DATAPATH=/usr/share/binutils-data/${CTARGET}/${PV}
+ if is_cross ; then
+ BINPATH=/usr/${CHOST}/${CTARGET}/binutils-bin/${PV}
+ else
+ BINPATH=/usr/${CTARGET}/binutils-bin/${PV}
+ fi
+
+ # CPPFLAGS only affects ld64, cctools don't use 'em (which currently is
+ # what we want)
+ append-cppflags -DNDEBUG
+
+ # Block API and thus snapshots supported on >= 10.6
+ [[ ${CHOST} == *darwin* && ${CHOST#*-darwin} -ge 10 ]] && \
+ append-cppflags -DSUPPORT_SNAPSHOTS
+
+ CCTOOLS_OFLAG=
+ if [[ ${CHOST} == *darwin* && ${CHOST#*-darwin} -le 8 ]] ; then
+ # cctools expect to use UNIX03 struct member names.
+ # This is default on > 10.4. Activate it on <= 10.4 by defining
+ # __DARWIN_UNIX03 explicitly.
+ CCTOOLS_OFLAG="-D__DARWIN_UNIX03=1"
+ fi
+
+ # if compiling with USE multitarget, extract all the known arches from
+ # create_configure and pass them back to it
+ creco=${LD64}/src/create_configure
+ ARCHS_TO_SUPPORT=""
+ if use multitarget ; then
+ ARCHS_TO_SUPPORT="$(grep KNOWN_ARCHS= $creco | \
+ cut -d\" -f2 | tr ',' ' ')"
+ fi
+
+ # Create configure.h for ld64 with SUPPORT_ARCH_<arch> defines in it.
+ DERIVED_FILE_DIR=${LD64}/src \
+ RC_SUPPORTED_ARCHS="$ARCHS_TO_SUPPORT" \
+ $creco
+
+ # do not depend on MachOFileAbstraction.hpp to define
+ # SUPPORT_ARCH_arm_any because that's not included by every file where
+ # our ppc/arm-optional patch uses it, ld.hpp in particular
+ grep "SUPPORT_ARCH_armv[0-9]" ${LD64}/src/configure.h >/dev/null && \
+ echo "#define SUPPORT_ARCH_arm_any 1" >> ${LD64}/src/configure.h
+}
+
+compile_ld64() {
+ einfo "building ${LD64}"
+ cd "${S}"/${LD64}/src
+ emake \
+ LTO=${ENABLE_LTO} \
+ || die "emake failed for ld64"
+ use test && emake build_test
+}
+
+compile_cctools() {
+ einfo "building ${CCTOOLS}"
+ cd "${S}"/${CCTOOLS}
+ # Suppress running dsymutil because it will warn about missing debug
+ # info which is expected when compiling without -g as we normally do.
+ # This might need some more thought if anyone ever wanted to build us
+ # for debugging with Apple's tools.
+ emake \
+ LIB_PRUNETRIE="-L../../${LD64}/src -lprunetrie" \
+ EFITOOLS= \
+ LTO="${ENABLE_LTO}" \
+ LTO_LIBDIR=../../../lib \
+ COMMON_SUBDIRS='libstuff ar misc otool' \
+ SUBDIRS_32= \
+ LEGACY= \
+ RC_ProjectSourceVersion=${CCTOOLS_VERSION} \
+ RC_CFLAGS="${CFLAGS}" \
+ OFLAG="${CCTOOLS_OFLAG}" \
+ DSYMUTIL=": disabled: dsymutil" \
+ || die "emake failed for the cctools"
+ cd "${S}"/${CCTOOLS}/as
+ emake \
+ BUILD_OBSOLETE_ARCH= \
+ RC_ProjectSourceVersion=${CCTOOLS_VERSION} \
+ RC_CFLAGS="-DASLIBEXECDIR=\"\\\"${EPREFIX}${LIBPATH}/\\\"\" -DCLANGDIR=\"\\\"${EPREFIX}/usr/bin/\\\"\" ${CFLAGS}" \
+ OFLAG="${CCTOOLS_OFLAG}" \
+ DSYMUTIL=": disabled: dsymutil" \
+ || die "emake failed for as"
+}
+
+src_compile() {
+ compile_ld64
+ compile_cctools
+}
+
+install_ld64() {
+ exeinto ${BINPATH}
+ doexe "${S}"/${LD64}/src/{ld64,rebase,dyldinfo,unwinddump,ObjectDump}
+ dosym ld64 ${BINPATH}/ld
+ insinto ${DATAPATH}/man/man1
+ doins "${S}"/${LD64}/doc/man/man1/{ld,ld64,rebase}.1
+}
+
+install_cctools() {
+ cd "${S}"/${CCTOOLS}
+ emake install_all_but_headers \
+ EFITOOLS= \
+ COMMON_SUBDIRS='ar misc otool' \
+ SUBDIRS_32= \
+ DSTROOT=\"${D}\" \
+ BINDIR=\"${EPREFIX}\"${BINPATH} \
+ LOCBINDIR=\"${EPREFIX}\"${BINPATH} \
+ USRBINDIR=\"${EPREFIX}\"${BINPATH} \
+ LOCLIBDIR=\"${EPREFIX}\"${LIBPATH} \
+ MANDIR=\"${EPREFIX}\"${DATAPATH}/man/
+ cd "${S}"/${CCTOOLS}/as
+ emake install \
+ BUILD_OBSOLETE_ARCH= \
+ DSTROOT=\"${D}\" \
+ USRBINDIR=\"${EPREFIX}\"${BINPATH} \
+ LIBDIR=\"${EPREFIX}\"${LIBPATH} \
+ LOCLIBDIR=\"${EPREFIX}\"${LIBPATH}
+
+ # upstream is starting to replace classic binutils with llvm-integrated
+ # ones. nm and size are now symlinks to llvm-{nm,size} while the classic
+ # version is preserved as {nm,size}-classic. (BTW: otool is a symlink to
+ # otool-classic for now but a wrapper llvm-otool that is calling
+ # llvm-objdump is present already.)
+ # Since our binutils do not live in the same directory as the llvm
+ # installation, we have to rewrite the symlinks to the llvm tools.
+ # This also means, that these tools still appear to be versioned via
+ # binutils-config but actually always run the currently installed llvm
+ # tool.
+ for tool in nm size ; do
+ # ${EPREFIX}/usr/x86_64-apple-darwin15/binutils-bin/7.3/$tool
+ # -> ${EPREFIX}/bin/llvm-$tool
+ ln -sfn ../../../bin/llvm-$tool "${D}/${EPREFIX}/${BINPATH}/$tool"
+ done
+
+ cd "${ED}"${BINPATH}
+ insinto ${DATAPATH}/man/man1
+ local skips manpage
+ # ar brings an up-to-date manpage with it
+ skips=( ar )
+ for bin in *; do
+ for skip in ${skips[@]}; do
+ if [[ ${bin} == ${skip} ]]; then
+ continue 2;
+ fi
+ done
+ manpage=${S}/${CCTOOLS}/man/${bin}.1
+ if [[ -f "${manpage}" ]]; then
+ doins "${manpage}"
+ fi
+ done
+ insinto ${DATAPATH}/man/man5
+ doins "${S}"/${CCTOOLS}/man/*.5
+}
+
+src_test() {
+ if ! [ "${EPREFIX}"/usr/bin/clang ] ; then
+ einfo "Test suite only works properly with clang - please install"
+ return
+ fi
+
+ einfo "Running unit tests"
+ cd "${S}"/${LD64}/unit-tests/test-cases
+ # provide the new ld as a symlink to clang so that -ccc-install-dir
+ # will pick it up
+ ln -sfn ../../src/ld64 ld
+ # use our arch command because the System's will report i386 even for an
+ # x86_64 prefix
+ perl ../bin/make-recursive.pl \
+ BUILT_PRODUCTS_DIR="${S}"/${LD64}/src \
+ ARCH="$(arch)" \
+ LD="${S}"/${LD64}/src/ld64 \
+ CC="${CC} -ccc-install-dir $PWD" \
+ CXX="${CXX} -ccc-install-dir $PWD" \
+ OTOOL="${S}"/${CCTOOLS}/otool/otool.NEW \
+ | perl ../bin/result-filter.pl
+}
+
+src_install() {
+ install_ld64
+ install_cctools
+
+ cd "${S}"
+ insinto /etc/env.d/binutils
+ cat <<-EOF > env.d
+ TARGET="${CHOST}"
+ VER="${PV}"
+ FAKE_TARGETS="${CHOST}"
+ EOF
+ newins env.d ${CHOST}-${PV}
+}
+
+pkg_postinst() {
+ binutils-config ${CHOST}-${PV}
+}
diff --git a/sys-devel/binutils-apple/binutils-apple-7.3.ebuild b/sys-devel/binutils-apple/binutils-apple-7.3.ebuild
new file mode 100644
index 000000000000..26f629c41ee5
--- /dev/null
+++ b/sys-devel/binutils-apple/binutils-apple-7.3.ebuild
@@ -0,0 +1,386 @@
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI="5"
+
+inherit eutils flag-o-matic toolchain-funcs
+
+LD64=ld64-264.3.101
+CCTOOLS_VERSION=886
+CCTOOLS=cctools-${CCTOOLS_VERSION}
+LIBUNWIND=libunwind-35.3
+DYLD=dyld-360.18
+
+DESCRIPTION="Darwin assembler as(1) and static linker ld(1), Xcode Tools ${PV}"
+HOMEPAGE="http://www.opensource.apple.com/darwinsource/"
+SRC_URI="http://www.opensource.apple.com/tarballs/ld64/${LD64}.tar.gz
+ http://www.opensource.apple.com/tarballs/cctools/${CCTOOLS}.tar.gz
+ http://www.opensource.apple.com/tarballs/dyld/${DYLD}.tar.gz
+ http://www.opensource.apple.com/tarballs/libunwind/${LIBUNWIND}.tar.gz
+ https://dev.gentoo.org/~grobian/distfiles/${PN}-patches-4.3-r1.tar.bz2
+ https://dev.gentoo.org/~grobian/distfiles/${PN}-patches-5.1-r2.tar.bz2
+ https://dev.gentoo.org/~grobian/distfiles/${PN}-patches-6.1-r1.tar.bz2
+ https://dev.gentoo.org/~grobian/distfiles/${PN}-patches-6.3-r1.tar.bz2
+ https://dev.gentoo.org/~grobian/distfiles/${PN}-patches-7.0-r2.tar.bz2
+ https://dev.gentoo.org/~grobian/distfiles/${PN}-patches-7.2-r0.tar.bz2
+ https://dev.gentoo.org/~grobian/distfiles/${PN}-patches-7.3-r0.tar.bz2"
+
+LICENSE="APSL-2"
+KEYWORDS="~ppc-macos ~x64-macos ~x86-macos"
+IUSE="lto test multitarget"
+
+# ld64 can now only be compiled using llvm and libc++ since it massivley uses
+# C++11 language fatures. *But additionally* the as driver now defaults to
+# calling clang as the assembler on many platforms. This can be disabled using
+# -Wa,-Q but since it's default we make llvm a static runtime dependency.
+RDEPEND="sys-devel/binutils-config
+ lto? ( app-arch/xar )
+ sys-devel/llvm
+ sys-libs/libcxx"
+DEPEND="${RDEPEND}
+ test? ( >=dev-lang/perl-5.8.8 )"
+
+SLOT="7"
+
+S=${WORKDIR}
+
+is_cross() { [[ ${CHOST} != ${CTARGET} ]] ; }
+
+src_prepare() {
+ if use multitarget ; then
+ ewarn "You have enabled support for non-standard target architectures"
+ ewarn "using USE=multitarget. This includes experimental support for"
+ ewarn "ppc and ppc64 which is a community forward-port from the last"
+ ewarn "version of ld64 to officially support PPC."
+
+ if [[ ${CHOST} == powerpc*-darwin* ]] ; then
+ ewarn "HERE BE DRAGONS! Your system seems to be PPC which means that"
+ ewarn "the actual usability of your Gentoo programs will depend on the"
+ ewarn "above-mentioned experimental PPC support in the linker. Be"
+ ewarn "sure to keep a known-to-work version like ${PN}-3.2.6 around!"
+ fi
+ fi
+
+ cd "${S}"/${LD64}/src
+ cp "${S}"/ld64-136-compile_stubs.h ld/compile_stubs.h
+ cp "${S}"/ld64-264.3.101-Makefile Makefile
+
+ epatch "${S}"/ld64-264.3.101-nolto.patch
+ epatch "${S}"/ld64-241.9-extraneous-includes.patch
+ epatch "${S}"/ld64-241.9-osatomic.patch
+ epatch "${S}"/ld64-236.3-crashreporter.patch
+ epatch "${S}"/ld64-264.3.101-nosnapshots.patch
+ epatch "${S}"/ld64-264.3.101-ppc.patch
+ epatch "${S}"/ld64-264.3.101-constant-types.patch
+ epatch "${S}"/ld64-241.9-register-names.patch
+ epatch "${S}"/ld64-241.9-get-comm-align.patch
+ epatch "${S}"/ld64-241.9-cc_md5.patch
+
+ # provide missing headers from libunwind and dyld
+ mkdir -p include/{mach,mach-o/arm} || die
+ # never present because it's private
+ cp ../../${DYLD}/include/mach-o/dyld_priv.h include/mach-o || die
+ # missing on <= 10.5
+ cp ../../${LIBUNWIND}/include/libunwind.h include/ || die
+ cp ../../${LIBUNWIND}/include/mach-o/compact_unwind_encoding.h include/mach-o || die
+ # missing on <= 10.4
+ cp ../../${DYLD}/include/mach-o/dyld_images.h include/mach-o || die
+ cp ../../${CCTOOLS}/include/mach-o/loader.h include/mach-o || die
+ # use copies from cctools because they're otherwise hidden in some SDK
+ cp ../../${CCTOOLS}/include/mach-o/arm/reloc.h include/mach-o/arm || die
+ # provide all required CPU_TYPEs on all platforms
+ cp ../../${CCTOOLS}/include/mach/machine.h include/mach/machine.h
+ # add alias for newer identifiers, because ld64 uses both but cctools
+ # header only defines the older
+ epatch "${S}"/ld64-236.3-missing-cputypes.patch
+
+ # mimic OS X Leopard-style Availability.h macros for libunwind.h on
+ # older systems
+ [[ ${CHOST} == *darwin* && ${CHOST#*-darwin} -le 8 ]] && \
+ echo "#define __OSX_AVAILABLE_STARTING(x,y) " > include/Availability.h
+
+ local VER_STR="\"@(#)PROGRAM:ld PROJECT:${LD64} (Gentoo ${PN}-${PVR})\\n\""
+ echo "char ldVersionString[] = ${VER_STR};" > version.cpp
+
+ epatch "${S}"/ld64-123.2-debug-backtrace.patch
+ if [[ ${CHOST} == powerpc*-darwin* ]] ; then
+ epatch "${S}"/ld64-123.2-darwin8-no-mlong-branch-warning.patch
+ epatch "${S}"/ld64-127.2-thread_state.patch
+ fi
+
+ cd "${S}"/${CCTOOLS}
+ epatch "${S}"/${PN}-4.5-as.patch
+ epatch "${S}"/${PN}-5.1-as-dir.patch
+ epatch "${S}"/${PN}-5.1-ranlib.patch
+ epatch "${S}"/${PN}-3.1.1-libtool-ranlib.patch
+ epatch "${S}"/${PN}-3.1.1-no-headers.patch
+ epatch "${S}"/${PN}-4.0-no-oss-dir.patch
+ epatch "${S}"/cctools-839-intel-retf.patch
+ epatch "${S}"/${PN}-5.1-extraneous-includes.patch
+ #epatch "${S}"/${PN}-5.1-otool-stdc.patch
+ epatch "${S}"/${PN}-5.1-constant-types.patch
+ epatch "${S}"/${PN}-5.1-strnlen.patch
+ epatch "${S}"/${PN}-5.1-ppc.patch
+ epatch "${S}"/${PN}-5.1-thread-state-redefined.patch
+ epatch "${S}"/${PN}-7.3-make-j.patch
+ epatch "${S}"/${PN}-7.0-lto-prefix-2.patch
+ epatch "${S}"/${PN}-7.0-clang-as.patch
+ epatch "${S}"/${PN}-7.3-nolto.patch
+ epatch "${S}"/${PN}-7.3-nollvm.patch
+ epatch "${S}"/${PN}-7.3-no-developertools-dir.patch
+ cp ../${LD64}/src/other/prune_trie.h include/mach-o/ || die
+
+ # do not build profileable libstuff to save compile time
+ sed -i -e "/^all:/s, profile , ," libstuff/Makefile
+
+ # cctools version is provided to make via RC_ProjectSourceVersion which
+ # generates and compiles it as apple_version[] into libstuff. From
+ # there it's picked up by the individual tools. Since
+ # RC_ProjectSourceVersion is also used as library version, we can't
+ # just append our local version info. So we hack the libstuff Makefile
+ # to include our Gentoo version.
+ sed -i -e "/cctools-.*(RC_ProjectSourceVersion).*OFILE_DIR/s,Version),Version) (Gentoo ${PN}-${PVR})," \
+ libstuff/Makefile
+
+ # clean up test suite
+ cd "${S}"/${LD64}/unit-tests/test-cases
+ local c
+
+ # we don't have llvm
+ ((++c)); rm -rf llvm-integration;
+
+ # we don't have dtrace
+ ((++c)); rm -rf dtrace-static-probes-coalescing;
+ ((++c)); rm -rf dtrace-static-probes;
+
+ # a file is missing
+ ((++c)); rm -rf eh-coalescing-r
+
+ # we don't do universal binaries
+ ((++c)); rm -rf blank-stubs;
+
+ # looks like a problem with apple's result-filter.pl
+ ((++c)); rm -rf implicit-common3;
+ ((++c)); rm -rf order_file-ans;
+
+ # TODO no idea what goes wrong here
+ ((++c)); rm -rf dwarf-debug-notes;
+
+ einfo "Deleted $c tests that were bound to fail"
+
+ cd "${S}"
+ ebegin "cleaning Makefiles from unwanted CFLAGS"
+ find . -name "Makefile" -print0 | xargs -0 sed \
+ -i \
+ -e 's/ -g / /g' \
+ -e 's/^G =.*$/G =/' \
+ -e 's/^OFLAG =.*$/OFLAG =/' \
+ -e 's/install -c -s/install/g'
+ eend $?
+}
+
+src_configure() {
+ ENABLE_LTO=0
+ use lto && ENABLE_LTO=1
+
+ export CTARGET=${CTARGET:-${CHOST}}
+ if [[ ${CTARGET} == ${CHOST} ]] ; then
+ if [[ ${CATEGORY} == cross-* ]] ; then
+ export CTARGET=${CATEGORY#cross-}
+ fi
+ fi
+
+ LIBPATH=/usr/$(get_libdir)/binutils/${CTARGET}/${PV}
+ INCPATH=${LIBPATH}/include
+ DATAPATH=/usr/share/binutils-data/${CTARGET}/${PV}
+ if is_cross ; then
+ BINPATH=/usr/${CHOST}/${CTARGET}/binutils-bin/${PV}
+ else
+ BINPATH=/usr/${CTARGET}/binutils-bin/${PV}
+ fi
+
+ # CPPFLAGS only affects ld64, cctools don't use 'em (which currently is
+ # what we want)
+ append-cppflags -DNDEBUG
+
+ # Block API and thus snapshots supported on >= 10.6
+ [[ ${CHOST} == *darwin* && ${CHOST#*-darwin} -ge 10 ]] && \
+ append-cppflags -DSUPPORT_SNAPSHOTS
+
+ CCTOOLS_OFLAG=
+ if [[ ${CHOST} == *darwin* && ${CHOST#*-darwin} -le 8 ]] ; then
+ # cctools expect to use UNIX03 struct member names.
+ # This is default on > 10.4. Activate it on <= 10.4 by defining
+ # __DARWIN_UNIX03 explicitly.
+ CCTOOLS_OFLAG="-D__DARWIN_UNIX03=1"
+ fi
+
+ # if compiling with USE multitarget, extract all the known arches from
+ # create_configure and pass them back to it
+ creco=${LD64}/src/create_configure
+ ARCHS_TO_SUPPORT=""
+ if use multitarget ; then
+ ARCHS_TO_SUPPORT="$(grep KNOWN_ARCHS= $creco | \
+ cut -d\" -f2 | tr ',' ' ')"
+ fi
+
+ # Create configure.h for ld64 with SUPPORT_ARCH_<arch> defines in it.
+ DERIVED_FILE_DIR=${LD64}/src \
+ RC_SUPPORTED_ARCHS="$ARCHS_TO_SUPPORT" \
+ $creco
+
+ # do not depend on MachOFileAbstraction.hpp to define
+ # SUPPORT_ARCH_arm_any because that's not included by every file where
+ # our ppc/arm-optional patch uses it, ld.hpp in particular
+ grep "SUPPORT_ARCH_armv[0-9]" ${LD64}/src/configure.h >/dev/null && \
+ echo "#define SUPPORT_ARCH_arm_any 1" >> ${LD64}/src/configure.h
+}
+
+compile_ld64() {
+ einfo "building ${LD64}"
+ cd "${S}"/${LD64}/src
+ emake \
+ LTO=${ENABLE_LTO} \
+ || die "emake failed for ld64"
+ use test && emake build_test
+}
+
+compile_cctools() {
+ einfo "building ${CCTOOLS}"
+ cd "${S}"/${CCTOOLS}
+ # Suppress running dsymutil because it will warn about missing debug
+ # info which is expected when compiling without -g as we normally do.
+ # This might need some more thought if anyone ever wanted to build us
+ # for debugging with Apple's tools.
+ emake \
+ LIB_PRUNETRIE="-L../../${LD64}/src -lprunetrie" \
+ EFITOOLS= \
+ LTO="${ENABLE_LTO}" \
+ LTO_LIBDIR=../../../lib \
+ COMMON_SUBDIRS='libstuff ar misc otool' \
+ SUBDIRS_32= \
+ LEGACY= \
+ RC_ProjectSourceVersion=${CCTOOLS_VERSION} \
+ RC_CFLAGS="${CFLAGS}" \
+ OFLAG="${CCTOOLS_OFLAG}" \
+ DSYMUTIL=": disabled: dsymutil" \
+ || die "emake failed for the cctools"
+ cd "${S}"/${CCTOOLS}/as
+ emake \
+ BUILD_OBSOLETE_ARCH= \
+ RC_ProjectSourceVersion=${CCTOOLS_VERSION} \
+ RC_CFLAGS="-DASLIBEXECDIR=\"\\\"${EPREFIX}${LIBPATH}/\\\"\" -DCLANGDIR=\"\\\"${EPREFIX}/usr/bin/\\\"\" ${CFLAGS}" \
+ OFLAG="${CCTOOLS_OFLAG}" \
+ DSYMUTIL=": disabled: dsymutil" \
+ || die "emake failed for as"
+}
+
+src_compile() {
+ compile_ld64
+ compile_cctools
+}
+
+install_ld64() {
+ exeinto ${BINPATH}
+ doexe "${S}"/${LD64}/src/{ld64,rebase,dyldinfo,unwinddump,ObjectDump}
+ dosym ld64 ${BINPATH}/ld
+ insinto ${DATAPATH}/man/man1
+ doins "${S}"/${LD64}/doc/man/man1/{ld,ld64,rebase}.1
+}
+
+install_cctools() {
+ cd "${S}"/${CCTOOLS}
+ emake install_all_but_headers \
+ EFITOOLS= \
+ COMMON_SUBDIRS='ar misc otool' \
+ SUBDIRS_32= \
+ DSTROOT=\"${D}\" \
+ BINDIR=\"${EPREFIX}\"${BINPATH} \
+ LOCBINDIR=\"${EPREFIX}\"${BINPATH} \
+ USRBINDIR=\"${EPREFIX}\"${BINPATH} \
+ LOCLIBDIR=\"${EPREFIX}\"${LIBPATH} \
+ MANDIR=\"${EPREFIX}\"${DATAPATH}/man/
+ cd "${S}"/${CCTOOLS}/as
+ emake install \
+ BUILD_OBSOLETE_ARCH= \
+ DSTROOT=\"${D}\" \
+ USRBINDIR=\"${EPREFIX}\"${BINPATH} \
+ LIBDIR=\"${EPREFIX}\"${LIBPATH} \
+ LOCLIBDIR=\"${EPREFIX}\"${LIBPATH}
+
+ # upstream is starting to replace classic binutils with llvm-integrated
+ # ones. nm and size are now symlinks to llvm-{nm,size} while the classic
+ # version is preserved as {nm,size}-classic. (BTW: otool is a symlink to
+ # otool-classic for now but a wrapper llvm-otool that is calling
+ # llvm-objdump is present already.)
+ # Since our binutils do not live in the same directory as the llvm
+ # installation, we have to rewrite the symlinks to the llvm tools.
+ # This also means, that these tools still appear to be versioned via
+ # binutils-config but actually always run the currently installed llvm
+ # tool.
+ for tool in nm size ; do
+ # ${EPREFIX}/usr/x86_64-apple-darwin15/binutils-bin/7.3/$tool
+ # -> ${EPREFIX}/bin/llvm-$tool
+ ln -sfn ../../../bin/llvm-$tool "${D}/${EPREFIX}/${BINPATH}/$tool"
+ done
+
+ cd "${ED}"${BINPATH}
+ insinto ${DATAPATH}/man/man1
+ local skips manpage
+ # ar brings an up-to-date manpage with it
+ skips=( ar )
+ for bin in *; do
+ for skip in ${skips[@]}; do
+ if [[ ${bin} == ${skip} ]]; then
+ continue 2;
+ fi
+ done
+ manpage=${S}/${CCTOOLS}/man/${bin}.1
+ if [[ -f "${manpage}" ]]; then
+ doins "${manpage}"
+ fi
+ done
+ insinto ${DATAPATH}/man/man5
+ doins "${S}"/${CCTOOLS}/man/*.5
+}
+
+src_test() {
+ if ! [ "${EPREFIX}"/usr/bin/clang ] ; then
+ einfo "Test suite only works properly with clang - please install"
+ return
+ fi
+
+ einfo "Running unit tests"
+ cd "${S}"/${LD64}/unit-tests/test-cases
+ # provide the new ld as a symlink to clang so that -ccc-install-dir
+ # will pick it up
+ ln -sfn ../../src/ld64 ld
+ # use our arch command because the System's will report i386 even for an
+ # x86_64 prefix
+ perl ../bin/make-recursive.pl \
+ BUILT_PRODUCTS_DIR="${S}"/${LD64}/src \
+ ARCH="$(arch)" \
+ LD="${S}"/${LD64}/src/ld64 \
+ CC="${CC} -ccc-install-dir $PWD" \
+ CXX="${CXX} -ccc-install-dir $PWD" \
+ OTOOL="${S}"/${CCTOOLS}/otool/otool.NEW \
+ | perl ../bin/result-filter.pl
+}
+
+src_install() {
+ install_ld64
+ install_cctools
+
+ cd "${S}"
+ insinto /etc/env.d/binutils
+ cat <<-EOF > env.d
+ TARGET="${CHOST}"
+ VER="${PV}"
+ FAKE_TARGETS="${CHOST}"
+ EOF
+ newins env.d ${CHOST}-${PV}
+}
+
+pkg_postinst() {
+ binutils-config ${CHOST}-${PV}
+}
diff --git a/sys-devel/binutils-apple/binutils-apple-8.1.ebuild b/sys-devel/binutils-apple/binutils-apple-8.1.ebuild
new file mode 100644
index 000000000000..d5ad6ab38a98
--- /dev/null
+++ b/sys-devel/binutils-apple/binutils-apple-8.1.ebuild
@@ -0,0 +1,334 @@
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI="6"
+
+inherit eutils flag-o-matic toolchain-funcs
+
+LD64=ld64-274.1
+CCTOOLS_VERSION=895
+CCTOOLS=cctools-${CCTOOLS_VERSION}
+DYLD=dyld-421.2
+
+DESCRIPTION="Darwin assembler as(1) and static linker ld(1), Xcode Tools ${PV}"
+HOMEPAGE="http://www.opensource.apple.com/darwinsource/"
+SRC_URI="http://www.opensource.apple.com/tarballs/ld64/${LD64}.tar.gz
+ http://www.opensource.apple.com/tarballs/cctools/${CCTOOLS}.tar.gz
+ http://www.opensource.apple.com/tarballs/dyld/${DYLD}.tar.gz
+ https://dev.gentoo.org/~grobian/distfiles/${PN}-patches-4.3-r1.tar.bz2
+ https://dev.gentoo.org/~grobian/distfiles/${PN}-patches-5.1-r2.tar.bz2
+ https://dev.gentoo.org/~grobian/distfiles/${PN}-patches-7.0-r2.tar.bz2
+ https://dev.gentoo.org/~grobian/distfiles/${PN}-patches-7.3-r1.tar.bz2
+ https://dev.gentoo.org/~grobian/distfiles/${PN}-patches-8.2-r0.tar.bz2"
+
+LICENSE="APSL-2"
+KEYWORDS="~x64-macos ~x86-macos"
+IUSE="lto tapi classic test"
+
+# ld64 can now only be compiled using llvm and libc++ since it massively uses
+# C++11 language features. *But additionally* the as driver now defaults to
+# calling clang as the assembler on many platforms. This can be disabled using
+# -Wa,-Q but since it's default we make llvm a static runtime dependency.
+RDEPEND="sys-devel/binutils-config
+ lto? ( app-arch/xar )
+ tapi? ( sys-libs/tapi )
+ sys-devel/llvm
+ sys-libs/libcxx"
+DEPEND="${RDEPEND}
+ test? ( >=dev-lang/perl-5.8.8 )"
+
+SLOT="8"
+
+S=${WORKDIR}
+
+is_cross() { [[ ${CHOST} != ${CTARGET} ]] ; }
+
+src_prepare() {
+ cd "${S}"/${LD64}/src
+ cp "${S}"/ld64-136-compile_stubs.h ld/compile_stubs.h
+ cp "${S}"/ld64-274.1-Makefile Makefile
+
+ epatch "${S}"/ld64-274.1-nolto.patch
+ epatch "${S}"/ld64-236.3-crashreporter.patch
+ epatch "${S}"/ld64-264.3.102-bitcode-case.patch
+ epatch "${S}"/ld64-274.1-unknown-fixup.patch
+ epatch "${S}"/ld64-274.1-notapi.patch
+
+ # workound llvm-3.9.{0,1} issue
+ # https://bugs.gentoo.org/show_bug.cgi?id=603580
+ # https://groups.google.com/forum/#!topic/llvm-dev/JY6nuKE__sU
+ # http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20160829/169553.html
+ sed -i -e '/COMPILE_TIME_ASSERT/d' ld/parsers/libunwind/*.hpp || die
+
+ # provide missing headers from libunwind and dyld
+ mkdir -p include/{mach,mach-o/arm} || die
+ # never present because it's private
+ cp ../../${DYLD}/include/mach-o/dyld_priv.h include/mach-o || die
+ # use copies from cctools because they're otherwise hidden in some SDK
+ cp ../../${CCTOOLS}/include/mach-o/arm/reloc.h include/mach-o/arm || die
+ # provide all required CPU_TYPEs on all platforms
+ cp ../../${CCTOOLS}/include/mach/machine.h include/mach/machine.h
+ # add alias for newer identifiers, because ld64 uses both but cctools
+ # header only defines the older
+ epatch "${S}"/ld64-236.3-missing-cputypes.patch
+
+ local VER_STR="\"@(#)PROGRAM:ld PROJECT:${LD64} (Gentoo ${PN}-${PVR})\\n\""
+ echo "char ldVersionString[] = ${VER_STR};" > version.cpp
+
+ epatch "${S}"/ld64-123.2-debug-backtrace.patch
+
+ cd "${S}"/${CCTOOLS}
+ epatch "${S}"/${PN}-4.5-as.patch
+ epatch "${S}"/${PN}-5.1-as-dir.patch
+ epatch "${S}"/${PN}-5.1-ranlib.patch
+ epatch "${S}"/${PN}-3.1.1-libtool-ranlib.patch
+ epatch "${S}"/${PN}-3.1.1-no-headers.patch
+ epatch "${S}"/${PN}-4.0-no-oss-dir.patch
+ epatch "${S}"/cctools-839-intel-retf.patch
+ epatch "${S}"/${PN}-5.1-extraneous-includes.patch
+ epatch "${S}"/${PN}-5.1-strnlen.patch
+ epatch "${S}"/${PN}-7.3-make-j.patch
+ epatch "${S}"/${PN}-7.0-lto-prefix-2.patch
+ epatch "${S}"/${PN}-7.0-clang-as.patch
+ epatch "${S}"/${PN}-8.1-nolto.patch
+ epatch "${S}"/${PN}-7.3-nollvm.patch
+ epatch "${S}"/${PN}-7.3-no-developertools-dir.patch
+ epatch "${S}"/${PN}-8.1-llvm-tools.patch
+ cp ../${LD64}/src/other/prune_trie.h include/mach-o/ || die
+
+ # do not build profileable libstuff to save compile time
+ sed -i -e "/^all:/s, profile , ," libstuff/Makefile
+
+ # cctools version is provided to make via RC_ProjectSourceVersion which
+ # generates and compiles it as apple_version[] into libstuff. From
+ # there it's picked up by the individual tools. Since
+ # RC_ProjectSourceVersion is also used as library version, we can't
+ # just append our local version info. So we hack the libstuff Makefile
+ # to include our Gentoo version.
+ sed -i -e "/cctools-.*(RC_ProjectSourceVersion).*OFILE_DIR/s,Version),Version) (Gentoo ${PN}-${PVR})," \
+ libstuff/Makefile
+
+ eapply_user
+
+ # clean up test suite
+ cd "${S}"/${LD64}/unit-tests/test-cases
+ local c
+
+ # we don't have llvm
+ ((++c)); rm -rf llvm-integration;
+
+ # we don't have dtrace
+ ((++c)); rm -rf dtrace-static-probes-coalescing;
+ ((++c)); rm -rf dtrace-static-probes;
+
+ # a file is missing
+ ((++c)); rm -rf eh-coalescing-r
+
+ # we don't do universal binaries
+ ((++c)); rm -rf blank-stubs;
+
+ # looks like a problem with apple's result-filter.pl
+ ((++c)); rm -rf implicit-common3;
+ ((++c)); rm -rf order_file-ans;
+
+ # TODO no idea what goes wrong here
+ ((++c)); rm -rf dwarf-debug-notes;
+
+ einfo "Deleted $c tests that were bound to fail"
+
+ cd "${S}"
+ ebegin "cleaning Makefiles from unwanted CFLAGS"
+ find . -name "Makefile" -print0 | xargs -0 sed \
+ -i \
+ -e 's/ -g / /g' \
+ -e 's/^G =.*$/G =/' \
+ -e 's/^OFLAG =.*$/OFLAG =/' \
+ -e 's/install -c -s/install/g'
+ eend $?
+}
+
+src_configure() {
+ ENABLE_LTO=0
+ use lto && ENABLE_LTO=1
+
+ export CTARGET=${CTARGET:-${CHOST}}
+ if [[ ${CTARGET} == ${CHOST} ]] ; then
+ if [[ ${CATEGORY} == cross-* ]] ; then
+ export CTARGET=${CATEGORY#cross-}
+ fi
+ fi
+
+ LIBPATH=/usr/$(get_libdir)/binutils/${CTARGET}/${PV}
+ INCPATH=${LIBPATH}/include
+ DATAPATH=/usr/share/binutils-data/${CTARGET}/${PV}
+ if is_cross ; then
+ BINPATH=/usr/${CHOST}/${CTARGET}/binutils-bin/${PV}
+ else
+ BINPATH=/usr/${CTARGET}/binutils-bin/${PV}
+ fi
+
+ # CPPFLAGS only affects ld64, cctools don't use 'em (which currently is
+ # what we want)
+ append-cppflags -DNDEBUG
+
+ # Create configure.h for ld64 with SUPPORT_ARCH_<arch> defines in it.
+ DERIVED_FILE_DIR=${LD64}/src \
+ ${LD64}/src/create_configure
+}
+
+compile_ld64() {
+ einfo "building ${LD64}"
+ cd "${S}"/${LD64}/src
+ emake \
+ LTO=${ENABLE_LTO} \
+ TAPI=$(use tapi && echo 1 || echo 0) \
+ || die "emake failed for ld64"
+ use test && emake build_test
+}
+
+compile_cctools() {
+ einfo "building ${CCTOOLS}"
+ cd "${S}"/${CCTOOLS}
+ # Suppress running dsymutil because it will warn about missing debug
+ # info which is expected when compiling without -g as we normally do.
+ # This might need some more thought if anyone ever wanted to build us
+ # for debugging with Apple's tools.
+ emake \
+ LIB_PRUNETRIE="-L../../${LD64}/src -lprunetrie" \
+ EFITOOLS= \
+ LTO="${ENABLE_LTO}" \
+ LTO_LIBDIR=../../../lib \
+ COMMON_SUBDIRS='libstuff ar misc otool' \
+ SUBDIRS_32= \
+ LEGACY= \
+ RC_ProjectSourceVersion=${CCTOOLS_VERSION} \
+ RC_CFLAGS="${CFLAGS}" \
+ OFLAG="${CCTOOLS_OFLAG}" \
+ DSYMUTIL=": disabled: dsymutil" \
+ || die "emake failed for the cctools"
+ cd "${S}"/${CCTOOLS}/as
+ emake \
+ BUILD_OBSOLETE_ARCH= \
+ RC_ProjectSourceVersion=${CCTOOLS_VERSION} \
+ RC_CFLAGS="-DASLIBEXECDIR=\"\\\"${EPREFIX}${LIBPATH}/\\\"\" -DCLANGDIR=\"\\\"${EPREFIX}/usr/bin/\\\"\" ${CFLAGS}" \
+ OFLAG="${CCTOOLS_OFLAG}" \
+ DSYMUTIL=": disabled: dsymutil" \
+ || die "emake failed for as"
+}
+
+src_compile() {
+ compile_ld64
+ compile_cctools
+}
+
+install_ld64() {
+ exeinto ${BINPATH}
+ doexe "${S}"/${LD64}/src/{ld64,rebase,dyldinfo,unwinddump,ObjectDump}
+ dosym ld64 ${BINPATH}/ld
+ insinto ${DATAPATH}/man/man1
+ doins "${S}"/${LD64}/doc/man/man1/{ld,ld64,rebase}.1
+}
+
+install_cctools() {
+ cd "${S}"/${CCTOOLS}
+ emake install_all_but_headers \
+ EFITOOLS= \
+ COMMON_SUBDIRS='ar misc otool' \
+ SUBDIRS_32= \
+ DSTROOT=\"${D}\" \
+ BINDIR=\"${EPREFIX}\"${BINPATH} \
+ LOCBINDIR=\"${EPREFIX}\"${BINPATH} \
+ USRBINDIR=\"${EPREFIX}\"${BINPATH} \
+ LOCLIBDIR=\"${EPREFIX}\"${LIBPATH} \
+ MANDIR=\"${EPREFIX}\"${DATAPATH}/man/
+ cd "${S}"/${CCTOOLS}/as
+ emake install \
+ BUILD_OBSOLETE_ARCH= \
+ DSTROOT=\"${D}\" \
+ USRBINDIR=\"${EPREFIX}\"${BINPATH} \
+ LIBDIR=\"${EPREFIX}\"${LIBPATH} \
+ LOCLIBDIR=\"${EPREFIX}\"${LIBPATH}
+
+ # upstream is starting to replace classic binutils with llvm-integrated
+ # ones. nm and size are now symlinks to llvm-{nm,size} while the classic
+ # version is preserved as {nm,size}-classic.
+ # Since our binutils do not live in the same directory as the llvm
+ # installation, we have to rewrite the symlinks to the llvm tools.
+ # This also means, that these tools still appear to be versioned via
+ # binutils-config but actually always run the currently installed llvm
+ # tool.
+ budir=${D}/${EPREFIX}/${BINPATH}
+ for tool in nm size ; do
+ # ${EPREFIX}/usr/x86_64-apple-darwin15/binutils-bin/7.3/$tool
+ # -> ${EPREFIX}/bin/llvm-$tool
+ use classic && \
+ ln -sfn ${tool}-classic "${budir}/${tool}" || \
+ ln -sfn ../../../bin/llvm-${tool} "${budir}/${tool}"
+ done
+
+ # Also, otool is now based on llvm-objdump. But a small wrapper installed
+ # as llvm-otool remains, providing command line compatibility.
+ use classic && \
+ ln -sfn otool-classic "${budir}/otool" || \
+ ln -sfn llvm-otool "${budir}/otool"
+
+ cd "${ED}"${BINPATH}
+ insinto ${DATAPATH}/man/man1
+ local skips manpage
+ # ar brings an up-to-date manpage with it
+ skips=( ar )
+ for bin in *; do
+ for skip in ${skips[@]}; do
+ if [[ ${bin} == ${skip} ]]; then
+ continue 2;
+ fi
+ done
+ manpage=${S}/${CCTOOLS}/man/${bin}.1
+ if [[ -f "${manpage}" ]]; then
+ doins "${manpage}"
+ fi
+ done
+ insinto ${DATAPATH}/man/man5
+ doins "${S}"/${CCTOOLS}/man/*.5
+}
+
+src_test() {
+ if ! [ "${EPREFIX}"/usr/bin/clang ] ; then
+ einfo "Test suite only works properly with clang - please install"
+ return
+ fi
+
+ einfo "Running unit tests"
+ cd "${S}"/${LD64}/unit-tests/test-cases
+ # provide the new ld as a symlink to clang so that -ccc-install-dir
+ # will pick it up
+ ln -sfn ../../src/ld64 ld
+ # use our arch command because the System's will report i386 even for an
+ # x86_64 prefix
+ perl ../bin/make-recursive.pl \
+ BUILT_PRODUCTS_DIR="${S}"/${LD64}/src \
+ ARCH="$(arch)" \
+ LD="${S}"/${LD64}/src/ld64 \
+ CC="${CC} -ccc-install-dir $PWD" \
+ CXX="${CXX} -ccc-install-dir $PWD" \
+ OTOOL="${S}"/${CCTOOLS}/otool/otool.NEW \
+ | perl ../bin/result-filter.pl
+}
+
+src_install() {
+ install_ld64
+ install_cctools
+
+ cd "${S}"
+ insinto /etc/env.d/binutils
+ cat <<-EOF > env.d
+ TARGET="${CHOST}"
+ VER="${PV}"
+ FAKE_TARGETS="${CHOST}"
+ EOF
+ newins env.d ${CHOST}-${PV}
+}
+
+pkg_postinst() {
+ binutils-config ${CHOST}-${PV}
+}
diff --git a/sys-devel/binutils-apple/binutils-apple-8.2.1.ebuild b/sys-devel/binutils-apple/binutils-apple-8.2.1.ebuild
new file mode 100644
index 000000000000..9cf67823890a
--- /dev/null
+++ b/sys-devel/binutils-apple/binutils-apple-8.2.1.ebuild
@@ -0,0 +1,334 @@
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI="6"
+
+inherit eutils flag-o-matic toolchain-funcs
+
+LD64=ld64-274.2
+CCTOOLS_VERSION=895
+CCTOOLS=cctools-${CCTOOLS_VERSION}
+DYLD=dyld-421.2
+
+DESCRIPTION="Darwin assembler as(1) and static linker ld(1), Xcode Tools ${PV}"
+HOMEPAGE="http://www.opensource.apple.com/darwinsource/"
+SRC_URI="http://www.opensource.apple.com/tarballs/ld64/${LD64}.tar.gz
+ http://www.opensource.apple.com/tarballs/cctools/${CCTOOLS}.tar.gz
+ http://www.opensource.apple.com/tarballs/dyld/${DYLD}.tar.gz
+ https://dev.gentoo.org/~grobian/distfiles/${PN}-patches-4.3-r1.tar.bz2
+ https://dev.gentoo.org/~grobian/distfiles/${PN}-patches-5.1-r2.tar.bz2
+ https://dev.gentoo.org/~grobian/distfiles/${PN}-patches-7.0-r2.tar.bz2
+ https://dev.gentoo.org/~grobian/distfiles/${PN}-patches-7.3-r1.tar.bz2
+ https://dev.gentoo.org/~grobian/distfiles/${PN}-patches-8.2-r0.tar.bz2"
+
+LICENSE="APSL-2"
+KEYWORDS="~x64-macos ~x86-macos"
+IUSE="lto tapi classic test"
+
+# ld64 can now only be compiled using llvm and libc++ since it massively uses
+# C++11 language features. *But additionally* the as driver now defaults to
+# calling clang as the assembler on many platforms. This can be disabled using
+# -Wa,-Q but since it's default we make llvm a static runtime dependency.
+RDEPEND="sys-devel/binutils-config
+ lto? ( app-arch/xar )
+ tapi? ( sys-libs/tapi )
+ sys-devel/llvm
+ sys-libs/libcxx"
+DEPEND="${RDEPEND}
+ test? ( >=dev-lang/perl-5.8.8 )"
+
+SLOT="8"
+
+S=${WORKDIR}
+
+is_cross() { [[ ${CHOST} != ${CTARGET} ]] ; }
+
+src_prepare() {
+ cd "${S}"/${LD64}/src
+ cp "${S}"/ld64-136-compile_stubs.h ld/compile_stubs.h
+ cp "${S}"/ld64-274.1-Makefile Makefile
+
+ epatch "${S}"/ld64-274.1-nolto.patch
+ epatch "${S}"/ld64-236.3-crashreporter.patch
+ epatch "${S}"/ld64-264.3.102-bitcode-case.patch
+ epatch "${S}"/ld64-274.1-unknown-fixup.patch
+ epatch "${S}"/ld64-274.1-notapi.patch
+
+ # workound llvm-3.9.{0,1} issue
+ # https://bugs.gentoo.org/show_bug.cgi?id=603580
+ # https://groups.google.com/forum/#!topic/llvm-dev/JY6nuKE__sU
+ # http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20160829/169553.html
+ sed -i -e '/COMPILE_TIME_ASSERT/d' ld/parsers/libunwind/*.hpp || die
+
+ # provide missing headers from libunwind and dyld
+ mkdir -p include/{mach,mach-o/arm} || die
+ # never present because it's private
+ cp ../../${DYLD}/include/mach-o/dyld_priv.h include/mach-o || die
+ # use copies from cctools because they're otherwise hidden in some SDK
+ cp ../../${CCTOOLS}/include/mach-o/arm/reloc.h include/mach-o/arm || die
+ # provide all required CPU_TYPEs on all platforms
+ cp ../../${CCTOOLS}/include/mach/machine.h include/mach/machine.h
+ # add alias for newer identifiers, because ld64 uses both but cctools
+ # header only defines the older
+ epatch "${S}"/ld64-236.3-missing-cputypes.patch
+
+ local VER_STR="\"@(#)PROGRAM:ld PROJECT:${LD64} (Gentoo ${PN}-${PVR})\\n\""
+ echo "char ldVersionString[] = ${VER_STR};" > version.cpp
+
+ epatch "${S}"/ld64-123.2-debug-backtrace.patch
+
+ cd "${S}"/${CCTOOLS}
+ epatch "${S}"/${PN}-4.5-as.patch
+ epatch "${S}"/${PN}-5.1-as-dir.patch
+ epatch "${S}"/${PN}-5.1-ranlib.patch
+ epatch "${S}"/${PN}-3.1.1-libtool-ranlib.patch
+ epatch "${S}"/${PN}-3.1.1-no-headers.patch
+ epatch "${S}"/${PN}-4.0-no-oss-dir.patch
+ epatch "${S}"/cctools-839-intel-retf.patch
+ epatch "${S}"/${PN}-5.1-extraneous-includes.patch
+ epatch "${S}"/${PN}-5.1-strnlen.patch
+ epatch "${S}"/${PN}-7.3-make-j.patch
+ epatch "${S}"/${PN}-7.0-lto-prefix-2.patch
+ epatch "${S}"/${PN}-7.0-clang-as.patch
+ epatch "${S}"/${PN}-8.1-nolto.patch
+ epatch "${S}"/${PN}-7.3-nollvm.patch
+ epatch "${S}"/${PN}-7.3-no-developertools-dir.patch
+ epatch "${S}"/${PN}-8.1-llvm-tools.patch
+ cp ../${LD64}/src/other/prune_trie.h include/mach-o/ || die
+
+ # do not build profileable libstuff to save compile time
+ sed -i -e "/^all:/s, profile , ," libstuff/Makefile
+
+ # cctools version is provided to make via RC_ProjectSourceVersion which
+ # generates and compiles it as apple_version[] into libstuff. From
+ # there it's picked up by the individual tools. Since
+ # RC_ProjectSourceVersion is also used as library version, we can't
+ # just append our local version info. So we hack the libstuff Makefile
+ # to include our Gentoo version.
+ sed -i -e "/cctools-.*(RC_ProjectSourceVersion).*OFILE_DIR/s,Version),Version) (Gentoo ${PN}-${PVR})," \
+ libstuff/Makefile
+
+ eapply_user
+
+ # clean up test suite
+ cd "${S}"/${LD64}/unit-tests/test-cases
+ local c
+
+ # we don't have llvm
+ ((++c)); rm -rf llvm-integration;
+
+ # we don't have dtrace
+ ((++c)); rm -rf dtrace-static-probes-coalescing;
+ ((++c)); rm -rf dtrace-static-probes;
+
+ # a file is missing
+ ((++c)); rm -rf eh-coalescing-r
+
+ # we don't do universal binaries
+ ((++c)); rm -rf blank-stubs;
+
+ # looks like a problem with apple's result-filter.pl
+ ((++c)); rm -rf implicit-common3;
+ ((++c)); rm -rf order_file-ans;
+
+ # TODO no idea what goes wrong here
+ ((++c)); rm -rf dwarf-debug-notes;
+
+ einfo "Deleted $c tests that were bound to fail"
+
+ cd "${S}"
+ ebegin "cleaning Makefiles from unwanted CFLAGS"
+ find . -name "Makefile" -print0 | xargs -0 sed \
+ -i \
+ -e 's/ -g / /g' \
+ -e 's/^G =.*$/G =/' \
+ -e 's/^OFLAG =.*$/OFLAG =/' \
+ -e 's/install -c -s/install/g'
+ eend $?
+}
+
+src_configure() {
+ ENABLE_LTO=0
+ use lto && ENABLE_LTO=1
+
+ export CTARGET=${CTARGET:-${CHOST}}
+ if [[ ${CTARGET} == ${CHOST} ]] ; then
+ if [[ ${CATEGORY} == cross-* ]] ; then
+ export CTARGET=${CATEGORY#cross-}
+ fi
+ fi
+
+ LIBPATH=/usr/$(get_libdir)/binutils/${CTARGET}/${PV}
+ INCPATH=${LIBPATH}/include
+ DATAPATH=/usr/share/binutils-data/${CTARGET}/${PV}
+ if is_cross ; then
+ BINPATH=/usr/${CHOST}/${CTARGET}/binutils-bin/${PV}
+ else
+ BINPATH=/usr/${CTARGET}/binutils-bin/${PV}
+ fi
+
+ # CPPFLAGS only affects ld64, cctools don't use 'em (which currently is
+ # what we want)
+ append-cppflags -DNDEBUG
+
+ # Create configure.h for ld64 with SUPPORT_ARCH_<arch> defines in it.
+ DERIVED_FILE_DIR=${LD64}/src \
+ ${LD64}/src/create_configure
+}
+
+compile_ld64() {
+ einfo "building ${LD64}"
+ cd "${S}"/${LD64}/src
+ emake \
+ LTO=${ENABLE_LTO} \
+ TAPI=$(use tapi && echo 1 || echo 0) \
+ || die "emake failed for ld64"
+ use test && emake build_test
+}
+
+compile_cctools() {
+ einfo "building ${CCTOOLS}"
+ cd "${S}"/${CCTOOLS}
+ # Suppress running dsymutil because it will warn about missing debug
+ # info which is expected when compiling without -g as we normally do.
+ # This might need some more thought if anyone ever wanted to build us
+ # for debugging with Apple's tools.
+ emake \
+ LIB_PRUNETRIE="-L../../${LD64}/src -lprunetrie" \
+ EFITOOLS= \
+ LTO="${ENABLE_LTO}" \
+ LTO_LIBDIR=../../../lib \
+ COMMON_SUBDIRS='libstuff ar misc otool' \
+ SUBDIRS_32= \
+ LEGACY= \
+ RC_ProjectSourceVersion=${CCTOOLS_VERSION} \
+ RC_CFLAGS="${CFLAGS}" \
+ OFLAG="${CCTOOLS_OFLAG}" \
+ DSYMUTIL=": disabled: dsymutil" \
+ || die "emake failed for the cctools"
+ cd "${S}"/${CCTOOLS}/as
+ emake \
+ BUILD_OBSOLETE_ARCH= \
+ RC_ProjectSourceVersion=${CCTOOLS_VERSION} \
+ RC_CFLAGS="-DASLIBEXECDIR=\"\\\"${EPREFIX}${LIBPATH}/\\\"\" -DCLANGDIR=\"\\\"${EPREFIX}/usr/bin/\\\"\" ${CFLAGS}" \
+ OFLAG="${CCTOOLS_OFLAG}" \
+ DSYMUTIL=": disabled: dsymutil" \
+ || die "emake failed for as"
+}
+
+src_compile() {
+ compile_ld64
+ compile_cctools
+}
+
+install_ld64() {
+ exeinto ${BINPATH}
+ doexe "${S}"/${LD64}/src/{ld64,rebase,dyldinfo,unwinddump,ObjectDump}
+ dosym ld64 ${BINPATH}/ld
+ insinto ${DATAPATH}/man/man1
+ doins "${S}"/${LD64}/doc/man/man1/{ld,ld64,rebase}.1
+}
+
+install_cctools() {
+ cd "${S}"/${CCTOOLS}
+ emake install_all_but_headers \
+ EFITOOLS= \
+ COMMON_SUBDIRS='ar misc otool' \
+ SUBDIRS_32= \
+ DSTROOT=\"${D}\" \
+ BINDIR=\"${EPREFIX}\"${BINPATH} \
+ LOCBINDIR=\"${EPREFIX}\"${BINPATH} \
+ USRBINDIR=\"${EPREFIX}\"${BINPATH} \
+ LOCLIBDIR=\"${EPREFIX}\"${LIBPATH} \
+ MANDIR=\"${EPREFIX}\"${DATAPATH}/man/
+ cd "${S}"/${CCTOOLS}/as
+ emake install \
+ BUILD_OBSOLETE_ARCH= \
+ DSTROOT=\"${D}\" \
+ USRBINDIR=\"${EPREFIX}\"${BINPATH} \
+ LIBDIR=\"${EPREFIX}\"${LIBPATH} \
+ LOCLIBDIR=\"${EPREFIX}\"${LIBPATH}
+
+ # upstream is starting to replace classic binutils with llvm-integrated
+ # ones. nm and size are now symlinks to llvm-{nm,size} while the classic
+ # version is preserved as {nm,size}-classic.
+ # Since our binutils do not live in the same directory as the llvm
+ # installation, we have to rewrite the symlinks to the llvm tools.
+ # This also means, that these tools still appear to be versioned via
+ # binutils-config but actually always run the currently installed llvm
+ # tool.
+ budir=${D}/${EPREFIX}/${BINPATH}
+ for tool in nm size ; do
+ # ${EPREFIX}/usr/x86_64-apple-darwin15/binutils-bin/7.3/$tool
+ # -> ${EPREFIX}/bin/llvm-$tool
+ use classic && \
+ ln -sfn ${tool}-classic "${budir}/${tool}" || \
+ ln -sfn ../../../bin/llvm-${tool} "${budir}/${tool}"
+ done
+
+ # Also, otool is now based on llvm-objdump. But a small wrapper installed
+ # as llvm-otool remains, providing command line compatibility.
+ use classic && \
+ ln -sfn otool-classic "${budir}/otool" || \
+ ln -sfn llvm-otool "${budir}/otool"
+
+ cd "${ED}"${BINPATH}
+ insinto ${DATAPATH}/man/man1
+ local skips manpage
+ # ar brings an up-to-date manpage with it
+ skips=( ar )
+ for bin in *; do
+ for skip in ${skips[@]}; do
+ if [[ ${bin} == ${skip} ]]; then
+ continue 2;
+ fi
+ done
+ manpage=${S}/${CCTOOLS}/man/${bin}.1
+ if [[ -f "${manpage}" ]]; then
+ doins "${manpage}"
+ fi
+ done
+ insinto ${DATAPATH}/man/man5
+ doins "${S}"/${CCTOOLS}/man/*.5
+}
+
+src_test() {
+ if ! [ "${EPREFIX}"/usr/bin/clang ] ; then
+ einfo "Test suite only works properly with clang - please install"
+ return
+ fi
+
+ einfo "Running unit tests"
+ cd "${S}"/${LD64}/unit-tests/test-cases
+ # provide the new ld as a symlink to clang so that -ccc-install-dir
+ # will pick it up
+ ln -sfn ../../src/ld64 ld
+ # use our arch command because the System's will report i386 even for an
+ # x86_64 prefix
+ perl ../bin/make-recursive.pl \
+ BUILT_PRODUCTS_DIR="${S}"/${LD64}/src \
+ ARCH="$(arch)" \
+ LD="${S}"/${LD64}/src/ld64 \
+ CC="${CC} -ccc-install-dir $PWD" \
+ CXX="${CXX} -ccc-install-dir $PWD" \
+ OTOOL="${S}"/${CCTOOLS}/otool/otool.NEW \
+ | perl ../bin/result-filter.pl
+}
+
+src_install() {
+ install_ld64
+ install_cctools
+
+ cd "${S}"
+ insinto /etc/env.d/binutils
+ cat <<-EOF > env.d
+ TARGET="${CHOST}"
+ VER="${PV}"
+ FAKE_TARGETS="${CHOST}"
+ EOF
+ newins env.d ${CHOST}-${PV}
+}
+
+pkg_postinst() {
+ binutils-config ${CHOST}-${PV}
+}
diff --git a/sys-devel/binutils-apple/metadata.xml b/sys-devel/binutils-apple/metadata.xml
new file mode 100644
index 000000000000..b6fa3676524c
--- /dev/null
+++ b/sys-devel/binutils-apple/metadata.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+ <maintainer type="project">
+ <email>prefix@gentoo.org</email>
+ <name>Gentoo Prefix</name>
+ </maintainer>
+ <use>
+ <flag name="lto">Add support for Link-Time Optimization with LLVM</flag>
+ <flag name="libcxx">Add support for libcxx</flag>
+ <flag name="multitarget">Compile for non-standard target
+ architectures (ppc and ppc64) -- experimental, Gentoo
+ only</flag>
+ <flag name="classic">Use nm, otool, etc. from this ebuild
+ instead of llvm-based tools</flag>
+ <flag name="tapi">Build against <pkg>sys-libs/tapi</pkg></flag>
+ </use>
+</pkgmetadata>