summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabian Groffen <grobian@gentoo.org>2016-07-10 19:30:30 +0200
committerFabian Groffen <grobian@gentoo.org>2016-07-10 19:30:30 +0200
commit5e648a50f95c170bd0dc3983e93adf96e1c8e037 (patch)
tree12759697722fd12207f6ea17bf16c6aa2277de3d /sys-devel
parentdev-python/PyQt4: introduce USE=compat to install deprecated pyqtconfig (diff)
downloadgentoo-5e648a50f95c170bd0dc3983e93adf96e1c8e037.tar.gz
gentoo-5e648a50f95c170bd0dc3983e93adf96e1c8e037.tar.bz2
gentoo-5e648a50f95c170bd0dc3983e93adf96e1c8e037.zip
sys-devel/binutils-apple: fix LTO for 7.x series, thanks Michael Weiser, bug #587622
Package-Manager: portage-2.2.28
Diffstat (limited to 'sys-devel')
-rw-r--r--sys-devel/binutils-apple/Manifest6
-rw-r--r--sys-devel/binutils-apple/binutils-apple-7.0-r1.ebuild373
-rw-r--r--sys-devel/binutils-apple/binutils-apple-7.1-r1.ebuild374
-rw-r--r--sys-devel/binutils-apple/binutils-apple-7.2-r1.ebuild374
-rw-r--r--sys-devel/binutils-apple/binutils-apple-7.3.1.ebuild390
-rw-r--r--sys-devel/binutils-apple/binutils-apple-7.3.ebuild390
6 files changed, 1907 insertions, 0 deletions
diff --git a/sys-devel/binutils-apple/Manifest b/sys-devel/binutils-apple/Manifest
index 711ba52319b..6b5b191d0c1 100644
--- a/sys-devel/binutils-apple/Manifest
+++ b/sys-devel/binutils-apple/Manifest
@@ -5,6 +5,9 @@ DIST binutils-apple-patches-5.1-r2.tar.bz2 51642 SHA256 fa179acf848b3cb4f888d8f8
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 cctools-698.1.tar.gz 2318018 SHA256 383f1c0c78a2b3efdfdf7ce01adb7e2f8ee9985164dba6ab1c0fae800a211cec SHA512 05e64df9bead958e6035b3cf449a2cb21b19cef10278348ebea8b47816b05a77ebd7f72fd90270400784a231b5d55c8f909653e8177cbe1332d7f7d618453f12 WHIRLPOOL 6ae1244ca97b13378e864609aa62efc4bf028b3e55bfb00cdbf9d20ed6cedd917c64ce337b2635dcabce334b8f994e2558fbda36055b951bf769a21950673e12
DIST cctools-750.tar.gz 1947953 SHA256 188855640da114e37e4ddd4824ff6cdc1ea89dfb6c90a23905c9ca315342f356 SHA512 e2e152a9fb7db47c60fe450e1fc92c6866ab89682c7fdc594b97e419ce93ea1353654bd4419bf3df99d119f554aa0f32993dc645dd7c4680840cd01b7dce2f67 WHIRLPOOL 98e48fca183ee47d138426c65401138954a86abc3b80bfc4c5d105b97b8eb583ae350657f1a7dc1154259d0bcdfe1d60dc0a63409826e9a24b178674a5afdf21
DIST cctools-795.tar.gz 1993795 SHA256 7fab7044b648e92a9fefd493a1bb6daa4246f24c5838d8b5c913a446e6bbd2ef SHA512 5a34a73dc71d3574a357f6b0f26a48a99dd0995d62695b309cdfe85c4960934b410455b1ba6bdbc9a4e32106bb45b35555604975d2a80ad1be21f5d4eac69254 WHIRLPOOL 2bd074ac8ef8542c2c3df5fae91a0bece2e1c31d6c6c771c55e7c7a3d90929f9a7cd420760dcb5ecffb9dd279abed4ba5ebf840c9e9bb983a806707d735cd735
@@ -16,6 +19,7 @@ DIST cctools-870.tar.gz 1702965 SHA256 b83f4b4696414b814cc1781ec4b68ff9c7bb97920
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 dyld-195.5.tar.gz 411615 SHA256 2cf0484c87cf79b606b351a7055a247dae84093ae92c747a74e0cde2c8c8f83c SHA512 f316d32f3e417cf0898a8e231df66572d3424765831375863799d3ff30f8e28342ca692426d0ece7a8d069b341a3b9ca79c625edc322d90e3f26f528ea555324 WHIRLPOOL e0e231653ad37ad8fdb7d5fbd372fe1dc34b80e41f7dafa8bb46f4c8fa4f5acb4574f4cd346304dfaca1f074667f381931ca5ff7a7efddaea770fb35d30539dc
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
@@ -30,6 +34,8 @@ DIST ld64-242.tar.gz 641597 SHA256 bec1a5e20b599d108be0017736833c1f6212ea26c67f2
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-85.2.1.tar.gz 598524 SHA256 4bcbcbdfd62efdc46c51700b8f5dae2cbd1638e9e50f649d5c7f242d32fca804 SHA512 b5ffaffc43e74f22688fecd9fb3023a59160cf051f9412f34e6b0acf1c4f9d43ba641e199d8d6b1c6cf3bbbbf117645988fd879ded1fec8be056b6941fe79999 WHIRLPOOL 7c50f462eb41808b57ea06b82bdf576460bddb4150abe7a678af541aa0b179105d994a2b6fd10152481aa28acc903265160945b4aae9dcfce0a1a1cfe4b9460a
DIST ld64-97.17.tar.gz 421947 SHA256 02bd46af0809eaa415d096d7d41c3e8e7d80f7d8d181840866fb87f036b4e089 SHA512 841774a1a7c0e2f661ac7e66703f7578d8f11274897ffa15f8c49daf290a23465763f264a4dae99f15754891f44c425c0d327652112007b499bc8f755a7fc9d6 WHIRLPOOL 7225b44d845b13c6b6d1a685170f2b6e15b81c48320fa3b570771938ed457a59452e80873996a4b2712a8f6813486063afd73acf979a97d823afb3d510d74678
DIST libunwind-30.tar.gz 82811 SHA256 6ac97d18cc2b05e6de1269bf5af03b81948bd2200dae827527f3dc618b82bd41 SHA512 57106eafa1516791b4e0db2de6c6336bc0c1cbd8bf098a6d3a809fafa457802c95a7aeae9137f4ca5922a3018dfd8f597907ea4187b0afbbf267500eae00041f WHIRLPOOL c3caf5ba593cffa2f0a9cdb256f518524e9500eaf0a013c4973dc9881b16efa0c388e70407bbed1fd331f100af2da01ddeee12d33b3afc1213d69c32ab5e1d0b
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 00000000000..06066434979
--- /dev/null
+++ b/sys-devel/binutils-apple/binutils-apple-7.0-r1.ebuild
@@ -0,0 +1,373 @@
+# Copyright 1999-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+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
+ http://dev.gentoo.org/~grobian/distfiles/${PN}-patches-4.3-r1.tar.bz2
+ http://dev.gentoo.org/~grobian/distfiles/${PN}-patches-5.1-r2.tar.bz2
+ http://dev.gentoo.org/~grobian/distfiles/${PN}-patches-6.1-r1.tar.bz2
+ http://dev.gentoo.org/~grobian/distfiles/${PN}-patches-6.3-r1.tar.bz2
+ http://dev.gentoo.org/~grobian/distfiles/${PN}-patches-7.0-r2.tar.bz2"
+
+LICENSE="APSL-2"
+KEYWORDS="~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 )"
+
+export CTARGET=${CTARGET:-${CHOST}}
+if [[ ${CTARGET} == ${CHOST} ]] ; then
+ if [[ ${CATEGORY} == cross-* ]] ; then
+ export CTARGET=${CATEGORY#cross-}
+ fi
+fi
+is_cross() { [[ ${CHOST} != ${CTARGET} ]] ; }
+
+if is_cross ; then
+ SLOT="${CTARGET}-7"
+else
+ SLOT="7"
+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
+
+S=${WORKDIR}
+
+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
+
+ # 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-r1.ebuild b/sys-devel/binutils-apple/binutils-apple-7.1-r1.ebuild
new file mode 100644
index 00000000000..f588ce7ae38
--- /dev/null
+++ b/sys-devel/binutils-apple/binutils-apple-7.1-r1.ebuild
@@ -0,0 +1,374 @@
+# Copyright 1999-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+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
+ http://dev.gentoo.org/~grobian/distfiles/${PN}-patches-4.3-r1.tar.bz2
+ http://dev.gentoo.org/~grobian/distfiles/${PN}-patches-5.1-r2.tar.bz2
+ http://dev.gentoo.org/~grobian/distfiles/${PN}-patches-6.1-r1.tar.bz2
+ http://dev.gentoo.org/~grobian/distfiles/${PN}-patches-6.3-r1.tar.bz2
+ http://dev.gentoo.org/~grobian/distfiles/${PN}-patches-7.0-r2.tar.bz2"
+
+
+LICENSE="APSL-2"
+KEYWORDS="~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 )"
+
+export CTARGET=${CTARGET:-${CHOST}}
+if [[ ${CTARGET} == ${CHOST} ]] ; then
+ if [[ ${CATEGORY} == cross-* ]] ; then
+ export CTARGET=${CATEGORY#cross-}
+ fi
+fi
+is_cross() { [[ ${CHOST} != ${CTARGET} ]] ; }
+
+if is_cross ; then
+ SLOT="${CTARGET}-7"
+else
+ SLOT="7"
+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
+
+S=${WORKDIR}
+
+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
+
+ # 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-r1.ebuild b/sys-devel/binutils-apple/binutils-apple-7.2-r1.ebuild
new file mode 100644
index 00000000000..e251faf5bbc
--- /dev/null
+++ b/sys-devel/binutils-apple/binutils-apple-7.2-r1.ebuild
@@ -0,0 +1,374 @@
+# Copyright 1999-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+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
+ http://dev.gentoo.org/~grobian/distfiles/${PN}-patches-4.3-r1.tar.bz2
+ http://dev.gentoo.org/~grobian/distfiles/${PN}-patches-5.1-r2.tar.bz2
+ http://dev.gentoo.org/~grobian/distfiles/${PN}-patches-6.1-r1.tar.bz2
+ http://dev.gentoo.org/~grobian/distfiles/${PN}-patches-6.3-r1.tar.bz2
+ http://dev.gentoo.org/~grobian/distfiles/${PN}-patches-7.0-r2.tar.bz2
+ http://dev.gentoo.org/~grobian/distfiles/${PN}-patches-7.2-r0.tar.bz2"
+
+LICENSE="APSL-2"
+KEYWORDS="~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 )"
+
+export CTARGET=${CTARGET:-${CHOST}}
+if [[ ${CTARGET} == ${CHOST} ]] ; then
+ if [[ ${CATEGORY} == cross-* ]] ; then
+ export CTARGET=${CATEGORY#cross-}
+ fi
+fi
+is_cross() { [[ ${CHOST} != ${CTARGET} ]] ; }
+
+if is_cross ; then
+ SLOT="${CTARGET}-7"
+else
+ SLOT="7"
+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
+
+S=${WORKDIR}
+
+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
+
+ # 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.3.1.ebuild b/sys-devel/binutils-apple/binutils-apple-7.3.1.ebuild
new file mode 100644
index 00000000000..68ecb9f08e1
--- /dev/null
+++ b/sys-devel/binutils-apple/binutils-apple-7.3.1.ebuild
@@ -0,0 +1,390 @@
+# Copyright 1999-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+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
+ http://dev.gentoo.org/~grobian/distfiles/${PN}-patches-4.3-r1.tar.bz2
+ http://dev.gentoo.org/~grobian/distfiles/${PN}-patches-5.1-r2.tar.bz2
+ http://dev.gentoo.org/~grobian/distfiles/${PN}-patches-6.1-r1.tar.bz2
+ http://dev.gentoo.org/~grobian/distfiles/${PN}-patches-6.3-r1.tar.bz2
+ http://dev.gentoo.org/~grobian/distfiles/${PN}-patches-7.0-r2.tar.bz2
+ http://dev.gentoo.org/~grobian/distfiles/${PN}-patches-7.2-r0.tar.bz2
+ http://dev.gentoo.org/~grobian/distfiles/${PN}-patches-7.3-r0.tar.bz2"
+
+LICENSE="APSL-2"
+KEYWORDS="~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 )"
+
+export CTARGET=${CTARGET:-${CHOST}}
+if [[ ${CTARGET} == ${CHOST} ]] ; then
+ if [[ ${CATEGORY} == cross-* ]] ; then
+ export CTARGET=${CATEGORY#cross-}
+ fi
+fi
+is_cross() { [[ ${CHOST} != ${CTARGET} ]] ; }
+
+if is_cross ; then
+ SLOT="${CTARGET}-7"
+else
+ SLOT="7"
+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
+
+S=${WORKDIR}
+
+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
+
+ # 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 00000000000..89e17b051e4
--- /dev/null
+++ b/sys-devel/binutils-apple/binutils-apple-7.3.ebuild
@@ -0,0 +1,390 @@
+# Copyright 1999-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+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
+ http://dev.gentoo.org/~grobian/distfiles/${PN}-patches-4.3-r1.tar.bz2
+ http://dev.gentoo.org/~grobian/distfiles/${PN}-patches-5.1-r2.tar.bz2
+ http://dev.gentoo.org/~grobian/distfiles/${PN}-patches-6.1-r1.tar.bz2
+ http://dev.gentoo.org/~grobian/distfiles/${PN}-patches-6.3-r1.tar.bz2
+ http://dev.gentoo.org/~grobian/distfiles/${PN}-patches-7.0-r2.tar.bz2
+ http://dev.gentoo.org/~grobian/distfiles/${PN}-patches-7.2-r0.tar.bz2
+ http://dev.gentoo.org/~grobian/distfiles/${PN}-patches-7.3-r0.tar.bz2"
+
+LICENSE="APSL-2"
+KEYWORDS="~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 )"
+
+export CTARGET=${CTARGET:-${CHOST}}
+if [[ ${CTARGET} == ${CHOST} ]] ; then
+ if [[ ${CATEGORY} == cross-* ]] ; then
+ export CTARGET=${CATEGORY#cross-}
+ fi
+fi
+is_cross() { [[ ${CHOST} != ${CTARGET} ]] ; }
+
+if is_cross ; then
+ SLOT="${CTARGET}-7"
+else
+ SLOT="7"
+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
+
+S=${WORKDIR}
+
+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
+
+ # 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}
+}