Gentoo Archives: gentoo-commits

From: "Andreas K. Hüttel" <dilfridge@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: sys-devel/binutils/
Date: Fri, 05 Aug 2022 19:06:38
Message-Id: 1659726383.461943f09bfe6674177e0ef2fef051d3d4bddda3.dilfridge@gentoo
1 commit: 461943f09bfe6674177e0ef2fef051d3d4bddda3
2 Author: Andreas K. Hüttel <dilfridge <AT> gentoo <DOT> org>
3 AuthorDate: Fri Aug 5 19:05:50 2022 +0000
4 Commit: Andreas K. Hüttel <dilfridge <AT> gentoo <DOT> org>
5 CommitDate: Fri Aug 5 19:06:23 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=461943f0
7
8 sys-devel/binutils: Version bump for testing, no keywords
9
10 Signed-off-by: Andreas K. Hüttel <dilfridge <AT> gentoo.org>
11
12 sys-devel/binutils/Manifest | 2 +
13 sys-devel/binutils/binutils-2.39.ebuild | 481 ++++++++++++++++++++++++++++++++
14 2 files changed, 483 insertions(+)
15
16 diff --git a/sys-devel/binutils/Manifest b/sys-devel/binutils/Manifest
17 index db3df3d2e7c4..4c4e0c5d62c2 100644
18 --- a/sys-devel/binutils/Manifest
19 +++ b/sys-devel/binutils/Manifest
20 @@ -13,3 +13,5 @@ DIST binutils-2.37_p1.tar.xz 22992196 BLAKE2B a8aa0f386d03a5b1466166ac7c40989c22
21 DIST binutils-2.38-patches-3.tar.xz 189068 BLAKE2B 5b14c90ab7dba253e92ad57b3a702fcbf48739dd0121ce8f739d88331da820ce44c35e16ac4bee394525c3a46bce980e9e1bbf4cbc9ce8a14fc324bc8fa059e7 SHA512 099266a8ef4272fd7f7552071e1892d114ed564a38b700df32e058ed691c6bfcd6f2454f649461f9c36594ea819a35d1e4cd2418609a2407be2a4f8885e500e3
22 DIST binutils-2.38-patches-4.tar.xz 193852 BLAKE2B 5a83e20008e58464ed563a6817a367e50684c59d08c47345cc546054269c42463d1651441720f865851e4e182e917df1a095c68e64226e0351b64e975d524096 SHA512 6657e547bb02898632cc45a8f1894be098aa7472b6725b65f95393e621abb127e468b4e50310720bf03f7e8d0a68bc2c47af76fc43aaa8f32b2e4a149c0c6290
23 DIST binutils-2.38.tar.xz 23651408 BLAKE2B 19ede396ec97b88e632aded2f69f4684cc5053109e06c3c4a1934944e3f0ceaa9e4a2604528a440189771f778cb5d75edd510163970eeea31afba87fa256feba SHA512 8bf0b0d193c9c010e0518ee2b2e5a830898af206510992483b427477ed178396cd210235e85fd7bd99a96fc6d5eedbeccbd48317a10f752b7336ada8b2bb826d
24 +DIST binutils-2.39-patches-2.tar.xz 16700 BLAKE2B 709220104a79fa1ff0cf1ee0c60336920112397478d7687f1a6484b1a3147b7e6233d393c0a6f335c69385236b7abc9dba6e6118a9d6940f226fcac56ba7da01 SHA512 ebaa169dc662b7e5f44a3aaf6d7de196d447c5485b4f87bb0f272d40921f6c1209a6804ed1d64dd4bfade82898c9f18f8fac2cf52e41bb70ec2b653c39203088
25 +DIST binutils-2.39.tar.xz 25167756 BLAKE2B ac6a5296c6586d53eaadcbffc5c399a6d79edf72450b9bb8b3525ce525129cef3d2eb90c85ef3bb3270b5a03b0e1ffb8f0b705f028158726f9777ebb8685066f SHA512 68e038f339a8c21faa19a57bbc447a51c817f47c2e06d740847c6e9cc3396c025d35d5369fa8c3f8b70414757c89f0e577939ddc0d70f283182504920f53b0a3
26
27 diff --git a/sys-devel/binutils/binutils-2.39.ebuild b/sys-devel/binutils/binutils-2.39.ebuild
28 new file mode 100644
29 index 000000000000..df7c2b678ef9
30 --- /dev/null
31 +++ b/sys-devel/binutils/binutils-2.39.ebuild
32 @@ -0,0 +1,481 @@
33 +# Copyright 1999-2022 Gentoo Authors
34 +# Distributed under the terms of the GNU General Public License v2
35 +
36 +EAPI=7
37 +
38 +inherit libtool flag-o-matic gnuconfig strip-linguas toolchain-funcs
39 +
40 +DESCRIPTION="Tools necessary to build programs"
41 +HOMEPAGE="https://sourceware.org/binutils/"
42 +LICENSE="GPL-3+"
43 +IUSE="cet default-gold doc +gold multitarget +nls pgo +plugins static-libs test vanilla"
44 +REQUIRED_USE="default-gold? ( gold )"
45 +
46 +# Variables that can be set here (ignored for live ebuilds)
47 +# PATCH_VER - the patchset version
48 +# Default: empty, no patching
49 +# PATCH_BINUTILS_VER - the binutils version in the patchset name
50 +# - Default: PV
51 +# PATCH_DEV - Use download URI https://dev.gentoo.org/~{PATCH_DEV}/distfiles/...
52 +# for the patchsets
53 +
54 +PATCH_VER=2
55 +PATCH_DEV=dilfridge
56 +
57 +if [[ ${PV} == 9999* ]]; then
58 + inherit git-r3
59 + SLOT=${PV}
60 +else
61 + PATCH_BINUTILS_VER=${PATCH_BINUTILS_VER:-${PV}}
62 + PATCH_DEV=${PATCH_DEV:-dilfridge}
63 + SRC_URI="mirror://gnu/binutils/binutils-${PV}.tar.xz https://dev.gentoo.org/~${PATCH_DEV}/distfiles/binutils-${PV}.tar.xz"
64 + [[ -z ${PATCH_VER} ]] || SRC_URI="${SRC_URI}
65 + https://dev.gentoo.org/~${PATCH_DEV}/distfiles/binutils-${PATCH_BINUTILS_VER}-patches-${PATCH_VER}.tar.xz"
66 + SLOT=$(ver_cut 1-2)
67 + # live ebuild
68 + #KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86"
69 +fi
70 +
71 +#
72 +# The cross-compile logic
73 +#
74 +export CTARGET=${CTARGET:-${CHOST}}
75 +if [[ ${CTARGET} == ${CHOST} ]] ; then
76 + if [[ ${CATEGORY} == cross-* ]] ; then
77 + export CTARGET=${CATEGORY#cross-}
78 + fi
79 +fi
80 +is_cross() { [[ ${CHOST} != ${CTARGET} ]] ; }
81 +
82 +#
83 +# The dependencies
84 +#
85 +RDEPEND="
86 + >=sys-devel/binutils-config-3
87 + sys-libs/zlib
88 +"
89 +DEPEND="${RDEPEND}"
90 +BDEPEND="
91 + doc? ( sys-apps/texinfo )
92 + test? (
93 + dev-util/dejagnu
94 + sys-devel/bc
95 + )
96 + nls? ( sys-devel/gettext )
97 + sys-devel/flex
98 + virtual/yacc
99 +"
100 +
101 +RESTRICT="!test? ( test )"
102 +
103 +MY_BUILDDIR=${WORKDIR}/build
104 +
105 +src_unpack() {
106 + if [[ ${PV} == 9999* ]] ; then
107 + EGIT_REPO_URI="https://anongit.gentoo.org/git/proj/toolchain/binutils-patches.git"
108 + EGIT_CHECKOUT_DIR=${WORKDIR}/patches-git
109 + git-r3_src_unpack
110 + mv patches-git/9999 patch || die
111 +
112 + EGIT_REPO_URI="https://sourceware.org/git/binutils-gdb.git"
113 + S=${WORKDIR}/binutils
114 + EGIT_CHECKOUT_DIR=${S}
115 + git-r3_src_unpack
116 + else
117 + unpack ${P/-hppa64/}.tar.xz
118 +
119 + cd "${WORKDIR}" || die
120 + unpack binutils-${PATCH_BINUTILS_VER}-patches-${PATCH_VER}.tar.xz
121 +
122 + # _p patch versions are Gentoo specific tarballs ...
123 + local dir=${P%_p?}
124 + dir=${dir/-hppa64/}
125 +
126 + S=${WORKDIR}/${dir}
127 + fi
128 +
129 + cd "${WORKDIR}" || die
130 + mkdir -p "${MY_BUILDDIR}" || die
131 +}
132 +
133 +src_prepare() {
134 + local patchsetname
135 + if [[ ${PV} == 9999* ]] ; then
136 + patchsetname="from git master"
137 + else
138 + patchsetname="${PATCH_BINUTILS_VER}-${PATCH_VER}"
139 + fi
140 +
141 + if [[ -n ${PATCH_VER} ]] || [[ ${PV} == 9999* ]] ; then
142 + if ! use vanilla; then
143 + einfo "Applying binutils patchset ${patchsetname}"
144 + eapply "${WORKDIR}/patch"
145 + einfo "Done."
146 + fi
147 + fi
148 +
149 + # Make sure our explicit libdir paths don't get clobbered, bug #562460
150 + sed -i \
151 + -e 's:@bfdlibdir@:@libdir@:g' \
152 + -e 's:@bfdincludedir@:@includedir@:g' \
153 + {bfd,opcodes}/Makefile.in || die
154 +
155 + # Fix locale issues if possible, bug #122216
156 + if [[ -e ${FILESDIR}/binutils-configure-LANG.patch ]] ; then
157 + einfo "Fixing misc issues in configure files"
158 + for f in $(find "${S}" -name configure -exec grep -l 'autoconf version 2.13' {} +) ; do
159 + ebegin " Updating ${f/${S}\/}"
160 + patch "${f}" "${FILESDIR}"/binutils-configure-LANG.patch >& "${T}"/configure-patch.log \
161 + || eerror "Please file a bug about this"
162 + eend $?
163 + done
164 + fi
165 +
166 + # Apply things from PATCHES and user dirs
167 + default
168 +
169 + # Run misc portage update scripts
170 + gnuconfig_update
171 + elibtoolize --portage --no-uclibc
172 +}
173 +
174 +toolchain-binutils_bugurl() {
175 + printf "https://bugs.gentoo.org/"
176 +}
177 +toolchain-binutils_pkgversion() {
178 + printf "Gentoo ${PV}"
179 + [[ -n ${PATCH_VER} ]] && printf " p${PATCH_VER}"
180 +}
181 +
182 +src_configure() {
183 + # See https://www.gnu.org/software/make/manual/html_node/Parallel-Output.html
184 + # Avoid really confusing logs from subconfigure spam, makes logs far
185 + # more legible.
186 + MAKEOPTS="--output-sync=line ${MAKEOPTS}"
187 +
188 + # Setup some paths
189 + LIBPATH=/usr/$(get_libdir)/binutils/${CTARGET}/${PV}
190 + INCPATH=${LIBPATH}/include
191 + DATAPATH=/usr/share/binutils-data/${CTARGET}/${PV}
192 + if is_cross ; then
193 + TOOLPATH=/usr/${CHOST}/${CTARGET}
194 + else
195 + TOOLPATH=/usr/${CTARGET}
196 + fi
197 + BINPATH=${TOOLPATH}/binutils-bin/${PV}
198 +
199 + # Make sure we filter $LINGUAS so that only ones that
200 + # actually work make it through, bug #42033
201 + strip-linguas -u */po
202 +
203 + # Keep things sane
204 + strip-flags
205 +
206 + use elibc_musl && append-ldflags -Wl,-z,stack-size=2097152
207 +
208 + local x
209 + echo
210 + for x in CATEGORY CBUILD CHOST CTARGET CFLAGS LDFLAGS ; do
211 + einfo "$(printf '%10s' ${x}:) ${!x}"
212 + done
213 + echo
214 +
215 + cd "${MY_BUILDDIR}" || die
216 + local myconf=()
217 +
218 + if use plugins ; then
219 + myconf+=( --enable-plugins )
220 + fi
221 + # enable gold (installed as ld.gold) and ld's plugin architecture
222 + if use gold ; then
223 + myconf+=( --enable-gold )
224 + if use default-gold; then
225 + myconf+=( --enable-gold=default )
226 + fi
227 + fi
228 +
229 + if use nls ; then
230 + myconf+=( --without-included-gettext )
231 + else
232 + myconf+=( --disable-nls )
233 + fi
234 +
235 + myconf+=( --with-system-zlib )
236 +
237 + # For bi-arch systems, enable a 64bit bfd. This matches the bi-arch
238 + # logic in toolchain.eclass. bug #446946
239 + #
240 + # We used to do it for everyone, but it's slow on 32bit arches. bug #438522
241 + case $(tc-arch) in
242 + ppc|sparc|x86) myconf+=( --enable-64-bit-bfd ) ;;
243 + esac
244 +
245 + use multitarget && myconf+=( --enable-targets=all --enable-64-bit-bfd )
246 +
247 + [[ -n ${CBUILD} ]] && myconf+=( --build=${CBUILD} )
248 +
249 + is_cross && myconf+=(
250 + --with-sysroot="${EPREFIX}"/usr/${CTARGET}
251 + --enable-poison-system-directories
252 + )
253 +
254 + myconf+=( --enable-secureplt )
255 +
256 + # mips can't do hash-style=gnu ...
257 + if [[ $(tc-arch) != mips ]] ; then
258 + myconf+=( --enable-default-hash-style=gnu )
259 + fi
260 +
261 + myconf+=(
262 + --prefix="${EPREFIX}"/usr
263 + --host=${CHOST}
264 + --target=${CTARGET}
265 + --datadir="${EPREFIX}"${DATAPATH}
266 + --datarootdir="${EPREFIX}"${DATAPATH}
267 + --infodir="${EPREFIX}"${DATAPATH}/info
268 + --mandir="${EPREFIX}"${DATAPATH}/man
269 + --bindir="${EPREFIX}"${BINPATH}
270 + --libdir="${EPREFIX}"${LIBPATH}
271 + --libexecdir="${EPREFIX}"${LIBPATH}
272 + --includedir="${EPREFIX}"${INCPATH}
273 + --enable-obsolete
274 + --enable-shared
275 + --enable-threads
276 + # Newer versions (>=2.27) offer a configure flag now.
277 + --enable-relro
278 + # Newer versions (>=2.24) make this an explicit option, bug #497268
279 + --enable-install-libiberty
280 + # Available from 2.35 on
281 + --enable-textrel-check=warning
282 +
283 + # Available from 2.39 on
284 + --enable-warn-execstack
285 + --enable-warn-rwx-segments
286 + # TODO: Available from 2.39+ on but let's try the warning on for a bit
287 + # first... (--enable-warn-execstack)
288 + # Could put it under USE=hardened?
289 + #--enable-default-execstack
290 +
291 + # Things to think about
292 + #--enable-deterministic-archives
293 +
294 + # Works better than vapier's patch, bug #808787
295 + --enable-new-dtags
296 +
297 + --disable-jansson
298 + --disable-werror
299 + --with-bugurl="$(toolchain-binutils_bugurl)"
300 + --with-pkgversion="$(toolchain-binutils_pkgversion)"
301 + $(use_enable static-libs static)
302 + # Disable modules that are in a combined binutils/gdb tree, bug #490566
303 + --disable-{gdb,libdecnumber,readline,sim}
304 + # Strip out broken static link flags.
305 + # https://gcc.gnu.org/PR56750
306 + --without-stage1-ldflags
307 + # Change SONAME to avoid conflict across
308 + # {native,cross}/binutils, binutils-libs. bug #666100
309 + --with-extra-soversion-suffix=gentoo-${CATEGORY}-${PN}-$(usex multitarget mt st)
310 +
311 + # avoid automagic dependency on (currently prefix) systems
312 + # systems with debuginfod library, bug #754753
313 + --without-debuginfod
314 +
315 + # Allow user to opt into CET for host libraries.
316 + # Ideally we would like automagic-or-disabled here.
317 + # But the check does not quite work on i686: bug #760926.
318 + $(use_enable cet)
319 + )
320 +
321 + if ! is_cross ; then
322 + myconf+=( $(use_enable pgo pgo-build lto) )
323 +
324 + if use pgo ; then
325 + export BUILD_CFLAGS="${CFLAGS}"
326 + fi
327 + fi
328 +
329 + ECONF_SOURCE="${S}" econf "${myconf[@]}" || die
330 +
331 + # Prevent makeinfo from running if doc is unset.
332 + if ! use doc ; then
333 + sed -i \
334 + -e '/^MAKEINFO/s:=.*:= true:' \
335 + Makefile || die
336 + fi
337 +}
338 +
339 +src_compile() {
340 + cd "${MY_BUILDDIR}" || die
341 +
342 + # see Note [tooldir hack for ldscripts]
343 + emake V=1 tooldir="${EPREFIX}${TOOLPATH}" all
344 +
345 + # only build info pages if the user wants them
346 + if use doc ; then
347 + emake V=1 info
348 + fi
349 +
350 + # we nuke the manpages when we're left with junk
351 + # (like when we bootstrap, no perl -> no manpages)
352 + find . -name '*.1' -a -size 0 -delete
353 +}
354 +
355 +src_test() {
356 + cd "${MY_BUILDDIR}" || die
357 +
358 + # bug #637066
359 + filter-flags -Wall -Wreturn-type
360 +
361 + emake -k V=1 check
362 +}
363 +
364 +src_install() {
365 + local x d
366 +
367 + cd "${MY_BUILDDIR}" || die
368 +
369 + # see Note [tooldir hack for ldscripts]
370 + emake V=1 DESTDIR="${D}" tooldir="${EPREFIX}${LIBPATH}" install
371 + rm -rf "${ED}"/${LIBPATH}/bin || die
372 + use static-libs || find "${ED}" -name '*.la' -delete
373 +
374 + # Newer versions of binutils get fancy with ${LIBPATH}, bug #171905
375 + cd "${ED}"/${LIBPATH} || die
376 + for d in ../* ; do
377 + [[ ${d} == ../${PV} ]] && continue
378 + mv ${d}/* . || die
379 + rmdir ${d} || die
380 + done
381 +
382 + # Now we collect everything intp the proper SLOT-ed dirs
383 + # When something is built to cross-compile, it installs into
384 + # /usr/$CHOST/ by default ... we have to 'fix' that :)
385 + if is_cross ; then
386 + cd "${ED}"/${BINPATH} || die
387 + for x in * ; do
388 + mv ${x} ${x/${CTARGET}-} || die
389 + done
390 +
391 + if [[ -d ${ED}/usr/${CHOST}/${CTARGET} ]] ; then
392 + mv "${ED}"/usr/${CHOST}/${CTARGET}/include "${ED}"/${INCPATH}
393 + mv "${ED}"/usr/${CHOST}/${CTARGET}/lib/* "${ED}"/${LIBPATH}/
394 + rm -r "${ED}"/usr/${CHOST}/{include,lib}
395 + fi
396 + fi
397 +
398 + insinto ${INCPATH}
399 + local libiberty_headers=(
400 + # Not all the libiberty headers. See libiberty/Makefile.in:install_to_libdir.
401 + demangle.h
402 + dyn-string.h
403 + fibheap.h
404 + hashtab.h
405 + libiberty.h
406 + objalloc.h
407 + splay-tree.h
408 + )
409 + doins "${libiberty_headers[@]/#/${S}/include/}"
410 + if [[ -d ${ED}/${LIBPATH}/lib ]] ; then
411 + mv "${ED}"/${LIBPATH}/lib/* "${ED}"/${LIBPATH}/ || die
412 + rm -r "${ED}"/${LIBPATH}/lib || die
413 + fi
414 +
415 + # Generate an env.d entry for this binutils
416 + insinto /etc/env.d/binutils
417 + cat <<-EOF > "${T}"/env.d
418 + TARGET="${CTARGET}"
419 + VER="${PV}"
420 + LIBPATH="${EPREFIX}${LIBPATH}"
421 + EOF
422 + newins "${T}"/env.d ${CTARGET}-${PV}
423 +
424 + # Handle documentation
425 + if ! is_cross ; then
426 + cd "${S}" || die
427 + dodoc README
428 +
429 + docinto bfd
430 + dodoc bfd/ChangeLog* bfd/README bfd/PORTING bfd/TODO
431 +
432 + docinto binutils
433 + dodoc binutils/ChangeLog binutils/NEWS binutils/README
434 +
435 + docinto gas
436 + dodoc gas/ChangeLog* gas/CONTRIBUTORS gas/NEWS gas/README*
437 +
438 + docinto gprof
439 + dodoc gprof/ChangeLog* gprof/TEST gprof/TODO gprof/bbconv.pl
440 +
441 + docinto ld
442 + dodoc ld/ChangeLog* ld/README ld/NEWS ld/TODO
443 +
444 + docinto libiberty
445 + dodoc libiberty/ChangeLog* libiberty/README
446 +
447 + docinto opcodes
448 + dodoc opcodes/ChangeLog*
449 + fi
450 +
451 + # Remove shared info pages
452 + rm -f "${ED}"/${DATAPATH}/info/{dir,configure.info,standards.info}
453 +
454 + # Trim all empty dirs
455 + find "${ED}" -depth -type d -exec rmdir {} + 2>/dev/null
456 +}
457 +
458 +pkg_postinst() {
459 + # Make sure this ${CTARGET} has a binutils version selected
460 + [[ -e ${EROOT}/etc/env.d/binutils/config-${CTARGET} ]] && return 0
461 + binutils-config ${CTARGET}-${PV}
462 +}
463 +
464 +pkg_postrm() {
465 + local current_profile=$(binutils-config -c ${CTARGET})
466 +
467 + # If no other versions exist, then uninstall for this
468 + # target ... otherwise, switch to the newest version
469 + # Note: only do this if this version is unmerged. We
470 + # rerun binutils-config if this is a remerge, as
471 + # we want the mtimes on the symlinks updated (if
472 + # it is the same as the current selected profile)
473 + if [[ ! -e ${EPREFIX}${BINPATH}/ld ]] && [[ ${current_profile} == ${CTARGET}-${PV} ]] ; then
474 + local choice=$(binutils-config -l | grep ${CTARGET} | awk '{print $2}')
475 + choice=${choice//$'\n'/ }
476 + choice=${choice/* }
477 + if [[ -z ${choice} ]] ; then
478 + binutils-config -u ${CTARGET}
479 + else
480 + binutils-config ${choice}
481 + fi
482 + elif [[ $(CHOST=${CTARGET} binutils-config -c) == ${CTARGET}-${PV} ]] ; then
483 + binutils-config ${CTARGET}-${PV}
484 + fi
485 +}
486 +
487 +# Note [slotting support]
488 +# -----------------------
489 +# Gentoo's layout for binutils files is non-standard as Gentoo
490 +# supports slotted installation for binutils. Many tools
491 +# still expect binutils to reside in known locations.
492 +# binutils-config package restores symlinks into known locations,
493 +# like:
494 +# /usr/bin/${CTARGET}-<tool>
495 +# /usr/bin/${CHOST}/${CTARGET}/lib/ldscrips
496 +# /usr/include/
497 +#
498 +# Note [tooldir hack for ldscripts]
499 +# ---------------------------------
500 +# Build system does not allow ./configure to tweak every location
501 +# we need for slotting binutils hence all the shuffling in
502 +# src_install(). This note is about SCRIPTDIR define handling.
503 +#
504 +# SCRIPTDIR defines 'ldscripts/' directory location. SCRIPTDIR value
505 +# is set at build-time in ld/Makefile.am as: 'scriptdir = $(tooldir)/lib'
506 +# and hardcoded as -DSCRIPTDIR='"$(scriptdir)"' at compile time.
507 +# Thus we can't just move files around after compilation finished.
508 +#
509 +# Our goal is the following:
510 +# - at build-time set scriptdir to point to symlinked location:
511 +# ${TOOLPATH}: /usr/${CHOST} (or /usr/${CHOST}/${CTARGET} for cross-case)
512 +# - at install-time set scriptdir to point to slotted location:
513 +# ${LIBPATH}: /usr/$(get_libdir)/binutils/${CTARGET}/${PV}