Gentoo Archives: gentoo-commits

From: Fabian Groffen <grobian@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/proj/prefix:master commit in: eclass/
Date: Mon, 06 Jun 2022 08:42:49
Message-Id: 1654504897.5027081b510a47cbccec3cabd2dc6504b0484821.grobian@gentoo
1 commit: 5027081b510a47cbccec3cabd2dc6504b0484821
2 Author: Fabian Groffen <grobian <AT> gentoo <DOT> org>
3 AuthorDate: Mon Jun 6 08:41:37 2022 +0000
4 Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org>
5 CommitDate: Mon Jun 6 08:41:37 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=5027081b
7
8 toolchain.eclass: sync with gx86
9
10 Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>
11
12 eclass/toolchain.eclass | 1327 +++++++++++++++++++++++++++--------------------
13 1 file changed, 751 insertions(+), 576 deletions(-)
14
15 diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass
16 index a07f9b680e..ed8c227c4a 100644
17 --- a/eclass/toolchain.eclass
18 +++ b/eclass/toolchain.eclass
19 @@ -1,23 +1,33 @@
20 -# Copyright 1999-2021 Gentoo Authors
21 +# Copyright 1999-2022 Gentoo Authors
22 # Distributed under the terms of the GNU General Public License v2
23
24 -# Maintainer: Toolchain Ninjas <toolchain@g.o>
25 -# @SUPPORTED_EAPIS: 5 6 7
26 +# @ECLASS: toolchain.eclass
27 +# @MAINTAINER:
28 +# Toolchain Ninjas <toolchain@g.o>
29 +# @SUPPORTED_EAPIS: 7 8
30 +# @BLURB: Common code for sys-devel/gcc ebuilds
31 +
32 +case ${EAPI} in
33 + 7) inherit eutils ;;
34 + 8) ;;
35 + *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
36 +esac
37 +
38 +if [[ ! ${_TOOLCHAIN_ECLASS} ]]; then
39 +_TOOLCHAIN_ECLASS=1
40
41 DESCRIPTION="The GNU Compiler Collection"
42 HOMEPAGE="https://gcc.gnu.org/"
43
44 -# TODO: Please audit this inherit list on future EAPI bumps and ideally
45 -# conditonalise them where possible.
46 -inherit eutils flag-o-matic gnuconfig libtool multilib pax-utils toolchain-funcs prefix
47 +inherit edo flag-o-matic gnuconfig libtool multilib pax-utils toolchain-funcs prefix
48
49 tc_is_live() {
50 [[ ${PV} == *9999* ]]
51 }
52
53 if tc_is_live ; then
54 - EGIT_REPO_URI="https://gcc.gnu.org/git/gcc.git"
55 - # naming style:
56 + EGIT_REPO_URI="https://gcc.gnu.org/git/gcc.git https://github.com/gcc-mirror/gcc"
57 + # Naming style:
58 # gcc-10.1.0_pre9999 -> gcc-10-branch
59 # Note that the micro version is required or lots of stuff will break.
60 # To checkout master set gcc_LIVE_BRANCH="master" in the ebuild before
61 @@ -25,20 +35,12 @@ if tc_is_live ; then
62 EGIT_BRANCH="releases/${PN}-${PV%.?.?_pre9999}"
63 EGIT_BRANCH=${EGIT_BRANCH//./_}
64 inherit git-r3
65 +elif [[ -n ${TOOLCHAIN_USE_GIT_PATCHES} ]] ; then
66 + inherit git-r3
67 fi
68
69 FEATURES=${FEATURES/multilib-strict/}
70
71 -case ${EAPI:-0} in
72 - 0|1|2|3|4*) die "Need to upgrade to at least EAPI=5" ;;
73 - 5*|6) inherit eapi7-ver ;;
74 - 7) ;;
75 - *) die "I don't speak EAPI ${EAPI}." ;;
76 -esac
77 -
78 -EXPORT_FUNCTIONS pkg_pretend pkg_setup src_unpack src_prepare src_configure \
79 - src_compile src_test src_install pkg_postinst pkg_postrm
80 -
81 #---->> globals <<----
82
83 export CTARGET=${CTARGET:-${CHOST}}
84 @@ -58,50 +60,116 @@ is_crosscompile() {
85 # The target prefix defaults to the host prefix, except for cross compilers, which targets the empty prefix by default.
86 : ${TPREFIX:=$(is_crosscompile || echo "${EPREFIX}")}
87
88 -# General purpose version check. Without a second arg matches up to minor version (x.x.x)
89 +# @FUNCTION: tc_version_is_at_least
90 +# @USAGE: ver1 [ver2]
91 +# @DESCRIPTION:
92 +# General purpose version check. Without a second argument, matches
93 +# up to minor version (x.x.x).
94 tc_version_is_at_least() {
95 ver_test "${2:-${GCC_RELEASE_VER}}" -ge "$1"
96 }
97
98 -# General purpose version range check
99 +# @FUNCTION: tc_version_is_between
100 +# @USAGE: ver1 ver2
101 +# @DESCRIPTION:
102 +# General purpose version range check.
103 # Note that it matches up to but NOT including the second version
104 tc_version_is_between() {
105 tc_version_is_at_least "${1}" && ! tc_version_is_at_least "${2}"
106 }
107
108 +# @ECLASS_VARIABLE: TOOLCHAIN_GCC_PV
109 +# @DEFAULT_UNSET
110 +# @DESCRIPTION:
111 +# Used to override GCC version. Useful for e.g. live ebuilds or snapshots.
112 +# Defaults to ${PV}.
113 +
114 +# @ECLASS_VARIABLE: TOOLCHAIN_USE_GIT_PATCHES
115 +# @DEFAULT_UNSET
116 +# @DESCRIPTION:
117 +# Used to force fetching patches from git. Useful for non-released versions
118 +# of GCC where we don't want to keep creating patchset tarballs for a new
119 +# release series (e.g. suppose 12.0 just got released, then adding snapshots
120 +# for 13.0, we don't want to create new patchsets for every single 13.0 snapshot,
121 +# so just grab patches from git each time if this variable is set).
122 +
123 +# @ECLASS_VARIABLE: TOOLCHAIN_PATCH_DEV
124 +# @DEFAULT_UNSET
125 +# @DESCRIPTION:
126 +# Indicate the developer who hosts the patchset for an ebuild.
127 +
128 +# @ECLASS_VARIABLE: GCC_PV
129 +# @INTERNAL
130 +# @DESCRIPTION:
131 +# Internal variable representing (spoofed) GCC version.
132 GCC_PV=${TOOLCHAIN_GCC_PV:-${PV}}
133 +
134 +# @ECLASS_VARIABLE: GCC_PVR
135 +# @INTERNAL
136 +# @DESCRIPTION:
137 +# Full GCC version including revision.
138 GCC_PVR=${GCC_PV}
139 [[ ${PR} != "r0" ]] && GCC_PVR=${GCC_PVR}-${PR}
140
141 +# @ECLASS_VARIABLE: GCC_RELEASE_VER
142 +# @INTERNAL
143 +# @DESCRIPTION:
144 # GCC_RELEASE_VER must always match 'gcc/BASE-VER' value.
145 # It's an internal representation of gcc version used for:
146 # - versioned paths on disk
147 # - 'gcc -dumpversion' output. Must always match <digit>.<digit>.<digit>.
148 GCC_RELEASE_VER=$(ver_cut 1-3 ${GCC_PV})
149
150 +# @ECLASS_VARIABLE: GCC_BRANCH_VER
151 +# @INTERNAL
152 +# @DESCRIPTION:
153 +# GCC branch version.
154 GCC_BRANCH_VER=$(ver_cut 1-2 ${GCC_PV})
155 +# @ECLASS_VARIABLE: GCCMAJOR
156 +# @INTERNAL
157 +# @DESCRIPTION:
158 +# Major GCC version.
159 GCCMAJOR=$(ver_cut 1 ${GCC_PV})
160 +# @ECLASS_VARIABLE: GCCMINOR
161 +# @INTERNAL
162 +# @DESCRIPTION:
163 +# Minor GCC version.
164 GCCMINOR=$(ver_cut 2 ${GCC_PV})
165 +# @ECLASS_VARIABLE: GCCMICRO
166 +# @INTERNAL
167 +# @DESCRIPTION:
168 +# GCC micro version.
169 GCCMICRO=$(ver_cut 3 ${GCC_PV})
170
171 +# @ECLASS_VARIABLE: GCC_CONFIG_VER
172 +# @INTERNAL
173 +# @DESCRIPTION:
174 # Ideally this variable should allow for custom gentoo versioning
175 # of binary and gcc-config names not directly tied to upstream
176 -# versioning. In practive it's hard to untangle from gcc/BASE-VER
177 +# versioning. In practice it's hard to untangle from gcc/BASE-VER
178 # (GCC_RELEASE_VER) value.
179 GCC_CONFIG_VER=${GCC_RELEASE_VER}
180
181 # Pre-release support. Versioning schema:
182 # 1.0.0_pre9999: live ebuild
183 -# 1.2.3_alphaYYYYMMDD: weekly snapshots
184 +# 1.2.3_pYYYYMMDD (or 1.2.3_preYYYYMMDD for unreleased major versions): weekly snapshots
185 # 1.2.3_rcYYYYMMDD: release candidates
186 -if [[ ${GCC_PV} == *_alpha* ]] ; then
187 - # weekly snapshots
188 - SNAPSHOT=${GCCMAJOR}-${GCC_PV##*_alpha}
189 +if [[ ${GCC_PV} == *_pre* ]] ; then
190 + # Weekly snapshots
191 + SNAPSHOT=${GCCMAJOR}-${GCC_PV##*_pre}
192 +elif [[ ${GCC_PV} == *_p* ]] ; then
193 + # Weekly snapshots
194 + SNAPSHOT=${GCCMAJOR}-${GCC_PV##*_p}
195 elif [[ ${GCC_PV} == *_rc* ]] ; then
196 - # release candidates
197 + # Release candidates
198 SNAPSHOT=${GCC_PV%_rc*}-RC-${GCC_PV##*_rc}
199 fi
200
201 +# Require minimum gcc version to simplify assumptions.
202 +# Normally we would require gcc-6+ (based on sys-devel/gcc)
203 +# but we still have sys-devel/gcc-apple-4.2.1_p5666.
204 +tc_version_is_at_least 4.2.1 || die "${ECLASS}: ${GCC_RELEASE_VER} is too old."
205 +
206 PREFIX=${TOOLCHAIN_PREFIX:-${EPREFIX}/usr}
207
208 LIBPATH=${TOOLCHAIN_LIBPATH:-${PREFIX}/lib/gcc/${CTARGET}/${GCC_CONFIG_VER}}
209 @@ -116,7 +184,7 @@ fi
210
211 DATAPATH=${TOOLCHAIN_DATAPATH:-${PREFIX}/share/gcc-data/${CTARGET}/${GCC_CONFIG_VER}}
212
213 -# Dont install in /usr/include/g++-v3/, but in gcc internal directory.
214 +# Don't install in /usr/include/g++-v3/, but instead to gcc's internal directory.
215 # We will handle /usr/include/g++-v3/ with gcc-config ...
216 STDCXX_INCDIR=${TOOLCHAIN_STDCXX_INCDIR:-${LIBPATH}/include/g++-v${GCC_BRANCH_VER/\.*/}}
217
218 @@ -126,46 +194,33 @@ LICENSE="GPL-3+ LGPL-3+ || ( GPL-3+ libgcc libstdc++ gcc-runtime-library-excepti
219 IUSE="test vanilla +nls"
220 RESTRICT="!test? ( test )"
221
222 -tc_supports_dostrip() {
223 - case ${EAPI:-0} in
224 - 5*|6) return 1 ;;
225 - 7) return 0 ;;
226 - *) die "Update apply_patches() for ${EAPI}." ;;
227 - esac
228 -}
229 -
230 -tc_supports_dostrip || RESTRICT+=" strip" # cross-compilers need controlled stripping
231 -
232 TC_FEATURES=()
233
234 tc_has_feature() {
235 has "$1" "${TC_FEATURES[@]}"
236 }
237
238 -if [[ ${PN} != "kgcc64" && ${PN} != gcc-* ]] ; then
239 - # --enable-altivec was dropped before gcc-4. We don't set it.
240 - # We drop USE=altivec for newer gccs only to avoid rebuilds
241 - # for most stable users. Once gcc-10 is stable we can drop it.
242 - if ! tc_version_is_at_least 10; then
243 - IUSE+=" altivec"
244 - fi
245 - IUSE+=" debug +cxx +nptl" TC_FEATURES+=(nptl)
246 +# Prefix: allow gcc-apple post 4.2.1
247 +if [[ ${PN} != "kgcc64" && ${PN} != gcc-* ]] ||
248 + [[ ${PN} == "gcc-apple" && tc_version_is_at_least 12.1 ]] ; then
249 + IUSE+=" debug +cxx +nptl" TC_FEATURES+=( nptl )
250 [[ -n ${PIE_VER} ]] && IUSE+=" nopie"
251 [[ -n ${SPECS_VER} ]] && IUSE+=" nossp"
252 - # fortran support appeared in 4.1, but 4.1 needs outdated mpfr
253 - tc_version_is_at_least 4.2 && IUSE+=" +fortran" TC_FEATURES+=(fortran)
254 - tc_version_is_at_least 3 && IUSE+=" doc hardened multilib objc"
255 - tc_version_is_between 3 7 && IUSE+=" awt gcj" TC_FEATURES+=(gcj)
256 - tc_version_is_at_least 3.3 && IUSE+=" pgo"
257 - tc_version_is_at_least 4.0 &&
258 - IUSE+=" objc-gc" TC_FEATURES+=(objc-gc)
259 - tc_version_is_at_least 4.1 && IUSE+=" libssp objc++"
260 - tc_version_is_at_least 4.2 && IUSE+=" +openmp"
261 + IUSE+=" +fortran" TC_FEATURES+=( fortran )
262 + IUSE+=" doc hardened multilib objc"
263 + tc_version_is_between 3 7 && IUSE+=" awt gcj" TC_FEATURES+=( gcj )
264 + IUSE+=" pgo"
265 + IUSE+=" objc-gc" TC_FEATURES+=( objc-gc )
266 + IUSE+=" libssp objc++"
267 + IUSE+=" +openmp"
268 +
269 tc_version_is_at_least 4.3 && IUSE+=" fixed-point"
270 tc_version_is_at_least 4.7 && IUSE+=" go"
271 +
272 # sanitizer support appeared in gcc-4.8, but <gcc-5 does not
273 # support modern glibc.
274 - tc_version_is_at_least 5 && IUSE+=" +sanitize"
275 + tc_version_is_at_least 5 && IUSE+=" +sanitize" TC_FEATURES+=( sanitize )
276 +
277 # Note:
278 # <gcc-4.8 supported graphite, it required forked ppl
279 # versions which we dropped. Since graphite was also experimental in
280 @@ -173,28 +228,24 @@ if [[ ${PN} != "kgcc64" && ${PN} != gcc-* ]] ; then
281 # <gcc-5 supported graphite, it required cloog
282 # <gcc-6.5 supported graphite, it required old incompatible isl
283 tc_version_is_at_least 6.5 &&
284 - IUSE+=" graphite" TC_FEATURES+=(graphite)
285 + IUSE+=" graphite" TC_FEATURES+=( graphite )
286 +
287 tc_version_is_between 4.9 8 && IUSE+=" cilk"
288 tc_version_is_at_least 4.9 && IUSE+=" ada"
289 -
290 - # Don't enable USE=vtv starting from gcc-10. Once gcc-10
291 - # stable everywhere disable by default on older versions
292 - # as well.
293 - if tc_version_is_at_least 10; then
294 - IUSE+=" vtv"
295 - elif tc_version_is_at_least 4.9; then
296 - IUSE+=" +vtv"
297 - fi
298 + tc_version_is_at_least 4.9 && IUSE+=" vtv"
299 tc_version_is_at_least 5.0 && IUSE+=" jit"
300 tc_version_is_between 5.0 9 && IUSE+=" mpx"
301 tc_version_is_at_least 6.0 && IUSE+=" +pie +ssp +pch"
302 +
303 # systemtap is a gentoo-specific switch: bug #654748
304 tc_version_is_at_least 8.0 &&
305 - IUSE+=" systemtap" TC_FEATURES+=(systemtap)
306 + IUSE+=" systemtap" TC_FEATURES+=( systemtap )
307 +
308 tc_version_is_at_least 9.0 && IUSE+=" d"
309 tc_version_is_at_least 9.1 && IUSE+=" lto"
310 - tc_version_is_at_least 10 && IUSE+=" zstd" TC_FEATURES+=(zstd)
311 - tc_version_is_at_least 11 && IUSE+=" valgrind" TC_FEATURES+=(valgrind)
312 + tc_version_is_at_least 10 && IUSE+=" cet"
313 + tc_version_is_at_least 10 && IUSE+=" zstd" TC_FEATURES+=( zstd )
314 + tc_version_is_at_least 11 && IUSE+=" valgrind" TC_FEATURES+=( valgrind )
315 tc_version_is_at_least 11 && IUSE+=" custom-cflags"
316 fi
317
318 @@ -209,17 +260,15 @@ fi
319 #---->> DEPEND <<----
320
321 RDEPEND="sys-libs/zlib
322 - nls? ( virtual/libintl )"
323 -
324 -tc_version_is_at_least 3 && RDEPEND+=" virtual/libiconv"
325 -
326 -if tc_version_is_at_least 4 ; then
327 - GMP_MPFR_DEPS=">=dev-libs/gmp-4.3.2:0= >=dev-libs/mpfr-2.4.2:0="
328 - if tc_version_is_at_least 4.3 ; then
329 - RDEPEND+=" ${GMP_MPFR_DEPS}"
330 - elif tc_has_feature fortran ; then
331 - RDEPEND+=" fortran? ( ${GMP_MPFR_DEPS} )"
332 - fi
333 + virtual/libiconv
334 + nls? ( virtual/libintl )
335 +"
336 +
337 +GMP_MPFR_DEPS=">=dev-libs/gmp-4.3.2:0= >=dev-libs/mpfr-2.4.2:0="
338 +if tc_version_is_at_least 4.3 ; then
339 + RDEPEND+=" ${GMP_MPFR_DEPS}"
340 +elif tc_has_feature fortran ; then
341 + RDEPEND+=" fortran? ( ${GMP_MPFR_DEPS} )"
342 fi
343
344 tc_version_is_at_least 4.5 && RDEPEND+=" >=dev-libs/mpc-0.8.1:0="
345 @@ -245,24 +294,28 @@ BDEPEND="
346 DEPEND="${RDEPEND}"
347
348 if tc_has_feature gcj ; then
349 - GCJ_DEPS=">=media-libs/libart_lgpl-2.1"
350 - GCJ_GTK_DEPS="
351 - x11-base/xorg-proto
352 - x11-libs/libXt
353 - x11-libs/libX11
354 - x11-libs/libXtst
355 - =x11-libs/gtk+-2*
356 - virtual/pkgconfig
357 + DEPEND+="
358 + gcj? (
359 + app-arch/zip
360 + app-arch/unzip
361 + >=media-libs/libart_lgpl-2.1
362 + awt? (
363 + x11-base/xorg-proto
364 + x11-libs/libXt
365 + x11-libs/libX11
366 + x11-libs/libXtst
367 + =x11-libs/gtk+-2*
368 + x11-libs/pango
369 + virtual/pkgconfig
370 + )
371 + )
372 "
373 - tc_version_is_at_least 3.4 && GCJ_GTK_DEPS+=" x11-libs/pango"
374 - tc_version_is_at_least 4.2 && GCJ_DEPS+=" app-arch/zip app-arch/unzip"
375 - DEPEND+=" gcj? ( awt? ( ${GCJ_GTK_DEPS} ) ${GCJ_DEPS} )"
376 fi
377
378 if tc_has_feature sanitize ; then
379 # libsanitizer relies on 'crypt.h' to be present
380 - # on target. glibc used to provide it unconditionally.
381 - # Nowadays it's a standalone library: #802648
382 + # on target. glibc user to provide it unconditionally.
383 + # Nowadays it's a standalone library: bug #802648
384 DEPEND+=" sanitize? ( virtual/libcrypt )"
385 fi
386
387 @@ -272,40 +325,86 @@ if tc_has_feature systemtap ; then
388 fi
389
390 if tc_has_feature zstd ; then
391 - DEPEND+=" zstd? ( app-arch/zstd )"
392 + DEPEND+=" zstd? ( app-arch/zstd:= )"
393 + RDEPEND+=" zstd? ( app-arch/zstd:= )"
394 fi
395
396 if tc_has_feature valgrind; then
397 BDEPEND+=" valgrind? ( dev-util/valgrind )"
398 fi
399
400 -case ${EAPI:-0} in
401 - 5*|6) DEPEND+=" ${BDEPEND}" ;;
402 -esac
403 -
404 # Prefix: our version is 1.9, so can't go with gx86's 2.3
405 -PDEPEND=">=sys-devel/gcc-config-1.7"
406 +PDEPEND=">=sys-devel/gcc-config-1.9"
407
408 #---->> S + SRC_URI essentials <<----
409
410 +# @ECLASS_VARIABLE: TOOLCHAIN_PATCH_SUFFIX
411 +# @DESCRIPTION:
412 +# Used to override compression used for for patchsets.
413 +# Default is xz for EAPI 8+ and bz2 for older EAPIs.
414 +if [[ ${EAPI} == 8 ]] ; then
415 + : ${TOOLCHAIN_PATCH_SUFFIX:=xz}
416 +else
417 + # Older EAPIs
418 + : ${TOOLCHAIN_PATCH_SUFFIX:=bz2}
419 +fi
420 +
421 +# @ECLASS_VARIABLE: TOOLCHAIN_SET_S
422 +# @DESCRIPTION:
423 +# Used to override value of S for snapshots and such. Mainly useful
424 +# if needing to set GCC_TARBALL_SRC_URI.
425 +: ${TOOLCHAIN_SET_S:=yes}
426 +
427 # Set the source directory depending on whether we're using
428 # a live git tree, snapshot, or release tarball.
429 -S=$(
430 - if tc_is_live ; then
431 - echo ${EGIT_CHECKOUT_DIR}
432 - elif [[ -n ${SNAPSHOT} ]] ; then
433 - echo ${WORKDIR}/gcc-${SNAPSHOT}
434 - else
435 - echo ${WORKDIR}/gcc-${GCC_RELEASE_VER}
436 - fi
437 -)
438 +if [[ ${TOOLCHAIN_SET_S} == yes ]] ; then
439 + S=$(
440 + if tc_is_live ; then
441 + echo ${EGIT_CHECKOUT_DIR}
442 + elif [[ -n ${SNAPSHOT} ]] ; then
443 + echo ${WORKDIR}/gcc-${SNAPSHOT}
444 + else
445 + echo ${WORKDIR}/gcc-${GCC_RELEASE_VER}
446 + fi
447 + )
448 +fi
449
450 gentoo_urls() {
451 - local devspace="HTTP~vapier/dist/URI HTTP~rhill/dist/URI
452 - HTTP~zorry/patches/gcc/URI HTTP~blueness/dist/URI
453 - HTTP~tamiko/distfiles/URI HTTP~sam/distfiles/URI HTTP~slyfox/distfiles/URI"
454 + # slyfox's distfiles are mirrored to sam's devspace
455 + declare -A devspace_urls=(
456 + [soap]=HTTP~soap/distfiles/URI
457 + [sam]=HTTP~sam/distfiles/sys-devel/gcc/URI
458 + [slyfox]=HTTP~sam/distfiles/URI
459 + [tamiko]=HTTP~tamiko/distfiles/URI
460 + [zorry]=HTTP~zorry/patches/gcc/URI
461 + [vapier]=HTTP~vapier/dist/URI
462 + [blueness]=HTTP~blueness/dist/URI
463 + )
464 +
465 + # Newer ebuilds should set TOOLCHAIN_PATCH_DEV and we'll just
466 + # return the full URL from the array.
467 + if [[ -n ${TOOLCHAIN_PATCH_DEV} ]] ; then
468 + local devspace_url=${devspace_urls[${TOOLCHAIN_PATCH_DEV}]}
469 + if [[ -n ${devspace_url} ]] ; then
470 + local devspace_url_exp=${devspace_url//HTTP/https:\/\/dev.gentoo.org\/}
471 + devspace_url_exp=${devspace_url_exp//URI/$1}
472 + echo ${devspace_url_exp}
473 + return
474 + fi
475 + fi
476 +
477 + # But we keep the old fallback list for compatibility with
478 + # older ebuilds (overlays etc).
479 + local devspace="
480 + HTTP~soap/distfiles/URI
481 + HTTP~sam/distfiles/URI
482 + HTTP~sam/distfiles/sys-devel/gcc/URI
483 + HTTP~tamiko/distfiles/URI
484 + HTTP~zorry/patches/gcc/URI
485 + HTTP~vapier/dist/URI
486 + HTTP~blueness/dist/URI"
487 devspace=${devspace//HTTP/https:\/\/dev.gentoo.org\/}
488 - echo mirror://gentoo/$1 ${devspace//URI/$1}
489 + echo ${devspace//URI/$1} mirror://gentoo/$1
490 }
491
492 # This function handles the basics of setting the SRC_URI for a gcc ebuild.
493 @@ -330,19 +429,19 @@ gentoo_urls() {
494 # PATCH_GCC_VER
495 # This should be set to the version of the gentoo patch tarball.
496 # The resulting filename of this tarball will be:
497 -# gcc-${PATCH_GCC_VER:-${GCC_RELEASE_VER}}-patches-${PATCH_VER}.tar.bz2
498 +# gcc-${PATCH_GCC_VER:-${GCC_RELEASE_VER}}-patches-${PATCH_VER}.tar.xz
499 #
500 # PIE_VER
501 # PIE_GCC_VER
502 # These variables control patching in various updates for the logic
503 -# controlling Position Independant Executables. PIE_VER is expected
504 +# controlling Position Independent Executables. PIE_VER is expected
505 # to be the version of this patch, and PIE_GCC_VER the gcc version of
506 # the patch:
507 # An example:
508 # PIE_VER="8.7.6.5"
509 # PIE_GCC_VER="3.4.0"
510 # The resulting filename of this tarball will be:
511 -# gcc-${PIE_GCC_VER:-${GCC_RELEASE_VER}}-piepatches-v${PIE_VER}.tar.bz2
512 +# gcc-${PIE_GCC_VER:-${GCC_RELEASE_VER}}-piepatches-v${PIE_VER}.tar.xz
513 #
514 # SPECS_VER
515 # SPECS_GCC_VER
516 @@ -354,7 +453,7 @@ gentoo_urls() {
517 # SPECS_VER="8.7.6.5"
518 # SPECS_GCC_VER="3.4.0"
519 # The resulting filename of this tarball will be:
520 -# gcc-${SPECS_GCC_VER:-${GCC_RELEASE_VER}}-specs-${SPECS_VER}.tar.bz2
521 +# gcc-${SPECS_GCC_VER:-${GCC_RELEASE_VER}}-specs-${SPECS_VER}.tar.xz
522 #
523 # CYGWINPORTS_GITREV
524 # If set, this variable signals that we should apply additional patches
525 @@ -365,7 +464,7 @@ gentoo_urls() {
526 # with a Cygwin target.
527 get_gcc_src_uri() {
528 export PATCH_GCC_VER=${PATCH_GCC_VER:-${GCC_RELEASE_VER}}
529 - export UCLIBC_GCC_VER=${UCLIBC_GCC_VER:-${PATCH_GCC_VER}}
530 + export MUSL_GCC_VER=${MUSL_GCC_VER:-${PATCH_GCC_VER}}
531 export PIE_GCC_VER=${PIE_GCC_VER:-${GCC_RELEASE_VER}}
532 export HTB_GCC_VER=${HTB_GCC_VER:-${GCC_RELEASE_VER}}
533 export SPECS_GCC_VER=${SPECS_GCC_VER:-${GCC_RELEASE_VER}}
534 @@ -375,10 +474,10 @@ get_gcc_src_uri() {
535 if tc_is_live ; then
536 : # Nothing to do w/git snapshots.
537 elif [[ -n ${GCC_TARBALL_SRC_URI} ]] ; then
538 - # pull gcc tarball from another location. Frequently used by gnat-gpl.
539 + # Pull gcc tarball from another location. Frequently used by gnat-gpl.
540 GCC_SRC_URI="${GCC_TARBALL_SRC_URI}"
541 elif [[ -n ${SNAPSHOT} ]] ; then
542 - GCC_SRC_URI="ftp://gcc.gnu.org/pub/gcc/snapshots/${SNAPSHOT}/gcc-${SNAPSHOT}.tar.xz"
543 + GCC_SRC_URI="https://gcc.gnu.org/pub/gcc/snapshots/${SNAPSHOT}/gcc-${SNAPSHOT}.tar.xz"
544 else
545 if tc_version_is_between 5.5 6 || tc_version_is_between 6.4 7 || tc_version_is_at_least 7.2 ; then
546 GCC_SRC_URI="mirror://gnu/gcc/gcc-${GCC_PV}/gcc-${GCC_RELEASE_VER}.tar.xz"
547 @@ -387,18 +486,18 @@ get_gcc_src_uri() {
548 fi
549 fi
550
551 - [[ -n ${UCLIBC_VER} ]] && \
552 - GCC_SRC_URI+=" $(gentoo_urls gcc-${UCLIBC_GCC_VER}-uclibc-patches-${UCLIBC_VER}.tar.bz2)"
553 [[ -n ${PATCH_VER} ]] && \
554 - GCC_SRC_URI+=" $(gentoo_urls gcc-${PATCH_GCC_VER}-patches-${PATCH_VER}.tar.bz2)"
555 + GCC_SRC_URI+=" $(gentoo_urls gcc-${PATCH_GCC_VER}-patches-${PATCH_VER}.tar.${TOOLCHAIN_PATCH_SUFFIX})"
556 + [[ -n ${MUSL_VER} ]] && \
557 + GCC_SRC_URI+=" $(gentoo_urls gcc-${MUSL_GCC_VER}-musl-patches-${MUSL_VER}.tar.${TOOLCHAIN_PATCH_SUFFIX})"
558
559 [[ -n ${PIE_VER} ]] && \
560 - PIE_CORE=${PIE_CORE:-gcc-${PIE_GCC_VER}-piepatches-v${PIE_VER}.tar.bz2} && \
561 + PIE_CORE=${PIE_CORE:-gcc-${PIE_GCC_VER}-piepatches-v${PIE_VER}.tar.${TOOLCHAIN_PATCH_SUFFIX}} && \
562 GCC_SRC_URI+=" $(gentoo_urls ${PIE_CORE})"
563
564 # gcc minispec for the hardened gcc 4 compiler
565 [[ -n ${SPECS_VER} ]] && \
566 - GCC_SRC_URI+=" $(gentoo_urls gcc-${SPECS_GCC_VER}-specs-${SPECS_VER}.tar.bz2)"
567 + GCC_SRC_URI+=" $(gentoo_urls gcc-${SPECS_GCC_VER}-specs-${SPECS_VER}.tar.${TOOLCHAIN_PATCH_SUFFIX})"
568
569 if tc_has_feature gcj ; then
570 if tc_version_is_at_least 4.5 ; then
571 @@ -436,9 +535,40 @@ toolchain_pkg_pretend() {
572 #---->> pkg_setup <<----
573
574 toolchain_pkg_setup() {
575 - # we dont want to use the installed compiler's specs to build gcc
576 + # We don't want to use the installed compiler's specs to build gcc
577 unset GCC_SPECS
578 - unset LANGUAGES #265283
579 +
580 + # bug #265283
581 + unset LANGUAGES
582 +
583 + # See https://www.gnu.org/software/make/manual/html_node/Parallel-Output.html
584 + # Avoid really confusing logs from subconfigure spam, makes logs far
585 + # more legible.
586 + MAKEOPTS="--output-sync=line ${MAKEOPTS}"
587 +}
588 +
589 +#---->> src_unpack <<----
590 +
591 +# @FUNCTION: toolchain_fetch_git_patches
592 +# @INTERNAL
593 +# @DESCRIPTION:
594 +# Fetch patches from Gentoo's gcc-patches repository.
595 +toolchain_fetch_git_patches() {
596 + local gcc_patches_repo="https://anongit.gentoo.org/git/proj/gcc-patches.git https://github.com/gentoo/gcc-patches"
597 +
598 + # If we weren't given a patchset number, pull it from git too.
599 + einfo "Fetching patchset from git as PATCH_VER is unset"
600 + EGIT_REPO_URI=${gcc_patches_repo} EGIT_BRANCH="master" \
601 + EGIT_CHECKOUT_DIR="${WORKDIR}"/patch.tmp \
602 + git-r3_src_unpack
603 +
604 + mkdir "${WORKDIR}"/patch || die
605 + mv "${WORKDIR}"/patch.tmp/${PATCH_GCC_VER}/gentoo/* "${WORKDIR}"/patch || die
606 +
607 + if [[ -n ${MUSL_VER} || -d "${WORKDIR}"/musl ]] && [[ ${CTARGET} == *musl* ]] ; then
608 + mkdir "${WORKDIR}"/musl || die
609 + mv "${WORKDIR}"/patch.tmp/${PATCH_GCC_VER}/musl/* "${WORKDIR}"/musl || die
610 + fi
611
612 # yuck, but how else to do it portable?
613 local realEPREFIX=$(python -c 'import os; print(os.path.realpath("'"${EPREFIX}"'"))')
614 @@ -450,37 +580,25 @@ toolchain_pkg_setup() {
615 fi
616 }
617
618 -#---->> src_unpack <<----
619 -
620 toolchain_src_unpack() {
621 if tc_is_live ; then
622 git-r3_src_unpack
623 +
624 + if [[ -z ${PATCH_VER} ]] && ! use vanilla ; then
625 + toolchain_fetch_git_patches
626 + fi
627 + elif [[ -z ${PATCH_VER} && -n ${TOOLCHAIN_USE_GIT_PATCHES} ]] ; then
628 + toolchain_fetch_git_patches
629 fi
630
631 - default_src_unpack
632 + default
633 }
634
635 #---->> src_prepare <<----
636
637 -# 'epatch' is not available in EAPI=7. Abstract away patchset application
638 -# until we eventually get all gcc ebuilds on EAPI=7 or later.
639 -tc_apply_patches() {
640 - [[ ${#@} -lt 2 ]] && die "usage: tc_apply_patches <message> <patches...>"
641 -
642 - einfo "$1"; shift
643 -
644 - case ${EAPI:-0} in
645 - # Note: even for EAPI=6 we used 'epatch' semantics. To avoid
646 - # breaking existing ebuilds use 'eapply' only in EAPI=7 or later.
647 - 5*|6) epatch "$@" ;;
648 - 7) eapply "$@" ;;
649 - *) die "Update apply_patches() for ${EAPI}." ;;
650 - esac
651 -}
652 -
653 toolchain_src_prepare() {
654 export BRANDING_GCC_PKGVERSION="Gentoo ${GCC_PVR}"
655 - cd "${S}"
656 + cd "${S}" || die
657
658 do_gcc_gentoo_patches
659 do_gcc_PIE_patches
660 @@ -490,11 +608,7 @@ toolchain_src_prepare() {
661 BRANDING_GCC_PKGVERSION="${BRANDING_GCC_PKGVERSION}, commit ${EGIT_VERSION}"
662 fi
663
664 - case ${EAPI:-0} in
665 - 5*) epatch_user;;
666 - 6|7) eapply_user ;;
667 - *) die "Update toolchain_src_prepare() for ${EAPI}." ;;
668 - esac
669 + eapply_user
670
671 if ( tc_version_is_at_least 4.8.2 || _tc_use_if_iuse hardened ) \
672 && ! use vanilla ; then
673 @@ -509,11 +623,11 @@ toolchain_src_prepare() {
674 sed -i -e "/\"\/System\/Library\/Frameworks\"\,/i\ \ \"${EPREFIX}/MacOSX.sdk/System/Library/Frameworks\"\, \"${EPREFIX}/Frameworks\"\, " \
675 "${S}"/gcc/config/darwin-c.c || die "sed gcc/config/darwin-c.c failed"
676
677 - # make sure the pkg config files install into multilib dirs.
678 - # since we configure with just one --libdir, we can't use that
679 - # (as gcc itself takes care of building multilibs). #435728
680 + # Make sure the pkg-config files install into multilib dirs.
681 + # Since we configure with just one --libdir, we can't use that
682 + # (as gcc itself takes care of building multilibs). bug #435728
683 find "${S}" -name Makefile.in \
684 - -exec sed -i '/^pkgconfigdir/s:=.*:=$(toolexeclibdir)/pkgconfig:' {} +
685 + -exec sed -i '/^pkgconfigdir/s:=.*:=$(toolexeclibdir)/pkgconfig:' {} + || die
686
687 setup_multilib_osdirnames
688 gcc_version_patch
689 @@ -546,7 +660,7 @@ toolchain_src_prepare() {
690
691 gnuconfig_update
692
693 - # update configure files
694 + # Update configure files
695 local f
696 einfo "Fixing misc issues in configure files"
697 for f in $(grep -l 'autoconf version 2.13' $(find "${S}" -name configure)) ; do
698 @@ -555,12 +669,12 @@ toolchain_src_prepare() {
699 || eerror "Please file a bug about this"
700 eend $?
701 done
702 - sed -i 's|A-Za-z0-9|[:alnum:]|g' "${S}"/gcc/*.awk #215828
703 + # bug #215828
704 + sed -i 's|A-Za-z0-9|[:alnum:]|g' "${S}"/gcc/*.awk || die
705
706 - # Prevent new texinfo from breaking old versions (see #198182, #464008)
707 - if tc_version_is_at_least 4.1; then
708 - tc_apply_patches "Remove texinfo (bug #198182, bug #464008)" "${FILESDIR}"/gcc-configure-texinfo.patch
709 - fi
710 + # Prevent new texinfo from breaking old versions (see #198182, bug #464008)
711 + einfo "Remove texinfo (bug #198182, bug #464008)"
712 + eapply "${FILESDIR}"/gcc-configure-texinfo.patch
713
714 # >=gcc-4
715 if [[ -x contrib/gcc_update ]] ; then
716 @@ -574,12 +688,28 @@ toolchain_src_prepare() {
717
718 do_gcc_gentoo_patches() {
719 if ! use vanilla ; then
720 - if [[ -n ${PATCH_VER} ]] ; then
721 - tc_apply_patches "Applying Gentoo patches ..." "${WORKDIR}"/patch/*.patch
722 + if [[ -n ${PATCH_VER} || -d "${WORKDIR}"/patch ]] ; then
723 + einfo "Applying Gentoo patches ..."
724 + eapply "${WORKDIR}"/patch/*.patch
725 BRANDING_GCC_PKGVERSION="${BRANDING_GCC_PKGVERSION} p${PATCH_VER}"
726 fi
727 - if [[ -n ${UCLIBC_VER} ]] ; then
728 - tc_apply_patches "Applying uClibc patches ..." "${WORKDIR}"/uclibc/*.patch
729 +
730 + if [[ -n ${MUSL_VER} || -d "${WORKDIR}"/musl ]] && [[ ${CTARGET} == *musl* ]] ; then
731 + if [[ ${CATEGORY} == cross-* ]] ; then
732 + # We don't want to apply some patches when cross-compiling.
733 + if [[ -d "${WORKDIR}"/musl/nocross ]] ; then
734 + rm -fv "${WORKDIR}"/musl/nocross/*.patch || die
735 + else
736 + # Just make an empty directory to make the glob below easier.
737 + mkdir -p "${WORKDIR}"/musl/nocross || die
738 + fi
739 + fi
740 +
741 + local shopt_save=$(shopt -p nullglob)
742 + shopt -s nullglob
743 + einfo "Applying musl patches ..."
744 + eapply "${WORKDIR}"/musl/{,nocross/}*.patch
745 + ${shopt_save}
746 fi
747 fi
748 }
749 @@ -588,7 +718,8 @@ do_gcc_PIE_patches() {
750 want_pie || return 0
751 use vanilla && return 0
752
753 - tc_apply_patches "Applying pie patches ..." "${WORKDIR}"/piepatch/*.patch
754 + einfo "Applying PIE patches ..."
755 + eapply "${WORKDIR}"/piepatch/*.patch
756
757 BRANDING_GCC_PKGVERSION="${BRANDING_GCC_PKGVERSION}, pie-${PIE_VER}"
758 }
759 @@ -598,7 +729,7 @@ do_gcc_CYGWINPORTS_patches() {
760 use elibc_Cygwin || return 0
761
762 local p d="${WORKDIR}/gcc-${CYGWINPORTS_GITREV}"
763 - # readarray -t is available since bash-4.4 only, #690686
764 + # readarray -t is available since bash-4.4 only, bug #690686
765 local patches=( $(
766 for p in $(
767 sed -e '1,/PATCH_URI="/d;/"/,$d' < "${d}"/gcc.cygport
768 @@ -606,21 +737,23 @@ do_gcc_CYGWINPORTS_patches() {
769 echo "${d}/${p}"
770 done
771 ) )
772 - tc_apply_patches "Applying cygwin port patches ..." ${patches[*]}
773 + einfo "Applying cygwin port patches ..."
774 + eapply -- "${patches[@]}"
775 }
776
777 # configure to build with the hardened GCC specs as the default
778 make_gcc_hard() {
779 local gcc_hard_flags=""
780
781 - # If we use gcc-6 or newer with pie enable to compile older gcc we need to pass -no-pie
782 - # to stage1; bug #618908
783 + # If we use gcc-6 or newer with PIE enabled to compile older gcc,
784 + # we need to pass -no-pie to stage1; bug #618908
785 if ! tc_version_is_at_least 6.0 && [[ $(gcc-major-version) -ge 6 ]] ; then
786 einfo "Disabling PIE in stage1 (only) ..."
787 sed -i -e "/^STAGE1_LDFLAGS/ s/$/ -no-pie/" "${S}"/Makefile.in || die
788 fi
789
790 - # Gcc >= 6.X we can use configurations options to turn pie/ssp on as default
791 + # For gcc >= 6.x, we can use configuration options to turn PIE/SSP
792 + # on as default
793 if tc_version_is_at_least 6.0 ; then
794 if _tc_use_if_iuse pie ; then
795 einfo "Updating gcc to use automatic PIE building ..."
796 @@ -630,16 +763,21 @@ make_gcc_hard() {
797 fi
798 if _tc_use_if_iuse hardened ; then
799 # Will add some hardened options as default, like:
800 - # -fstack-clash-protection
801 - # -z now
802 - # see *_all_extra-options.patch gcc patches.
803 + # * -fstack-clash-protection
804 + # * -z now
805 + # See gcc *_all_extra-options.patch patches.
806 gcc_hard_flags+=" -DEXTRA_OPTIONS"
807 - # rebrand to make bug reports easier
808 +
809 + if _tc_use_if_iuse cet && [[ ${CTARGET} == *x86_64*-linux* ]] ; then
810 + gcc_hard_flags+=" -DEXTRA_OPTIONS_CF"
811 + fi
812 +
813 + # Rebrand to make bug reports easier
814 BRANDING_GCC_PKGVERSION=${BRANDING_GCC_PKGVERSION/Gentoo/Gentoo Hardened}
815 fi
816 else
817 if _tc_use_if_iuse hardened ; then
818 - # rebrand to make bug reports easier
819 + # Rebrand to make bug reports easier
820 BRANDING_GCC_PKGVERSION=${BRANDING_GCC_PKGVERSION/Gentoo/Gentoo Hardened}
821 if hardened_gcc_works ; then
822 einfo "Updating gcc to use automatic PIE + SSP building ..."
823 @@ -653,7 +791,7 @@ make_gcc_hard() {
824 ewarn "PIE has not been enabled by default"
825 gcc_hard_flags+=" -DEFAULT_SSP"
826 else
827 - # do nothing if hardened isn't supported, but don't die either
828 + # Do nothing if hardened isn't supported, but don't die either
829 ewarn "hardened is not supported for this arch in this gcc version"
830 return 0
831 fi
832 @@ -665,16 +803,16 @@ make_gcc_hard() {
833 fi
834 fi
835
836 - # we want to be able to control the pie patch logic via something other
837 + # We want to be able to control the PIE patch logic via something other
838 # than ALL_CFLAGS...
839 sed -e '/^ALL_CFLAGS/iHARD_CFLAGS = ' \
840 -e 's|^ALL_CFLAGS = |ALL_CFLAGS = $(HARD_CFLAGS) |' \
841 - -i "${S}"/gcc/Makefile.in
842 + -i "${S}"/gcc/Makefile.in || die
843 # Need to add HARD_CFLAGS to ALL_CXXFLAGS on >= 4.7
844 if tc_version_is_at_least 4.7 ; then
845 sed -e '/^ALL_CXXFLAGS/iHARD_CFLAGS = ' \
846 -e 's|^ALL_CXXFLAGS = |ALL_CXXFLAGS = $(HARD_CFLAGS) |' \
847 - -i "${S}"/gcc/Makefile.in
848 + -i "${S}"/gcc/Makefile.in || die
849 fi
850
851 sed -i \
852 @@ -703,13 +841,13 @@ setup_multilib_osdirnames() {
853 local config
854 local libdirs="../lib64 ../lib32"
855
856 - # this only makes sense for some Linux targets
857 + # This only makes sense for some Linux targets
858 case ${CTARGET} in
859 - x86_64*-linux*) config="i386" ;;
860 - powerpc64*-linux*) config="rs6000" ;;
861 - sparc64*-linux*) config="sparc" ;;
862 - s390x*-linux*) config="s390" ;;
863 - *) return 0 ;;
864 + x86_64*-linux*) config="i386" ;;
865 + powerpc64*-linux*) config="rs6000" ;;
866 + sparc64*-linux*) config="sparc" ;;
867 + s390x*-linux*) config="s390" ;;
868 + *) return 0 ;;
869 esac
870 config+="/t-linux64"
871
872 @@ -718,14 +856,14 @@ setup_multilib_osdirnames() {
873 sed_args+=( -e 's:$[(]call if_multiarch[^)]*[)]::g' )
874 fi
875 if [[ ${SYMLINK_LIB} == "yes" ]] ; then
876 - einfo "updating multilib directories to be: ${libdirs}"
877 + einfo "Updating multilib directories to be: ${libdirs}"
878 if tc_version_is_at_least 4.6.4 || tc_version_is_at_least 4.7 ; then
879 sed_args+=( -e '/^MULTILIB_OSDIRNAMES.*lib32/s:[$][(]if.*):../lib32:' )
880 else
881 sed_args+=( -e "/^MULTILIB_OSDIRNAMES/s:=.*:= ${libdirs}:" )
882 fi
883 else
884 - einfo "using upstream multilib; disabling lib32 autodetection"
885 + einfo "Using upstream multilib; disabling lib32 autodetection"
886 sed_args+=( -r -e 's:[$][(]if.*,(.*)[)]:\1:' )
887 fi
888 sed -i "${sed_args[@]}" "${S}"/gcc/config/${config} || die
889 @@ -737,7 +875,7 @@ gcc_version_patch() {
890
891 local version_string=${GCC_RELEASE_VER}
892
893 - einfo "patching gcc version: ${version_string} (${BRANDING_GCC_PKGVERSION})"
894 + einfo "Patching gcc version: ${version_string} (${BRANDING_GCC_PKGVERSION})"
895
896 local gcc_sed=( -e 's:gcc\.gnu\.org/bugs\.html:bugs\.gentoo\.org/:' )
897 if grep -qs VERSUFFIX "${S}"/gcc/version.c ; then
898 @@ -760,10 +898,10 @@ toolchain_src_configure() {
899 einfo "LDFLAGS=\"${LDFLAGS}\""
900
901 # Force internal zip based jar script to avoid random
902 - # issues with 3rd party jar implementations. #384291
903 + # issues with 3rd party jar implementations. bug #384291
904 export JAR=no
905
906 - # For hardened gcc 4.3 piepatchset to build the hardened specs
907 + # For hardened gcc 4.3: add the pie patchset to build the hardened specs
908 # file (build.specs) to use when building gcc.
909 if ! tc_version_is_at_least 4.4 && want_minispecs ; then
910 setup_minispecs_gcc_build_specs
911 @@ -771,6 +909,8 @@ toolchain_src_configure() {
912
913 local confgcc=( --host=${CHOST} )
914
915 + local build_config_targets=()
916 +
917 if is_crosscompile || tc-is-cross-compiler ; then
918 # Straight from the GCC install doc:
919 # "GCC has code to correctly determine the correct value for target
920 @@ -810,16 +950,13 @@ toolchain_src_configure() {
921 is_d && GCC_LANG+=",d"
922 is_gcj && GCC_LANG+=",java"
923 is_go && GCC_LANG+=",go"
924 - is_jit && GCC_LANG+=",jit"
925 if is_objc || is_objcxx ; then
926 GCC_LANG+=",objc"
927 - if tc_version_is_at_least 4 ; then
928 - use objc-gc && confgcc+=( --enable-objc-gc )
929 - fi
930 + use objc-gc && confgcc+=( --enable-objc-gc )
931 is_objcxx && GCC_LANG+=",obj-c++"
932 fi
933
934 - # fortran support just got sillier! the lang value can be f77 for
935 + # Fortran support just got sillier! The lang value can be f77 for
936 # fortran77, f95 for fortran95, or just plain old fortran for the
937 # currently supported standard depending on gcc version.
938 is_fortran && GCC_LANG+=",fortran"
939 @@ -845,11 +982,11 @@ toolchain_src_configure() {
940 confgcc+=( --disable-nls )
941 fi
942
943 - tc_version_is_at_least 3.4 || confgcc+=( --disable-libunwind-exceptions )
944 + confgcc+=( --disable-libunwind-exceptions )
945
946 # Use the default ("release") checking because upstream usually neglects
947 # to test "disabled" so it has a history of breaking. bug #317217
948 - if tc_version_is_at_least 3.4 && in_iuse debug ; then
949 + if in_iuse debug ; then
950 # The "release" keyword is new to 4.0. bug #551636
951 local off=$(tc_version_is_at_least 4.0 && echo release || echo no)
952 confgcc+=( --enable-checking="${GCC_CHECKS_LIST:-$(usex debug yes ${off})}" )
953 @@ -861,12 +998,12 @@ toolchain_src_configure() {
954 --with-pkgversion="${BRANDING_GCC_PKGVERSION}"
955 )
956
957 - # If we want hardened support with the newer piepatchset for >=gcc 4.4
958 + # If we want hardened support with the newer PIE patchset for >=gcc 4.4
959 if tc_version_is_at_least 4.4 && want_minispecs && in_iuse hardened ; then
960 confgcc+=( $(use_enable hardened esp) )
961 fi
962
963 - # allow gcc to search for clock funcs in the main C lib.
964 + # Allow gcc to search for clock funcs in the main C lib.
965 # if it can't find them, then tough cookies -- we aren't
966 # going to link in -lrt to all C++ apps. bug #411681
967 if tc_version_is_at_least 4.4 && is_cxx ; then
968 @@ -875,17 +1012,18 @@ toolchain_src_configure() {
969
970 # Build compiler itself using LTO
971 if tc_version_is_at_least 9.1 && _tc_use_if_iuse lto ; then
972 - confgcc+=( --with-build-config=bootstrap-lto )
973 + build_config_targets+=( bootstrap-lto )
974 + fi
975 +
976 + if tc_version_is_at_least 12 && _tc_use_if_iuse cet ; then
977 + build_config_targets+=( bootstrap-cet )
978 fi
979
980 - # Support to disable pch when building libstdcxx
981 + # Support to disable PCH when building libstdcxx
982 if tc_version_is_at_least 6.0 && ! _tc_use_if_iuse pch ; then
983 confgcc+=( --disable-libstdcxx-pch )
984 fi
985
986 - # The jit language requires this.
987 - is_jit && confgcc+=( --enable-host-shared )
988 -
989 # build-id was disabled for file collisions: bug #526144
990 #
991 # # Turn on the -Wl,--build-id flag by default for ELF targets. bug #525942
992 @@ -898,7 +1036,7 @@ toolchain_src_configure() {
993 # ;;
994 # esac
995
996 - # newer gcc versions like to bootstrap themselves with C++,
997 + # Newer gcc versions like to bootstrap themselves with C++,
998 # so we need to manually disable it ourselves
999 if tc_version_is_between 4.7 4.8 && ! is_cxx ; then
1000 confgcc+=( --disable-build-with-cxx --disable-build-poststage1-with-cxx )
1001 @@ -914,55 +1052,65 @@ toolchain_src_configure() {
1002 # disable a bunch of features or gcc goes boom
1003 local needed_libc=""
1004 case ${CTARGET} in
1005 - *-linux) needed_libc=error-unknown-libc;;
1006 - *-dietlibc) needed_libc=dietlibc;;
1007 - *-elf|*-eabi)
1008 - needed_libc=newlib
1009 - # Bare-metal targets don't have access to clock_gettime()
1010 - # arm-none-eabi example: bug #589672
1011 - # But we explicitly do --enable-libstdcxx-time above.
1012 - # Undoing it here.
1013 - confgcc+=( --disable-libstdcxx-time )
1014 - ;;
1015 - *-gentoo-freebsd*) needed_libc=freebsd-lib;;
1016 - *-gnu*) needed_libc=glibc;;
1017 - *-klibc) needed_libc=klibc;;
1018 - *-musl*) needed_libc=musl;;
1019 - *-uclibc*)
1020 - # Enable shared library support only on targets
1021 - # that support it: bug #291870
1022 - if ! echo '#include <features.h>' | \
1023 - $(tc-getCPP ${CTARGET}) -E -dD - 2>/dev/null | \
1024 - grep -q __HAVE_SHARED__
1025 - then
1026 - confgcc+=( --disable-shared )
1027 - fi
1028 - needed_libc=uclibc-ng
1029 - ;;
1030 - *-cygwin) needed_libc=cygwin;;
1031 - x86_64-*-mingw*|\
1032 - *-w64-mingw*) needed_libc=mingw64-runtime;;
1033 - mingw*|*-mingw*) needed_libc=mingw-runtime;;
1034 - avr) confgcc+=( --enable-shared --disable-threads );;
1035 - *-apple-darwin*) confgcc+=( --with-sysroot="${EPREFIX}${PREFIX}/${CTARGET}" );;
1036 - *-solaris*) confgcc+=( --with-sysroot="${EPREFIX}${PREFIX}/${CTARGET}"
1037 - );;
1038 - *-freebsd*) confgcc+=( --with-sysroot="${EPREFIX}${PREFIX}/${CTARGET}"
1039 - );;
1040 + *-linux)
1041 + needed_libc=error-unknown-libc
1042 + ;;
1043 + *-dietlibc)
1044 + needed_libc=dietlibc
1045 + ;;
1046 + *-elf|*-eabi)
1047 + needed_libc=newlib
1048 + # Bare-metal targets don't have access to clock_gettime()
1049 + # arm-none-eabi example: bug #589672
1050 + # But we explicitly do --enable-libstdcxx-time above.
1051 + # Undoing it here.
1052 + confgcc+=( --disable-libstdcxx-time )
1053 + ;;
1054 + *-gnu*)
1055 + needed_libc=glibc
1056 + ;;
1057 + *-klibc)
1058 + needed_libc=klibc
1059 + ;;
1060 + *-musl*)
1061 + needed_libc=musl
1062 + ;;
1063 + *-cygwin)
1064 + needed_libc=cygwin
1065 + ;;
1066 + x86_64-*-mingw*|*-w64-mingw*)
1067 + needed_libc=mingw64-runtime
1068 + ;;
1069 + avr)
1070 + confgcc+=( --enable-shared --disable-threads )
1071 + ;;
1072 + # Prefix targets
1073 + *-apple-darwin*)
1074 + confgcc+=( --with-sysroot="${EPREFIX}${PREFIX}/${CTARGET}" )
1075 + ;;
1076 + *-solaris*)
1077 + confgcc+=( --with-sysroot="${EPREFIX}${PREFIX}/${CTARGET}" )
1078 + ;;
1079 + *-freebsd*)
1080 + confgcc+=( --with-sysroot="${EPREFIX}${PREFIX}/${CTARGET}" )
1081 + ;;
1082 esac
1083 +
1084 if [[ -n ${needed_libc} ]] ; then
1085 local confgcc_no_libc=( --disable-shared )
1086 # requires libc: bug #734820
1087 tc_version_is_at_least 4.6 && confgcc_no_libc+=( --disable-libquadmath )
1088 # requires libc
1089 tc_version_is_at_least 4.8 && confgcc_no_libc+=( --disable-libatomic )
1090 +
1091 if ! has_version ${CATEGORY}/${needed_libc} ; then
1092 confgcc+=(
1093 "${confgcc_no_libc[@]}"
1094 --disable-threads
1095 --without-headers
1096 )
1097 - if [[ $needed_libc == glibc ]]; then
1098 +
1099 + if [[ ${needed_libc} == glibc ]] ; then
1100 # By default gcc looks at glibc's headers
1101 # to detect long double support. This does
1102 # not work for --disable-headers mode.
1103 @@ -980,7 +1128,7 @@ toolchain_src_configure() {
1104 fi
1105 fi
1106
1107 - tc_version_is_at_least 4.2 && confgcc+=( --disable-bootstrap )
1108 + confgcc+=( --disable-bootstrap )
1109 else
1110 if tc-is-static-only ; then
1111 confgcc+=( --disable-shared )
1112 @@ -988,10 +1136,12 @@ toolchain_src_configure() {
1113 confgcc+=( --enable-shared )
1114 fi
1115 case ${CHOST} in
1116 - mingw*|*-mingw*)
1117 - confgcc+=( --enable-threads=win32 ) ;;
1118 - *)
1119 - confgcc+=( --enable-threads=posix ) ;;
1120 + mingw*|*-mingw*)
1121 + confgcc+=( --enable-threads=win32 )
1122 + ;;
1123 + *)
1124 + confgcc+=( --enable-threads=posix )
1125 + ;;
1126 esac
1127
1128 if use prefix ; then
1129 @@ -1012,39 +1162,21 @@ toolchain_src_configure() {
1130 # __cxa_atexit is "essential for fully standards-compliant handling of
1131 # destructors", but apparently requires glibc.
1132 case ${CTARGET} in
1133 - *-uclibc*)
1134 - if tc_has_feature nptl ; then
1135 + *-elf|*-eabi)
1136 + confgcc+=( --with-newlib )
1137 + ;;
1138 + *-musl*)
1139 + confgcc+=( --enable-__cxa_atexit )
1140 + ;;
1141 + *-gnu*)
1142 confgcc+=(
1143 - --disable-__cxa_atexit
1144 - $(use_enable nptl tls)
1145 + --enable-__cxa_atexit
1146 + --enable-clocale=gnu
1147 )
1148 - fi
1149 - tc_version_is_between 3.3 3.4 && confgcc+=( --enable-sjlj-exceptions )
1150 - if tc_version_is_between 3.4 4.3 ; then
1151 - confgcc+=( --enable-clocale=uclibc )
1152 - fi
1153 - ;;
1154 - *-elf|*-eabi)
1155 - confgcc+=( --with-newlib )
1156 - ;;
1157 - *-musl*)
1158 - confgcc+=( --enable-__cxa_atexit )
1159 - ;;
1160 - *-gnu*)
1161 - confgcc+=(
1162 - --enable-__cxa_atexit
1163 - --enable-clocale=gnu
1164 - )
1165 - ;;
1166 - *-freebsd*)
1167 - confgcc+=( --enable-__cxa_atexit )
1168 - ;;
1169 - *-openbsd*)
1170 - confgcc+=( --enable-__cxa_atexit )
1171 - ;;
1172 - *-solaris*)
1173 - confgcc+=( --enable-__cxa_atexit )
1174 - ;;
1175 + ;;
1176 + *-solaris*)
1177 + confgcc+=( --enable-__cxa_atexit )
1178 + ;;
1179 esac
1180
1181 ### arch options
1182 @@ -1057,102 +1189,117 @@ toolchain_src_configure() {
1183 tc_version_is_at_least 4.3 && in_iuse fixed-point && confgcc+=( $(use_enable fixed-point) )
1184
1185 case $(tc-is-softfloat) in
1186 - yes) confgcc+=( --with-float=soft ) ;;
1187 - softfp) confgcc+=( --with-float=softfp ) ;;
1188 - *)
1189 - # If they've explicitly opt-ed in, do hardfloat,
1190 - # otherwise let the gcc default kick in.
1191 - case ${CTARGET//_/-} in
1192 - *-hardfloat-*|*eabihf) confgcc+=( --with-float=hard ) ;;
1193 - esac
1194 + yes)
1195 + confgcc+=( --with-float=soft )
1196 + ;;
1197 + softfp)
1198 + confgcc+=( --with-float=softfp )
1199 + ;;
1200 + *)
1201 + # If they've explicitly opt-ed in, do hardfloat,
1202 + # otherwise let the gcc default kick in.
1203 + case ${CTARGET//_/-} in
1204 + *-hardfloat-*|*eabihf)
1205 + confgcc+=( --with-float=hard )
1206 + ;;
1207 + esac
1208 esac
1209
1210 local with_abi_map=()
1211 case $(tc-arch) in
1212 - arm) #264534 #414395
1213 - local a arm_arch=${CTARGET%%-*}
1214 - # Remove trailing endian variations first: eb el be bl b l
1215 - for a in e{b,l} {b,l}e b l ; do
1216 - if [[ ${arm_arch} == *${a} ]] ; then
1217 - arm_arch=${arm_arch%${a}}
1218 - break
1219 + arm)
1220 + # bug 264534, bug #414395
1221 + local a arm_arch=${CTARGET%%-*}
1222 + # Remove trailing endian variations first: eb el be bl b l
1223 + for a in e{b,l} {b,l}e b l ; do
1224 + if [[ ${arm_arch} == *${a} ]] ; then
1225 + arm_arch=${arm_arch%${a}}
1226 + break
1227 + fi
1228 + done
1229 +
1230 + # Convert armv6m to armv6-m
1231 + [[ ${arm_arch} == armv6m ]] && arm_arch=armv6-m
1232 + # Convert armv7{a,r,m} to armv7-{a,r,m}
1233 + [[ ${arm_arch} == armv7? ]] && arm_arch=${arm_arch/7/7-}
1234 + # See if this is a valid --with-arch flag
1235 + if (srcdir=${S}/gcc target=${CTARGET} with_arch=${arm_arch};
1236 + . "${srcdir}"/config.gcc) &>/dev/null
1237 + then
1238 + confgcc+=( --with-arch=${arm_arch} )
1239 fi
1240 - done
1241 - # Convert armv7{a,r,m} to armv7-{a,r,m}
1242 - [[ ${arm_arch} == armv7? ]] && arm_arch=${arm_arch/7/7-}
1243 - # See if this is a valid --with-arch flag
1244 - if (srcdir=${S}/gcc target=${CTARGET} with_arch=${arm_arch};
1245 - . "${srcdir}"/config.gcc) &>/dev/null
1246 - then
1247 - confgcc+=( --with-arch=${arm_arch} )
1248 - fi
1249
1250 - # Make default mode thumb for microcontroller classes #418209
1251 - [[ ${arm_arch} == *-m ]] && confgcc+=( --with-mode=thumb )
1252 + # Make default mode thumb for microcontroller classes #418209
1253 + [[ ${arm_arch} == *-m ]] && confgcc+=( --with-mode=thumb )
1254
1255 - # Enable hardvfp
1256 - if [[ $(tc-is-softfloat) == "no" ]] && \
1257 - [[ ${CTARGET} == armv[67]* ]] && \
1258 - tc_version_is_at_least 4.5
1259 - then
1260 - # Follow the new arm hardfp distro standard by default
1261 - confgcc+=( --with-float=hard )
1262 - case ${CTARGET} in
1263 - armv6*) confgcc+=( --with-fpu=vfp ) ;;
1264 - armv7*) confgcc+=( --with-fpu=vfpv3-d16 ) ;;
1265 - esac
1266 - fi
1267 - ;;
1268 - mips)
1269 - # Add --with-abi flags to set default ABI
1270 - confgcc+=( --with-abi=$(gcc-abi-map ${TARGET_DEFAULT_ABI}) )
1271 - ;;
1272 - amd64)
1273 - # drop the older/ABI checks once this get's merged into some
1274 - # version of gcc upstream
1275 - if tc_version_is_at_least 4.8 && has x32 $(get_all_abis TARGET) ; then
1276 + # Enable hardvfp
1277 + if [[ $(tc-is-softfloat) == "no" ]] && \
1278 + [[ ${CTARGET} == armv[67]* ]] && \
1279 + tc_version_is_at_least 4.5
1280 + then
1281 + # Follow the new arm hardfp distro standard by default
1282 + confgcc+=( --with-float=hard )
1283 + case ${CTARGET} in
1284 + armv6*) confgcc+=( --with-fpu=vfp ) ;;
1285 + armv7*) confgcc+=( --with-fpu=vfpv3-d16 ) ;;
1286 + esac
1287 + fi
1288 + ;;
1289 + mips)
1290 + # Add --with-abi flags to set default ABI
1291 confgcc+=( --with-abi=$(gcc-abi-map ${TARGET_DEFAULT_ABI}) )
1292 - fi
1293 - ;;
1294 - x86)
1295 - # Default arch for x86 is normally i386, lets give it a bump
1296 - # since glibc will do so based on CTARGET anyways
1297 - confgcc+=( --with-arch=${CTARGET%%-*} )
1298 - ;;
1299 - hppa)
1300 - # Enable sjlj exceptions for backward compatibility on hppa
1301 - [[ ${GCCMAJOR} == "3" ]] && confgcc+=( --enable-sjlj-exceptions )
1302 - ;;
1303 - ppc)
1304 - # Set up defaults based on current CFLAGS
1305 - is-flagq -mfloat-gprs=double && confgcc+=( --enable-e500-double )
1306 - [[ ${CTARGET//_/-} == *-e500v2-* ]] && confgcc+=( --enable-e500-double )
1307 - ;;
1308 - ppc64)
1309 - # On ppc64 big endian target gcc assumes elfv1 by default,
1310 - # and elfv2 on little endian
1311 - # but musl does not support elfv1 at all on any endian ppc64
1312 - # see https://git.musl-libc.org/cgit/musl/tree/INSTALL
1313 - # https://bugs.gentoo.org/704784
1314 - # https://gcc.gnu.org/PR93157
1315 - [[ ${CTARGET} == powerpc64-*-musl ]] && confgcc+=( --with-abi=elfv2 )
1316 - ;;
1317 - riscv)
1318 - # Add --with-abi flags to set default ABI
1319 - confgcc+=( --with-abi=$(gcc-abi-map ${TARGET_DEFAULT_ABI}) )
1320 - ;;
1321 + ;;
1322 +
1323 + amd64)
1324 + # drop the older/ABI checks once this get's merged into some
1325 + # version of gcc upstream
1326 + if tc_version_is_at_least 4.8 && has x32 $(get_all_abis TARGET) ; then
1327 + confgcc+=( --with-abi=$(gcc-abi-map ${TARGET_DEFAULT_ABI}) )
1328 + fi
1329 + ;;
1330 + x86)
1331 + # Default arch for x86 is normally i386, lets give it a bump
1332 + # since glibc will do so based on CTARGET anyways
1333 + confgcc+=( --with-arch=${CTARGET%%-*} )
1334 + ;;
1335 + hppa)
1336 + # Enable sjlj exceptions for backward compatibility on hppa
1337 + [[ ${GCCMAJOR} == "3" ]] && confgcc+=( --enable-sjlj-exceptions )
1338 + ;;
1339 + ppc)
1340 + # Set up defaults based on current CFLAGS
1341 + is-flagq -mfloat-gprs=double && confgcc+=( --enable-e500-double )
1342 + [[ ${CTARGET//_/-} == *-e500v2-* ]] && confgcc+=( --enable-e500-double )
1343 + ;;
1344 + ppc64)
1345 + # On ppc64 big endian target gcc assumes elfv1 by default,
1346 + # and elfv2 on little endian
1347 + # but musl does not support elfv1 at all on any endian ppc64
1348 + # see https://git.musl-libc.org/cgit/musl/tree/INSTALL
1349 + # bug #704784
1350 + # https://gcc.gnu.org/PR93157
1351 + [[ ${CTARGET} == powerpc64-*-musl ]] && confgcc+=( --with-abi=elfv2 )
1352 + ;;
1353 + riscv)
1354 + # Add --with-abi flags to set default ABI
1355 + confgcc+=( --with-abi=$(gcc-abi-map ${TARGET_DEFAULT_ABI}) )
1356 + ;;
1357 esac
1358
1359 # if the target can do biarch (-m32/-m64), enable it. overhead should
1360 # be small, and should simplify building of 64bit kernels in a 32bit
1361 - # userland by not needing sys-devel/kgcc64. #349405
1362 - if use !prefix ; then #406689
1363 + # userland by not needing sys-devel/kgcc64. bug #349405
1364 case $(tc-arch) in
1365 - ppc|ppc64) tc_version_is_at_least 3.4 && confgcc+=( --enable-targets=all ) ;;
1366 - sparc) tc_version_is_at_least 4.4 && confgcc+=( --enable-targets=all ) ;;
1367 - amd64|x86) tc_version_is_at_least 4.3 && confgcc+=( --enable-targets=all ) ;;
1368 + ppc|ppc64)
1369 + confgcc+=( --enable-targets=all )
1370 + ;;
1371 + sparc)
1372 + tc_version_is_at_least 4.4 && confgcc+=( --enable-targets=all )
1373 + ;;
1374 + amd64|x86)
1375 + tc_version_is_at_least 4.3 && confgcc+=( --enable-targets=all )
1376 + ;;
1377 esac
1378 - fi
1379
1380 # On Darwin we need libdir to be set in order to get correct install names
1381 # for things like libobjc-gnu, libgcj and libfortran. If we enable it on
1382 @@ -1172,47 +1319,44 @@ toolchain_src_configure() {
1383 fi
1384 fi
1385
1386 - if tc_version_is_at_least 4.2 ; then
1387 - if in_iuse openmp ; then
1388 - # Make sure target has pthreads support. #326757 #335883
1389 - # There shouldn't be a chicken & egg problem here as openmp won't
1390 - # build without a C library, and you can't build that w/out
1391 - # already having a compiler ...
1392 - if ! is_crosscompile || \
1393 - $(tc-getCPP ${CTARGET}) -E - <<<"#include <pthread.h>" >& /dev/null
1394 - then
1395 - confgcc+=( $(use_enable openmp libgomp) )
1396 - else
1397 - # Force disable as the configure script can be dumb #359855
1398 - confgcc+=( --disable-libgomp )
1399 - fi
1400 + if in_iuse openmp ; then
1401 + # Make sure target has pthreads support: bug #326757, bug #335883
1402 + # There shouldn't be a chicken & egg problem here as openmp won't
1403 + # build without a C library, and you can't build that w/out
1404 + # already having a compiler ...
1405 + if ! is_crosscompile || \
1406 + $(tc-getCPP ${CTARGET}) -E - <<<"#include <pthread.h>" >& /dev/null
1407 + then
1408 + confgcc+=( $(use_enable openmp libgomp) )
1409 else
1410 - # For gcc variants where we don't want openmp (e.g. kgcc)
1411 + # Force disable as the configure script can be dumb #359855
1412 confgcc+=( --disable-libgomp )
1413 fi
1414 + else
1415 + # For gcc variants where we don't want openmp (e.g. kgcc)
1416 + confgcc+=( --disable-libgomp )
1417 fi
1418
1419 - if tc_version_is_at_least 4.0 ; then
1420 - if _tc_use_if_iuse libssp ; then
1421 - confgcc+=( --enable-libssp )
1422 + if _tc_use_if_iuse libssp ; then
1423 + confgcc+=( --enable-libssp )
1424 + else
1425 + if hardened_gcc_is_stable ssp; then
1426 + export gcc_cv_libc_provides_ssp=yes
1427 + fi
1428 + if _tc_use_if_iuse ssp; then
1429 + # On some targets USE="ssp -libssp" is an invalid
1430 + # configuration as target libc does not provide
1431 + # stack_chk_* functions. Do not disable libssp there.
1432 + case ${CTARGET} in
1433 + mingw*|*-mingw*)
1434 + ewarn "Not disabling libssp"
1435 + ;;
1436 + *)
1437 + confgcc+=( --disable-libssp )
1438 + ;;
1439 + esac
1440 else
1441 - # Not all libcs have ssp built in. I assume only glibc has
1442 - # this for now.
1443 - use elibc_glibc &&
1444 - if hardened_gcc_is_stable ssp; then
1445 - export gcc_cv_libc_provides_ssp=yes
1446 - fi
1447 - if _tc_use_if_iuse ssp; then
1448 - # On some targets USE="ssp -libssp" is an invalid
1449 - # configuration as target libc does not provide
1450 - # stack_chk_* functions. Do not disable libssp there.
1451 - case ${CTARGET} in
1452 - mingw*|*-mingw*) ewarn "Not disabling libssp" ;;
1453 - *) confgcc+=( --disable-libssp ) ;;
1454 - esac
1455 - else
1456 - confgcc+=( --disable-libssp )
1457 - fi
1458 + confgcc+=( --disable-libssp )
1459 fi
1460 fi
1461
1462 @@ -1220,6 +1364,10 @@ toolchain_src_configure() {
1463 confgcc+=( --disable-libada )
1464 fi
1465
1466 + if in_iuse cet ; then
1467 + confgcc+=( $(use_enable cet) )
1468 + fi
1469 +
1470 if in_iuse cilk ; then
1471 confgcc+=( $(use_enable cilk libcilkrts) )
1472 fi
1473 @@ -1248,6 +1396,8 @@ toolchain_src_configure() {
1474 confgcc+=( $(use_with zstd) )
1475 fi
1476
1477 + # This only controls whether the compiler *supports* LTO, not whether
1478 + # it's *built using* LTO. Hence we do it without a USE flag.
1479 if tc_version_is_at_least 4.6 ; then
1480 confgcc+=( --enable-lto )
1481 elif tc_version_is_at_least 4.5 ; then
1482 @@ -1255,7 +1405,7 @@ toolchain_src_configure() {
1483 fi
1484
1485 # graphite was added in 4.4 but we only support it in 6.5+ due to external
1486 - # library issues. #448024, #701270
1487 + # library issues. bug #448024, bug #701270
1488 if tc_version_is_at_least 6.5 && in_iuse graphite ; then
1489 confgcc+=( $(use_with graphite isl) )
1490 use graphite && confgcc+=( --disable-isl-version-check )
1491 @@ -1288,7 +1438,7 @@ toolchain_src_configure() {
1492 fi
1493
1494 # Disable gcc info regeneration -- it ships with generated info pages
1495 - # already. Our custom version/urls/etc... trigger it. #464008
1496 + # already. Our custom version/urls/etc... trigger it. bug #464008
1497 export gcc_cv_prog_makeinfo_modern=no
1498
1499 # Do not let the X detection get in our way. We know things can be found
1500 @@ -1299,6 +1449,11 @@ toolchain_src_configure() {
1501
1502 confgcc+=( "$@" ${EXTRA_ECONF} )
1503
1504 + if [[ -n ${build_config_targets} ]] ; then
1505 + # ./configure --with-build-config='bootstrap-lto bootstrap-cet'
1506 + confgcc+=( --with-build-config="${build_config_targets[*]}" )
1507 + fi
1508 +
1509 # Nothing wrong with a good dose of verbosity
1510 echo
1511 einfo "PREFIX: ${PREFIX}"
1512 @@ -1309,23 +1464,45 @@ toolchain_src_configure() {
1513 echo
1514 einfo "Languages: ${GCC_LANG}"
1515 echo
1516 - einfo "Configuring GCC with: ${confgcc[@]//--/\n\t--}"
1517 - echo
1518
1519 # Build in a separate build tree
1520 - mkdir -p "${WORKDIR}"/build
1521 + mkdir -p "${WORKDIR}"/build || die
1522 pushd "${WORKDIR}"/build > /dev/null
1523
1524 - # and now to do the actual configuration
1525 + # ...and now to do the actual configuration
1526 addwrite /dev/zero
1527 - echo "${S}"/configure "${confgcc[@]}"
1528 +
1529 + local gcc_shell="${BROOT}"/bin/bash
1530 # Older gcc versions did not detect bash and re-exec itself, so force the
1531 - # use of bash. Newer ones will auto-detect, but this is not harmful.
1532 - CONFIG_SHELL="${EPREFIX}/bin/bash" \
1533 - bash "${S}"/configure "${confgcc[@]}" || die "failed to run configure"
1534 + # use of bash for them.
1535 + if tc_version_is_at_least 11.2 ; then
1536 + gcc_shell="${BROOT}"/bin/sh
1537 + fi
1538
1539 - # return to whatever directory we were in before
1540 - popd > /dev/null
1541 + if is_jit ; then
1542 + einfo "Configuring JIT gcc"
1543 +
1544 + mkdir -p "${WORKDIR}"/build-jit || die
1545 + pushd "${WORKDIR}"/build-jit > /dev/null || die
1546 + CONFIG_SHELL="${gcc_shell}" edo "${gcc_shell}" "${S}"/configure \
1547 + "${confgcc[@]}" \
1548 + --disable-libada \
1549 + --disable-libsanitizer \
1550 + --disable-libvtv \
1551 + --disable-libgomp \
1552 + --disable-libquadmath \
1553 + --disable-libatomic \
1554 + --disable-lto \
1555 + --disable-bootstrap \
1556 + --enable-host-shared \
1557 + --enable-languages=jit
1558 + popd > /dev/null || die
1559 + fi
1560 +
1561 + CONFIG_SHELL="${gcc_shell}" edo "${gcc_shell}" "${S}"/configure "${confgcc[@]}"
1562 +
1563 + # Return to whatever directory we were in before
1564 + popd > /dev/null || die
1565 }
1566
1567 # Replace -m flags unsupported by the version being built with the best
1568 @@ -1341,20 +1518,9 @@ downgrade_arch_flags() {
1569 myarch=$(get-flag march)
1570 mytune=$(get-flag mtune)
1571
1572 - # If -march=native isn't supported we have to tease out the actual arch
1573 - if [[ ${myarch} == native || ${mytune} == native ]] ; then
1574 - if ! tc_version_is_at_least 4.2 ${bver}; then
1575 - arch=$($(tc-getCC) -march=native -v -E -P - </dev/null 2>&1 \
1576 - | sed -rn "/cc1.*-march/s:.*-march=([^ ']*).*:\1:p")
1577 - replace-cpu-flags native ${arch}
1578 - fi
1579 - fi
1580 -
1581 # Handle special -mtune flags
1582 [[ ${mytune} == intel ]] && ! tc_version_is_at_least 4.9 ${bver} && replace-cpu-flags intel generic
1583 - [[ ${mytune} == generic ]] && ! tc_version_is_at_least 4.2 ${bver} && filter-flags '-mtune=*'
1584 [[ ${mytune} == x86-64 ]] && filter-flags '-mtune=*'
1585 - tc_version_is_at_least 3.4 ${bver} || filter-flags '-mtune=*'
1586
1587 # "added" "arch" "replacement"
1588 local archlist=(
1589 @@ -1386,14 +1552,6 @@ downgrade_arch_flags() {
1590 4.3 geode k6-2 # gcc.gnu.org/PR41989#c22
1591 4.3 k8-sse3 k8
1592 4.3 opteron-sse3 k8
1593 - 3.4 athlon-fx x86-64
1594 - 3.4 athlon64 x86-64
1595 - 3.4 c3-2 c3
1596 - 3.4 k8 x86-64
1597 - 3.4 opteron x86-64
1598 - 3.4 pentium-m pentium3
1599 - 3.4 pentium3m pentium3
1600 - 3.4 pentium4m pentium4
1601 )
1602
1603 for ((i = 0; i < ${#archlist[@]}; i += 3)) ; do
1604 @@ -1416,7 +1574,7 @@ downgrade_arch_flags() {
1605 fi
1606 done
1607
1608 - # we only check -mno* here since -m* get removed by strip-flags later on
1609 + # We only check -mno* here since -m* get removed by strip-flags later on
1610 local isalist=(
1611 4.9 -mno-sha
1612 4.9 -mno-avx512pf
1613 @@ -1468,35 +1626,21 @@ gcc_do_filter_flags() {
1614 # relating to failed builds, we strip most CFLAGS out to ensure as few
1615 # problems as possible.
1616 strip-flags
1617 +
1618 # Lock gcc at -O2; we want to be conservative here.
1619 filter-flags '-O?'
1620 append-flags -O2
1621 fi
1622
1623 - # dont want to funk ourselves
1624 + # Don't want to funk ourselves
1625 filter-flags '-mabi*' -m31 -m32 -m64
1626
1627 - filter-flags -frecord-gcc-switches # 490738
1628 - filter-flags -mno-rtm -mno-htm # 506202
1629 + # bug #490738
1630 + filter-flags -frecord-gcc-switches
1631 + # bug #506202
1632 + filter-flags -mno-rtm -mno-htm
1633
1634 - if tc_version_is_between 3.2 3.4 ; then
1635 - # XXX: this is so outdated it's barely useful, but it don't hurt...
1636 - replace-cpu-flags G3 750
1637 - replace-cpu-flags G4 7400
1638 - replace-cpu-flags G5 7400
1639 -
1640 - # XXX: should add a sed or something to query all supported flags
1641 - # from the gcc source and trim everything else ...
1642 - filter-flags -f{no-,}unit-at-a-time -f{no-,}web -mno-tls-direct-seg-refs
1643 - filter-flags -f{no-,}stack-protector{,-all}
1644 - filter-flags -fvisibility-inlines-hidden -fvisibility=hidden
1645 - # and warning options
1646 - filter-flags -Wextra -Wstack-protector
1647 - fi
1648 - if ! tc_version_is_at_least 4.1 ; then
1649 - filter-flags -fdiagnostics-show-option
1650 - filter-flags -Wstack-protector
1651 - fi
1652 + filter-flags '-fsanitize=*'
1653
1654 if tc_version_is_between 6 8 ; then
1655 # -mstackrealign triggers crashes in exception throwing
1656 @@ -1505,40 +1649,37 @@ gcc_do_filter_flags() {
1657 filter-flags -mstackrealign
1658 fi
1659
1660 - if tc_version_is_at_least 3.4 ; then
1661 - case $(tc-arch) in
1662 - amd64|x86)
1663 - filter-flags '-mcpu=*'
1664 + case $(tc-arch) in
1665 + amd64|x86)
1666 + filter-flags '-mcpu=*'
1667
1668 - tc_version_is_between 4.4 4.5 && append-flags -mno-avx # 357287
1669 + # bug #357287
1670 + tc_version_is_between 4.4 4.5 && append-flags -mno-avx
1671
1672 - if tc_version_is_between 4.6 4.7 ; then
1673 - # https://bugs.gentoo.org/411333
1674 - # https://bugs.gentoo.org/466454
1675 - replace-cpu-flags c3-2 pentium2 pentium3 pentium3m pentium-m i686
1676 - fi
1677 - ;;
1678 - alpha)
1679 - # https://bugs.gentoo.org/454426
1680 - append-ldflags -Wl,--no-relax
1681 - ;;
1682 - sparc)
1683 - # temporary workaround for random ICEs reproduced by multiple users
1684 - # https://bugs.gentoo.org/457062
1685 - tc_version_is_between 4.6 4.8 && MAKEOPTS+=" -j1"
1686 - ;;
1687 - *-macos)
1688 - # http://gcc.gnu.org/PR25127
1689 - # used to break on 4.1 4.2 now breaks on 10 too, so
1690 - # filter everywhere
1691 + if tc_version_is_between 4.6 4.7 ; then
1692 + # bug #411333, bug #466454
1693 + replace-cpu-flags c3-2 pentium2 pentium3 pentium3m pentium-m i686
1694 + fi
1695 + ;;
1696 + alpha)
1697 + # bug #454426
1698 + append-ldflags -Wl,--no-relax
1699 + ;;
1700 + sparc)
1701 + # Temporary workaround for random ICEs reproduced by multiple users
1702 + # bug #457062
1703 + tc_version_is_between 4.6 4.8 && MAKEOPTS+=" -j1"
1704 + ;;
1705 + *-macos)
1706 + # https://gcc.gnu.org/PR25127
1707 + tc_version_is_between 4.0 4.2 && \
1708 filter-flags '-mcpu=*' '-march=*' '-mtune=*'
1709 - ;;
1710 - esac
1711 - fi
1712 + ;;
1713 + esac
1714
1715 strip-unsupported-flags
1716
1717 - # these are set here so we have something sane at configure time
1718 + # These are set here so we have something sane at configure time
1719 if is_crosscompile ; then
1720 # Set this to something sane for both native and target
1721 CFLAGS="-O2 -pipe"
1722 @@ -1580,7 +1721,7 @@ gcc-multilib-configure() {
1723 confgcc+=( --enable-multilib )
1724 fi
1725
1726 - # translate our notion of multilibs into gcc's
1727 + # Translate our notion of multilibs into gcc's
1728 local abi list
1729 for abi in $(get_all_abis TARGET) ; do
1730 local l=$(gcc-abi-map ${abi})
1731 @@ -1599,9 +1740,15 @@ gcc-abi-map() {
1732 # Convert the ABI name we use in Gentoo to what gcc uses
1733 local map=()
1734 case ${CTARGET} in
1735 - mips*) map=("o32 32" "n32 n32" "n64 64") ;;
1736 - riscv*) map=("lp64d lp64d" "lp64 lp64" "ilp32d ilp32d" "ilp32 ilp32") ;;
1737 - x86_64*) map=("amd64 m64" "x86 m32" "x32 mx32") ;;
1738 + mips*)
1739 + map=("o32 32" "n32 n32" "n64 64")
1740 + ;;
1741 + riscv*)
1742 + map=("lp64d lp64d" "lp64 lp64" "ilp32d ilp32d" "ilp32 ilp32")
1743 + ;;
1744 + x86_64*)
1745 + map=("amd64 m64" "x86 m32" "x32 mx32")
1746 + ;;
1747 esac
1748
1749 local m
1750 @@ -1628,9 +1775,9 @@ toolchain_src_compile() {
1751 # Older gcc versions did not detect bash and re-exec itself, so force the
1752 # use of bash. Newer ones will auto-detect, but this is not harmful.
1753 # This needs to be set for compile as well, as it's used in libtool
1754 - # generation, which will break install otherwise (at least in 3.3.6): #664486
1755 - CONFIG_SHELL="${EPREFIX}/bin/bash" \
1756 - gcc_do_make ${GCC_MAKE_TARGET}
1757 + # generation, which will break install otherwise (at least in 3.3.6): bug #664486
1758 + CONFIG_SHELL="${BROOT}/bin/bash" \
1759 + gcc_do_make ${GCC_MAKE_TARGET}
1760 }
1761
1762 gcc_do_make() {
1763 @@ -1645,11 +1792,11 @@ gcc_do_make() {
1764
1765 # default target
1766 if is_crosscompile || tc-is-cross-compiler ; then
1767 - # 3 stage bootstrapping doesnt quite work when you cant run the
1768 - # resulting binaries natively ^^;
1769 + # 3 stage bootstrapping doesn't quite work when you can't run the
1770 + # resulting binaries natively
1771 GCC_MAKE_TARGET=${GCC_MAKE_TARGET-all}
1772 else
1773 - if tc_version_is_at_least 3.3 && _tc_use_if_iuse pgo; then
1774 + if _tc_use_if_iuse pgo; then
1775 GCC_MAKE_TARGET=${GCC_MAKE_TARGET-profiledbootstrap}
1776 else
1777 GCC_MAKE_TARGET=${GCC_MAKE_TARGET-bootstrap-lean}
1778 @@ -1680,6 +1827,19 @@ gcc_do_make() {
1779 BOOT_CFLAGS=${BOOT_CFLAGS-"$(get_abi_CFLAGS ${TARGET_DEFAULT_ABI}) ${CFLAGS}"}
1780 fi
1781
1782 + if is_jit ; then
1783 + # TODO: docs for jit?
1784 + pushd "${WORKDIR}"/build-jit > /dev/null || die
1785 +
1786 + einfo "Building JIT"
1787 + emake \
1788 + LDFLAGS="${LDFLAGS}" \
1789 + STAGE1_CFLAGS="${STAGE1_CFLAGS}" \
1790 + LIBPATH="${LIBPATH}" \
1791 + BOOT_CFLAGS="${BOOT_CFLAGS}"
1792 + popd > /dev/null || die
1793 + fi
1794 +
1795 einfo "Compiling ${PN} (${GCC_MAKE_TARGET})..."
1796
1797 pushd "${WORKDIR}"/build >/dev/null
1798 @@ -1692,8 +1852,7 @@ gcc_do_make() {
1799 STAGE1_CFLAGS="${STAGE1_CFLAGS}" \
1800 LIBPATH="${LIBPATH}" \
1801 BOOT_CFLAGS="${BOOT_CFLAGS}" \
1802 - ${GCC_MAKE_TARGET} \
1803 - || die "emake failed with ${GCC_MAKE_TARGET}"
1804 + ${GCC_MAKE_TARGET}
1805
1806 if is_ada; then
1807 # Without these links it is not getting the good compiler
1808 @@ -1710,16 +1869,17 @@ gcc_do_make() {
1809 if type -p doxygen > /dev/null ; then
1810 if tc_version_is_at_least 4.3 ; then
1811 cd "${CTARGET}"/libstdc++-v3/doc
1812 - emake doc-man-doxygen || ewarn "failed to make docs"
1813 - elif tc_version_is_at_least 3.0 ; then
1814 + emake doc-man-doxygen
1815 + else
1816 cd "${CTARGET}"/libstdc++-v3
1817 - emake doxygen-man || ewarn "failed to make docs"
1818 + emake doxygen-man
1819 fi
1820 - # Clean bogus manpages. #113902
1821 + # Clean bogus manpages. bug #113902
1822 find -name '*_build_*' -delete
1823 - # Blow away generated directory references. Newer versions of gcc
1824 - # have gotten better at this, but not perfect. This is easier than
1825 - # backporting all of the various doxygen patches. #486754
1826 +
1827 + # Blow away generated directory references. Newer versions of gcc
1828 + # have gotten better at this, but not perfect. This is easier than
1829 + # backporting all of the various doxygen patches. bug #486754
1830 find -name '*_.3' -exec grep -l ' Directory Reference ' {} + | \
1831 xargs rm -f
1832 else
1833 @@ -1734,6 +1894,7 @@ gcc_do_make() {
1834
1835 toolchain_src_test() {
1836 cd "${WORKDIR}"/build
1837 +
1838 # 'asan' wants to be preloaded first, so does 'sandbox'.
1839 # To make asan tests work disable sandbox for all of test suite.
1840 # 'backtrace' tests also does not like 'libsandbox.so' presence.
1841 @@ -1746,12 +1907,10 @@ toolchain_src_install() {
1842 cd "${WORKDIR}"/build
1843
1844 # Don't allow symlinks in private gcc include dir as this can break the build
1845 - # Keep them in prefix for things like 'machine->ia64' #gcc PR26189
1846 - use prefix ||
1847 find gcc/include*/ -type l -delete
1848
1849 # Copy over the info pages. We disabled their generation earlier, but the
1850 - # build system only expects to install out of the build dir, not the source. #464008
1851 + # build system only expects to install out of the build dir, not the source. bug #464008
1852 mkdir -p gcc/doc
1853 local x=
1854 for x in "${S}"/gcc/doc/*.info* ; do
1855 @@ -1771,8 +1930,32 @@ toolchain_src_install() {
1856 && use !prefix && rm -f "${x}"
1857 done < <(find gcc/include*/ -name '*.h')
1858
1859 + if is_jit ; then
1860 + # See https://gcc.gnu.org/onlinedocs/gcc-11.3.0/jit/internals/index.html#packaging-notes
1861 + # and bug #843341.
1862 + #
1863 + # Both of the non-JIT and JIT builds are configured to install to $(DESTDIR)
1864 + # Install the configuration with --enable-host-shared first
1865 + # *then* the one without, so that the faster build
1866 + # of "cc1" et al overwrites the slower build.
1867 + #
1868 + # Do the 'make install' from the build directory
1869 + pushd "${WORKDIR}"/build-jit > /dev/null || die
1870 + S="${WORKDIR}"/build-jit emake DESTDIR="${D}" install
1871 +
1872 + # Punt some tools which are really only useful while building gcc
1873 + find "${ED}" -name install-tools -prune -type d -exec rm -rf "{}" \;
1874 + # This one comes with binutils
1875 + find "${ED}" -name libiberty.a -delete
1876 +
1877 + # Move the libraries to the proper location
1878 + gcc_movelibs
1879 +
1880 + popd > /dev/null || die
1881 + fi
1882 +
1883 # Do the 'make install' from the build directory
1884 - S="${WORKDIR}"/build emake -j1 DESTDIR="${D}" install || die
1885 + S="${WORKDIR}"/build emake DESTDIR="${D}" install
1886
1887 # Punt some tools which are really only useful while building gcc
1888 find "${ED}" -name install-tools -prune -type d -exec rm -rf "{}" \;
1889 @@ -1796,7 +1979,7 @@ toolchain_src_install() {
1890 # Setup the gcc_env_entry for hardened gcc 4 with minispecs
1891 want_minispecs && copy_minispecs_gcc_specs
1892
1893 - # Make sure we dont have stuff lying around that
1894 + # Make sure we don't have stuff lying around that
1895 # can nuke multiple versions of gcc
1896 gcc_slot_java
1897
1898 @@ -1835,7 +2018,7 @@ toolchain_src_install() {
1899 # When cross-building gcc does install native tools.
1900 if ! is_crosscompile; then
1901 # Rename the main go binaries as we don't want to clobber dev-lang/go
1902 - # when gcc-config runs. #567806
1903 + # when gcc-config runs. bug #567806
1904 if tc_version_is_at_least 5 && is_go ; then
1905 for x in go gofmt; do
1906 mv ${x} ${x}-${GCCMAJOR} || die
1907 @@ -1843,7 +2026,7 @@ toolchain_src_install() {
1908 fi
1909 fi
1910
1911 - # As gcc installs object files built against bost ${CHOST} and ${CTARGET}
1912 + # As gcc installs object files built against both ${CHOST} and ${CTARGET}
1913 # ideally we will need to strip them using different tools:
1914 # Using ${CHOST} tools:
1915 # - "${D}${BINPATH}"
1916 @@ -1853,29 +2036,27 @@ toolchain_src_install() {
1917 # - "${D}${LIBPATH}"
1918 # As dostrip does not specify host to override ${CHOST} tools just skip
1919 # non-native binary stripping.
1920 - is_crosscompile && tc_supports_dostrip && dostrip -x "${LIBPATH}"
1921 + is_crosscompile && dostrip -x "${LIBPATH}"
1922
1923 - cd "${S}"
1924 + cd "${S}" || die
1925 if is_crosscompile; then
1926 rm -rf "${ED}"/usr/share/{man,info}
1927 rm -rf "${D}"${DATAPATH}/{man,info}
1928 else
1929 - if tc_version_is_at_least 3.0 ; then
1930 - local cxx_mandir=$(find "${WORKDIR}/build/${CTARGET}/libstdc++-v3" -name man)
1931 - if [[ -d ${cxx_mandir} ]] ; then
1932 - cp -r "${cxx_mandir}"/man? "${D}${DATAPATH}"/man/
1933 - fi
1934 + local cxx_mandir=$(find "${WORKDIR}/build/${CTARGET}/libstdc++-v3" -name man)
1935 + if [[ -d ${cxx_mandir} ]] ; then
1936 + cp -r "${cxx_mandir}"/man? "${D}${DATAPATH}"/man/
1937 fi
1938 fi
1939
1940 - # portage regenerates 'dir' files on it's own: bug #672408
1941 + # Portage regenerates 'dir' files on its own: bug #672408
1942 # Drop 'dir' files to avoid collisions.
1943 if [[ -f "${D}${DATAPATH}"/info/dir ]]; then
1944 einfo "Deleting '${D}${DATAPATH}/info/dir'"
1945 rm "${D}${DATAPATH}"/info/dir || die
1946 fi
1947
1948 - # prune empty dirs left behind
1949 + # Prune empty dirs left behind
1950 find "${ED}" -depth -type d -delete 2>/dev/null
1951
1952 # libstdc++.la: Delete as it doesn't add anything useful: g++ itself
1953 @@ -1891,14 +2072,14 @@ toolchain_src_install() {
1954 # libgomp-plugin-*.la: Same as above, and it's an internal plugin only
1955 # loaded via dlopen.
1956 # libgfortran.la: gfortran itself handles linkage correctly in the
1957 - # dynamic & static case (libgfortran.spec). #573302
1958 + # dynamic & static case (libgfortran.spec). bug #573302
1959 # libgfortranbegin.la: Same as above, and it's an internal lib.
1960 # libmpx.la: gcc itself handles linkage correctly (libmpx.spec).
1961 # libmpxwrappers.la: See above.
1962 # libitm.la: gcc itself handles linkage correctly (libitm.spec).
1963 # libvtv.la: gcc itself handles linkage correctly.
1964 # lib*san.la: Sanitizer linkage is handled internally by gcc, and they
1965 - # do not support static linking. #487550 #546700
1966 + # do not support static linking. bug #487550, bug #546700
1967 find "${D}${LIBPATH}" \
1968 '(' \
1969 -name libstdc++.la -o \
1970 @@ -1928,9 +2109,12 @@ toolchain_src_install() {
1971 pushd "${D}${LIBPATH}" >/dev/null
1972 for py in $(find . -name '*-gdb.py') ; do
1973 local multidir=${py%/*}
1974 +
1975 insinto "${gdbdir}/${multidir}"
1976 - sed -i "/^libdir =/s:=.*:= '${LIBPATH}/${multidir}':" "${py}" || die #348128
1977 - doins "${py}" || die
1978 + # bug #348128
1979 + sed -i "/^libdir =/s:=.*:= '${LIBPATH}/${multidir}':" "${py}" || die
1980 + doins "${py}"
1981 +
1982 rm "${py}" || die
1983 done
1984 popd >/dev/null
1985 @@ -1939,13 +2123,13 @@ toolchain_src_install() {
1986 export QA_EXECSTACK="usr/lib*/go/*/*.gox"
1987 export QA_WX_LOAD="usr/lib*/go/*/*.gox"
1988
1989 - # Disable RANDMMAP so PCH works. #301299
1990 + # Disable RANDMMAP so PCH works, bug #301299
1991 if tc_version_is_at_least 4.3 ; then
1992 pax-mark -r "${D}${PREFIX}/libexec/gcc/${CTARGET}/${GCC_CONFIG_VER}/cc1"
1993 pax-mark -r "${D}${PREFIX}/libexec/gcc/${CTARGET}/${GCC_CONFIG_VER}/cc1plus"
1994 fi
1995
1996 - # Disable MPROTECT so java works. #574808
1997 + # Disable MPROTECT so java works, bug #574808
1998 if is_gcj ; then
1999 pax-mark -m "${D}${PREFIX}/libexec/gcc/${CTARGET}/${GCC_CONFIG_VER}/ecj1"
2000 pax-mark -m "${D}${PREFIX}/${CTARGET}/gcc-bin/${GCC_CONFIG_VER}/gij"
2001 @@ -1956,9 +2140,6 @@ toolchain_src_install() {
2002 # when installing gcc, it dumps internal libraries into /usr/lib
2003 # instead of the private gcc lib path
2004 gcc_movelibs() {
2005 - # older versions of gcc did not support --print-multi-os-directory
2006 - tc_version_is_at_least 3.2 || return 0
2007 -
2008 # For non-target libs which are for CHOST and not CTARGET, we want to
2009 # move them to the compiler-specific CHOST internal dir. This is stuff
2010 # that you want to link against when building tools rather than building
2011 @@ -1967,9 +2148,10 @@ gcc_movelibs() {
2012 dodir "${HOSTLIBPATH#${EPREFIX}}"
2013 mv "${ED}"/usr/$(get_libdir)/libcc1* "${D}${HOSTLIBPATH}" || die
2014 fi
2015 +
2016 # libgccjit gets installed to /usr/lib, not /usr/$(get_libdir). Probably
2017 # due to a bug in gcc build system.
2018 - if is_jit ; then
2019 + if [[ ${PWD} == "${WORKDIR}"/build-jit ]] && is_jit ; then
2020 dodir "${LIBPATH#${EPREFIX}}"
2021 mv "${ED}"/usr/lib/libgccjit* "${D}${LIBPATH}" || die
2022 fi
2023 @@ -2024,8 +2206,8 @@ gcc_movelibs() {
2024 find -depth "${ED}" -type d -exec rmdir {} + >& /dev/null
2025 }
2026
2027 -# make sure the libtool archives have libdir set to where they actually
2028 -# -are-, and not where they -used- to be. also, any dependencies we have
2029 +# Make sure the libtool archives have libdir set to where they actually
2030 +# -are-, and not where they -used- to be. Also, any dependencies we have
2031 # on our own .la files need to be updated.
2032 fix_libtool_libdir_paths() {
2033 local libpath="$1"
2034 @@ -2038,7 +2220,7 @@ fix_libtool_libdir_paths() {
2035 allarchives="\(${allarchives// /\\|}\)"
2036 popd >/dev/null
2037
2038 - # The libdir might not have any .la files. #548782
2039 + # The libdir might not have any .la files. bug #548782
2040 find "./${dir}" -maxdepth 1 -name '*.la' \
2041 -exec sed -i -e "/^libdir=/s:=.*:='${dir}':" {} + || die
2042 # Would be nice to combine these, but -maxdepth can not be specified
2043 @@ -2073,21 +2255,16 @@ create_gcc_env_entry() {
2044 # workaround for libtool being stupid and using .la's from
2045 # conflicting ABIs by using the first one in the search path
2046 local ldpaths mosdirs
2047 - if tc_version_is_at_least 3.2 ; then
2048 - local mdir mosdir abi ldpath
2049 - for abi in $(get_all_abis TARGET) ; do
2050 - mdir=$($(XGCC) $(get_abi_CFLAGS ${abi}) --print-multi-directory)
2051 - ldpath=${LIBPATH}
2052 - [[ ${mdir} != "." ]] && ldpath+="/${mdir}"
2053 - ldpaths="${ldpath}${ldpaths:+:${ldpaths}}"
2054 -
2055 - mosdir=$($(XGCC) $(get_abi_CFLAGS ${abi}) -print-multi-os-directory)
2056 - mosdirs="${mosdir}${mosdirs:+:${mosdirs}}"
2057 - done
2058 - else
2059 - # Older gcc's didn't do multilib, so logic is simple.
2060 - ldpaths=${LIBPATH}
2061 - fi
2062 + local mdir mosdir abi ldpath
2063 + for abi in $(get_all_abis TARGET) ; do
2064 + mdir=$($(XGCC) $(get_abi_CFLAGS ${abi}) --print-multi-directory)
2065 + ldpath=${LIBPATH}
2066 + [[ ${mdir} != "." ]] && ldpath+="/${mdir}"
2067 + ldpaths="${ldpath}${ldpaths:+:${ldpaths}}"
2068 +
2069 + mosdir=$($(XGCC) $(get_abi_CFLAGS ${abi}) -print-multi-os-directory)
2070 + mosdirs="${mosdir}${mosdirs:+:${mosdirs}}"
2071 + done
2072
2073 cat <<-EOF > ${gcc_envd_file}
2074 GCC_PATH="${BINPATH}"
2075 @@ -2129,12 +2306,12 @@ create_revdep_rebuild_entry() {
2076 }
2077
2078 copy_minispecs_gcc_specs() {
2079 - # on gcc 6 we don't need minispecs
2080 + # On gcc 6, we don't need minispecs
2081 if tc_version_is_at_least 6.0 ; then
2082 return 0
2083 fi
2084
2085 - # setup the hardenedno* specs files and the vanilla specs file.
2086 + # Setup the hardenedno* specs files and the vanilla specs file.
2087 if hardened_gcc_works ; then
2088 create_gcc_env_entry hardenednopiessp
2089 fi
2090 @@ -2184,7 +2361,7 @@ gcc_slot_java() {
2091 done
2092
2093 # Rename jar because it could clash with Kaffe's jar if this gcc is
2094 - # primary compiler (aka don't have the -<version> extension)
2095 + # primary compiler (aka doesn't have the -<version> extension)
2096 cd "${D}${BINPATH}"
2097 [[ -f jar ]] && mv -f jar gcj-jar
2098 }
2099 @@ -2193,40 +2370,40 @@ gcc_slot_java() {
2100
2101 toolchain_pkg_postinst() {
2102 do_gcc_config
2103 - if [[ ! ${ROOT%/} && -f ${EPREFIX}/usr/share/eselect/modules/compiler-shadow.eselect ]] ; then
2104 + if [[ ! ${ROOT} && -f ${EPREFIX}/usr/share/eselect/modules/compiler-shadow.eselect ]] ; then
2105 eselect compiler-shadow update all
2106 fi
2107
2108 if ! is_crosscompile && [[ ${PN} != "kgcc64" ]] ; then
2109 # gcc stopped installing .la files fixer in June 2020.
2110 # Cleaning can be removed in June 2022.
2111 - rm -f "${EROOT%/}"/sbin/fix_libtool_files.sh
2112 - rm -f "${EROOT%/}"/usr/sbin/fix_libtool_files.sh
2113 - rm -f "${EROOT%/}"/usr/share/gcc-data/fixlafiles.awk
2114 + rm -f "${EROOT}"/sbin/fix_libtool_files.sh
2115 + rm -f "${EROOT}"/usr/sbin/fix_libtool_files.sh
2116 + rm -f "${EROOT}"/usr/share/gcc-data/fixlafiles.awk
2117 fi
2118 }
2119
2120 toolchain_pkg_postrm() {
2121 do_gcc_config
2122 - if [[ ! ${ROOT%/} && -f ${EPREFIX}/usr/share/eselect/modules/compiler-shadow.eselect ]] ; then
2123 + if [[ ! ${ROOT} && -f ${EPREFIX}/usr/share/eselect/modules/compiler-shadow.eselect ]] ; then
2124 eselect compiler-shadow clean all
2125 fi
2126
2127 - # clean up the cruft left behind by cross-compilers
2128 + # Clean up the cruft left behind by cross-compilers
2129 if is_crosscompile ; then
2130 - if [[ -z $(ls "${EROOT%/}"/etc/env.d/gcc/${CTARGET}* 2>/dev/null) ]] ; then
2131 + if [[ -z $(ls "${EROOT}"/etc/env.d/gcc/${CTARGET}* 2>/dev/null) ]] ; then
2132 einfo "Removing last cross-compiler instance. Deleting dangling symlinks."
2133 - rm -f "${EROOT%/}"/etc/env.d/gcc/config-${CTARGET}
2134 - rm -f "${EROOT%/}"/etc/env.d/??gcc-${CTARGET}
2135 - rm -f "${EROOT%/}"/usr/bin/${CTARGET}-{gcc,{g,c}++}{,32,64}
2136 + rm -f "${EROOT}"/etc/env.d/gcc/config-${CTARGET}
2137 + rm -f "${EROOT}"/etc/env.d/??gcc-${CTARGET}
2138 + rm -f "${EROOT}"/usr/bin/${CTARGET}-{gcc,{g,c}++}{,32,64}
2139 fi
2140 return 0
2141 fi
2142
2143 # gcc stopped installing .la files fixer in June 2020.
2144 # Cleaning can be removed in June 2022.
2145 - rm -f "${EROOT%/}"/sbin/fix_libtool_files.sh
2146 - rm -f "${EROOT%/}"/usr/share/gcc-data/fixlafiles.awk
2147 + rm -f "${EROOT}"/sbin/fix_libtool_files.sh
2148 + rm -f "${EROOT}"/usr/share/gcc-data/fixlafiles.awk
2149 }
2150
2151 do_gcc_config() {
2152 @@ -2240,12 +2417,12 @@ do_gcc_config() {
2153 current_gcc_config=$(env -i ROOT="${ROOT}" "${EPREFIX}"/usr/bin/gcc-config -c ${CTARGET} 2>/dev/null)
2154 if [[ -n ${current_gcc_config} ]] ; then
2155 local current_specs use_specs
2156 - # figure out which specs-specific config is active
2157 + # Figure out which specs-specific config is active
2158 current_specs=$(gcc-config -S ${current_gcc_config} | awk '{print $3}')
2159 [[ -n ${current_specs} ]] && use_specs=-${current_specs}
2160
2161 if [[ -n ${use_specs} ]] && \
2162 - [[ ! -e ${EROOT%/}/etc/env.d/gcc/${CTARGET}-${GCC_CONFIG_VER}${use_specs} ]]
2163 + [[ ! -e ${EROOT}/etc/env.d/gcc/${CTARGET}-${GCC_CONFIG_VER}${use_specs} ]]
2164 then
2165 ewarn "The currently selected specs-specific gcc config,"
2166 ewarn "${current_specs}, doesn't exist anymore. This is usually"
2167 @@ -2258,7 +2435,7 @@ do_gcc_config() {
2168 target="${CTARGET}-${GCC_CONFIG_VER}${use_specs}"
2169 else
2170 # The curent target is invalid. Attempt to switch to a valid one.
2171 - # Blindly pick the latest version. #529608
2172 + # Blindly pick the latest version. bug #529608
2173 # TODO: Should update gcc-config to accept `-l ${CTARGET}` rather than
2174 # doing a partial grep like this.
2175 target=$(gcc-config -l 2>/dev/null | grep " ${CTARGET}-[0-9]" | tail -1 | awk '{print $2}')
2176 @@ -2273,9 +2450,9 @@ should_we_gcc_config() {
2177 local curr_config
2178 curr_config=$(env -i ROOT="${ROOT}" "${EPREFIX}"/usr/bin/gcc-config -c ${CTARGET} 2>&1) || return 0
2179
2180 - # if the previously selected config has the same major.minor (branch) as
2181 + # If the previously selected config has the same major.minor (branch) as
2182 # the version we are installing, then it will probably be uninstalled
2183 - # for being in the same SLOT, make sure we run gcc-config.
2184 + # for being in the same SLOT, so make sure we run gcc-config.
2185 local curr_config_ver=$(env -i ROOT="${ROOT}" "${EPREFIX}"/usr/bin/gcc-config -S ${curr_config} | awk '{print $2}')
2186
2187 local curr_branch_ver=$(ver_cut 1-2 ${curr_config_ver})
2188 @@ -2283,12 +2460,14 @@ should_we_gcc_config() {
2189 if [[ ${curr_branch_ver} == ${GCC_BRANCH_VER} ]] ; then
2190 return 0
2191 else
2192 - # if we're installing a genuinely different compiler version,
2193 + # If we're installing a genuinely different compiler version,
2194 # we should probably tell the user -how- to switch to the new
2195 - # gcc version, since we're not going to do it for him/her.
2196 + # gcc version, since we're not going to do it for them.
2197 + #
2198 # We don't want to switch from say gcc-3.3 to gcc-3.4 right in
2199 # the middle of an emerge operation (like an 'emerge -e world'
2200 # which could install multiple gcc versions).
2201 + #
2202 # Only warn if we're installing a pkg as we might be called from
2203 # the pkg_{pre,post}rm steps. #446830
2204 if [[ ${EBUILD_PHASE} == *"inst" ]] ; then
2205 @@ -2364,15 +2543,16 @@ is_go() {
2206
2207 is_jit() {
2208 gcc-lang-supported jit || return 1
2209 +
2210 # cross-compiler does not really support jit as it has
2211 - # to generate code for a target. On target like avr
2212 + # to generate code for a target. On targets like avr,
2213 # libgcclit.so can't link at all: bug #594572
2214 is_crosscompile && return 1
2215 +
2216 _tc_use_if_iuse jit
2217 }
2218
2219 is_multilib() {
2220 - tc_version_is_at_least 3 || return 1
2221 _tc_use_if_iuse multilib
2222 }
2223
2224 @@ -2395,7 +2575,7 @@ get_make_var() {
2225
2226 XGCC() { get_make_var GCC_FOR_TARGET ; }
2227
2228 -# The gentoo piessp patches allow for 3 configurations:
2229 +# The gentoo pie-ssp patches allow for 3 configurations:
2230 # 1) PIE+SSP by default
2231 # 2) PIE by default
2232 # 3) SSP by default
2233 @@ -2404,8 +2584,6 @@ hardened_gcc_works() {
2234 # $gcc_cv_ld_pie is unreliable as it simply take the output of
2235 # `ld --help | grep -- -pie`, that reports the option in all cases, also if
2236 # the loader doesn't actually load the resulting executables.
2237 - # To avoid breakage, blacklist FreeBSD here at least
2238 - [[ ${CTARGET} == *-freebsd* ]] && return 1
2239
2240 want_pie || return 1
2241 _tc_use_if_iuse nopie && return 1
2242 @@ -2427,17 +2605,9 @@ hardened_gcc_works() {
2243 hardened_gcc_is_stable() {
2244 local tocheck
2245 if [[ $1 == "pie" ]] ; then
2246 - if [[ ${CTARGET} == *-uclibc* ]] ; then
2247 - tocheck=${PIE_UCLIBC_STABLE}
2248 - else
2249 - tocheck=${PIE_GLIBC_STABLE}
2250 - fi
2251 + tocheck=${PIE_GLIBC_STABLE}
2252 elif [[ $1 == "ssp" ]] ; then
2253 - if [[ ${CTARGET} == *-uclibc* ]] ; then
2254 - tocheck=${SSP_UCLIBC_STABLE}
2255 - elif [[ ${CTARGET} == *-gnu* ]] ; then
2256 - tocheck=${SSP_STABLE}
2257 - fi
2258 + tocheck=${SSP_STABLE}
2259 else
2260 die "hardened_gcc_stable needs to be called with pie or ssp"
2261 fi
2262 @@ -2447,7 +2617,7 @@ hardened_gcc_is_stable() {
2263 }
2264
2265 want_minispecs() {
2266 - # on gcc 6 we don't need minispecs
2267 + # On gcc 6, we don't need minispecs
2268 if tc_version_is_at_least 6.0 ; then
2269 return 0
2270 fi
2271 @@ -2495,6 +2665,11 @@ toolchain_death_notice() {
2272 fi
2273 }
2274
2275 +fi
2276 +
2277 +EXPORT_FUNCTIONS pkg_pretend pkg_setup src_unpack src_prepare src_configure \
2278 + src_compile src_test src_install pkg_postinst pkg_postrm
2279 +
2280 # Note [implicitly enabled flags]
2281 # -------------------------------
2282 # Usually configure-based packages handle explicit feature requests