summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys-devel/binutils-apple/ChangeLog4
-rw-r--r--sys-devel/binutils-apple/Manifest16
-rw-r--r--sys-devel/binutils-apple/binutils-apple-4.1.ebuild4
-rw-r--r--sys-devel/binutils-apple/binutils-apple-4.2.ebuild290
-rw-r--r--sys-devel/binutils-apple/files/binutils-apple-4.2-as-dir.patch45
-rw-r--r--sys-devel/binutils-apple/files/binutils-apple-4.2-lto.patch34
-rw-r--r--sys-devel/binutils-apple/files/ld64-127.2-lto.patch214
7 files changed, 598 insertions, 9 deletions
diff --git a/sys-devel/binutils-apple/ChangeLog b/sys-devel/binutils-apple/ChangeLog
index 18a97d315046..5cd5c876b93f 100644
--- a/sys-devel/binutils-apple/ChangeLog
+++ b/sys-devel/binutils-apple/ChangeLog
@@ -1,6 +1,6 @@
# ChangeLog for sys-devel/binutils-apple
-# Copyright 1999-2011 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/sys-devel/binutils-apple/ChangeLog,v 1.23 2011/10/19 06:45:18 grobian Exp $
+# Copyright 1999-2010 Gentoo Foundation; Distributed under the GPL v2
+# $Header: /var/cvsroot/gentoo-x86/sys-devel/binutils-apple/ChangeLog,v 1.24 2011/11/05 16:30:56 grobian Exp $
19 Oct 2011; Fabian Groffen <grobian@gentoo.org> files/ld64-123.2-Makefile:
Fix compilation of ld64, add back wrongly dropped LD64LIBS, thanks Charles
diff --git a/sys-devel/binutils-apple/Manifest b/sys-devel/binutils-apple/Manifest
index 07368742abbf..ffde689e2dce 100644
--- a/sys-devel/binutils-apple/Manifest
+++ b/sys-devel/binutils-apple/Manifest
@@ -20,10 +20,13 @@ AUX binutils-apple-3.2.3-ranlib.patch 2866 RMD160 3e9c64eea5676b872cbf60268ecb47
AUX binutils-apple-4.0-as-dir.patch 1458 RMD160 b409d3cc62cdeb5a66af2c0939423066c288c07d SHA1 abcfbee6b4470786aa4e3aa30b951c3277a52c4b SHA256 b33439299340b311ef606e11427a7ded25b75e1d35791bb50d7815f4f87b6abc
AUX binutils-apple-4.0-as.patch 2738 RMD160 f7601fc41f373f8e7ef122d059dd04ca42d400af SHA1 fb5f02cf3ead339c0e1723f89e996615f3c15d2f SHA256 b068f2a8bff9fb8f7dd92eb64c9587c9517ef51e682211f81b57e69b7e25fdef
AUX binutils-apple-4.0-no-oss-dir.patch 604 RMD160 844f112ff9dfcd4618a8b1e8a65318397ea16c2c SHA1 beadc9fead70c8befe66eef7d024913d00b79e3f SHA256 fda851a89d86ecc4c90850b4d744daae478e2e55f83522d51a50c2a28f09223f
+AUX binutils-apple-4.2-as-dir.patch 1089 RMD160 9c2c6cff6f117c71b309d7466aff98ea5c85c7d2 SHA1 f4e1ef7fdc4a65d46d2f2c6011fb85ef51a6a74f SHA256 d964d09b75265af6cc84bb9aa8e772c0d1655fc8d7e5ddef7155a4ef019be26a
+AUX binutils-apple-4.2-lto.patch 859 RMD160 a671d53a1e563dc52365bb12759145a6a0ab3b27 SHA1 a51d5f2e57239d66ae13b4e069dad76dac0233ed SHA256 c9f3e1b28740454c35034dc0ebd135fc7410f4799f0e077dafb0456c9c3acc4c
AUX ld64-123.2-Makefile 1484 RMD160 6ec79f460e355e75308890d0925aae1711b57793 SHA1 a6ec0641df66c5f48e87fd5dbbd9419527e64c1b SHA256 7499f48f3a1c72e3f0483c3c8bc03dcd6082440bee2bc0017ae63740d37a5147
AUX ld64-123.2-darwin8-no-mlong-branch-warning.patch 790 RMD160 00f8bdb53843777e615d9d7947378d914c7cf077 SHA1 26d3f38a847b4a1d21397d5599ece60d25d30f83 SHA256 d3d5750998000a5fe296efff3298c0096ebbd9118c637a67b070f93acadea4ef
AUX ld64-123.2-debug-backtrace.patch 338 RMD160 1b9b8739da7dc70544f413e30c7fc88103af4ecc SHA1 ebfa3b86fe2a9931f5a814c00f697bf6936f76b5 SHA256 26b16aa555bb15dcb6d799785aed0d240e50cbe0a77968a2a4fe92623bd105ab
AUX ld64-123.2.1-lto.patch 6387 RMD160 e4ae378f7328875898f03d8b5db59e6f15c2a9ce SHA1 70189a53ddc53c96cdc2f9090f67ad1cb1e9c20e SHA256 5a8c0d0673a48db3cbb08c8234763bdb2149294cebc7707bf394461a73d9ae65
+AUX ld64-127.2-lto.patch 5719 RMD160 2117c40625eb11eda2f3065731602c66dee6a935 SHA1 71d0e8fa68894e9c73255c026d5b2d5e6551761e SHA256 20c4b5ffeaa052337220f6276548fbdf16071860c5cdc67b8697a1f41f130155
AUX ld64-95.2.12-Makefile 728 RMD160 56104bcb07a3845b11cf9034f1051c0ceebf681d SHA1 7549a604ea69ad1ad93b92511a70634033cdbab8 SHA256 3e1181c3dc7aaa8cb5d02cc00fc0f760d052bb2714883833a5aaa2fa3105f88d
AUX ld64-95.2.12-darwin8-no-mlong-branch-warning.patch 620 RMD160 cf17f65dda73393a921896b8844493b237dc3307 SHA1 b834e98d61a9ecd70aa99b89b5575a8e32b5b2f7 SHA256 ca0455c78e77f84e7d15e6edf19085b0729a12baf29a89455af84e947f201b1d
AUX libunwind-30-Makefile 580 RMD160 2f4d35afd951e6f4543c16ac23eb9a669abfb906 SHA1 11e1d46fb95f87819b0877ceff0ee743fbc8eb82 SHA256 eb080881fc223a326fd08ac65da05c4d939a553a95ca978794caeeafa7780a0e
@@ -38,8 +41,10 @@ DIST cctools-773.tar.gz 1962238 RMD160 3ea1b348c878efebc1d1ba9d50a89840c272aafd
DIST cctools-782.tar.gz 1981521 RMD160 5b50b75ff7825a97fa4f095d135a6372ce787c10 SHA1 1ed1e38564fc00dc2825382ca5c856403b5eeba3 SHA256 fdf0f60adfab24dd87af9e91c364743e006a241d297ee3cbba7b628fda6d7a9c
DIST cctools-795.tar.gz 1993795 RMD160 0932fa5a96b81e50528211abfec01a9b66790485 SHA1 e4b67b6dac2173a519a57c92ef7be5bf3013417f SHA256 7fab7044b648e92a9fefd493a1bb6daa4246f24c5838d8b5c913a446e6bbd2ef
DIST cctools-806.tar.gz 2004935 RMD160 91c0a3f192f1eed60b64ef5a0a06918d0ce0b0c9 SHA1 e4f9a7ee0eef930e81d50b6b7300b8ddc1c7b341 SHA256 6116c06920112c634f6df2fa8b2f171ee3b90ff2176137da5856336695a6a676
+DIST cctools-809.tar.gz 2014410 RMD160 f433124035ac0ef403bdc6edec087bdedd0b4375 SHA1 b7bff424c86420866543379effb5b70d4404b95b SHA256 03ba62749b843b131c7304a044a98c6ffacd65b1399b921d69add0375f79d8ad
DIST dyld-195.5.tar.gz 411615 RMD160 7f36612730f7fde53359314b899efe493378a086 SHA1 97b68163281a3ec82ab2e2a777bea08511c95976 SHA256 2cf0484c87cf79b606b351a7055a247dae84093ae92c747a74e0cde2c8c8f83c
DIST ld64-123.2.1.tar.gz 452872 RMD160 8ebca37c8e6b5fa02c43afe419bef12ca8330898 SHA1 0664f9dc2f7e3532444ccaeee118728b2be7fbbf SHA256 8d9d92288375f81ca2c91b74ed1d4206a5bbcbd463ccec1e85decdcdc2f0ca1a
+DIST ld64-127.2.tar.gz 496975 RMD160 8ee709341549a1944732daef6ebab7ef1acfcc6e SHA1 df51258a75e4c5f0df185b99f74f7232d310f45e SHA256 97b75547b2bd761306ab3e15ae297f01e7ab9760b922bc657f4ef72e4e052142
DIST ld64-85.2.1.tar.gz 598524 RMD160 42c80bd4ad6e9f96a757245e6a2b95084c009ff1 SHA1 31a7debf4c407c32b8bd1a51a4b4a7ae68dc8b85 SHA256 4bcbcbdfd62efdc46c51700b8f5dae2cbd1638e9e50f649d5c7f242d32fca804
DIST ld64-85.2.2.tar.gz 298144 RMD160 f7f897666a072e07f1888beca5b22fdd75fa1b61 SHA1 33c655bd7cbfecd70807dbde428615fb0947f31b SHA256 01ab6f6f1ce91203722c5cd56666ffa81da0eafe8beee1490a383811d56d86aa
DIST ld64-95.2.12.tar.gz 401104 RMD160 35de89aa1d31d100bd952829df4316e640c03cb4 SHA1 eea384a5ed3b5a994cc24e076c74ad20e6f8b68a SHA256 5a5ea02bd81d74f4f773403bebe34950acf4830fb7fee0d466305276f869097c
@@ -56,13 +61,14 @@ EBUILD binutils-apple-3.2.3-r1.ebuild 6521 RMD160 6bd22707129894fc03f8949c79c1b0
EBUILD binutils-apple-3.2.3-r2.ebuild 6669 RMD160 8a32c0be4ec8a6e8c89f5c2155fb172ebc4565e4 SHA1 9c495edc134edf36478897a7950510e7b57f92fe SHA256 17b6d484e33a20939d00a6bf496fe6aefa2920d21c4fbb6bbf359e853f754f7f
EBUILD binutils-apple-3.2.6.ebuild 6670 RMD160 1a7df67ed733c1a22aca1414e7a2b3f1c1597d9c SHA1 6e5b37a6c5c63c87999f5dd67526cfd8936f44e8 SHA256 241af9c47b9165234672ee61466d4ba21af689cec6ab5e7f606d1f60355b30b8
EBUILD binutils-apple-3.2.ebuild 5913 RMD160 47df8d8d2e207eb95e10359f35c2c5fd152f8938 SHA1 26b56881f56b63bc3f9b25aeae6c814f969f5dfd SHA256 41fb357219cdbb20f16200d05016c1866046f9a351994b738d6e0b7176f3488e
-EBUILD binutils-apple-4.1.ebuild 7849 RMD160 a510ae60ea26e5a6a3974840b83ed3c85a1989e4 SHA1 68c39c1353bb093b5e2d0a08f893958286db1819 SHA256 c0c1b32032744a35729375783e50d77ef72c348521f7382f241cee93480eea92
-MISC ChangeLog 8579 RMD160 012d104ef6f4e9d135418b55e3fe2feba3b876c9 SHA1 ce42e9bd3b678fdaa74520921f2ae16bc166fb3b SHA256 2964eada343e7e8674e12965129c62e9c544c68f95b5054a681a539d5af15d1a
+EBUILD binutils-apple-4.1.ebuild 7849 RMD160 e8bb00338ea2b25be30504b4273cea43e292eda4 SHA1 c1cbdefd5a79f14019d1e6e9866e644d9c1d1467 SHA256 baa8febfa59cabb6470e1c2bcd17c217a0580ca74aa04aa83e14465345097e0e
+EBUILD binutils-apple-4.2.ebuild 7891 RMD160 347f343cd1b57191d66a92fd52535576b3ee7ba5 SHA1 74e82dc18dfbab64ef319930cadedefbd81c5fd3 SHA256 cf74cd25439b3ef6c2b69cf9ddd733ef7bf6518ca153ac921c3b78ad04b40091
+MISC ChangeLog 8579 RMD160 42f3acfaf0b01f03c846d74382e08608a4c212d9 SHA1 fad97d57940e5052c721415ae9060f8dad67d40b SHA256 47030db23f0c5b6391afde3cd55387d9d37ee53d0d2ecc2b614dad51df9da65e
MISC metadata.xml 250 RMD160 1d572689c02f6408ad8dfcfc955f8dfb7ec3a201 SHA1 dbd7759df5303c9dd998023753a3361206bad1e2 SHA256 f783a2767bd8eb2edebc0b1b1391fdcb461dcdb7a7c99dc1b82504c466688e79
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.18 (Darwin)
-iEYEARECAAYFAk6ecgQACgkQX3X2B8XHTokNaQCfa3+e3bZgC4TwLOPOQiSv145u
-Pv0AoIEOChxqmI7gOWBYPKPymm7zJhc3
-=DzW2
+iEYEARECAAYFAk61ZMYACgkQX3X2B8XHToncfgCdHBQRPO+IVg/7pnJ81EpO/5ex
+L+0An2uIMWSd3ED+zQYqPQPWg05/hpA9
+=smQg
-----END PGP SIGNATURE-----
diff --git a/sys-devel/binutils-apple/binutils-apple-4.1.ebuild b/sys-devel/binutils-apple/binutils-apple-4.1.ebuild
index e8d5fae2d980..ddb16191060d 100644
--- a/sys-devel/binutils-apple/binutils-apple-4.1.ebuild
+++ b/sys-devel/binutils-apple/binutils-apple-4.1.ebuild
@@ -1,6 +1,6 @@
-# Copyright 1999-2011 Gentoo Foundation
+# Copyright 2010-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/sys-devel/binutils-apple/binutils-apple-4.1.ebuild,v 1.4 2011/09/25 09:32:15 grobian Exp $
+# $Header: /var/cvsroot/gentoo-x86/sys-devel/binutils-apple/binutils-apple-4.1.ebuild,v 1.5 2011/11/05 16:30:56 grobian Exp $
EAPI="3"
diff --git a/sys-devel/binutils-apple/binutils-apple-4.2.ebuild b/sys-devel/binutils-apple/binutils-apple-4.2.ebuild
new file mode 100644
index 000000000000..5cd37f03556a
--- /dev/null
+++ b/sys-devel/binutils-apple/binutils-apple-4.2.ebuild
@@ -0,0 +1,290 @@
+# Copyright 2010-2011 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/sys-devel/binutils-apple/binutils-apple-4.2.ebuild,v 1.1 2011/11/05 16:30:56 grobian Exp $
+
+EAPI="3"
+
+inherit eutils flag-o-matic toolchain-funcs
+
+RESTRICT="test" # the test suite will test what's installed.
+
+LD64=ld64-127.2
+CCTOOLS=cctools-809
+LIBUNWIND=libunwind-30
+DYLD=dyld-195.5
+# http://lists.apple.com/archives/Darwin-dev/2009/Sep/msg00025.html
+UNWIND=binutils-apple-3.2-unwind-patches-5
+
+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/libunwind/${LIBUNWIND}.tar.gz
+ http://www.opensource.apple.com/tarballs/dyld/${DYLD}.tar.gz
+ http://www.gentoo.org/~grobian/distfiles/${UNWIND}.tar.xz
+ http://www.gentoo.org/~grobian/distfiles/libunwind-llvm-115426.tar.bz2"
+
+LICENSE="APSL-2"
+KEYWORDS="~ppc-macos ~x64-macos ~x86-macos"
+IUSE="lto test"
+
+RDEPEND="sys-devel/binutils-config
+ lto? ( sys-devel/llvm )
+ test? ( >=dev-lang/perl-5.8.8 )"
+DEPEND="${RDEPEND}
+ >=sys-devel/gcc-apple-4.2.1"
+
+export CTARGET=${CTARGET:-${CHOST}}
+if [[ ${CTARGET} == ${CHOST} ]] ; then
+ if [[ ${CATEGORY/cross-} != ${CATEGORY} ]] ; then
+ export CTARGET=${CATEGORY/cross-}
+ fi
+fi
+is_cross() { [[ ${CHOST} != ${CTARGET} ]] ; }
+
+if is_cross ; then
+ SLOT="${CTARGET}-4"
+else
+ SLOT="4"
+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() {
+ cd "${S}"/${LIBUNWIND}/src
+ cp "${FILESDIR}"/${LIBUNWIND}-Makefile Makefile
+
+ cd "${S}"/${LD64}/src
+ cp "${FILESDIR}"/ld64-123.2-Makefile Makefile
+ epatch "${FILESDIR}"/${LD64}-lto.patch
+
+ ln -s ../../${CCTOOLS}/include
+ cp other/prune_trie.h include/mach-o/ || die
+ # use our own copy of lto.h, which doesn't require llvm build-env
+ mkdir -p include/llvm-c || die
+ cp "${WORKDIR}"/ld64-unwind/ld64-97.14-llvm-lto.h include/llvm-c/lto.h || die
+ # make libunwind sources known
+ ln -s ../../${LIBUNWIND}/src libunwind || die
+ cp ../../${LIBUNWIND}/include/*.h include/ || die
+ # mimic OS X Lion-style Availability.h macros
+ if [[ ${CHOST#*-darwin} -le 10 ]] ; then
+ {
+ echo "#define __OSX_AVAILABLE_STARTING(x,y) "
+ echo "#define __OSX_AVAILABLE_BUT_DEPRECATED(a,b,c,d) "
+ } > include/Availability.h
+ fi
+
+ echo '' > configure.h
+ echo '' > linker_opts
+ local VER_STR="\"@(#)PROGRAM:ld PROJECT:${LD64} (Gentoo ${PN}-${PVR})\\n\""
+ echo "char ldVersionString[] = ${VER_STR};" > version.cpp
+
+ epatch "${FILESDIR}"/ld64-123.2-debug-backtrace.patch
+ if [[ ${CHOST} == powerpc*-darwin* ]] ; then
+ epatch "${FILESDIR}"/ld64-123.2.1-darwin8-no-mlong-branch-warning.patch
+ sed -i -e '/#include <mach-o\/loader.h>/a\#include <mach/i386/thread_status.h>' \
+ ld/HeaderAndLoadCommands.hpp || die
+ fi
+ if use !lto ; then
+ sed -i -e '/#define LTO_SUPPORT 1/d' other/ObjectDump.cpp || die
+ fi
+
+ cd "${S}"/${CCTOOLS}
+ epatch "${FILESDIR}"/${PN}-4.0-as.patch
+ epatch "${FILESDIR}"/${PN}-4.2-as-dir.patch
+ epatch "${FILESDIR}"/${PN}-3.2.3-ranlib.patch
+ epatch "${FILESDIR}"/${PN}-3.1.1-libtool-ranlib.patch
+ epatch "${FILESDIR}"/${PN}-3.1.1-nmedit.patch
+ epatch "${FILESDIR}"/${PN}-3.1.1-no-headers.patch
+ epatch "${FILESDIR}"/${PN}-4.0-no-oss-dir.patch
+ epatch "${FILESDIR}"/${PN}-4.2-lto.patch
+
+ # clean up test suite
+ cd "${S}"/${LD64}
+# epatch "${FILESDIR}"/${PN}-3.1.1-testsuite.patch
+
+ 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/^OFLAG =.*$/OFLAG =/' \
+ -e 's/install -c -s/install/g'
+ eend $?
+
+ # -pg is used and the two are incompatible
+ filter-flags -fomit-frame-pointer
+}
+
+src_configure() {
+ tc-export CC CXX AR
+ if use lto ; then
+ append-flags -DLTO_SUPPORT
+ append-ldflags -L"${EPREFIX}"/usr/$(get_libdir)/llvm
+ append-libs LTO
+ LTO=1
+ else
+ append-flags -ULTO_SUPPORT
+ LTO=0
+ fi
+ append-flags -DNDEBUG
+ append-flags -I${WORKDIR}/libunwind/include
+}
+
+compile_libunwind() {
+ # not used, just for testing, and possible use in the future
+ einfo "building ${LIBUNWIND}"
+ cd "${S}"/${LIBUNWIND}/src
+ emake DYLDINCS=-I../../${DYLD}/include || die
+}
+
+compile_ld64() {
+ einfo "building ${LD64}"
+ cd "${S}"/${LD64}/src
+ # remove antiquated copy that's available on any OSX system and
+ # breaks ld64 compilation
+ mv include/mach-o/dyld.h{,.disable}
+ emake \
+ LTO=${LTO} \
+ CFLAGS="${CFLAGS}" \
+ CXXFLAGS="${CXXFLAGS} -I../../${DYLD}/include" \
+ LDFLAGS="${LDFLAGS} ${LIBS}" \
+ || die "emake failed for ld64"
+ use test && emake build_test
+ # restore, it's necessary for cctools' install
+ mv include/mach-o/dyld.h{.disable,}
+}
+
+compile_cctools() {
+ einfo "building ${CCTOOLS}"
+ cd "${S}"/${CCTOOLS}
+ emake \
+ LIB_PRUNETRIE="-L../../${LD64}/src -lprunetrie" \
+ EFITOOLS= LTO= \
+ COMMON_SUBDIRS='libstuff ar misc otool' \
+ SUBDIRS_32= \
+ RC_CFLAGS="${CFLAGS}" OFLAG="${CFLAGS}" \
+ || die "emake failed for the cctools"
+ cd "${S}"/${CCTOOLS}/as
+ emake \
+ BUILD_OBSOLETE_ARCH= \
+ RC_CFLAGS="-DASLIBEXECDIR=\"\\\"${EPREFIX}${LIBPATH}/\\\"\" ${CFLAGS}" \
+ || 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= LTO= \
+ COMMON_SUBDIRS='ar misc otool' \
+ SUBDIRS_32= \
+ RC_CFLAGS="${CFLAGS}" OFLAG="${CFLAGS}" \
+ 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() {
+ einfo "Running unit tests"
+ cd "${S}"/${LD64}/unit-tests/test-cases
+ # need host arch, since GNU arch doesn't do what Apple's does
+ tc-export CC CXX
+ perl ../bin/make-recursive.pl \
+ ARCH="$(/usr/bin/arch)" \
+ RELEASEDIR="${S}"/${LD64}/src \
+ | 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/files/binutils-apple-4.2-as-dir.patch b/sys-devel/binutils-apple/files/binutils-apple-4.2-as-dir.patch
new file mode 100644
index 000000000000..b3047f6215fd
--- /dev/null
+++ b/sys-devel/binutils-apple/files/binutils-apple-4.2-as-dir.patch
@@ -0,0 +1,45 @@
+--- as/driver.c
++++ as/driver.c
+@@ -230,7 +230,11 @@
+ /*
+ * If this assembler exist try to run it else print an error message.
+ */
++#ifndef ASLIBEXECDIR
+ as = makestr(prefix, LIB, arch_name, AS, NULL);
++#else
++ as = makestr(ASLIBEXECDIR, arch_name, AS, NULL);
++#endif
+ if(access(as, F_OK) == 0){
+ argv[0] = as;
+ if(execute(argv, verbose))
+@@ -238,6 +242,9 @@
+ else
+ exit(1);
+ }
++#ifdef ASLIBEXECDIR
++ as_local = "";
++#else
+ as_local = makestr(prefix, LOCALLIB, arch_name, AS, NULL);
+ if(access(as_local, F_OK) == 0){
+ argv[0] = as_local;
+@@ -246,10 +253,12 @@
+ else
+ exit(1);
+ }
++#endif
+ printf("%s: assembler (%s or %s) for architecture %s not installed\n",
+ progname, as, as_local, arch_name);
+ arch_flags = get_arch_flags();
+ count = 0;
++#ifndef ASLIBEXECDIR
+ for(i = 0; arch_flags[i].name != NULL; i++){
+ as = makestr(prefix, LIB, arch_flags[i].name, AS, NULL);
+ if(access(as, F_OK) == 0){
+@@ -270,6 +279,7 @@
+ }
+ }
+ }
++#endif
+ if(count == 0)
+ printf("%s: no assemblers installed\n", progname);
+ exit(1);
diff --git a/sys-devel/binutils-apple/files/binutils-apple-4.2-lto.patch b/sys-devel/binutils-apple/files/binutils-apple-4.2-lto.patch
new file mode 100644
index 000000000000..791a922dd425
--- /dev/null
+++ b/sys-devel/binutils-apple/files/binutils-apple-4.2-lto.patch
@@ -0,0 +1,34 @@
+--- misc/lipo.c
++++ misc/lipo.c
+@@ -1191,6 +1191,7 @@
+ thin->fat_arch.align = 0;
+ }
+ else{
++#ifdef LTO_SUPPORT
+ if(is_llvm_bitcode_from_memory(addr, size, &input->arch_flag,
+ NULL) != 0){
+ /* create a thin file struct for it */
+@@ -1204,6 +1205,7 @@
+ thin->fat_arch.align = 0;
+ }
+ else
++#endif
+ fatal("can't figure out the architecture type of: %s",
+ input->name);
+ }
+@@ -1444,6 +1446,7 @@
+ if(strncmp(ar_name, SYMDEF, sizeof(SYMDEF) - 1) != 0){
+ ar_addr = addr + offset + ar_name_size;
+ ar_size = strtoul(ar_hdr->ar_size, NULL, 10);
++#ifdef LTO_SUPPORT
+ if(is_llvm_bitcode_from_memory(ar_addr, ar_size,
+ &arch_flag, NULL) != 0){
+ if(*cputype == 0){
+@@ -1466,6 +1464,7 @@
+ (*cpusubtype) & ~CPU_SUBTYPE_MASK);
+ }
+ }
++#endif
+ }
+ }
+ }
diff --git a/sys-devel/binutils-apple/files/ld64-127.2-lto.patch b/sys-devel/binutils-apple/files/ld64-127.2-lto.patch
new file mode 100644
index 000000000000..b9a3f14042c5
--- /dev/null
+++ b/sys-devel/binutils-apple/files/ld64-127.2-lto.patch
@@ -0,0 +1,214 @@
+--- src/ld/InputFiles.cpp
++++ src/ld/InputFiles.cpp
+@@ -58,7 +58,9 @@
+ #include "macho_relocatable_file.h"
+ #include "macho_dylib_file.h"
+ #include "archive_file.h"
++#ifdef LTO
+ #include "lto_file.h"
++#endif
+ #include "opaque_section_file.h"
+
+
+@@ -175,9 +177,11 @@
+ if ( result != NULL )
+ return result;
+
++#ifdef LTO
+ result = lto::archName(p, len);
+ if ( result != NULL )
+ return result;
++#endif
+
+ if ( strncmp((const char*)p, "!<arch>\n", 8) == 0 )
+ return "archive";
+@@ -264,10 +268,12 @@
+ if ( objResult != NULL )
+ return this->addObject(objResult, info, len);
+
++#if LTO
+ // see if it is an llvm object file
+ objResult = lto::parse(p, len, info.path, info.modTime, _nextInputOrdinal, _options.architecture(), _options.subArchitecture(), _options.logAllFiles());
+ if ( objResult != NULL )
+ return this->addObject(objResult, info, len);
++#endif
+
+ // see if it is a dynamic library
+ ld::dylib::File* dylibResult = mach_o::dylib::parse(p, len, info.path, info.modTime, _options, _nextInputOrdinal, info.options.fBundleLoader, indirectDylib);
+@@ -291,6 +297,7 @@
+ return this->addArchive(archiveResult, info, len);
+ }
+
++#ifdef LTO
+ // does not seem to be any valid linker input file, check LTO misconfiguration problems
+ if ( lto::archName((uint8_t*)p, len) != NULL ) {
+ if ( lto::libLTOisLoaded() ) {
+@@ -315,6 +322,7 @@
+ throwf("could not process llvm bitcode object file, because %s could not be loaded", libLTO);
+ }
+ }
++#endif
+
+ // error handling
+ if ( ((fat_header*)p)->magic == OSSwapBigToHostInt32(FAT_MAGIC) ) {
+--- src/ld/Options.cpp
++++ src/ld/Options.cpp
+@@ -36,10 +36,12 @@
+ #include "Architectures.hpp"
+ #include "MachOFileAbstraction.hpp"
+
++#ifdef LTO
+ // upward dependency on lto::version()
+ namespace lto {
+ extern const char* version();
+ }
++#endif
+
+ // magic to place command line in crash reports
+ const int crashreporterBufferSize = 2000;
+@@ -2766,9 +2768,11 @@
+ fprintf(stderr, "%s", ldVersionString);
+ // if only -v specified, exit cleanly
+ if ( argc == 2 ) {
++#ifdef LTO
+ const char* ltoVers = lto::version();
+ if ( ltoVers != NULL )
+ fprintf(stderr, "%s\n", ltoVers);
++#endif
+ exit(0);
+ }
+ }
+--- src/ld/Resolver.cpp
++++ src/ld/Resolver.cpp
+@@ -58,7 +58,9 @@
+ #include "InputFiles.h"
+ #include "SymbolTable.h"
+ #include "Resolver.h"
++#ifdef LTO
+ #include "parsers/lto_file.h"
++#endif
+
+
+ namespace ld {
+@@ -1315,6 +1317,7 @@
+
+ void Resolver::linkTimeOptimize()
+ {
++#ifdef LTO
+ // only do work here if some llvm obj files where loaded
+ if ( ! _haveLLVMObjs )
+ return;
+@@ -1415,6 +1418,9 @@
+ // check new code does not override some dylib
+ this->checkDylibSymbolCollisions();
+ }
++#else
++ return;
++#endif
+ }
+
+
+--- src/ld/ld.cpp
++++ src/ld/ld.cpp
+@@ -83,7 +83,9 @@
+ #include "parsers/archive_file.h"
+ #include "parsers/macho_relocatable_file.h"
+ #include "parsers/macho_dylib_file.h"
++#ifdef LTO
+ #include "parsers/lto_file.h"
++#endif
+ #include "parsers/opaque_section_file.h"
+
+
+--- src/ld/parsers/archive_file.cpp
++++ src/ld/parsers/archive_file.cpp
+@@ -39,7 +39,9 @@
+ #include "Architectures.hpp"
+
+ #include "macho_relocatable_file.h"
++#ifdef LTO
+ #include "lto_file.h"
++#endif
+ #include "archive_file.h"
+
+
+@@ -91,8 +93,10 @@
+ private:
+ static bool validMachOFile(const uint8_t* fileContent, uint64_t fileLength,
+ const mach_o::relocatable::ParserOptions& opts);
++#ifdef LTO
+ static bool validLTOFile(const uint8_t* fileContent, uint64_t fileLength,
+ const mach_o::relocatable::ParserOptions& opts);
++#endif
+ static cpu_type_t architecture();
+
+ class Entry : ar_hdr
+@@ -239,12 +243,13 @@
+ return mach_o::relocatable::isObjectFile(fileContent, fileLength, opts);
+ }
+
++#ifdef LTO
+ template <typename A>
+ bool File<A>::validLTOFile(const uint8_t* fileContent, uint64_t fileLength, const mach_o::relocatable::ParserOptions& opts)
+ {
+ return lto::isObjectFile(fileContent, fileLength, opts.architecture, opts.subType);
+ }
+-
++#endif
+
+
+ template <typename A>
+@@ -263,7 +268,11 @@
+ if ( (p==start) && ((strcmp(memberName, SYMDEF_SORTED) == 0) || (strcmp(memberName, SYMDEF) == 0)) )
+ continue;
+ // archive is valid if first .o file is valid
+- return (validMachOFile(p->content(), p->contentSize(), opts) || validLTOFile(p->content(), p->contentSize(), opts));
++ return (validMachOFile(p->content(), p->contentSize(), opts)
++#ifdef LTO
++ || validLTOFile(p->content(), p->contentSize(), opts)
++#endif
++ );
+ }
+ // empty archive
+ return true;
+@@ -363,6 +372,7 @@
+ _instantiatedEntries[member] = state;
+ return _instantiatedEntries[member];
+ }
++#ifdef LTO
+ // see if member is llvm bitcode file
+ result = lto::parse(member->content(), member->contentSize(),
+ mPath, member->modificationTime(), this->ordinal() + memberIndex,
+@@ -372,6 +382,7 @@
+ _instantiatedEntries[member] = state;
+ return _instantiatedEntries[member];
+ }
++#endif
+
+ throwf("archive member '%s' with length %d is not mach-o or llvm bitcode", memberName, member->contentSize());
+ }
+--- src/other/ObjectDump.cpp
++++ src/other/ObjectDump.cpp
+@@ -33,7 +33,9 @@
+
+ #include "MachOFileAbstraction.hpp"
+ #include "parsers/macho_relocatable_file.h"
++#ifdef LTO
+ #include "parsers/lto_file.h"
++#endif
+
+ static bool sDumpContent= true;
+ static bool sDumpStabs = false;
+@@ -1150,10 +1152,12 @@
+ if ( objResult != NULL )
+ return objResult;
+
++#ifdef LTO
+ // see if it is an llvm object file
+ objResult = lto::parse(p, fileLen, path, stat_buf.st_mtime, 0, sPreferredArch, sPreferredSubArch, false);
+ if ( objResult != NULL )
+ return objResult;
++#endif
+
+ throwf("not a mach-o object file: %s", path);
+ #else