Gentoo Archives: gentoo-commits

From: Fabian Groffen <grobian@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: sys-devel/binutils-apple/
Date: Fri, 29 Dec 2017 13:50:15
Message-Id: 1514555399.e31bea4612e174201032c496edc62b8e97109569.grobian@gentoo
1 commit: e31bea4612e174201032c496edc62b8e97109569
2 Author: Fabian Groffen <grobian <AT> gentoo <DOT> org>
3 AuthorDate: Fri Dec 29 13:49:59 2017 +0000
4 Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org>
5 CommitDate: Fri Dec 29 13:49:59 2017 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=e31bea46
7
8 sys-devel/binutils-apple: patchbump for llvm 4/5 by Michael Weiser
9
10 Closes: https://bugs.gentoo.org/642292
11 Package-Manager: Portage-2.3.13, Repoman-2.3.3
12
13 sys-devel/binutils-apple/Manifest | 1 +
14 .../binutils-apple/binutils-apple-8.2.1-r1.ebuild | 366 +++++++++++++++++++++
15 2 files changed, 367 insertions(+)
16
17 diff --git a/sys-devel/binutils-apple/Manifest b/sys-devel/binutils-apple/Manifest
18 index 1818fa06667..f404c7a7bfb 100644
19 --- a/sys-devel/binutils-apple/Manifest
20 +++ b/sys-devel/binutils-apple/Manifest
21 @@ -8,6 +8,7 @@ DIST binutils-apple-patches-7.2-r0.tar.bz2 2917 BLAKE2B 53bf5c5c8a21bcaa4df6b1fe
22 DIST binutils-apple-patches-7.3-r0.tar.bz2 44576 BLAKE2B a9f23fe66f9b3e25b8975c9148db996fb3133f70b11768fe400993c90d62b6da2c9704a99104c6921dfae5052b5e0d66bd1af02640df8166a957fef9a092d52a SHA512 6b092c586ac4c3a3c65229a7490f93b0f0d38348e5a2db4f73d6062c737007ee0a5b6bdb5948b7aac1d74d32442fa501ba92161a9ffe13151288432c6a706c43
23 DIST binutils-apple-patches-7.3-r1.tar.bz2 44737 BLAKE2B 4ac5d3b50c04b1ab71dc1c266db8b44e9d34f12bcc8a53966232cb5a6999b2662f9891367a2e7f8ea4f0f014b19594c1adf8dd945a18419980bca729c1de302e SHA512 ce4b3a725e19cb632b0c101a32488ce09a8bb89aed08339d5518d834cb68c525b2e0c8b66564a945c077915e92cc6be3f7028c5baacb870b3ca9b9422b4fb0da
24 DIST binutils-apple-patches-8.2-r0.tar.bz2 5771 BLAKE2B b562ea4dd9214bc66695dbdb2452c88b1885ae1e36904516ea664157cbf0b54421d80cd0df792fcc431a3e0b98e804488c651b3fa29b368445450d0d13a1502c SHA512 92d04396630a31b752a24845c27fe8da2e37eb176117c9b31193e8f48af7ade707cda4060289b848965310afd05b2f121c740b0e5baa56b79c5481273a88c84e
25 +DIST binutils-apple-patches-8.2-r1.tar.bz2 10830 BLAKE2B 345db8619873e9e91b79c3fdc0685fc46f82366df0b6153c1a59fbe5c122622e799754397e980e8752ef01ef25bbac81bb8f0339e92168790211b1d9c03bef2d SHA512 e7ca8cbac75671846c044abcd5415cfcf5832ff71acd5a2799b643369b02f2f7148990398c51913a3758e589f9fbff875e333aadf568e2a8a2defeafaa2aca95
26 DIST cctools-822.tar.gz 2024412 BLAKE2B 6b58499a9dfc2a1b166ff428f1e263cd44e03c50cdc8f6e467cfee93bc2dc2a9c81bf7626479dce195b152f04217e2d3a427afac45484cba4c5f2bdfbb7e46f9 SHA512 8b02cc837d5e0520f35da445f25ba86b5042d5caa27b49a599e829ed89428cf78dbd1831bcf6c18301f941fbfb31ac2114e248041d98008a466e1574f4fe1586
27 DIST cctools-855.tar.gz 1699635 BLAKE2B 4d98cf2bbced6894083dc2733a35cf9a4c47f71172fe98265a8f047218cc90276085919129553e3a1ea0658416eebf3b7cf0908bd32ac1a224480554257999ee SHA512 50f5d015ce807aa5ca274dd2deea810b8b375110e60b5e334ca4b2170526b738ea5f86a5436caebbdb748badc3b89601d0f450f5b867d8393c89e336a3db4b3f
28 DIST cctools-862.tar.gz 1702345 BLAKE2B de84058aa78824562b0eabf93a29badaba0908a7140336a281a6ea46a9b09d893433a908c299e8de866a76e0eeb98b730570958fc8fac559ccc6e35f5138b121 SHA512 faa401c1dc55bfb9cd2a9a9cc7bc9d473ee63b019607967c8b0da325514d6a1f7b1f52404370bcc018e86d30d75a4b01183f49b793f577110663efe43871360a
29
30 diff --git a/sys-devel/binutils-apple/binutils-apple-8.2.1-r1.ebuild b/sys-devel/binutils-apple/binutils-apple-8.2.1-r1.ebuild
31 new file mode 100644
32 index 00000000000..bf8351a7b24
33 --- /dev/null
34 +++ b/sys-devel/binutils-apple/binutils-apple-8.2.1-r1.ebuild
35 @@ -0,0 +1,366 @@
36 +# Copyright 1999-2017 Gentoo Foundation
37 +# Distributed under the terms of the GNU General Public License v2
38 +
39 +EAPI="6"
40 +
41 +inherit eutils flag-o-matic toolchain-funcs llvm prefix
42 +
43 +LD64=ld64-274.2
44 +CCTOOLS_VERSION=895
45 +CCTOOLS=cctools-${CCTOOLS_VERSION}
46 +DYLD=dyld-421.2
47 +
48 +DESCRIPTION="Darwin assembler as(1) and static linker ld(1), Xcode Tools ${PV}"
49 +HOMEPAGE="http://www.opensource.apple.com/darwinsource/"
50 +SRC_URI="http://www.opensource.apple.com/tarballs/ld64/${LD64}.tar.gz
51 + http://www.opensource.apple.com/tarballs/cctools/${CCTOOLS}.tar.gz
52 + http://www.opensource.apple.com/tarballs/dyld/${DYLD}.tar.gz
53 + https://dev.gentoo.org/~grobian/distfiles/${PN}-patches-4.3-r1.tar.bz2
54 + https://dev.gentoo.org/~grobian/distfiles/${PN}-patches-5.1-r2.tar.bz2
55 + https://dev.gentoo.org/~grobian/distfiles/${PN}-patches-7.3-r1.tar.bz2
56 + https://dev.gentoo.org/~grobian/distfiles/${PN}-patches-8.2-r1.tar.bz2"
57 +
58 +LICENSE="APSL-2"
59 +KEYWORDS="~x64-macos ~x86-macos"
60 +IUSE="lto tapi classic test"
61 +
62 +# ld64 can now only be compiled using llvm and libc++ since it massively uses
63 +# C++11 language features. *But additionally* the as driver now defaults to
64 +# calling clang as the assembler on many platforms. This can be disabled using
65 +# -Wa,-Q but since it's default we make llvm a static runtime dependency.
66 +RDEPEND="sys-devel/binutils-config
67 + lto? ( app-arch/xar )
68 + tapi? ( sys-libs/tapi )
69 + sys-devel/llvm
70 + sys-libs/libcxx"
71 +DEPEND="${RDEPEND}
72 + test? ( >=dev-lang/perl-5.8.8 )"
73 +
74 +SLOT="8"
75 +
76 +S=${WORKDIR}
77 +
78 +is_cross() { [[ ${CHOST} != ${CTARGET} ]] ; }
79 +
80 +llvm_pkg_setup() {
81 + # eclass version will die if no LLVM can be found which will break prefix
82 + # bootstrap
83 + :
84 +}
85 +
86 +src_prepare() {
87 + cd "${S}"/${LD64}/src
88 + cp "${S}"/ld64-136-compile_stubs.h ld/compile_stubs.h
89 + cp "${S}"/ld64-274.2-Makefile Makefile
90 +
91 + epatch "${S}"/ld64-274.1-nolto.patch
92 + epatch "${S}"/ld64-236.3-crashreporter.patch
93 + epatch "${S}"/ld64-264.3.102-bitcode-case.patch
94 + epatch "${S}"/ld64-274.1-unknown-fixup.patch
95 + epatch "${S}"/ld64-274.1-notapi.patch
96 + epatch "${S}"/ld64-274.2-cfi-info-type.patch
97 +
98 + # workound llvm-3.9.{0,1} issue
99 + # https://bugs.gentoo.org/show_bug.cgi?id=603580
100 + # https://groups.google.com/forum/#!topic/llvm-dev/JY6nuKE__sU
101 + # http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20160829/169553.html
102 + sed -i -e '/COMPILE_TIME_ASSERT/d' ld/parsers/libunwind/*.hpp || die
103 +
104 + # provide missing headers from libunwind and dyld
105 + mkdir -p include/{mach,mach-o/arm} || die
106 + # never present because it's private
107 + cp ../../${DYLD}/include/mach-o/dyld_priv.h include/mach-o || die
108 + # use copies from cctools because they're otherwise hidden in some SDK
109 + cp ../../${CCTOOLS}/include/mach-o/arm/reloc.h include/mach-o/arm || die
110 + # provide all required CPU_TYPEs on all platforms
111 + cp ../../${CCTOOLS}/include/mach/machine.h include/mach/machine.h
112 + # add alias for newer identifiers, because ld64 uses both but cctools
113 + # header only defines the older
114 + epatch "${S}"/ld64-236.3-missing-cputypes.patch
115 +
116 + local VER_STR="\"@(#)PROGRAM:ld PROJECT:${LD64} (Gentoo ${PN}-${PVR})\\n\""
117 + echo "char ldVersionString[] = ${VER_STR};" > version.cpp
118 +
119 + epatch "${S}"/ld64-123.2-debug-backtrace.patch
120 +
121 + cd "${S}"/${CCTOOLS}
122 + epatch "${S}"/${PN}-4.5-as.patch
123 + epatch "${S}"/${PN}-5.1-as-dir.patch
124 + epatch "${S}"/${PN}-5.1-ranlib.patch
125 + epatch "${S}"/${PN}-3.1.1-libtool-ranlib.patch
126 + epatch "${S}"/${PN}-3.1.1-no-headers.patch
127 + epatch "${S}"/${PN}-4.0-no-oss-dir.patch
128 + epatch "${S}"/cctools-839-intel-retf.patch
129 + epatch "${S}"/${PN}-5.1-extraneous-includes.patch
130 + epatch "${S}"/${PN}-5.1-strnlen.patch
131 + epatch "${S}"/${PN}-7.3-make-j.patch
132 + epatch "${S}"/${PN}-7.3-no-developertools-dir.patch
133 + epatch "${S}"/${PN}-8.2.1-llvm-prefix-3.patch
134 + epatch "${S}"/${PN}-8.2.1-llvm-shim.patch
135 + eprefixify libstuff/execute.c
136 + cp ../${LD64}/src/other/prune_trie.h include/mach-o/ || die
137 +
138 + # do not build profileable libstuff to save compile time
139 + sed -i -e "/^all:/s, profile , ," libstuff/Makefile
140 +
141 + # cctools version is provided to make via RC_ProjectSourceVersion which
142 + # generates and compiles it as apple_version[] into libstuff. From
143 + # there it's picked up by the individual tools. Since
144 + # RC_ProjectSourceVersion is also used as library version, we can't
145 + # just append our local version info. So we hack the libstuff Makefile
146 + # to include our Gentoo version.
147 + sed -i -e "/cctools-.*(RC_ProjectSourceVersion).*OFILE_DIR/s,Version),Version) (Gentoo ${PN}-${PVR})," \
148 + libstuff/Makefile
149 +
150 + eapply_user
151 +
152 + # clean up test suite
153 + cd "${S}"/${LD64}/unit-tests/test-cases
154 + local c
155 +
156 + # we don't have llvm
157 + ((++c)); rm -rf llvm-integration;
158 +
159 + # we don't have dtrace
160 + ((++c)); rm -rf dtrace-static-probes-coalescing;
161 + ((++c)); rm -rf dtrace-static-probes;
162 +
163 + # a file is missing
164 + ((++c)); rm -rf eh-coalescing-r
165 +
166 + # we don't do universal binaries
167 + ((++c)); rm -rf blank-stubs;
168 +
169 + # looks like a problem with apple's result-filter.pl
170 + ((++c)); rm -rf implicit-common3;
171 + ((++c)); rm -rf order_file-ans;
172 +
173 + # TODO no idea what goes wrong here
174 + ((++c)); rm -rf dwarf-debug-notes;
175 +
176 + einfo "Deleted $c tests that were bound to fail"
177 +
178 + cd "${S}"
179 + ebegin "cleaning Makefiles from unwanted CFLAGS"
180 + find . -name "Makefile" -print0 | xargs -0 sed \
181 + -i \
182 + -e 's/ -g / /g' \
183 + -e 's/^G =.*$/G =/' \
184 + -e 's/^OFLAG =.*$/OFLAG =/' \
185 + -e 's/install -c -s/install/g'
186 + eend $?
187 +}
188 +
189 +src_configure() {
190 + ENABLE_LTO=0
191 + if use lto ; then
192 + ENABLE_LTO=1
193 +
194 + LLVM_INCDIR=$(get_llvm_prefix)/include
195 + LLVM_LIBDIR=$(get_llvm_prefix)/lib
196 +
197 + [ -n "${LLVM_INCDIR}" -a -n "${LLVM_LIBDIR}" ] || \
198 + die "LLVM not found - LTO support can not be enabled"
199 +
200 + # LTO and LLVM support currently both depend only on libLTO being
201 + # present. So we can enable both.
202 + CCTOOLS_LTO_CFLAGS="-DLTO_SUPPORT -I${LLVM_INCDIR}"
203 + CCTOOLS_LLVM_CFLAGS="-DLLVM_SUPPORT -I${LLVM_INCDIR}"
204 + fi
205 +
206 + export CTARGET=${CTARGET:-${CHOST}}
207 + if [[ ${CTARGET} == ${CHOST} ]] ; then
208 + if [[ ${CATEGORY} == cross-* ]] ; then
209 + export CTARGET=${CATEGORY#cross-}
210 + fi
211 + fi
212 +
213 + LIBPATH=/usr/$(get_libdir)/binutils/${CTARGET}/${PV}
214 + DATAPATH=/usr/share/binutils-data/${CTARGET}/${PV}
215 + if is_cross ; then
216 + BINPATH=/usr/${CHOST}/${CTARGET}/binutils-bin/${PV}
217 + else
218 + BINPATH=/usr/${CTARGET}/binutils-bin/${PV}
219 + fi
220 +
221 + # CPPFLAGS only affects ld64, cctools don't use 'em (which currently is
222 + # what we want)
223 + append-cppflags -DNDEBUG
224 +
225 + # Create configure.h for ld64 with SUPPORT_ARCH_<arch> defines in it.
226 + DERIVED_FILE_DIR=${LD64}/src \
227 + ${LD64}/src/create_configure
228 +}
229 +
230 +compile_ld64() {
231 + einfo "building ${LD64}"
232 + cd "${S}"/${LD64}/src
233 + emake \
234 + LTO=${ENABLE_LTO} \
235 + LTO_INCDIR=${LLVM_INCDIR} \
236 + LTO_LIBDIR=${LLVM_LIBDIR} \
237 + TAPI=$(use tapi && echo 1 || echo 0) \
238 + TAPI_LIBDIR=${EPREFIX}/usr/lib \
239 + || die "emake failed for ld64"
240 + use test && emake build_test
241 +}
242 +
243 +compile_cctools() {
244 + einfo "building ${CCTOOLS}"
245 + cd "${S}"/${CCTOOLS}
246 + # Suppress running dsymutil because it will warn about missing debug
247 + # info which is expected when compiling without -g as we normally do.
248 + # This might need some more thought if anyone ever wanted to build us
249 + # for debugging with Apple's tools.
250 + emake \
251 + LIB_PRUNETRIE="-L../../${LD64}/src -lprunetrie" \
252 + EFITOOLS= \
253 + LTO="${CCTOOLS_LTO_CFLAGS} ${CCTOOLS_LLVM_CFLAGS}" \
254 + COMMON_SUBDIRS='libstuff ar misc otool' \
255 + SUBDIRS_32= \
256 + LEGACY= \
257 + RC_ProjectSourceVersion=${CCTOOLS_VERSION} \
258 + RC_CFLAGS="${CFLAGS}" \
259 + OFLAG="${CCTOOLS_OFLAG}" \
260 + DSYMUTIL=": disabled: dsymutil" \
261 + || die "emake failed for the cctools"
262 + cd "${S}"/${CCTOOLS}/as
263 + emake \
264 + BUILD_OBSOLETE_ARCH= \
265 + RC_ProjectSourceVersion=${CCTOOLS_VERSION} \
266 + RC_CFLAGS="-DASLIBEXECDIR=\"\\\"${EPREFIX}${LIBPATH}/\\\"\" ${CFLAGS}" \
267 + OFLAG="${CCTOOLS_OFLAG}" \
268 + DSYMUTIL=": disabled: dsymutil" \
269 + || die "emake failed for as"
270 +}
271 +
272 +src_compile() {
273 + compile_ld64
274 + compile_cctools
275 +}
276 +
277 +install_ld64() {
278 + exeinto ${BINPATH}
279 + doexe "${S}"/${LD64}/src/{ld64,rebase,dyldinfo,unwinddump,ObjectDump}
280 + dosym ld64 ${BINPATH}/ld
281 + insinto ${DATAPATH}/man/man1
282 + doins "${S}"/${LD64}/doc/man/man1/{ld,ld64,rebase}.1
283 +}
284 +
285 +install_cctools() {
286 + cd "${S}"/${CCTOOLS}
287 + emake install_all_but_headers \
288 + EFITOOLS= \
289 + COMMON_SUBDIRS='ar misc otool' \
290 + SUBDIRS_32= \
291 + DSTROOT=\"${D}\" \
292 + BINDIR=\"${EPREFIX}\"${BINPATH} \
293 + LOCBINDIR=\"${EPREFIX}\"${BINPATH} \
294 + USRBINDIR=\"${EPREFIX}\"${BINPATH} \
295 + LOCLIBDIR=\"${EPREFIX}\"${LIBPATH} \
296 + MANDIR=\"${EPREFIX}\"${DATAPATH}/man/
297 + cd "${S}"/${CCTOOLS}/as
298 + emake install \
299 + BUILD_OBSOLETE_ARCH= \
300 + DSTROOT=\"${D}\" \
301 + USRBINDIR=\"${EPREFIX}\"${BINPATH} \
302 + LIBDIR=\"${EPREFIX}\"${LIBPATH} \
303 + LOCLIBDIR=\"${EPREFIX}\"${LIBPATH}
304 +
305 + # upstream is starting to replace classic binutils with llvm-integrated
306 + # ones. In Xcode, nm and size are now symlinks to llvm-{nm,size} while the
307 + # classic version is preserved as {nm,size}-classic. When asked to do so
308 + # by use classic we statically link to the classic version.
309 + # binutils-bin/<version>/<tool>
310 + # -> binutils-bin/<version>/<tool>-classic
311 + #
312 + # Otherwise we try to find and use the llvm version of the tool. Since our
313 + # binutils do not live in the same directory as the llvm installation and
314 + # llvm tends to move around, we use a shim that tries to find the llvm
315 + # version of the tool in prefix. It will fall back to the classic tool if
316 + # it fails.
317 + # binutils-bin/<version>/<tool>
318 + # -> binutils-bin/<version>/llvm-<tool>
319 + # -> $EPREFIX/usr/lib/llvm/<major/bin/llvm-<tool>
320 + # -> $EPREFIX/usr/bin/llvm-<tool>
321 + # -> binutils-bin/<version>/<tool>-classic
322 + budir=${D}/${EPREFIX}/${BINPATH}
323 + for tool in nm size ; do
324 + use classic && \
325 + ln -sfn ${tool}-classic "${budir}/${tool}" || \
326 + ln -sfn llvm-shim "${budir}/${tool}"
327 + done
328 +
329 + # Also, otool is now based on llvm-objdump. But a small wrapper installed
330 + # as llvm-otool remains, providing command line compatibility.
331 + use classic && \
332 + ln -sfn otool-classic "${budir}/otool" || \
333 + ln -sfn llvm-otool "${budir}/otool"
334 +
335 + # And finally, although our cctools don't actually contain dsymutil and
336 + # objdump, we provide access to the llvm versions of them via the shim to
337 + # be in line with Xcode.
338 + for tool in objdump dsymutil ; do
339 + ln -sfn llvm-shim "${budir}/${tool}"
340 + done
341 +
342 + cd "${ED}"${BINPATH}
343 + insinto ${DATAPATH}/man/man1
344 + local skips manpage
345 + # ar brings an up-to-date manpage with it
346 + skips=( ar )
347 + for bin in *; do
348 + for skip in ${skips[@]}; do
349 + if [[ ${bin} == ${skip} ]]; then
350 + continue 2;
351 + fi
352 + done
353 + manpage=${S}/${CCTOOLS}/man/${bin}.1
354 + if [[ -f "${manpage}" ]]; then
355 + doins "${manpage}"
356 + fi
357 + done
358 + insinto ${DATAPATH}/man/man5
359 + doins "${S}"/${CCTOOLS}/man/*.5
360 +}
361 +
362 +src_test() {
363 + if ! [ "${EPREFIX}"/usr/bin/clang ] ; then
364 + einfo "Test suite only works properly with clang - please install"
365 + return
366 + fi
367 +
368 + einfo "Running unit tests"
369 + cd "${S}"/${LD64}/unit-tests/test-cases
370 + # provide the new ld as a symlink to clang so that -ccc-install-dir
371 + # will pick it up
372 + ln -sfn ../../src/ld64 ld
373 + # use our arch command because the System's will report i386 even for an
374 + # x86_64 prefix
375 + perl ../bin/make-recursive.pl \
376 + BUILT_PRODUCTS_DIR="${S}"/${LD64}/src \
377 + ARCH="$(arch)" \
378 + LD="${S}"/${LD64}/src/ld64 \
379 + CC="${CC} -ccc-install-dir $PWD" \
380 + CXX="${CXX} -ccc-install-dir $PWD" \
381 + OTOOL="${S}"/${CCTOOLS}/otool/otool.NEW \
382 + | perl ../bin/result-filter.pl
383 +}
384 +
385 +src_install() {
386 + install_ld64
387 + install_cctools
388 +
389 + cd "${S}"
390 + insinto /etc/env.d/binutils
391 + cat <<-EOF > env.d
392 + TARGET="${CHOST}"
393 + VER="${PV}"
394 + FAKE_TARGETS="${CHOST}"
395 + EOF
396 + newins env.d ${CHOST}-${PV}
397 +}
398 +
399 +pkg_postinst() {
400 + binutils-config ${CHOST}-${PV}
401 +}