Gentoo Archives: gentoo-commits

From: "Andreas K. Hüttel" <dilfridge@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/riscv:master commit in: eclass/
Date: Fri, 03 May 2019 21:55:16
Message-Id: 1556920346.bf81b6ad16948c9cbfe135c0113779bae0d0c587.dilfridge@gentoo
1 commit: bf81b6ad16948c9cbfe135c0113779bae0d0c587
2 Author: Andreas K. Hüttel <dilfridge <AT> gentoo <DOT> org>
3 AuthorDate: Fri May 3 21:52:26 2019 +0000
4 Commit: Andreas K. Hüttel <dilfridge <AT> gentoo <DOT> org>
5 CommitDate: Fri May 3 21:52:26 2019 +0000
6 URL: https://gitweb.gentoo.org/proj/riscv.git/commit/?id=bf81b6ad
7
8 eclass: moved to main tree
9
10 Signed-off-by: Andreas K. Hüttel <dilfridge <AT> gentoo.org>
11
12 eclass/multilib.eclass | 487 ---------
13 eclass/toolchain.eclass | 2544 -----------------------------------------------
14 2 files changed, 3031 deletions(-)
15
16 diff --git a/eclass/multilib.eclass b/eclass/multilib.eclass
17 deleted file mode 100644
18 index 63bde5c..0000000
19 --- a/eclass/multilib.eclass
20 +++ /dev/null
21 @@ -1,487 +0,0 @@
22 -# Copyright 1999-2015 Gentoo Foundation
23 -# Distributed under the terms of the GNU General Public License v2
24 -
25 -# @ECLASS: multilib.eclass
26 -# @MAINTAINER:
27 -# amd64@g.o
28 -# toolchain@g.o
29 -# @BLURB: This eclass is for all functions pertaining to handling multilib configurations.
30 -# @DESCRIPTION:
31 -# This eclass is for all functions pertaining to handling multilib configurations.
32 -
33 -if [[ -z ${_MULTILIB_ECLASS} ]]; then
34 -_MULTILIB_ECLASS=1
35 -
36 -inherit toolchain-funcs
37 -
38 -# Defaults:
39 -export MULTILIB_ABIS=${MULTILIB_ABIS:-"default"}
40 -export DEFAULT_ABI=${DEFAULT_ABI:-"default"}
41 -export CFLAGS_default
42 -export LDFLAGS_default
43 -export CHOST_default=${CHOST_default:-${CHOST}}
44 -export CTARGET_default=${CTARGET_default:-${CTARGET:-${CHOST_default}}}
45 -export LIBDIR_default=${CONF_LIBDIR:-"lib"}
46 -export KERNEL_ABI=${KERNEL_ABI:-${DEFAULT_ABI}}
47 -
48 -# @FUNCTION: has_multilib_profile
49 -# @DESCRIPTION:
50 -# Return true if the current profile is a multilib profile and lists more than
51 -# one abi in ${MULTILIB_ABIS}. When has_multilib_profile returns true, that
52 -# profile should enable the 'multilib' use flag. This is so you can DEPEND on
53 -# a package only for multilib or not multilib.
54 -has_multilib_profile() {
55 - [ -n "${MULTILIB_ABIS}" -a "${MULTILIB_ABIS}" != "${MULTILIB_ABIS/ /}" ]
56 -}
57 -
58 -# @FUNCTION: get_libdir
59 -# @RETURN: the libdir for the selected ABI
60 -# @DESCRIPTION:
61 -# This function simply returns the desired lib directory. With portage
62 -# 2.0.51, we now have support for installing libraries to lib32/lib64
63 -# to accomidate the needs of multilib systems. It's no longer a good idea
64 -# to assume all libraries will end up in lib. Replace any (sane) instances
65 -# where lib is named directly with $(get_libdir) if possible.
66 -#
67 -# Jeremy Huddleston <eradicator@g.o> (23 Dec 2004):
68 -# Added support for ${ABI} and ${DEFAULT_ABI}. If they're both not set,
69 -# fall back on old behavior. Any profile that has these set should also
70 -# depend on a newer version of portage (not yet released) which uses these
71 -# over CONF_LIBDIR in econf, dolib, etc...
72 -if has "${EAPI:-0}" 0 1 2 3 4 5; then
73 - get_libdir() {
74 - local CONF_LIBDIR
75 - if [ -n "${CONF_LIBDIR_OVERRIDE}" ] ; then
76 - # if there is an override, we want to use that... always.
77 - echo ${CONF_LIBDIR_OVERRIDE}
78 - else
79 - get_abi_LIBDIR
80 - fi
81 - }
82 -fi
83 -
84 -# @FUNCTION: get_abi_var
85 -# @USAGE: <VAR> [ABI]
86 -# @RETURN: returns the value of ${<VAR>_<ABI>} which should be set in make.defaults
87 -# @INTERNAL
88 -# @DESCRIPTION:
89 -# ex:
90 -# CFLAGS=$(get_abi_var CFLAGS sparc32) # CFLAGS=-m32
91 -#
92 -# Note that the prefered method is to set CC="$(tc-getCC) $(get_abi_CFLAGS)"
93 -# This will hopefully be added to portage soon...
94 -#
95 -# If <ABI> is not specified, ${ABI} is used.
96 -# If <ABI> is not specified and ${ABI} is not defined, ${DEFAULT_ABI} is used.
97 -# If <ABI> is not specified and ${ABI} and ${DEFAULT_ABI} are not defined, we return an empty string.
98 -get_abi_var() {
99 - local flag=$1
100 - local abi=${2:-${ABI:-${DEFAULT_ABI:-default}}}
101 - local var="${flag}_${abi}"
102 - echo ${!var}
103 -}
104 -
105 -# @FUNCTION: get_abi_CFLAGS
106 -# @USAGE: [ABI]
107 -# @DESCRIPTION:
108 -# Alias for 'get_abi_var CFLAGS'
109 -get_abi_CFLAGS() { get_abi_var CFLAGS "$@"; }
110 -
111 -# @FUNCTION: get_abi_LDFLAGS
112 -# @USAGE: [ABI]
113 -# @DESCRIPTION:
114 -# Alias for 'get_abi_var LDFLAGS'
115 -get_abi_LDFLAGS() { get_abi_var LDFLAGS "$@"; }
116 -
117 -# @FUNCTION: get_abi_CHOST
118 -# @USAGE: [ABI]
119 -# @DESCRIPTION:
120 -# Alias for 'get_abi_var CHOST'
121 -get_abi_CHOST() { get_abi_var CHOST "$@"; }
122 -
123 -# @FUNCTION: get_abi_CTARGET
124 -# @USAGE: [ABI]
125 -# @DESCRIPTION:
126 -# Alias for 'get_abi_var CTARGET'
127 -get_abi_CTARGET() { get_abi_var CTARGET "$@"; }
128 -
129 -# @FUNCTION: get_abi_FAKE_TARGETS
130 -# @USAGE: [ABI]
131 -# @DESCRIPTION:
132 -# Alias for 'get_abi_var FAKE_TARGETS'
133 -get_abi_FAKE_TARGETS() { get_abi_var FAKE_TARGETS "$@"; }
134 -
135 -# @FUNCTION: get_abi_LIBDIR
136 -# @USAGE: [ABI]
137 -# @DESCRIPTION:
138 -# Alias for 'get_abi_var LIBDIR'
139 -get_abi_LIBDIR() { get_abi_var LIBDIR "$@"; }
140 -
141 -# @FUNCTION: get_install_abis
142 -# @DESCRIPTION:
143 -# Return a list of the ABIs we want to install for with
144 -# the last one in the list being the default.
145 -get_install_abis() {
146 - local x order=""
147 -
148 - if [[ -z ${MULTILIB_ABIS} ]] ; then
149 - echo "default"
150 - return 0
151 - fi
152 -
153 - if [[ ${EMULTILIB_PKG} == "true" ]] ; then
154 - for x in ${MULTILIB_ABIS} ; do
155 - if [[ ${x} != "${DEFAULT_ABI}" ]] ; then
156 - has ${x} ${ABI_DENY} || order="${order} ${x}"
157 - fi
158 - done
159 - has ${DEFAULT_ABI} ${ABI_DENY} || order="${order} ${DEFAULT_ABI}"
160 -
161 - if [[ -n ${ABI_ALLOW} ]] ; then
162 - local ordera=""
163 - for x in ${order} ; do
164 - if has ${x} ${ABI_ALLOW} ; then
165 - ordera="${ordera} ${x}"
166 - fi
167 - done
168 - order=${ordera}
169 - fi
170 - else
171 - order=${DEFAULT_ABI}
172 - fi
173 -
174 - if [[ -z ${order} ]] ; then
175 - die "The ABI list is empty. Are you using a proper multilib profile? Perhaps your USE flags or MULTILIB_ABIS are too restrictive for this package."
176 - fi
177 -
178 - echo ${order}
179 - return 0
180 -}
181 -
182 -# @FUNCTION: get_all_abis
183 -# @DESCRIPTION:
184 -# Return a list of the ABIs supported by this profile.
185 -# the last one in the list being the default.
186 -get_all_abis() {
187 - local x order="" mvar dvar
188 -
189 - mvar="MULTILIB_ABIS"
190 - dvar="DEFAULT_ABI"
191 - if [[ -n $1 ]] ; then
192 - mvar="$1_${mvar}"
193 - dvar="$1_${dvar}"
194 - fi
195 -
196 - if [[ -z ${!mvar} ]] ; then
197 - echo "default"
198 - return 0
199 - fi
200 -
201 - for x in ${!mvar}; do
202 - if [[ ${x} != ${!dvar} ]] ; then
203 - order="${order:+${order} }${x}"
204 - fi
205 - done
206 - order="${order:+${order} }${!dvar}"
207 -
208 - echo ${order}
209 - return 0
210 -}
211 -
212 -# @FUNCTION: get_all_libdirs
213 -# @DESCRIPTION:
214 -# Returns a list of all the libdirs used by this profile. This includes
215 -# those that might not be touched by the current ebuild and always includes
216 -# "lib".
217 -get_all_libdirs() {
218 - local libdirs abi
219 -
220 - for abi in ${MULTILIB_ABIS}; do
221 - libdirs+=" $(get_abi_LIBDIR ${abi})"
222 - done
223 - [[ " ${libdirs} " != *" lib "* ]] && libdirs+=" lib"
224 -
225 - echo "${libdirs}"
226 -}
227 -
228 -# @FUNCTION: is_final_abi
229 -# @DESCRIPTION:
230 -# Return true if ${ABI} is the last ABI on our list (or if we're not
231 -# using the new multilib configuration. This can be used to determine
232 -# if we're in the last (or only) run through src_{unpack,compile,install}
233 -is_final_abi() {
234 - has_multilib_profile || return 0
235 - set -- $(get_install_abis)
236 - local LAST_ABI=$#
237 - [[ ${!LAST_ABI} == ${ABI} ]]
238 -}
239 -
240 -# @FUNCTION: number_abis
241 -# @DESCRIPTION:
242 -# echo the number of ABIs we will be installing for
243 -number_abis() {
244 - set -- `get_install_abis`
245 - echo $#
246 -}
247 -
248 -# @FUNCTION: get_exeext
249 -# @DESCRIPTION:
250 -# Returns standard executable program suffix (null, .exe, etc.)
251 -# for the current platform identified by CHOST.
252 -#
253 -# Example:
254 -# get_exeext
255 -# Returns: null string (almost everywhere) || .exe (mingw*) || ...
256 -get_exeext() {
257 - case ${CHOST} in
258 - *-cygwin*|mingw*|*-mingw*) echo ".exe";;
259 - esac
260 -}
261 -
262 -# @FUNCTION: get_libname
263 -# @USAGE: [version]
264 -# @DESCRIPTION:
265 -# Returns libname with proper suffix {.so,.dylib,.dll,etc} and optionally
266 -# supplied version for the current platform identified by CHOST.
267 -#
268 -# Example:
269 -# get_libname ${PV}
270 -# Returns: .so.${PV} (ELF) || .${PV}.dylib (MACH) || ...
271 -get_libname() {
272 - local libname
273 - local ver=$1
274 - case ${CHOST} in
275 - *-cygwin*) libname="dll.a";; # import lib
276 - mingw*|*-mingw*) libname="dll";;
277 - *-darwin*) libname="dylib";;
278 - *-mint*) libname="irrelevant";;
279 - hppa*-hpux*) libname="sl";;
280 - *) libname="so";;
281 - esac
282 -
283 - if [[ -z $* ]] ; then
284 - echo ".${libname}"
285 - else
286 - for ver in "$@" ; do
287 - case ${CHOST} in
288 - *-cygwin*) echo ".${ver}.${libname}";;
289 - *-darwin*) echo ".${ver}.${libname}";;
290 - *-mint*) echo ".${libname}";;
291 - *) echo ".${libname}.${ver}";;
292 - esac
293 - done
294 - fi
295 -}
296 -
297 -# @FUNCTION: get_modname
298 -# @USAGE:
299 -# @DESCRIPTION:
300 -# Returns modulename with proper suffix {.so,.bundle,etc} for the current
301 -# platform identified by CHOST.
302 -#
303 -# Example:
304 -# libfoo$(get_modname)
305 -# Returns: libfoo.so (ELF) || libfoo.bundle (MACH) || ...
306 -get_modname() {
307 - local modname
308 - local ver=$1
309 - case ${CHOST} in
310 - *-darwin*) modname="bundle";;
311 - *) modname="so";;
312 - esac
313 -
314 - echo ".${modname}"
315 -}
316 -
317 -# This is for the toolchain to setup profile variables when pulling in
318 -# a crosscompiler (and thus they aren't set in the profile)
319 -multilib_env() {
320 - local CTARGET=${1:-${CTARGET}}
321 - local cpu=${CTARGET%%*-}
322 -
323 - case ${cpu} in
324 - aarch64*)
325 - # Not possible to do multilib with aarch64 and a single toolchain.
326 - export CFLAGS_arm=${CFLAGS_arm-}
327 - case ${cpu} in
328 - aarch64*be) export CHOST_arm="armv8b-${CTARGET#*-}";;
329 - *) export CHOST_arm="armv8l-${CTARGET#*-}";;
330 - esac
331 - CHOST_arm=${CHOST_arm/%-gnu/-gnueabi}
332 - export CTARGET_arm=${CHOST_arm}
333 - export LIBDIR_arm="lib"
334 -
335 - export CFLAGS_arm64=${CFLAGS_arm64-}
336 - export CHOST_arm64=${CTARGET}
337 - export CTARGET_arm64=${CHOST_arm64}
338 - export LIBDIR_arm64="lib64"
339 -
340 - : ${MULTILIB_ABIS=arm64}
341 - : ${DEFAULT_ABI=arm64}
342 - ;;
343 - x86_64*)
344 - export CFLAGS_x86=${CFLAGS_x86--m32}
345 - export CHOST_x86=${CTARGET/x86_64/i686}
346 - CHOST_x86=${CHOST_x86/%-gnux32/-gnu}
347 - export CTARGET_x86=${CHOST_x86}
348 - if [[ ${SYMLINK_LIB} == "yes" ]] ; then
349 - export LIBDIR_x86="lib32"
350 - else
351 - export LIBDIR_x86="lib"
352 - fi
353 -
354 - export CFLAGS_amd64=${CFLAGS_amd64--m64}
355 - export CHOST_amd64=${CTARGET/%-gnux32/-gnu}
356 - export CTARGET_amd64=${CHOST_amd64}
357 - export LIBDIR_amd64="lib64"
358 -
359 - export CFLAGS_x32=${CFLAGS_x32--mx32}
360 - export CHOST_x32=${CTARGET/%-gnu/-gnux32}
361 - export CTARGET_x32=${CHOST_x32}
362 - export LIBDIR_x32="libx32"
363 -
364 - case ${CTARGET} in
365 - *-gnux32)
366 - : ${MULTILIB_ABIS=x32 amd64 x86}
367 - : ${DEFAULT_ABI=x32}
368 - ;;
369 - *)
370 - : ${MULTILIB_ABIS=amd64 x86}
371 - : ${DEFAULT_ABI=amd64}
372 - ;;
373 - esac
374 - ;;
375 - mips64*|mipsisa64*)
376 - export CFLAGS_o32=${CFLAGS_o32--mabi=32}
377 - export CHOST_o32=${CTARGET/mips64/mips}
378 - export CHOST_o32=${CHOST_o32/mipsisa64/mipsisa32}
379 - export CTARGET_o32=${CHOST_o32}
380 - export LIBDIR_o32="lib"
381 -
382 - export CFLAGS_n32=${CFLAGS_n32--mabi=n32}
383 - export CHOST_n32=${CTARGET}
384 - export CTARGET_n32=${CHOST_n32}
385 - export LIBDIR_n32="lib32"
386 -
387 - export CFLAGS_n64=${CFLAGS_n64--mabi=64}
388 - export CHOST_n64=${CTARGET}
389 - export CTARGET_n64=${CHOST_n64}
390 - export LIBDIR_n64="lib64"
391 -
392 - : ${MULTILIB_ABIS=n64 n32 o32}
393 - : ${DEFAULT_ABI=n32}
394 - ;;
395 - powerpc64*)
396 - export CFLAGS_ppc=${CFLAGS_ppc--m32}
397 - export CHOST_ppc=${CTARGET/powerpc64/powerpc}
398 - export CTARGET_ppc=${CHOST_ppc}
399 - export LIBDIR_ppc="lib"
400 -
401 - export CFLAGS_ppc64=${CFLAGS_ppc64--m64}
402 - export CHOST_ppc64=${CTARGET}
403 - export CTARGET_ppc64=${CHOST_ppc64}
404 - export LIBDIR_ppc64="lib64"
405 -
406 - : ${MULTILIB_ABIS=ppc64 ppc}
407 - : ${DEFAULT_ABI=ppc64}
408 - ;;
409 - riscv64*)
410 - export CFLAGS_lp64d=${CFLAGS_lp64d--mabi=lp64d}
411 - export CHOST_lp64d=${CTARGET}
412 - export CTARGET_lp64d=${CTARGET}
413 - export LIBDIR_lp64d="lib64/lp64d"
414 -
415 - export CFLAGS_lp64=${CFLAGS_lp64--mabi=lp64}
416 - export CHOST_lp64=${CTARGET}
417 - export CTARGET_lp64=${CTARGET}
418 - export LIBDIR_lp64="lib64/lp64"
419 -
420 - : ${MULTILIB_ABIS=lp64d lp64}
421 - : ${DEFAULT_ABI=lp64d}
422 - ;;
423 - s390x*)
424 - export CFLAGS_s390=${CFLAGS_s390--m31} # the 31 is not a typo
425 - export CHOST_s390=${CTARGET/s390x/s390}
426 - export CTARGET_s390=${CHOST_s390}
427 - export LIBDIR_s390="lib"
428 -
429 - export CFLAGS_s390x=${CFLAGS_s390x--m64}
430 - export CHOST_s390x=${CTARGET}
431 - export CTARGET_s390x=${CHOST_s390x}
432 - export LIBDIR_s390x="lib64"
433 -
434 - : ${MULTILIB_ABIS=s390x s390}
435 - : ${DEFAULT_ABI=s390x}
436 - ;;
437 - sparc64*)
438 - export CFLAGS_sparc32=${CFLAGS_sparc32--m32}
439 - export CHOST_sparc32=${CTARGET/sparc64/sparc}
440 - export CTARGET_sparc32=${CHOST_sparc32}
441 - export LIBDIR_sparc32="lib"
442 -
443 - export CFLAGS_sparc64=${CFLAGS_sparc64--m64}
444 - export CHOST_sparc64=${CTARGET}
445 - export CTARGET_sparc64=${CHOST_sparc64}
446 - export LIBDIR_sparc64="lib64"
447 -
448 - : ${MULTILIB_ABIS=sparc64 sparc32}
449 - : ${DEFAULT_ABI=sparc64}
450 - ;;
451 - *)
452 - : ${MULTILIB_ABIS=default}
453 - : ${DEFAULT_ABI=default}
454 - ;;
455 - esac
456 -
457 - export MULTILIB_ABIS DEFAULT_ABI
458 -}
459 -
460 -# @FUNCTION: multilib_toolchain_setup
461 -# @DESCRIPTION:
462 -# Hide multilib details here for packages which are forced to be compiled for a
463 -# specific ABI when run on another ABI (like x86-specific packages on amd64)
464 -multilib_toolchain_setup() {
465 - local v vv
466 -
467 - export ABI=$1
468 -
469 - # First restore any saved state we have laying around.
470 - if [[ ${_DEFAULT_ABI_SAVED} == "true" ]] ; then
471 - for v in CHOST CBUILD AS CC CXX F77 FC LD PKG_CONFIG_{LIBDIR,PATH} ; do
472 - vv="_abi_saved_${v}"
473 - [[ ${!vv+set} == "set" ]] && export ${v}="${!vv}" || unset ${v}
474 - unset ${vv}
475 - done
476 - unset _DEFAULT_ABI_SAVED
477 - fi
478 -
479 - # We want to avoid the behind-the-back magic of gcc-config as it
480 - # screws up ccache and distcc. See #196243 for more info.
481 - if [[ ${ABI} != ${DEFAULT_ABI} ]] ; then
482 - # Back that multilib-ass up so we can restore it later
483 - for v in CHOST CBUILD AS CC CXX F77 FC LD PKG_CONFIG_{LIBDIR,PATH} ; do
484 - vv="_abi_saved_${v}"
485 - [[ ${!v+set} == "set" ]] && export ${vv}="${!v}" || unset ${vv}
486 - done
487 - export _DEFAULT_ABI_SAVED="true"
488 -
489 - # Set CBUILD only if not cross-compiling.
490 - if [[ ${CBUILD} == "${CHOST}" ]]; then
491 - export CBUILD=$(get_abi_CHOST $1)
492 - fi
493 -
494 - # Set the CHOST native first so that we pick up the native
495 - # toolchain and not a cross-compiler by accident #202811.
496 - export CHOST=$(get_abi_CHOST ${DEFAULT_ABI})
497 - export CC="$(tc-getCC) $(get_abi_CFLAGS)"
498 - export CXX="$(tc-getCXX) $(get_abi_CFLAGS)"
499 - export F77="$(tc-getF77) $(get_abi_CFLAGS)"
500 - export FC="$(tc-getFC) $(get_abi_CFLAGS)"
501 - export LD="$(tc-getLD) $(get_abi_LDFLAGS)"
502 - export CHOST=$(get_abi_CHOST $1)
503 - export PKG_CONFIG_LIBDIR=${EPREFIX}/usr/$(get_libdir)/pkgconfig
504 - export PKG_CONFIG_PATH=${EPREFIX}/usr/share/pkgconfig
505 - fi
506 -}
507 -
508 -fi
509
510 diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass
511 deleted file mode 100644
512 index ff66986..0000000
513 --- a/eclass/toolchain.eclass
514 +++ /dev/null
515 @@ -1,2544 +0,0 @@
516 -# Copyright 1999-2018 Gentoo Foundation
517 -# Distributed under the terms of the GNU General Public License v2
518 -
519 -# Maintainer: Toolchain Ninjas <toolchain@g.o>
520 -# @SUPPORTED_EAPIS: 5 6
521 -
522 -DESCRIPTION="The GNU Compiler Collection"
523 -HOMEPAGE="https://gcc.gnu.org/"
524 -RESTRICT="strip" # cross-compilers need controlled stripping
525 -
526 -inherit eutils fixheadtails flag-o-matic gnuconfig libtool multilib pax-utils toolchain-funcs prefix
527 -
528 -if [[ ${PV} == *_pre9999* ]] ; then
529 - EGIT_REPO_URI="git://gcc.gnu.org/git/gcc.git"
530 - # naming style:
531 - # gcc-4.7.1_pre9999 -> gcc-4_7-branch
532 - # Note that the micro version is required or lots of stuff will break.
533 - # To checkout master set gcc_LIVE_BRANCH="master" in the ebuild before
534 - # inheriting this eclass.
535 - EGIT_BRANCH="${PN}-${PV%.?_pre9999}-branch"
536 - EGIT_BRANCH=${EGIT_BRANCH//./_}
537 - inherit git-2
538 -fi
539 -
540 -FEATURES=${FEATURES/multilib-strict/}
541 -
542 -case ${EAPI:-0} in
543 - 0|1|2|3|4*) die "Need to upgrade to at least EAPI=5" ;;
544 - 5*|6) inherit eapi7-ver ;;
545 - *) die "I don't speak EAPI ${EAPI}." ;;
546 -esac
547 -EXPORT_FUNCTIONS pkg_pretend pkg_setup src_unpack src_prepare src_configure \
548 - src_compile src_test src_install pkg_postinst pkg_postrm
549 -
550 -#---->> globals <<----
551 -
552 -export CTARGET=${CTARGET:-${CHOST}}
553 -if [[ ${CTARGET} = ${CHOST} ]] ; then
554 - if [[ ${CATEGORY} == cross-* ]] ; then
555 - export CTARGET=${CATEGORY#cross-}
556 - fi
557 -fi
558 -: ${TARGET_ABI:=${ABI}}
559 -: ${TARGET_MULTILIB_ABIS:=${MULTILIB_ABIS}}
560 -: ${TARGET_DEFAULT_ABI:=${DEFAULT_ABI}}
561 -
562 -is_crosscompile() {
563 - [[ ${CHOST} != ${CTARGET} ]]
564 -}
565 -
566 -# General purpose version check. Without a second arg matches up to minor version (x.x.x)
567 -tc_version_is_at_least() {
568 - ver_test "${2:-${GCC_RELEASE_VER}}" -ge "$1"
569 -}
570 -
571 -# General purpose version range check
572 -# Note that it matches up to but NOT including the second version
573 -tc_version_is_between() {
574 - tc_version_is_at_least "${1}" && ! tc_version_is_at_least "${2}"
575 -}
576 -
577 -GCC_PV=${TOOLCHAIN_GCC_PV:-${PV}}
578 -GCC_PVR=${GCC_PV}
579 -[[ ${PR} != "r0" ]] && GCC_PVR=${GCC_PVR}-${PR}
580 -GCC_RELEASE_VER=$(ver_cut 1-3 ${GCC_PV})
581 -GCC_BRANCH_VER=$(ver_cut 1-2 ${GCC_PV})
582 -GCCMAJOR=$(ver_cut 1 ${GCC_PV})
583 -GCCMINOR=$(ver_cut 2 ${GCC_PV})
584 -GCCMICRO=$(ver_cut 3 ${GCC_PV})
585 -[[ ${BRANCH_UPDATE-notset} == "notset" ]] && \
586 - BRANCH_UPDATE=$(ver_cut 4 ${GCC_PV})
587 -
588 -# According to gcc/c-cppbuiltin.c, GCC_CONFIG_VER MUST match this regex.
589 -# ([^0-9]*-)?[0-9]+[.][0-9]+([.][0-9]+)?([- ].*)?
590 -GCC_CONFIG_VER=${GCC_CONFIG_VER:-$(ver_rs 3 '-' ${GCC_PV})}
591 -
592 -# Pre-release support
593 -if [[ ${GCC_PV} == *_pre* ]] ; then
594 - PRERELEASE=${GCC_PV/_pre/-}
595 -elif [[ ${GCC_PV} == *_alpha* ]] ; then
596 - SNAPSHOT=${GCC_BRANCH_VER}-${GCC_PV##*_alpha}
597 -elif [[ ${GCC_PV} == *_beta* ]] ; then
598 - SNAPSHOT=${GCC_BRANCH_VER}-${GCC_PV##*_beta}
599 -elif [[ ${GCC_PV} == *_rc* ]] ; then
600 - SNAPSHOT=${GCC_PV%_rc*}-RC-${GCC_PV##*_rc}
601 -fi
602 -
603 -if [[ ${SNAPSHOT} == [56789].0-* ]] ; then
604 - # The gcc-5+ releases have dropped the .0 for some reason.
605 - SNAPSHOT=${SNAPSHOT/.0}
606 -fi
607 -
608 -PREFIX=${TOOLCHAIN_PREFIX:-${EPREFIX}/usr}
609 -
610 -if tc_version_is_at_least 3.4.0 ; then
611 - LIBPATH=${TOOLCHAIN_LIBPATH:-${PREFIX}/lib/gcc/${CTARGET}/${GCC_CONFIG_VER}}
612 -else
613 - LIBPATH=${TOOLCHAIN_LIBPATH:-${PREFIX}/lib/gcc-lib/${CTARGET}/${GCC_CONFIG_VER}}
614 -fi
615 -INCLUDEPATH=${TOOLCHAIN_INCLUDEPATH:-${LIBPATH}/include}
616 -
617 -if is_crosscompile ; then
618 - BINPATH=${TOOLCHAIN_BINPATH:-${PREFIX}/${CHOST}/${CTARGET}/gcc-bin/${GCC_CONFIG_VER}}
619 - HOSTLIBPATH=${PREFIX}/${CHOST}/${CTARGET}/lib/${GCC_CONFIG_VER}
620 -else
621 - BINPATH=${TOOLCHAIN_BINPATH:-${PREFIX}/${CTARGET}/gcc-bin/${GCC_CONFIG_VER}}
622 -fi
623 -
624 -DATAPATH=${TOOLCHAIN_DATAPATH:-${PREFIX}/share/gcc-data/${CTARGET}/${GCC_CONFIG_VER}}
625 -
626 -# Dont install in /usr/include/g++-v3/, but in gcc internal directory.
627 -# We will handle /usr/include/g++-v3/ with gcc-config ...
628 -STDCXX_INCDIR=${TOOLCHAIN_STDCXX_INCDIR:-${LIBPATH}/include/g++-v${GCC_BRANCH_VER/\.*/}}
629 -
630 -#---->> LICENSE+SLOT+IUSE logic <<----
631 -
632 -if tc_version_is_at_least 4.6 ; then
633 - LICENSE="GPL-3+ LGPL-3+ || ( GPL-3+ libgcc libstdc++ gcc-runtime-library-exception-3.1 ) FDL-1.3+"
634 -elif tc_version_is_at_least 4.4 ; then
635 - LICENSE="GPL-3+ LGPL-3+ || ( GPL-3+ libgcc libstdc++ gcc-runtime-library-exception-3.1 ) FDL-1.2+"
636 -elif tc_version_is_at_least 4.3 ; then
637 - LICENSE="GPL-3+ LGPL-3+ || ( GPL-3+ libgcc libstdc++ ) FDL-1.2+"
638 -elif tc_version_is_at_least 4.2 ; then
639 - LICENSE="GPL-3+ LGPL-2.1+ || ( GPL-3+ libgcc libstdc++ ) FDL-1.2+"
640 -elif tc_version_is_at_least 3.3 ; then
641 - LICENSE="GPL-2+ LGPL-2.1+ FDL-1.2+"
642 -else
643 - LICENSE="GPL-2+ LGPL-2.1+ FDL-1.1+"
644 -fi
645 -
646 -if tc_version_is_at_least 8.3; then
647 - GCC_EBUILD_TEST_FLAG='test'
648 -else
649 - # Don't force USE regression-test->test change on every
650 - # gcc ebuild just yet. Let's do the change when >=gcc-8.3
651 - # is commonly used as a main compiler.
652 - GCC_EBUILD_TEST_FLAG='regression-test'
653 -fi
654 -IUSE="${GCC_EBUILD_TEST_FLAG} vanilla +nls +nptl"
655 -
656 -TC_FEATURES=()
657 -
658 -tc_has_feature() {
659 - has "$1" "${TC_FEATURES[@]}"
660 -}
661 -
662 -if [[ ${PN} != "kgcc64" && ${PN} != gcc-* ]] ; then
663 - IUSE+=" altivec debug +cxx +fortran" TC_FEATURES+=(fortran)
664 - [[ -n ${PIE_VER} ]] && IUSE+=" nopie"
665 - [[ -n ${HTB_VER} ]] && IUSE+=" boundschecking"
666 - [[ -n ${D_VER} ]] && IUSE+=" d"
667 - [[ -n ${SPECS_VER} ]] && IUSE+=" nossp"
668 - tc_version_is_at_least 3 && IUSE+=" doc hardened multilib objc"
669 - tc_version_is_between 3 7 && IUSE+=" awt gcj" TC_FEATURES+=(gcj)
670 - tc_version_is_at_least 3.3 && IUSE+=" pgo"
671 - tc_version_is_at_least 4.0 &&
672 - IUSE+=" objc-gc" TC_FEATURES+=(objc-gc)
673 - tc_version_is_between 4.0 4.9 && IUSE+=" mudflap"
674 - tc_version_is_at_least 4.1 && IUSE+=" libssp objc++"
675 - tc_version_is_at_least 4.2 && IUSE+=" +openmp"
676 - tc_version_is_at_least 4.3 && IUSE+=" fixed-point"
677 - tc_version_is_at_least 4.7 && IUSE+=" go"
678 - # Note: while <=gcc-4.7 also supported graphite, it required forked ppl
679 - # versions which we dropped. Since graphite was also experimental in
680 - # the older versions, we don't want to bother supporting it. #448024
681 - tc_version_is_at_least 4.8 &&
682 - IUSE+=" graphite +sanitize" TC_FEATURES+=(graphite)
683 - tc_version_is_between 4.9 8 && IUSE+=" cilk"
684 - tc_version_is_at_least 4.9 && IUSE+=" +vtv"
685 - tc_version_is_at_least 5.0 && IUSE+=" jit mpx"
686 - tc_version_is_at_least 6.0 && IUSE+=" +pie +ssp +pch"
687 - # systemtap is a gentoo-specific switch: bug #654748
688 - tc_version_is_at_least 8.0 &&
689 - IUSE+=" systemtap" TC_FEATURES+=(systemtap)
690 -fi
691 -
692 -SLOT="${GCC_CONFIG_VER}"
693 -
694 -#---->> DEPEND <<----
695 -
696 -RDEPEND="sys-libs/zlib
697 - nls? ( virtual/libintl )"
698 -
699 -tc_version_is_at_least 3 && RDEPEND+=" virtual/libiconv"
700 -
701 -if tc_version_is_at_least 4 ; then
702 - GMP_MPFR_DEPS=">=dev-libs/gmp-4.3.2:0= >=dev-libs/mpfr-2.4.2:0="
703 - if tc_version_is_at_least 4.3 ; then
704 - RDEPEND+=" ${GMP_MPFR_DEPS}"
705 - elif tc_has_feature fortran ; then
706 - RDEPEND+=" fortran? ( ${GMP_MPFR_DEPS} )"
707 - fi
708 -fi
709 -
710 -tc_version_is_at_least 4.5 && RDEPEND+=" >=dev-libs/mpc-0.8.1:0="
711 -
712 -if tc_has_feature objc-gc ; then
713 - if tc_version_is_at_least 7 ; then
714 - RDEPEND+=" objc-gc? ( >=dev-libs/boehm-gc-7.4.2 )"
715 - fi
716 -fi
717 -
718 -if tc_has_feature graphite ; then
719 - if tc_version_is_at_least 5.0 ; then
720 - RDEPEND+=" graphite? ( >=dev-libs/isl-0.14:0= )"
721 - elif tc_version_is_at_least 4.8 ; then
722 - RDEPEND+="
723 - graphite? (
724 - >=dev-libs/cloog-0.18.0:0=
725 - >=dev-libs/isl-0.11.1:0=
726 - )"
727 - fi
728 -fi
729 -
730 -DEPEND="${RDEPEND}
731 - >=sys-devel/bison-1.875
732 - >=sys-devel/flex-2.5.4
733 - nls? ( sys-devel/gettext )
734 - ${GCC_EBUILD_TEST_FLAG}? (
735 - >=dev-util/dejagnu-1.4.4
736 - >=sys-devel/autogen-5.5.4
737 - )"
738 -
739 -if tc_has_feature gcj ; then
740 - GCJ_DEPS=">=media-libs/libart_lgpl-2.1"
741 - GCJ_GTK_DEPS="
742 - x11-base/xorg-proto
743 - x11-libs/libXt
744 - x11-libs/libX11
745 - x11-libs/libXtst
746 - =x11-libs/gtk+-2*
747 - virtual/pkgconfig
748 - "
749 - tc_version_is_at_least 3.4 && GCJ_GTK_DEPS+=" x11-libs/pango"
750 - tc_version_is_at_least 4.2 && GCJ_DEPS+=" app-arch/zip app-arch/unzip"
751 - DEPEND+=" gcj? ( awt? ( ${GCJ_GTK_DEPS} ) ${GCJ_DEPS} )"
752 -fi
753 -
754 -if tc_has_feature systemtap ; then
755 - # gcc needs sys/sdt.h headers on target
756 - DEPEND+=" systemtap? ( dev-util/systemtap )"
757 -fi
758 -
759 -PDEPEND=">=sys-devel/gcc-config-1.7"
760 -
761 -#---->> S + SRC_URI essentials <<----
762 -
763 -# Set the source directory depending on whether we're using
764 -# a prerelease, snapshot, or release tarball.
765 -S=$(
766 - if [[ -n ${PRERELEASE} ]] ; then
767 - echo ${WORKDIR}/gcc-${PRERELEASE}
768 - elif [[ -n ${SNAPSHOT} ]] ; then
769 - echo ${WORKDIR}/gcc-${SNAPSHOT}
770 - else
771 - echo ${WORKDIR}/gcc-${GCC_RELEASE_VER}
772 - fi
773 -)
774 -
775 -gentoo_urls() {
776 - local devspace="HTTP~vapier/dist/URI HTTP~rhill/dist/URI
777 - HTTP~zorry/patches/gcc/URI HTTP~blueness/dist/URI
778 - HTTP~tamiko/distfiles/URI HTTP~slyfox/distfiles/URI"
779 - devspace=${devspace//HTTP/https:\/\/dev.gentoo.org\/}
780 - echo mirror://gentoo/$1 ${devspace//URI/$1}
781 -}
782 -
783 -# This function handles the basics of setting the SRC_URI for a gcc ebuild.
784 -# To use, set SRC_URI with:
785 -#
786 -# SRC_URI="$(get_gcc_src_uri)"
787 -#
788 -# Other than the variables normally set by portage, this function's behavior
789 -# can be altered by setting the following:
790 -#
791 -# SNAPSHOT
792 -# If set, this variable signals that we should be using a snapshot of
793 -# gcc. It is expected to be in the format "YYYY-MM-DD". Note that if
794 -# the ebuild has a _pre suffix, this variable is ignored and the
795 -# prerelease tarball is used instead.
796 -#
797 -# BRANCH_UPDATE
798 -# If set, this variable signals that we should be using the main
799 -# release tarball (determined by ebuild version) and applying a
800 -# CVS branch update patch against it. The location of this branch
801 -# update patch is assumed to be in ${GENTOO_TOOLCHAIN_BASE_URI}.
802 -# Just like with SNAPSHOT, this variable is ignored if the ebuild
803 -# has a _pre suffix.
804 -#
805 -# PATCH_VER
806 -# PATCH_GCC_VER
807 -# This should be set to the version of the gentoo patch tarball.
808 -# The resulting filename of this tarball will be:
809 -# gcc-${PATCH_GCC_VER:-${GCC_RELEASE_VER}}-patches-${PATCH_VER}.tar.bz2
810 -#
811 -# PIE_VER
812 -# PIE_GCC_VER
813 -# These variables control patching in various updates for the logic
814 -# controlling Position Independant Executables. PIE_VER is expected
815 -# to be the version of this patch, and PIE_GCC_VER the gcc version of
816 -# the patch:
817 -# An example:
818 -# PIE_VER="8.7.6.5"
819 -# PIE_GCC_VER="3.4.0"
820 -# The resulting filename of this tarball will be:
821 -# gcc-${PIE_GCC_VER:-${GCC_RELEASE_VER}}-piepatches-v${PIE_VER}.tar.bz2
822 -#
823 -# SPECS_VER
824 -# SPECS_GCC_VER
825 -# This is for the minispecs files included in the hardened gcc-4.x
826 -# The specs files for hardenedno*, vanilla and for building the "specs" file.
827 -# SPECS_VER is expected to be the version of this patch, SPECS_GCC_VER
828 -# the gcc version of the patch.
829 -# An example:
830 -# SPECS_VER="8.7.6.5"
831 -# SPECS_GCC_VER="3.4.0"
832 -# The resulting filename of this tarball will be:
833 -# gcc-${SPECS_GCC_VER:-${GCC_RELEASE_VER}}-specs-${SPECS_VER}.tar.bz2
834 -#
835 -# HTB_VER
836 -# HTB_GCC_VER
837 -# These variables control whether or not an ebuild supports Herman
838 -# ten Brugge's bounds-checking patches. If you want to use a patch
839 -# for an older gcc version with a new gcc, make sure you set
840 -# HTB_GCC_VER to that version of gcc.
841 -#
842 -# CYGWINPORTS_GITREV
843 -# If set, this variable signals that we should apply additional patches
844 -# maintained by upstream Cygwin developers at github/cygwinports/gcc,
845 -# using the specified git commit id there. The list of patches to
846 -# apply is extracted from gcc.cygport, maintained there as well.
847 -# This is done for compilers running on Cygwin, not for cross compilers
848 -# with a Cygwin target.
849 -get_gcc_src_uri() {
850 - export PATCH_GCC_VER=${PATCH_GCC_VER:-${GCC_RELEASE_VER}}
851 - export UCLIBC_GCC_VER=${UCLIBC_GCC_VER:-${PATCH_GCC_VER}}
852 - export PIE_GCC_VER=${PIE_GCC_VER:-${GCC_RELEASE_VER}}
853 - export HTB_GCC_VER=${HTB_GCC_VER:-${GCC_RELEASE_VER}}
854 - export SPECS_GCC_VER=${SPECS_GCC_VER:-${GCC_RELEASE_VER}}
855 -
856 - # Set where to download gcc itself depending on whether we're using a
857 - # prerelease, snapshot, or release tarball.
858 - if [[ ${PV} == *9999* ]] ; then
859 - # Nothing to do w/git snapshots.
860 - :
861 - elif [[ -n ${PRERELEASE} ]] ; then
862 - GCC_SRC_URI="ftp://gcc.gnu.org/pub/gcc/prerelease-${PRERELEASE}/gcc-${PRERELEASE}.tar.bz2"
863 - elif [[ -n ${SNAPSHOT} ]] ; then
864 - if tc_version_is_between 5.5 6 || tc_version_is_between 6.4 7 || tc_version_is_at_least 7.2 ; then
865 - GCC_SRC_URI="ftp://gcc.gnu.org/pub/gcc/snapshots/${SNAPSHOT}/gcc-${SNAPSHOT}.tar.xz"
866 - else
867 - GCC_SRC_URI="ftp://gcc.gnu.org/pub/gcc/snapshots/${SNAPSHOT}/gcc-${SNAPSHOT}.tar.bz2"
868 - fi
869 - else
870 - if tc_version_is_between 5.5 6 || tc_version_is_between 6.4 7 || tc_version_is_at_least 7.2 ; then
871 - GCC_SRC_URI="mirror://gnu/gcc/gcc-${GCC_PV}/gcc-${GCC_RELEASE_VER}.tar.xz"
872 - else
873 - GCC_SRC_URI="mirror://gnu/gcc/gcc-${GCC_PV}/gcc-${GCC_RELEASE_VER}.tar.bz2"
874 - fi
875 - # we want all branch updates to be against the main release
876 - [[ -n ${BRANCH_UPDATE} ]] && \
877 - GCC_SRC_URI+=" $(gentoo_urls gcc-${GCC_RELEASE_VER}-branch-update-${BRANCH_UPDATE}.patch.bz2)"
878 - fi
879 -
880 - [[ -n ${UCLIBC_VER} ]] && \
881 - GCC_SRC_URI+=" $(gentoo_urls gcc-${UCLIBC_GCC_VER}-uclibc-patches-${UCLIBC_VER}.tar.bz2)"
882 - [[ -n ${PATCH_VER} ]] && \
883 - GCC_SRC_URI+=" $(gentoo_urls gcc-${PATCH_GCC_VER}-patches-${PATCH_VER}.tar.bz2)"
884 -
885 - # strawberry pie, Cappuccino and a Gauloises (it's a good thing)
886 - [[ -n ${PIE_VER} ]] && \
887 - PIE_CORE=${PIE_CORE:-gcc-${PIE_GCC_VER}-piepatches-v${PIE_VER}.tar.bz2} && \
888 - GCC_SRC_URI+=" $(gentoo_urls ${PIE_CORE})"
889 -
890 - # gcc minispec for the hardened gcc 4 compiler
891 - [[ -n ${SPECS_VER} ]] && \
892 - GCC_SRC_URI+=" $(gentoo_urls gcc-${SPECS_GCC_VER}-specs-${SPECS_VER}.tar.bz2)"
893 -
894 - # gcc bounds checking patch
895 - if [[ -n ${HTB_VER} ]] ; then
896 - local HTBFILE="bounds-checking-gcc-${HTB_GCC_VER}-${HTB_VER}.patch.bz2"
897 - GCC_SRC_URI+="
898 - boundschecking? (
899 - mirror://sourceforge/boundschecking/${HTBFILE}
900 - $(gentoo_urls ${HTBFILE})
901 - )"
902 - fi
903 -
904 - [[ -n ${D_VER} ]] && \
905 - GCC_SRC_URI+=" d? ( mirror://sourceforge/dgcc/gdc-${D_VER}-src.tar.bz2 )"
906 -
907 - if tc_has_feature gcj ; then
908 - if tc_version_is_at_least 4.5 ; then
909 - GCC_SRC_URI+=" gcj? ( ftp://sourceware.org/pub/java/ecj-4.5.jar )"
910 - elif tc_version_is_at_least 4.3 ; then
911 - GCC_SRC_URI+=" gcj? ( ftp://sourceware.org/pub/java/ecj-4.3.jar )"
912 - fi
913 - fi
914 -
915 - # Cygwin patches from https://github.com/cygwinports/gcc
916 - [[ -n ${CYGWINPORTS_GITREV} ]] && \
917 - GCC_SRC_URI+=" elibc_Cygwin? ( https://github.com/cygwinports/gcc/archive/${CYGWINPORTS_GITREV}.tar.gz
918 - -> gcc-cygwinports-${CYGWINPORTS_GITREV}.tar.gz )"
919 -
920 - echo "${GCC_SRC_URI}"
921 -}
922 -
923 -SRC_URI=$(get_gcc_src_uri)
924 -
925 -#---->> pkg_pretend <<----
926 -
927 -toolchain_pkg_pretend() {
928 - if [[ -n ${PRERELEASE}${SNAPSHOT} || ${PV} == *9999* ]] &&
929 - [[ -z ${I_PROMISE_TO_SUPPLY_PATCHES_WITH_BUGS} ]] ; then
930 - die "Please \`export I_PROMISE_TO_SUPPLY_PATCHES_WITH_BUGS=1\` or define it" \
931 - "in your make.conf if you want to use this version."
932 - fi
933 -
934 - if ! use_if_iuse cxx ; then
935 - use_if_iuse go && ewarn 'Go requires a C++ compiler, disabled due to USE="-cxx"'
936 - use_if_iuse objc++ && ewarn 'Obj-C++ requires a C++ compiler, disabled due to USE="-cxx"'
937 - use_if_iuse gcj && ewarn 'GCJ requires a C++ compiler, disabled due to USE="-cxx"'
938 - fi
939 -
940 - want_minispecs
941 -}
942 -
943 -#---->> pkg_setup <<----
944 -
945 -toolchain_pkg_setup() {
946 - # we dont want to use the installed compiler's specs to build gcc
947 - unset GCC_SPECS
948 - unset LANGUAGES #265283
949 -}
950 -
951 -#---->> src_unpack <<----
952 -
953 -toolchain_src_unpack() {
954 - if [[ ${PV} == *9999* ]]; then
955 - git-2_src_unpack
956 - else
957 - gcc_quick_unpack
958 - fi
959 -}
960 -
961 -gcc_quick_unpack() {
962 - pushd "${WORKDIR}" > /dev/null
963 - export PATCH_GCC_VER=${PATCH_GCC_VER:-${GCC_RELEASE_VER}}
964 - export UCLIBC_GCC_VER=${UCLIBC_GCC_VER:-${PATCH_GCC_VER}}
965 - export PIE_GCC_VER=${PIE_GCC_VER:-${GCC_RELEASE_VER}}
966 - export HTB_GCC_VER=${HTB_GCC_VER:-${GCC_RELEASE_VER}}
967 - export SPECS_GCC_VER=${SPECS_GCC_VER:-${GCC_RELEASE_VER}}
968 -
969 - if [[ -n ${GCC_A_FAKEIT} ]] ; then
970 - unpack ${GCC_A_FAKEIT}
971 - elif [[ -n ${PRERELEASE} ]] ; then
972 - unpack gcc-${PRERELEASE}.tar.bz2
973 - elif [[ -n ${SNAPSHOT} ]] ; then
974 - if tc_version_is_between 5.5 6 || tc_version_is_between 6.4 7 || tc_version_is_at_least 7.2 ; then
975 - unpack gcc-${SNAPSHOT}.tar.xz
976 - else
977 - unpack gcc-${SNAPSHOT}.tar.bz2
978 - fi
979 - elif [[ ${PV} != *9999* ]] ; then
980 - if tc_version_is_between 5.5 6 || tc_version_is_between 6.4 7 || tc_version_is_at_least 7.2 ; then
981 - unpack gcc-${GCC_RELEASE_VER}.tar.xz
982 - else
983 - unpack gcc-${GCC_RELEASE_VER}.tar.bz2
984 - fi
985 - # We want branch updates to be against a release tarball
986 - if [[ -n ${BRANCH_UPDATE} ]] ; then
987 - pushd "${S}" > /dev/null
988 - epatch "${DISTDIR}"/gcc-${GCC_RELEASE_VER}-branch-update-${BRANCH_UPDATE}.patch.bz2
989 - popd > /dev/null
990 - fi
991 - fi
992 -
993 - if [[ -n ${D_VER} ]] && use d ; then
994 - pushd "${S}"/gcc > /dev/null
995 - unpack gdc-${D_VER}-src.tar.bz2
996 - cd ..
997 - ebegin "Adding support for the D language"
998 - ./gcc/d/setup-gcc.sh >& "${T}"/dgcc.log
999 - if ! eend $? ; then
1000 - eerror "The D GCC package failed to apply"
1001 - eerror "Please include this log file when posting a bug report:"
1002 - eerror " ${T}/dgcc.log"
1003 - die "failed to include the D language"
1004 - fi
1005 - popd > /dev/null
1006 - fi
1007 -
1008 - [[ -n ${PATCH_VER} ]] && \
1009 - unpack gcc-${PATCH_GCC_VER}-patches-${PATCH_VER}.tar.bz2
1010 -
1011 - [[ -n ${UCLIBC_VER} ]] && \
1012 - unpack gcc-${UCLIBC_GCC_VER}-uclibc-patches-${UCLIBC_VER}.tar.bz2
1013 -
1014 - if want_pie ; then
1015 - if [[ -n ${PIE_CORE} ]] ; then
1016 - unpack ${PIE_CORE}
1017 - else
1018 - unpack gcc-${PIE_GCC_VER}-piepatches-v${PIE_VER}.tar.bz2
1019 - fi
1020 - [[ -n ${SPECS_VER} ]] && \
1021 - unpack gcc-${SPECS_GCC_VER}-specs-${SPECS_VER}.tar.bz2
1022 - fi
1023 -
1024 - use_if_iuse boundschecking && unpack "bounds-checking-gcc-${HTB_GCC_VER}-${HTB_VER}.patch.bz2"
1025 -
1026 - [[ -n ${CYGWINPORTS_GITREV} ]] && use elibc_Cygwin && unpack "gcc-cygwinports-${CYGWINPORTS_GITREV}.tar.gz"
1027 -
1028 - popd > /dev/null
1029 -}
1030 -
1031 -#---->> src_prepare <<----
1032 -
1033 -toolchain_src_prepare() {
1034 - export BRANDING_GCC_PKGVERSION="Gentoo ${GCC_PVR}"
1035 - cd "${S}"
1036 -
1037 - if ! use vanilla ; then
1038 - if [[ -n ${PATCH_VER} ]] ; then
1039 - guess_patch_type_in_dir "${WORKDIR}"/patch
1040 - EPATCH_MULTI_MSG="Applying Gentoo patches ..." \
1041 - epatch "${WORKDIR}"/patch
1042 - BRANDING_GCC_PKGVERSION="${BRANDING_GCC_PKGVERSION} p${PATCH_VER}"
1043 - fi
1044 - if [[ -n ${UCLIBC_VER} ]] ; then
1045 - guess_patch_type_in_dir "${WORKDIR}"/uclibc
1046 - EPATCH_MULTI_MSG="Applying uClibc patches ..." \
1047 - epatch "${WORKDIR}"/uclibc
1048 - fi
1049 - fi
1050 - do_gcc_HTB_patches
1051 - do_gcc_PIE_patches
1052 - do_gcc_CYGWINPORTS_patches
1053 -
1054 - case ${EAPI:-0} in
1055 - 5*) epatch_user;;
1056 - 6) eapply_user ;;
1057 - *) die "Update toolchain_src_prepare() for ${EAPI}." ;;
1058 - esac
1059 -
1060 - if ( tc_version_is_at_least 4.8.2 || use_if_iuse hardened ) && ! use vanilla ; then
1061 - make_gcc_hard
1062 - fi
1063 -
1064 - # install the libstdc++ python into the right location
1065 - # http://gcc.gnu.org/PR51368
1066 - if tc_version_is_between 4.5 4.7 ; then
1067 - sed -i \
1068 - '/^pythondir =/s:=.*:= $(datadir)/python:' \
1069 - "${S}"/libstdc++-v3/python/Makefile.in || die
1070 - fi
1071 -
1072 - # make sure the pkg config files install into multilib dirs.
1073 - # since we configure with just one --libdir, we can't use that
1074 - # (as gcc itself takes care of building multilibs). #435728
1075 - find "${S}" -name Makefile.in \
1076 - -exec sed -i '/^pkgconfigdir/s:=.*:=$(toolexeclibdir)/pkgconfig:' {} +
1077 -
1078 - # No idea when this first started being fixed, but let's go with 4.3.x for now
1079 - if ! tc_version_is_at_least 4.3 ; then
1080 - fix_files=""
1081 - for x in contrib/test_summary libstdc++-v3/scripts/check_survey.in ; do
1082 - [[ -e ${x} ]] && fix_files="${fix_files} ${x}"
1083 - done
1084 - ht_fix_file ${fix_files} */configure *.sh */Makefile.in
1085 - fi
1086 -
1087 - setup_multilib_osdirnames
1088 - gcc_version_patch
1089 -
1090 - if tc_version_is_at_least 4.1 ; then
1091 - if [[ -n ${SNAPSHOT} || -n ${PRERELEASE} ]] ; then
1092 - # BASE-VER must be a three-digit version number
1093 - # followed by an optional -pre string
1094 - # eg. 4.5.1, 4.6.2-pre20120213, 4.7.0-pre9999
1095 - # If BASE-VER differs from ${PV/_/-} then libraries get installed in
1096 - # the wrong directory.
1097 - echo ${PV/_/-} > "${S}"/gcc/BASE-VER
1098 - fi
1099 - fi
1100 -
1101 - # >= gcc-4.3 doesn't bundle ecj.jar, so copy it
1102 - if tc_version_is_at_least 4.3 && use_if_iuse gcj ; then
1103 - if tc_version_is_at_least 4.5 ; then
1104 - einfo "Copying ecj-4.5.jar"
1105 - cp -pPR "${DISTDIR}/ecj-4.5.jar" "${S}/ecj.jar" || die
1106 - else
1107 - einfo "Copying ecj-4.3.jar"
1108 - cp -pPR "${DISTDIR}/ecj-4.3.jar" "${S}/ecj.jar" || die
1109 - fi
1110 - fi
1111 -
1112 - # disable --as-needed from being compiled into gcc specs
1113 - # natively when using a gcc version < 3.4.4
1114 - # http://gcc.gnu.org/PR14992
1115 - if ! tc_version_is_at_least 3.4.4 ; then
1116 - sed -i -e s/HAVE_LD_AS_NEEDED/USE_LD_AS_NEEDED/g "${S}"/gcc/config.in
1117 - fi
1118 -
1119 - # In gcc 3.3.x and 3.4.x, rename the java bins to gcc-specific names
1120 - # in line with gcc-4.
1121 - if tc_version_is_between 3.3 4.0 ; then
1122 - do_gcc_rename_java_bins
1123 - fi
1124 -
1125 - # Prevent libffi from being installed
1126 - if tc_version_is_between 3.0 4.8 ; then
1127 - sed -i -e 's/\(install.*:\) install-.*recursive/\1/' "${S}"/libffi/Makefile.in || die
1128 - sed -i -e 's/\(install-data-am:\).*/\1/' "${S}"/libffi/include/Makefile.in || die
1129 - fi
1130 -
1131 - # Fixup libtool to correctly generate .la files with portage
1132 - elibtoolize --portage --shallow --no-uclibc
1133 -
1134 - gnuconfig_update
1135 -
1136 - # update configure files
1137 - local f
1138 - einfo "Fixing misc issues in configure files"
1139 - for f in $(grep -l 'autoconf version 2.13' $(find "${S}" -name configure)) ; do
1140 - ebegin " Updating ${f/${S}\/} [LANG]"
1141 - patch "${f}" "${FILESDIR}"/gcc-configure-LANG.patch >& "${T}"/configure-patch.log \
1142 - || eerror "Please file a bug about this"
1143 - eend $?
1144 - done
1145 - sed -i 's|A-Za-z0-9|[:alnum:]|g' "${S}"/gcc/*.awk #215828
1146 -
1147 - # Prevent new texinfo from breaking old versions (see #198182, #464008)
1148 - tc_version_is_at_least 4.1 && epatch "${FILESDIR}"/gcc-configure-texinfo.patch
1149 -
1150 - if [[ -x contrib/gcc_update ]] ; then
1151 - einfo "Touching generated files"
1152 - ./contrib/gcc_update --touch | \
1153 - while read f ; do
1154 - einfo " ${f%%...}"
1155 - done
1156 - fi
1157 -}
1158 -
1159 -guess_patch_type_in_dir() {
1160 - [[ -n $(ls "$1"/*.bz2 2>/dev/null) ]] \
1161 - && EPATCH_SUFFIX="patch.bz2" \
1162 - || EPATCH_SUFFIX="patch"
1163 -}
1164 -
1165 -do_gcc_HTB_patches() {
1166 - use_if_iuse boundschecking || return 0
1167 -
1168 - # modify the bounds checking patch with a regression patch
1169 - epatch "${WORKDIR}/bounds-checking-gcc-${HTB_GCC_VER}-${HTB_VER}.patch"
1170 - BRANDING_GCC_PKGVERSION="${BRANDING_GCC_PKGVERSION}, HTB-${HTB_GCC_VER}-${HTB_VER}"
1171 -}
1172 -
1173 -do_gcc_PIE_patches() {
1174 - want_pie || return 0
1175 - use vanilla && return 0
1176 -
1177 - if tc_version_is_at_least 4.3.2 ; then
1178 - guess_patch_type_in_dir "${WORKDIR}"/piepatch/
1179 - EPATCH_MULTI_MSG="Applying pie patches ..." \
1180 - epatch "${WORKDIR}"/piepatch/
1181 - else
1182 - guess_patch_type_in_dir "${WORKDIR}"/piepatch/upstream
1183 -
1184 - # corrects startfile/endfile selection and shared/static/pie flag usage
1185 - EPATCH_MULTI_MSG="Applying upstream pie patches ..." \
1186 - epatch "${WORKDIR}"/piepatch/upstream
1187 - # adds non-default pie support (rs6000)
1188 - EPATCH_MULTI_MSG="Applying non-default pie patches ..." \
1189 - epatch "${WORKDIR}"/piepatch/nondef
1190 - # adds default pie support (rs6000 too) if DEFAULT_PIE[_SSP] is defined
1191 - EPATCH_MULTI_MSG="Applying default pie patches ..." \
1192 - epatch "${WORKDIR}"/piepatch/def
1193 - fi
1194 -
1195 - BRANDING_GCC_PKGVERSION="${BRANDING_GCC_PKGVERSION}, pie-${PIE_VER}"
1196 -}
1197 -
1198 -do_gcc_CYGWINPORTS_patches() {
1199 - [[ -n ${CYGWINPORTS_GITREV} ]] || return 0
1200 - use elibc_Cygwin || return 0
1201 -
1202 - local -a patches
1203 - local p d="${WORKDIR}/gcc-${CYGWINPORTS_GITREV}"
1204 - readarray -t patches < <(sed -e '1,/PATCH_URI="/d;/"/,$d' < "${d}"/gcc.cygport)
1205 - for p in ${patches[*]}; do
1206 - epatch "${d}/${p}"
1207 - done
1208 -}
1209 -
1210 -# configure to build with the hardened GCC specs as the default
1211 -make_gcc_hard() {
1212 -
1213 - local gcc_hard_flags=""
1214 -
1215 - # If we use gcc-6 or newer with pie enable to compile older gcc we need to pass -no-pie
1216 - # to stage1; bug 618908
1217 - if ! tc_version_is_at_least 6.0 && [[ $(gcc-major-version) -ge 6 ]] ; then
1218 - einfo "Disabling PIE in stage1 (only) ..."
1219 - sed -i -e "/^STAGE1_LDFLAGS/ s/$/ -no-pie/" "${S}"/Makefile.in || die
1220 - fi
1221 -
1222 - # Gcc >= 6.X we can use configurations options to turn pie/ssp on as default
1223 - if tc_version_is_at_least 6.0 ; then
1224 - if use_if_iuse pie ; then
1225 - einfo "Updating gcc to use automatic PIE building ..."
1226 - fi
1227 - if use_if_iuse ssp ; then
1228 - einfo "Updating gcc to use automatic SSP building ..."
1229 - fi
1230 - if use_if_iuse hardened ; then
1231 - # Will add some optimatizion as default.
1232 - gcc_hard_flags+=" -DEXTRA_OPTIONS"
1233 - # rebrand to make bug reports easier
1234 - BRANDING_GCC_PKGVERSION=${BRANDING_GCC_PKGVERSION/Gentoo/Gentoo Hardened}
1235 - fi
1236 - else
1237 - if use_if_iuse hardened ; then
1238 - # rebrand to make bug reports easier
1239 - BRANDING_GCC_PKGVERSION=${BRANDING_GCC_PKGVERSION/Gentoo/Gentoo Hardened}
1240 - if hardened_gcc_works ; then
1241 - einfo "Updating gcc to use automatic PIE + SSP building ..."
1242 - gcc_hard_flags+=" -DEFAULT_PIE_SSP"
1243 - elif hardened_gcc_works pie ; then
1244 - einfo "Updating gcc to use automatic PIE building ..."
1245 - ewarn "SSP has not been enabled by default"
1246 - gcc_hard_flags+=" -DEFAULT_PIE"
1247 - elif hardened_gcc_works ssp ; then
1248 - einfo "Updating gcc to use automatic SSP building ..."
1249 - ewarn "PIE has not been enabled by default"
1250 - gcc_hard_flags+=" -DEFAULT_SSP"
1251 - else
1252 - # do nothing if hardened isn't supported, but don't die either
1253 - ewarn "hardened is not supported for this arch in this gcc version"
1254 - return 0
1255 - fi
1256 - else
1257 - if hardened_gcc_works ssp ; then
1258 - einfo "Updating gcc to use automatic SSP building ..."
1259 - gcc_hard_flags+=" -DEFAULT_SSP"
1260 - fi
1261 - fi
1262 - fi
1263 -
1264 - # we want to be able to control the pie patch logic via something other
1265 - # than ALL_CFLAGS...
1266 - sed -e '/^ALL_CFLAGS/iHARD_CFLAGS = ' \
1267 - -e 's|^ALL_CFLAGS = |ALL_CFLAGS = $(HARD_CFLAGS) |' \
1268 - -i "${S}"/gcc/Makefile.in
1269 - # Need to add HARD_CFLAGS to ALL_CXXFLAGS on >= 4.7
1270 - if tc_version_is_at_least 4.7 ; then
1271 - sed -e '/^ALL_CXXFLAGS/iHARD_CFLAGS = ' \
1272 - -e 's|^ALL_CXXFLAGS = |ALL_CXXFLAGS = $(HARD_CFLAGS) |' \
1273 - -i "${S}"/gcc/Makefile.in
1274 - fi
1275 -
1276 - sed -i \
1277 - -e "/^HARD_CFLAGS = /s|=|= ${gcc_hard_flags} |" \
1278 - "${S}"/gcc/Makefile.in || die
1279 -
1280 -}
1281 -
1282 -# This is a historical wart. The original Gentoo/amd64 port used:
1283 -# lib32 - 32bit binaries (x86)
1284 -# lib64 - 64bit binaries (x86_64)
1285 -# lib - "native" binaries (a symlink to lib64)
1286 -# Most other distros use the logic (including mainline gcc):
1287 -# lib - 32bit binaries (x86)
1288 -# lib64 - 64bit binaries (x86_64)
1289 -# Over time, Gentoo is migrating to the latter form.
1290 -#
1291 -# Unfortunately, due to distros picking the lib32 behavior, newer gcc
1292 -# versions will dynamically detect whether to use lib or lib32 for its
1293 -# 32bit multilib. So, to keep the automagic from getting things wrong
1294 -# while people are transitioning from the old style to the new style,
1295 -# we always set the MULTILIB_OSDIRNAMES var for relevant targets.
1296 -setup_multilib_osdirnames() {
1297 - is_multilib || return 0
1298 -
1299 - local config
1300 - local libdirs="../lib64 ../lib32"
1301 -
1302 - # this only makes sense for some Linux targets
1303 - case ${CTARGET} in
1304 - x86_64*-linux*) config="i386" ;;
1305 - powerpc64*-linux*) config="rs6000" ;;
1306 - sparc64*-linux*) config="sparc" ;;
1307 - s390x*-linux*) config="s390" ;;
1308 - *) return 0 ;;
1309 - esac
1310 - config+="/t-linux64"
1311 -
1312 - local sed_args=()
1313 - if tc_version_is_at_least 4.6 ; then
1314 - sed_args+=( -e 's:$[(]call if_multiarch[^)]*[)]::g' )
1315 - fi
1316 - if [[ ${SYMLINK_LIB} == "yes" ]] ; then
1317 - einfo "updating multilib directories to be: ${libdirs}"
1318 - if tc_version_is_at_least 4.6.4 || tc_version_is_at_least 4.7 ; then
1319 - sed_args+=( -e '/^MULTILIB_OSDIRNAMES.*lib32/s:[$][(]if.*):../lib32:' )
1320 - else
1321 - sed_args+=( -e "/^MULTILIB_OSDIRNAMES/s:=.*:= ${libdirs}:" )
1322 - fi
1323 - else
1324 - einfo "using upstream multilib; disabling lib32 autodetection"
1325 - sed_args+=( -r -e 's:[$][(]if.*,(.*)[)]:\1:' )
1326 - fi
1327 - sed -i "${sed_args[@]}" "${S}"/gcc/config/${config} || die
1328 -}
1329 -
1330 -gcc_version_patch() {
1331 - # gcc-4.3+ has configure flags (whoo!)
1332 - tc_version_is_at_least 4.3 && return 0
1333 -
1334 - local version_string=${GCC_CONFIG_VER}
1335 - [[ -n ${BRANCH_UPDATE} ]] && version_string+=" ${BRANCH_UPDATE}"
1336 -
1337 - einfo "patching gcc version: ${version_string} (${BRANDING_GCC_PKGVERSION})"
1338 -
1339 - local gcc_sed=( -e 's:gcc\.gnu\.org/bugs\.html:bugs\.gentoo\.org/:' )
1340 - if grep -qs VERSUFFIX "${S}"/gcc/version.c ; then
1341 - gcc_sed+=( -e "/VERSUFFIX \"\"/s:\"\":\" (${BRANDING_GCC_PKGVERSION})\":" )
1342 - else
1343 - version_string="${version_string} (${BRANDING_GCC_PKGVERSION})"
1344 - gcc_sed+=( -e "/const char version_string\[\] = /s:= \".*\":= \"${version_string}\":" )
1345 - fi
1346 - sed -i "${gcc_sed[@]}" "${S}"/gcc/version.c || die
1347 -}
1348 -
1349 -do_gcc_rename_java_bins() {
1350 - # bug #139918 - conflict between gcc and java-config-2 for ownership of
1351 - # /usr/bin/rmi{c,registry}. Done with mv & sed rather than a patch
1352 - # because patches would be large (thanks to the rename of man files),
1353 - # and it's clear from the sed invocations that all that changes is the
1354 - # rmi{c,registry} names to grmi{c,registry} names.
1355 - # Kevin F. Quinn 2006-07-12
1356 - einfo "Renaming jdk executables rmic and rmiregistry to grmic and grmiregistry."
1357 - # 1) Move the man files if present (missing prior to gcc-3.4)
1358 - for manfile in rmic rmiregistry ; do
1359 - [[ -f ${S}/gcc/doc/${manfile}.1 ]] || continue
1360 - mv "${S}"/gcc/doc/${manfile}.1 "${S}"/gcc/doc/g${manfile}.1
1361 - done
1362 - # 2) Fixup references in the docs if present (mission prior to gcc-3.4)
1363 - for jfile in gcc/doc/gcj.info gcc/doc/grmic.1 gcc/doc/grmiregistry.1 gcc/java/gcj.texi ; do
1364 - [[ -f ${S}/${jfile} ]] || continue
1365 - sed -i -e 's:rmiregistry:grmiregistry:g' "${S}"/${jfile} ||
1366 - die "Failed to fixup file ${jfile} for rename to grmiregistry"
1367 - sed -i -e 's:rmic:grmic:g' "${S}"/${jfile} ||
1368 - die "Failed to fixup file ${jfile} for rename to grmic"
1369 - done
1370 - # 3) Fixup Makefiles to build the changed executable names
1371 - # These are present in all 3.x versions, and are the important bit
1372 - # to get gcc to build with the new names.
1373 - for jfile in libjava/Makefile.am libjava/Makefile.in gcc/java/Make-lang.in ; do
1374 - sed -i -e 's:rmiregistry:grmiregistry:g' "${S}"/${jfile} ||
1375 - die "Failed to fixup file ${jfile} for rename to grmiregistry"
1376 - # Careful with rmic on these files; it's also the name of a directory
1377 - # which should be left unchanged. Replace occurrences of 'rmic$',
1378 - # 'rmic_' and 'rmic '.
1379 - sed -i -e 's:rmic\([$_ ]\):grmic\1:g' "${S}"/${jfile} ||
1380 - die "Failed to fixup file ${jfile} for rename to grmic"
1381 - done
1382 -}
1383 -
1384 -#---->> src_configure <<----
1385 -
1386 -toolchain_src_configure() {
1387 - downgrade_arch_flags
1388 - gcc_do_filter_flags
1389 -
1390 - einfo "CFLAGS=\"${CFLAGS}\""
1391 - einfo "CXXFLAGS=\"${CXXFLAGS}\""
1392 - einfo "LDFLAGS=\"${LDFLAGS}\""
1393 -
1394 - # Force internal zip based jar script to avoid random
1395 - # issues with 3rd party jar implementations. #384291
1396 - export JAR=no
1397 -
1398 - # For hardened gcc 4.3 piepatchset to build the hardened specs
1399 - # file (build.specs) to use when building gcc.
1400 - if ! tc_version_is_at_least 4.4 && want_minispecs ; then
1401 - setup_minispecs_gcc_build_specs
1402 - fi
1403 -
1404 - local confgcc=( --host=${CHOST} )
1405 -
1406 - if is_crosscompile || tc-is-cross-compiler ; then
1407 - # Straight from the GCC install doc:
1408 - # "GCC has code to correctly determine the correct value for target
1409 - # for nearly all native systems. Therefore, we highly recommend you
1410 - # not provide a configure target when configuring a native compiler."
1411 - confgcc+=( --target=${CTARGET} )
1412 - fi
1413 - [[ -n ${CBUILD} ]] && confgcc+=( --build=${CBUILD} )
1414 -
1415 - confgcc+=(
1416 - --prefix="${PREFIX}"
1417 - --bindir="${BINPATH}"
1418 - --includedir="${INCLUDEPATH}"
1419 - --datadir="${DATAPATH}"
1420 - --mandir="${DATAPATH}/man"
1421 - --infodir="${DATAPATH}/info"
1422 - --with-gxx-include-dir="${STDCXX_INCDIR}"
1423 - )
1424 -
1425 - # Stick the python scripts in their own slotted directory (bug #279252)
1426 - #
1427 - # --with-python-dir=DIR
1428 - # Specifies where to install the Python modules used for aot-compile. DIR
1429 - # should not include the prefix used in installation. For example, if the
1430 - # Python modules are to be installed in /usr/lib/python2.5/site-packages,
1431 - # then --with-python-dir=/lib/python2.5/site-packages should be passed.
1432 - #
1433 - # This should translate into "/share/gcc-data/${CTARGET}/${GCC_CONFIG_VER}/python"
1434 - if tc_version_is_at_least 4.4 ; then
1435 - confgcc+=( --with-python-dir=${DATAPATH/$PREFIX/}/python )
1436 - fi
1437 -
1438 - ### language options
1439 -
1440 - local GCC_LANG="c"
1441 - is_cxx && GCC_LANG+=",c++"
1442 - is_d && GCC_LANG+=",d"
1443 - is_gcj && GCC_LANG+=",java"
1444 - is_go && GCC_LANG+=",go"
1445 - is_jit && GCC_LANG+=",jit"
1446 - if is_objc || is_objcxx ; then
1447 - GCC_LANG+=",objc"
1448 - if tc_version_is_at_least 4 ; then
1449 - use objc-gc && confgcc+=( --enable-objc-gc )
1450 - fi
1451 - is_objcxx && GCC_LANG+=",obj-c++"
1452 - fi
1453 -
1454 - # fortran support just got sillier! the lang value can be f77 for
1455 - # fortran77, f95 for fortran95, or just plain old fortran for the
1456 - # currently supported standard depending on gcc version.
1457 - is_fortran && GCC_LANG+=",fortran"
1458 - is_f77 && GCC_LANG+=",f77"
1459 - is_f95 && GCC_LANG+=",f95"
1460 -
1461 - # We do NOT want 'ADA support' in here!
1462 - # is_ada && GCC_LANG+=",ada"
1463 -
1464 - confgcc+=( --enable-languages=${GCC_LANG} )
1465 -
1466 - ### general options
1467 -
1468 - confgcc+=(
1469 - --enable-obsolete
1470 - --enable-secureplt
1471 - --disable-werror
1472 - --with-system-zlib
1473 - )
1474 -
1475 - if use nls ; then
1476 - confgcc+=( --enable-nls --without-included-gettext )
1477 - else
1478 - confgcc+=( --disable-nls )
1479 - fi
1480 -
1481 - tc_version_is_at_least 3.4 || confgcc+=( --disable-libunwind-exceptions )
1482 -
1483 - # Use the default ("release") checking because upstream usually neglects
1484 - # to test "disabled" so it has a history of breaking. #317217
1485 - if tc_version_is_at_least 3.4 && in_iuse debug ; then
1486 - # The "release" keyword is new to 4.0. #551636
1487 - local off=$(tc_version_is_at_least 4.0 && echo release || echo no)
1488 - confgcc+=( --enable-checking="${GCC_CHECKS_LIST:-$(usex debug yes ${off})}" )
1489 - fi
1490 -
1491 - # Branding
1492 - tc_version_is_at_least 4.3 && confgcc+=(
1493 - --with-bugurl=https://bugs.gentoo.org/
1494 - --with-pkgversion="${BRANDING_GCC_PKGVERSION}"
1495 - )
1496 -
1497 - # If we want hardened support with the newer piepatchset for >=gcc 4.4
1498 - if tc_version_is_at_least 4.4 && want_minispecs && in_iuse hardened ; then
1499 - confgcc+=( $(use_enable hardened esp) )
1500 - fi
1501 -
1502 - # allow gcc to search for clock funcs in the main C lib.
1503 - # if it can't find them, then tough cookies -- we aren't
1504 - # going to link in -lrt to all C++ apps. #411681
1505 - if tc_version_is_at_least 4.4 && is_cxx ; then
1506 - confgcc+=( --enable-libstdcxx-time )
1507 - fi
1508 -
1509 - # Support to disable pch when building libstdcxx
1510 - if tc_version_is_at_least 6.0 && ! use_if_iuse pch ; then
1511 - confgcc+=( --disable-libstdcxx-pch )
1512 - fi
1513 -
1514 - # The jit language requires this.
1515 - is_jit && confgcc+=( --enable-host-shared )
1516 -
1517 - # # Turn on the -Wl,--build-id flag by default for ELF targets. #525942
1518 - # # This helps with locating debug files.
1519 - # case ${CTARGET} in
1520 - # *-linux-*|*-elf|*-eabi)
1521 - # tc_version_is_at_least 4.5 && confgcc+=(
1522 - # --enable-linker-build-id
1523 - # )
1524 - # ;;
1525 - # esac
1526 -
1527 - # newer gcc versions like to bootstrap themselves with C++,
1528 - # so we need to manually disable it ourselves
1529 - if tc_version_is_between 4.7 4.8 && ! is_cxx ; then
1530 - confgcc+=( --disable-build-with-cxx --disable-build-poststage1-with-cxx )
1531 - fi
1532 -
1533 - ### Cross-compiler options
1534 - if is_crosscompile ; then
1535 - # Enable build warnings by default with cross-compilers when system
1536 - # paths are included (e.g. via -I flags).
1537 - confgcc+=( --enable-poison-system-directories )
1538 -
1539 - # When building a stage1 cross-compiler (just C compiler), we have to
1540 - # disable a bunch of features or gcc goes boom
1541 - local needed_libc=""
1542 - case ${CTARGET} in
1543 - *-linux) needed_libc=no-fucking-clue;;
1544 - *-dietlibc) needed_libc=dietlibc;;
1545 - *-elf|*-eabi)
1546 - needed_libc=newlib
1547 - # Bare-metal targets don't have access to clock_gettime()
1548 - # arm-none-eabi example: bug #589672
1549 - # But we explicitly do --enable-libstdcxx-time above.
1550 - # Undoing it here.
1551 - confgcc+=( --disable-libstdcxx-time )
1552 - ;;
1553 - *-freebsd*) needed_libc=freebsd-lib;;
1554 - *-gnu*) needed_libc=glibc;;
1555 - *-klibc) needed_libc=klibc;;
1556 - *-musl*) needed_libc=musl;;
1557 - *-uclibc*)
1558 - if ! echo '#include <features.h>' | \
1559 - $(tc-getCPP ${CTARGET}) -E -dD - 2>/dev/null | \
1560 - grep -q __HAVE_SHARED__
1561 - then #291870
1562 - confgcc+=( --disable-shared )
1563 - fi
1564 - needed_libc=uclibc-ng
1565 - ;;
1566 - *-cygwin) needed_libc=cygwin;;
1567 - x86_64-*-mingw*|\
1568 - *-w64-mingw*) needed_libc=mingw64-runtime;;
1569 - mingw*|*-mingw*) needed_libc=mingw-runtime;;
1570 - avr) confgcc+=( --enable-shared --disable-threads );;
1571 - esac
1572 - if [[ -n ${needed_libc} ]] ; then
1573 - local confgcc_no_libc=( --disable-shared )
1574 - tc_version_is_at_least 4.8 && confgcc_no_libc+=( --disable-libatomic )
1575 - if ! has_version ${CATEGORY}/${needed_libc} ; then
1576 - confgcc+=(
1577 - "${confgcc_no_libc[@]}"
1578 - --disable-threads
1579 - --without-headers
1580 - )
1581 - elif has_version "${CATEGORY}/${needed_libc}[headers-only(-)]" ; then
1582 - confgcc+=(
1583 - "${confgcc_no_libc[@]}"
1584 - --with-sysroot="${PREFIX}"/${CTARGET}
1585 - )
1586 - else
1587 - confgcc+=( --with-sysroot="${PREFIX}"/${CTARGET} )
1588 - fi
1589 - fi
1590 -
1591 - tc_version_is_at_least 4.2 && confgcc+=( --disable-bootstrap )
1592 - else
1593 - if tc-is-static-only ; then
1594 - confgcc+=( --disable-shared )
1595 - else
1596 - confgcc+=( --enable-shared )
1597 - fi
1598 - case ${CHOST} in
1599 - mingw*|*-mingw*)
1600 - confgcc+=( --enable-threads=win32 ) ;;
1601 - *)
1602 - confgcc+=( --enable-threads=posix ) ;;
1603 - esac
1604 - fi
1605 -
1606 - # __cxa_atexit is "essential for fully standards-compliant handling of
1607 - # destructors", but apparently requires glibc.
1608 - case ${CTARGET} in
1609 - *-uclibc*)
1610 - confgcc+=(
1611 - --disable-__cxa_atexit
1612 - $(use_enable nptl tls)
1613 - )
1614 - tc_version_is_between 3.3 3.4 && confgcc+=( --enable-sjlj-exceptions )
1615 - if tc_version_is_between 3.4 4.3 ; then
1616 - confgcc+=( --enable-clocale=uclibc )
1617 - fi
1618 - ;;
1619 - *-elf|*-eabi)
1620 - confgcc+=( --with-newlib )
1621 - ;;
1622 - *-gnu*)
1623 - confgcc+=(
1624 - --enable-__cxa_atexit
1625 - --enable-clocale=gnu
1626 - )
1627 - ;;
1628 - *-freebsd*)
1629 - confgcc+=( --enable-__cxa_atexit )
1630 - ;;
1631 - *-solaris*)
1632 - confgcc+=( --enable-__cxa_atexit )
1633 - ;;
1634 - esac
1635 -
1636 - ### arch options
1637 -
1638 - gcc-multilib-configure
1639 -
1640 - # ppc altivec support
1641 - in_iuse altivec && confgcc+=( $(use_enable altivec) )
1642 -
1643 - # gcc has fixed-point arithmetic support in 4.3 for mips targets that can
1644 - # significantly increase compile time by several hours. This will allow
1645 - # users to control this feature in the event they need the support.
1646 - tc_version_is_at_least 4.3 && in_iuse fixed-point && confgcc+=( $(use_enable fixed-point) )
1647 -
1648 - case $(tc-is-softfloat) in
1649 - yes) confgcc+=( --with-float=soft ) ;;
1650 - softfp) confgcc+=( --with-float=softfp ) ;;
1651 - *)
1652 - # If they've explicitly opt-ed in, do hardfloat,
1653 - # otherwise let the gcc default kick in.
1654 - case ${CTARGET//_/-} in
1655 - *-hardfloat-*|*eabihf) confgcc+=( --with-float=hard ) ;;
1656 - esac
1657 - esac
1658 -
1659 - local with_abi_map=()
1660 - case $(tc-arch) in
1661 - arm) #264534 #414395
1662 - local a arm_arch=${CTARGET%%-*}
1663 - # Remove trailing endian variations first: eb el be bl b l
1664 - for a in e{b,l} {b,l}e b l ; do
1665 - if [[ ${arm_arch} == *${a} ]] ; then
1666 - arm_arch=${arm_arch%${a}}
1667 - break
1668 - fi
1669 - done
1670 - # Convert armv7{a,r,m} to armv7-{a,r,m}
1671 - [[ ${arm_arch} == armv7? ]] && arm_arch=${arm_arch/7/7-}
1672 - # See if this is a valid --with-arch flag
1673 - if (srcdir=${S}/gcc target=${CTARGET} with_arch=${arm_arch};
1674 - . "${srcdir}"/config.gcc) &>/dev/null
1675 - then
1676 - confgcc+=( --with-arch=${arm_arch} )
1677 - fi
1678 -
1679 - # Make default mode thumb for microcontroller classes #418209
1680 - [[ ${arm_arch} == *-m ]] && confgcc+=( --with-mode=thumb )
1681 -
1682 - # Enable hardvfp
1683 - if [[ $(tc-is-softfloat) == "no" ]] && \
1684 - [[ ${CTARGET} == armv[67]* ]] && \
1685 - tc_version_is_at_least 4.5
1686 - then
1687 - # Follow the new arm hardfp distro standard by default
1688 - confgcc+=( --with-float=hard )
1689 - case ${CTARGET} in
1690 - armv6*) confgcc+=( --with-fpu=vfp ) ;;
1691 - armv7*) confgcc+=( --with-fpu=vfpv3-d16 ) ;;
1692 - esac
1693 - fi
1694 - ;;
1695 - mips)
1696 - # Add --with-abi flags to set default ABI
1697 - confgcc+=( --with-abi=$(gcc-abi-map ${TARGET_DEFAULT_ABI}) )
1698 - ;;
1699 - amd64)
1700 - # drop the older/ABI checks once this get's merged into some
1701 - # version of gcc upstream
1702 - if tc_version_is_at_least 4.8 && has x32 $(get_all_abis TARGET) ; then
1703 - confgcc+=( --with-abi=$(gcc-abi-map ${TARGET_DEFAULT_ABI}) )
1704 - fi
1705 - ;;
1706 - x86)
1707 - # Default arch for x86 is normally i386, lets give it a bump
1708 - # since glibc will do so based on CTARGET anyways
1709 - confgcc+=( --with-arch=${CTARGET%%-*} )
1710 - ;;
1711 - hppa)
1712 - # Enable sjlj exceptions for backward compatibility on hppa
1713 - [[ ${GCCMAJOR} == "3" ]] && confgcc+=( --enable-sjlj-exceptions )
1714 - ;;
1715 - ppc)
1716 - # Set up defaults based on current CFLAGS
1717 - is-flagq -mfloat-gprs=double && confgcc+=( --enable-e500-double )
1718 - [[ ${CTARGET//_/-} == *-e500v2-* ]] && confgcc+=( --enable-e500-double )
1719 - ;;
1720 - esac
1721 -
1722 - # if the target can do biarch (-m32/-m64), enable it. overhead should
1723 - # be small, and should simplify building of 64bit kernels in a 32bit
1724 - # userland by not needing sys-devel/kgcc64. #349405
1725 - case $(tc-arch) in
1726 - ppc|ppc64) tc_version_is_at_least 3.4 && confgcc+=( --enable-targets=all ) ;;
1727 - sparc) tc_version_is_at_least 4.4 && confgcc+=( --enable-targets=all ) ;;
1728 - amd64|x86) tc_version_is_at_least 4.3 && confgcc+=( --enable-targets=all ) ;;
1729 - esac
1730 -
1731 - # On Darwin we need libdir to be set in order to get correct install names
1732 - # for things like libobjc-gnu, libgcj and libfortran. If we enable it on
1733 - # non-Darwin we screw up the behaviour this eclass relies on. We in
1734 - # particular need this over --libdir for bug #255315.
1735 - [[ ${CTARGET} == *-darwin* ]] && \
1736 - confgcc+=( --enable-version-specific-runtime-libs )
1737 -
1738 - ### library options
1739 -
1740 - if tc_version_is_between 3.0 7.0 ; then
1741 - if ! is_gcj ; then
1742 - confgcc+=( --disable-libgcj )
1743 - elif use awt ; then
1744 - confgcc+=( --enable-java-awt=gtk )
1745 - fi
1746 - fi
1747 -
1748 - if tc_version_is_at_least 4.2 ; then
1749 - if in_iuse openmp ; then
1750 - # Make sure target has pthreads support. #326757 #335883
1751 - # There shouldn't be a chicken & egg problem here as openmp won't
1752 - # build without a C library, and you can't build that w/out
1753 - # already having a compiler ...
1754 - if ! is_crosscompile || \
1755 - $(tc-getCPP ${CTARGET}) -E - <<<"#include <pthread.h>" >& /dev/null
1756 - then
1757 - confgcc+=( $(use_enable openmp libgomp) )
1758 - else
1759 - # Force disable as the configure script can be dumb #359855
1760 - confgcc+=( --disable-libgomp )
1761 - fi
1762 - else
1763 - # For gcc variants where we don't want openmp (e.g. kgcc)
1764 - confgcc+=( --disable-libgomp )
1765 - fi
1766 - fi
1767 -
1768 - if tc_version_is_at_least 4.0 ; then
1769 - if in_iuse mudflap ; then
1770 - confgcc+=( $(use_enable mudflap libmudflap) )
1771 - else
1772 - confgcc+=( --disable-libmudflap )
1773 - fi
1774 -
1775 - if use_if_iuse libssp ; then
1776 - confgcc+=( --enable-libssp )
1777 - else
1778 - if hardened_gcc_is_stable ssp; then
1779 - export gcc_cv_libc_provides_ssp=yes
1780 - fi
1781 - if use_if_iuse ssp; then
1782 - # On some targets USE="ssp -libssp" is an invalid
1783 - # configuration as target libc does not provide
1784 - # stack_chk_* functions. Do not disable libssp there.
1785 - case ${CTARGET} in
1786 - mingw*|*-mingw*) ewarn "Not disabling libssp" ;;
1787 - *) confgcc+=( --disable-libssp ) ;;
1788 - esac
1789 - else
1790 - confgcc+=( --disable-libssp )
1791 - fi
1792 - fi
1793 - fi
1794 -
1795 - if in_iuse cilk ; then
1796 - confgcc+=( $(use_enable cilk libcilkrts) )
1797 - fi
1798 -
1799 - if in_iuse mpx ; then
1800 - confgcc+=( $(use_enable mpx libmpx) )
1801 - fi
1802 -
1803 - if in_iuse systemtap ; then
1804 - confgcc+=( $(use_enable systemtap) )
1805 - fi
1806 -
1807 - if in_iuse vtv ; then
1808 - confgcc+=(
1809 - $(use_enable vtv vtable-verify)
1810 - # See Note [implicitly enabled flags]
1811 - $(usex vtv '' --disable-libvtv)
1812 - )
1813 - fi
1814 -
1815 - # newer gcc's come with libquadmath, but only fortran uses
1816 - # it, so auto punt it when we don't care
1817 - if tc_version_is_at_least 4.6 && ! is_fortran ; then
1818 - confgcc+=( --disable-libquadmath )
1819 - fi
1820 -
1821 - if tc_version_is_at_least 4.6 ; then
1822 - confgcc+=( --enable-lto )
1823 - elif tc_version_is_at_least 4.5 ; then
1824 - confgcc+=( --disable-lto )
1825 - fi
1826 -
1827 - # graphite was added in 4.4 but we only support it in 4.8+ due to external
1828 - # library issues. #448024
1829 - if tc_version_is_at_least 5.0 && in_iuse graphite ; then
1830 - confgcc+=( $(use_with graphite isl) )
1831 - use graphite && confgcc+=( --disable-isl-version-check )
1832 - elif tc_version_is_at_least 4.8 && in_iuse graphite ; then
1833 - confgcc+=( $(use_with graphite cloog) )
1834 - use graphite && confgcc+=( --disable-isl-version-check )
1835 - elif tc_version_is_at_least 4.4 ; then
1836 - confgcc+=( --without-{cloog,ppl} )
1837 - fi
1838 -
1839 - if tc_version_is_at_least 4.8 && in_iuse sanitize ; then
1840 - # See Note [implicitly enabled flags]
1841 - confgcc+=( $(usex sanitize '' --disable-libsanitizer) )
1842 - fi
1843 -
1844 - if tc_version_is_at_least 6.0 && in_iuse pie ; then
1845 - confgcc+=( $(use_enable pie default-pie) )
1846 - fi
1847 -
1848 - if tc_version_is_at_least 6.0 && in_iuse ssp ; then
1849 - confgcc+=(
1850 - # This defaults to -fstack-protector-strong.
1851 - $(use_enable ssp default-ssp)
1852 - )
1853 - fi
1854 -
1855 - # Disable gcc info regeneration -- it ships with generated info pages
1856 - # already. Our custom version/urls/etc... trigger it. #464008
1857 - export gcc_cv_prog_makeinfo_modern=no
1858 -
1859 - # Do not let the X detection get in our way. We know things can be found
1860 - # via system paths, so no need to hardcode things that'll break multilib.
1861 - # Older gcc versions will detect ac_x_libraries=/usr/lib64 which ends up
1862 - # killing the 32bit builds which want /usr/lib.
1863 - export ac_cv_have_x='have_x=yes ac_x_includes= ac_x_libraries='
1864 -
1865 - confgcc+=( "$@" ${EXTRA_ECONF} )
1866 -
1867 - # Nothing wrong with a good dose of verbosity
1868 - echo
1869 - einfo "PREFIX: ${PREFIX}"
1870 - einfo "BINPATH: ${BINPATH}"
1871 - einfo "LIBPATH: ${LIBPATH}"
1872 - einfo "DATAPATH: ${DATAPATH}"
1873 - einfo "STDCXX_INCDIR: ${STDCXX_INCDIR}"
1874 - echo
1875 - einfo "Languages: ${GCC_LANG}"
1876 - echo
1877 - einfo "Configuring GCC with: ${confgcc[@]//--/\n\t--}"
1878 - echo
1879 -
1880 - # Build in a separate build tree
1881 - mkdir -p "${WORKDIR}"/build
1882 - pushd "${WORKDIR}"/build > /dev/null
1883 -
1884 - # and now to do the actual configuration
1885 - addwrite /dev/zero
1886 - echo "${S}"/configure "${confgcc[@]}"
1887 - # Older gcc versions did not detect bash and re-exec itself, so force the
1888 - # use of bash. Newer ones will auto-detect, but this is not harmful.
1889 - CONFIG_SHELL="${EPREFIX}/bin/bash" \
1890 - bash "${S}"/configure "${confgcc[@]}" || die "failed to run configure"
1891 -
1892 - # return to whatever directory we were in before
1893 - popd > /dev/null
1894 -}
1895 -
1896 -# Replace -m flags unsupported by the version being built with the best
1897 -# available equivalent
1898 -downgrade_arch_flags() {
1899 - local arch bver i isa myarch mytune rep ver
1900 -
1901 - bver=${1:-${GCC_BRANCH_VER}}
1902 - [[ $(gcc-version) < ${bver} ]] && return 0
1903 - [[ $(tc-arch) != amd64 && $(tc-arch) != x86 ]] && return 0
1904 -
1905 - myarch=$(get-flag march)
1906 - mytune=$(get-flag mtune)
1907 -
1908 - # If -march=native isn't supported we have to tease out the actual arch
1909 - if [[ ${myarch} == native || ${mytune} == native ]] ; then
1910 - if [[ ${bver} < 4.2 ]] ; then
1911 - arch=$($(tc-getCC) -march=native -v -E -P - </dev/null 2>&1 \
1912 - | sed -rn "/cc1.*-march/s:.*-march=([^ ']*).*:\1:p")
1913 - replace-cpu-flags native ${arch}
1914 - fi
1915 - fi
1916 -
1917 - # Handle special -mtune flags
1918 - [[ ${mytune} == intel && ${bver} < 4.9 ]] && replace-cpu-flags intel generic
1919 - [[ ${mytune} == generic && ${bver} < 4.2 ]] && filter-flags '-mtune=*'
1920 - [[ ${mytune} == x86-64 ]] && filter-flags '-mtune=*'
1921 - [[ ${bver} < 3.4 ]] && filter-flags '-mtune=*'
1922 -
1923 - # "added" "arch" "replacement"
1924 - local archlist=(
1925 - 4.9 bdver4 bdver3
1926 - 4.9 bonnell atom
1927 - 4.9 broadwell core-avx2
1928 - 4.9 haswell core-avx2
1929 - 4.9 ivybridge core-avx-i
1930 - 4.9 nehalem corei7
1931 - 4.9 sandybridge corei7-avx
1932 - 4.9 silvermont corei7
1933 - 4.9 westmere corei7
1934 - 4.8 bdver3 bdver2
1935 - 4.8 btver2 btver1
1936 - 4.7 bdver2 bdver1
1937 - 4.7 core-avx2 core-avx-i
1938 - 4.6 bdver1 amdfam10
1939 - 4.6 btver1 amdfam10
1940 - 4.6 core-avx-i core2
1941 - 4.6 corei7 core2
1942 - 4.6 corei7-avx core2
1943 - 4.5 atom core2
1944 - 4.3 amdfam10 k8
1945 - 4.3 athlon64-sse3 k8
1946 - 4.3 barcelona k8
1947 - 4.3 core2 nocona
1948 - 4.3 geode k6-2 # gcc.gnu.org/PR41989#c22
1949 - 4.3 k8-sse3 k8
1950 - 4.3 opteron-sse3 k8
1951 - 3.4 athlon-fx x86-64
1952 - 3.4 athlon64 x86-64
1953 - 3.4 c3-2 c3
1954 - 3.4 k8 x86-64
1955 - 3.4 opteron x86-64
1956 - 3.4 pentium-m pentium3
1957 - 3.4 pentium3m pentium3
1958 - 3.4 pentium4m pentium4
1959 - )
1960 -
1961 - for ((i = 0; i < ${#archlist[@]}; i += 3)) ; do
1962 - myarch=$(get-flag march)
1963 - mytune=$(get-flag mtune)
1964 -
1965 - ver=${archlist[i]}
1966 - arch=${archlist[i + 1]}
1967 - rep=${archlist[i + 2]}
1968 -
1969 - [[ ${myarch} != ${arch} && ${mytune} != ${arch} ]] && continue
1970 -
1971 - if [[ ${ver} > ${bver} ]] ; then
1972 - einfo "Replacing ${myarch} (added in gcc ${ver}) with ${rep}..."
1973 - [[ ${myarch} == ${arch} ]] && replace-cpu-flags ${myarch} ${rep}
1974 - [[ ${mytune} == ${arch} ]] && replace-cpu-flags ${mytune} ${rep}
1975 - continue
1976 - else
1977 - break
1978 - fi
1979 - done
1980 -
1981 - # we only check -mno* here since -m* get removed by strip-flags later on
1982 - local isalist=(
1983 - 4.9 -mno-sha
1984 - 4.9 -mno-avx512pf
1985 - 4.9 -mno-avx512f
1986 - 4.9 -mno-avx512er
1987 - 4.9 -mno-avx512cd
1988 - 4.8 -mno-xsaveopt
1989 - 4.8 -mno-xsave
1990 - 4.8 -mno-rtm
1991 - 4.8 -mno-fxsr
1992 - 4.7 -mno-lzcnt
1993 - 4.7 -mno-bmi2
1994 - 4.7 -mno-avx2
1995 - 4.6 -mno-tbm
1996 - 4.6 -mno-rdrnd
1997 - 4.6 -mno-fsgsbase
1998 - 4.6 -mno-f16c
1999 - 4.6 -mno-bmi
2000 - 4.5 -mno-xop
2001 - 4.5 -mno-movbe
2002 - 4.5 -mno-lwp
2003 - 4.5 -mno-fma4
2004 - 4.4 -mno-pclmul
2005 - 4.4 -mno-fma
2006 - 4.4 -mno-avx
2007 - 4.4 -mno-aes
2008 - 4.3 -mno-ssse3
2009 - 4.3 -mno-sse4a
2010 - 4.3 -mno-sse4
2011 - 4.3 -mno-sse4.2
2012 - 4.3 -mno-sse4.1
2013 - 4.3 -mno-popcnt
2014 - 4.3 -mno-abm
2015 - )
2016 -
2017 - for ((i = 0; i < ${#isalist[@]}; i += 2)) ; do
2018 - ver=${isalist[i]}
2019 - isa=${isalist[i + 1]}
2020 - [[ ${ver} > ${bver} ]] && filter-flags ${isa} ${isa/-m/-mno-}
2021 - done
2022 -}
2023 -
2024 -gcc_do_filter_flags() {
2025 - strip-flags
2026 - replace-flags -O? -O2
2027 -
2028 - # dont want to funk ourselves
2029 - filter-flags '-mabi*' -m31 -m32 -m64
2030 -
2031 - # on riscv, only specific combinations of march and mabi work... so we need
2032 - # to strip both and trust the compiler to do the right thing, otherwise
2033 - # multilib build fails
2034 - [[ $(tc-arch) == riscv* ]] && filter-flags '-march*'
2035 -
2036 - filter-flags -frecord-gcc-switches # 490738
2037 - filter-flags -mno-rtm -mno-htm # 506202
2038 -
2039 - if tc_version_is_between 3.2 3.4 ; then
2040 - # XXX: this is so outdated it's barely useful, but it don't hurt...
2041 - replace-cpu-flags G3 750
2042 - replace-cpu-flags G4 7400
2043 - replace-cpu-flags G5 7400
2044 -
2045 - # XXX: should add a sed or something to query all supported flags
2046 - # from the gcc source and trim everything else ...
2047 - filter-flags -f{no-,}unit-at-a-time -f{no-,}web -mno-tls-direct-seg-refs
2048 - filter-flags -f{no-,}stack-protector{,-all}
2049 - filter-flags -fvisibility-inlines-hidden -fvisibility=hidden
2050 - # and warning options
2051 - filter-flags -Wextra -Wstack-protector
2052 - fi
2053 - if ! tc_version_is_at_least 4.1 ; then
2054 - filter-flags -fdiagnostics-show-option
2055 - filter-flags -Wstack-protector
2056 - fi
2057 -
2058 - if tc_version_is_at_least 3.4 ; then
2059 - case $(tc-arch) in
2060 - amd64|x86)
2061 - filter-flags '-mcpu=*'
2062 -
2063 - tc_version_is_between 4.4 4.5 && append-flags -mno-avx # 357287
2064 -
2065 - if tc_version_is_between 4.6 4.7 ; then
2066 - # https://bugs.gentoo.org/411333
2067 - # https://bugs.gentoo.org/466454
2068 - replace-cpu-flags c3-2 pentium2 pentium3 pentium3m pentium-m i686
2069 - fi
2070 - ;;
2071 - alpha)
2072 - # https://bugs.gentoo.org/454426
2073 - append-ldflags -Wl,--no-relax
2074 - ;;
2075 - sparc)
2076 - # temporary workaround for random ICEs reproduced by multiple users
2077 - # https://bugs.gentoo.org/457062
2078 - tc_version_is_between 4.6 4.8 && MAKEOPTS+=" -j1"
2079 - ;;
2080 - *-macos)
2081 - # http://gcc.gnu.org/PR25127
2082 - tc_version_is_between 4.0 4.2 && \
2083 - filter-flags '-mcpu=*' '-march=*' '-mtune=*'
2084 - ;;
2085 - esac
2086 - fi
2087 -
2088 - strip-unsupported-flags
2089 -
2090 - # these are set here so we have something sane at configure time
2091 - if is_crosscompile ; then
2092 - # Set this to something sane for both native and target
2093 - CFLAGS="-O2 -pipe"
2094 - FFLAGS=${CFLAGS}
2095 - FCFLAGS=${CFLAGS}
2096 -
2097 - # "hppa2.0-unknown-linux-gnu" -> hppa2_0_unknown_linux_gnu
2098 - local VAR="CFLAGS_"${CTARGET//[-.]/_}
2099 - CXXFLAGS=${!VAR-${CFLAGS}}
2100 - fi
2101 -
2102 - export GCJFLAGS=${GCJFLAGS:-${CFLAGS}}
2103 -}
2104 -
2105 -setup_minispecs_gcc_build_specs() {
2106 - # Setup the "build.specs" file for gcc 4.3 to use when building.
2107 - if hardened_gcc_works pie ; then
2108 - cat "${WORKDIR}"/specs/pie.specs >> "${WORKDIR}"/build.specs
2109 - fi
2110 - if hardened_gcc_works ssp ; then
2111 - for s in ssp sspall ; do
2112 - cat "${WORKDIR}"/specs/${s}.specs >> "${WORKDIR}"/build.specs
2113 - done
2114 - fi
2115 - for s in nostrict znow ; do
2116 - cat "${WORKDIR}"/specs/${s}.specs >> "${WORKDIR}"/build.specs
2117 - done
2118 - export GCC_SPECS="${WORKDIR}"/build.specs
2119 -}
2120 -
2121 -gcc-multilib-configure() {
2122 - if ! is_multilib ; then
2123 - confgcc+=( --disable-multilib )
2124 - # Fun times: if we are building for a target that has multiple
2125 - # possible ABI formats, and the user has told us to pick one
2126 - # that isn't the default, then not specifying it via the list
2127 - # below will break that on us.
2128 - else
2129 - confgcc+=( --enable-multilib )
2130 - fi
2131 -
2132 - # translate our notion of multilibs into gcc's
2133 - local abi list
2134 - for abi in $(get_all_abis TARGET) ; do
2135 - local l=$(gcc-abi-map ${abi})
2136 - [[ -n ${l} ]] && list+=",${l}"
2137 - done
2138 - if [[ -n ${list} ]] ; then
2139 - case ${CTARGET} in
2140 - x86_64*)
2141 - tc_version_is_at_least 4.8 && confgcc+=( --with-multilib-list=${list:1} )
2142 - ;;
2143 - esac
2144 - fi
2145 -}
2146 -
2147 -gcc-abi-map() {
2148 - # Convert the ABI name we use in Gentoo to what gcc uses
2149 - local map=()
2150 - case ${CTARGET} in
2151 - mips*) map=("o32 32" "n32 n32" "n64 64") ;;
2152 - x86_64*) map=("amd64 m64" "x86 m32" "x32 mx32") ;;
2153 - esac
2154 -
2155 - local m
2156 - for m in "${map[@]}" ; do
2157 - l=( ${m} )
2158 - [[ $1 == ${l[0]} ]] && echo ${l[1]} && break
2159 - done
2160 -}
2161 -
2162 -#----> src_compile <----
2163 -
2164 -toolchain_src_compile() {
2165 - touch "${S}"/gcc/c-gperf.h
2166 -
2167 - # Do not make manpages if we do not have perl ...
2168 - [[ ! -x /usr/bin/perl ]] \
2169 - && find "${WORKDIR}"/build -name '*.[17]' -exec touch {} +
2170 -
2171 - # Older gcc versions did not detect bash and re-exec itself, so force the
2172 - # use of bash. Newer ones will auto-detect, but this is not harmful.
2173 - # This needs to be set for compile as well, as it's used in libtool
2174 - # generation, which will break install otherwise (at least in 3.3.6): #664486
2175 - CONFIG_SHELL="${EPREFIX}/bin/bash" \
2176 - gcc_do_make ${GCC_MAKE_TARGET}
2177 -}
2178 -
2179 -gcc_do_make() {
2180 - # This function accepts one optional argument, the make target to be used.
2181 - # If omitted, gcc_do_make will try to guess whether it should use all,
2182 - # or bootstrap-lean depending on CTARGET and arch.
2183 - # An example of how to use this function:
2184 - #
2185 - # gcc_do_make all-target-libstdc++-v3
2186 -
2187 - [[ -n ${1} ]] && GCC_MAKE_TARGET=${1}
2188 -
2189 - # default target
2190 - if is_crosscompile || tc-is-cross-compiler ; then
2191 - # 3 stage bootstrapping doesnt quite work when you cant run the
2192 - # resulting binaries natively ^^;
2193 - GCC_MAKE_TARGET=${GCC_MAKE_TARGET-all}
2194 - else
2195 - if tc_version_is_at_least 3.3 && use_if_iuse pgo; then
2196 - GCC_MAKE_TARGET=${GCC_MAKE_TARGET-profiledbootstrap}
2197 - else
2198 - GCC_MAKE_TARGET=${GCC_MAKE_TARGET-bootstrap-lean}
2199 - fi
2200 - fi
2201 -
2202 - # Older versions of GCC could not do profiledbootstrap in parallel due to
2203 - # collisions with profiling info.
2204 - # boundschecking also seems to introduce parallel build issues.
2205 - if [[ ${GCC_MAKE_TARGET} == "profiledbootstrap" ]] || use_if_iuse boundschecking ; then
2206 - ! tc_version_is_at_least 4.6 && export MAKEOPTS="${MAKEOPTS} -j1"
2207 - fi
2208 -
2209 - if [[ ${GCC_MAKE_TARGET} == "all" ]] ; then
2210 - STAGE1_CFLAGS=${STAGE1_CFLAGS-"${CFLAGS}"}
2211 - elif [[ $(gcc-version) == "3.4" && ${GCC_BRANCH_VER} == "3.4" ]] && gcc-specs-ssp ; then
2212 - # See bug #79852
2213 - STAGE1_CFLAGS=${STAGE1_CFLAGS-"-O2"}
2214 - fi
2215 -
2216 - if is_crosscompile; then
2217 - # In 3.4, BOOT_CFLAGS is never used on a crosscompile...
2218 - # but I'll leave this in anyways as someone might have had
2219 - # some reason for putting it in here... --eradicator
2220 - BOOT_CFLAGS=${BOOT_CFLAGS-"-O2"}
2221 - else
2222 - # we only want to use the system's CFLAGS if not building a
2223 - # cross-compiler.
2224 - BOOT_CFLAGS=${BOOT_CFLAGS-"$(get_abi_CFLAGS ${TARGET_DEFAULT_ABI}) ${CFLAGS}"}
2225 - fi
2226 -
2227 - einfo "Compiling ${PN} (${GCC_MAKE_TARGET})..."
2228 -
2229 - pushd "${WORKDIR}"/build >/dev/null
2230 -
2231 - emake \
2232 - LDFLAGS="${LDFLAGS}" \
2233 - STAGE1_CFLAGS="${STAGE1_CFLAGS}" \
2234 - LIBPATH="${LIBPATH}" \
2235 - BOOT_CFLAGS="${BOOT_CFLAGS}" \
2236 - ${GCC_MAKE_TARGET} \
2237 - || die "emake failed with ${GCC_MAKE_TARGET}"
2238 -
2239 - if ! is_crosscompile && use_if_iuse cxx && use_if_iuse doc ; then
2240 - if type -p doxygen > /dev/null ; then
2241 - if tc_version_is_at_least 4.3 ; then
2242 - cd "${CTARGET}"/libstdc++-v3/doc
2243 - emake doc-man-doxygen || ewarn "failed to make docs"
2244 - elif tc_version_is_at_least 3.0 ; then
2245 - cd "${CTARGET}"/libstdc++-v3
2246 - emake doxygen-man || ewarn "failed to make docs"
2247 - fi
2248 - # Clean bogus manpages. #113902
2249 - find -name '*_build_*' -delete
2250 - # Blow away generated directory references. Newer versions of gcc
2251 - # have gotten better at this, but not perfect. This is easier than
2252 - # backporting all of the various doxygen patches. #486754
2253 - find -name '*_.3' -exec grep -l ' Directory Reference ' {} + | \
2254 - xargs rm -f
2255 - else
2256 - ewarn "Skipping libstdc++ manpage generation since you don't have doxygen installed"
2257 - fi
2258 - fi
2259 -
2260 - popd >/dev/null
2261 -}
2262 -
2263 -#---->> src_test <<----
2264 -
2265 -toolchain_src_test() {
2266 - if use ${GCC_EBUILD_TEST_FLAG} ; then
2267 - cd "${WORKDIR}"/build
2268 - # enable verbose test run and result logging
2269 - emake -k check RUNTESTFLAGS='-a -v'
2270 - fi
2271 -}
2272 -
2273 -#---->> src_install <<----
2274 -
2275 -toolchain_src_install() {
2276 - cd "${WORKDIR}"/build
2277 -
2278 - # Do allow symlinks in private gcc include dir as this can break the build
2279 - find gcc/include*/ -type l -delete
2280 -
2281 - # Copy over the info pages. We disabled their generation earlier, but the
2282 - # build system only expects to install out of the build dir, not the source. #464008
2283 - mkdir -p gcc/doc
2284 - local x=
2285 - for x in "${S}"/gcc/doc/*.info* ; do
2286 - if [[ -f ${x} ]] ; then
2287 - cp "${x}" gcc/doc/ || die
2288 - fi
2289 - done
2290 -
2291 - # We remove the generated fixincludes, as they can cause things to break
2292 - # (ncurses, openssl, etc). We do not prevent them from being built, as
2293 - # in the following commit which we revert:
2294 - # https://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/eclass/toolchain.eclass?r1=1.647&r2=1.648
2295 - # This is because bsd userland needs fixedincludes to build gcc, while
2296 - # linux does not. Both can dispose of them afterwards.
2297 - while read x ; do
2298 - grep -q 'It has been auto-edited by fixincludes from' "${x}" \
2299 - && rm -f "${x}"
2300 - done < <(find gcc/include*/ -name '*.h')
2301 -
2302 - # Do the 'make install' from the build directory
2303 - S="${WORKDIR}"/build emake -j1 DESTDIR="${D}" install || die
2304 -
2305 - # Punt some tools which are really only useful while building gcc
2306 - find "${ED}" -name install-tools -prune -type d -exec rm -rf "{}" \;
2307 - # This one comes with binutils
2308 - find "${ED}" -name libiberty.a -delete
2309 -
2310 - # Move the libraries to the proper location
2311 - gcc_movelibs
2312 -
2313 - # Basic sanity check
2314 - if ! is_crosscompile ; then
2315 - local EXEEXT
2316 - eval $(grep ^EXEEXT= "${WORKDIR}"/build/gcc/config.log)
2317 - [[ -r ${D}${BINPATH}/gcc${EXEEXT} ]] || die "gcc not found in ${ED}"
2318 - fi
2319 -
2320 - dodir /etc/env.d/gcc
2321 - create_gcc_env_entry
2322 -
2323 - # Setup the gcc_env_entry for hardened gcc 4 with minispecs
2324 - want_minispecs && copy_minispecs_gcc_specs
2325 -
2326 - # Make sure we dont have stuff lying around that
2327 - # can nuke multiple versions of gcc
2328 - gcc_slot_java
2329 -
2330 - dodir /usr/bin
2331 - cd "${D}"${BINPATH}
2332 - # Ugh: we really need to auto-detect this list.
2333 - # It's constantly out of date.
2334 - for x in cpp gcc g++ c++ gcov g77 gcj gcjh gfortran gccgo ; do
2335 - # For some reason, g77 gets made instead of ${CTARGET}-g77...
2336 - # this should take care of that
2337 - if [[ -f ${x} ]] ; then
2338 - # In case they're hardlinks, clear out the target first
2339 - # otherwise the mv below will complain.
2340 - rm -f ${CTARGET}-${x}
2341 - mv ${x} ${CTARGET}-${x}
2342 - fi
2343 -
2344 - if [[ -f ${CTARGET}-${x} ]] ; then
2345 - if ! is_crosscompile ; then
2346 - ln -sf ${CTARGET}-${x} ${x}
2347 - dosym ${BINPATH#${EPREFIX}}/${CTARGET}-${x} \
2348 - /usr/bin/${x}-${GCC_CONFIG_VER}
2349 - fi
2350 - # Create versioned symlinks
2351 - dosym ${BINPATH#${EPREFIX}}/${CTARGET}-${x} \
2352 - /usr/bin/${CTARGET}-${x}-${GCC_CONFIG_VER}
2353 - fi
2354 -
2355 - if [[ -f ${CTARGET}-${x}-${GCC_CONFIG_VER} ]] ; then
2356 - rm -f ${CTARGET}-${x}-${GCC_CONFIG_VER}
2357 - ln -sf ${CTARGET}-${x} ${CTARGET}-${x}-${GCC_CONFIG_VER}
2358 - fi
2359 - done
2360 -
2361 - # When gcc builds a crosscompiler it does not install unprefixed tools.
2362 - # When cross-building gcc does install native tools.
2363 - if ! is_crosscompile; then
2364 - # Rename the main go binaries as we don't want to clobber dev-lang/go
2365 - # when gcc-config runs. #567806
2366 - if tc_version_is_at_least 5 && is_go ; then
2367 - for x in go gofmt; do
2368 - mv ${x} ${x}-${GCCMAJOR} || die
2369 - done
2370 - fi
2371 - fi
2372 -
2373 - # TODO: implement stripping (we use RESTRICT=strip)
2374 - # As gcc installs object files both build against ${CHOST} and ${CTARGET}
2375 - # we will ned to run stripping using different tools:
2376 - # Using ${CHOST} tools:
2377 - # - "${D}${BINPATH}"
2378 - # - (for is_crosscompile) "${D}${HOSTLIBPATH}"
2379 - # - "${D}${PREFIX}/libexec/gcc/${CTARGET}/${GCC_CONFIG_VER}"
2380 - # Using ${CTARGET} tools:
2381 - # - "${D}${LIBPATH}"
2382 -
2383 - cd "${S}"
2384 - if is_crosscompile; then
2385 - rm -rf "${ED}"/usr/share/{man,info}
2386 - rm -rf "${D}"${DATAPATH}/{man,info}
2387 - else
2388 - if tc_version_is_at_least 3.0 ; then
2389 - local cxx_mandir=$(find "${WORKDIR}/build/${CTARGET}/libstdc++-v3" -name man)
2390 - if [[ -d ${cxx_mandir} ]] ; then
2391 - cp -r "${cxx_mandir}"/man? "${D}${DATAPATH}"/man/
2392 - fi
2393 - fi
2394 - fi
2395 -
2396 - # portage regenerates 'dir' files on it's own: bug #672408
2397 - # Drop 'dir' files to avoid collisions.
2398 - if [[ -f "${D}${DATAPATH}"/info/dir ]]; then
2399 - einfo "Deleting '${D}${DATAPATH}/info/dir'"
2400 - rm "${D}${DATAPATH}"/info/dir || die
2401 - fi
2402 -
2403 - # prune empty dirs left behind
2404 - find "${ED}" -depth -type d -delete 2>/dev/null
2405 -
2406 - # install testsuite results
2407 - if use ${GCC_EBUILD_TEST_FLAG}; then
2408 - docinto testsuite
2409 - find "${WORKDIR}"/build -type f -name "*.sum" -exec dodoc {} +
2410 - find "${WORKDIR}"/build -type f -path "*/testsuite/*.log" -exec dodoc {} +
2411 - fi
2412 -
2413 - # Rather install the script, else portage with changing $FILESDIR
2414 - # between binary and source package borks things ....
2415 - if ! is_crosscompile && [[ ${PN} != "kgcc64" ]] ; then
2416 - insinto "${DATAPATH#${EPREFIX}}"
2417 - newins "$(prefixify_ro "${FILESDIR}"/awk/fixlafiles.awk-no_gcc_la)" fixlafiles.awk || die
2418 - exeinto "${DATAPATH#${EPREFIX}}"
2419 - doexe "$(prefixify_ro "${FILESDIR}"/fix_libtool_files.sh)" || die
2420 - doexe "${FILESDIR}"/c{89,99} || die
2421 - fi
2422 -
2423 - # libstdc++.la: Delete as it doesn't add anything useful: g++ itself
2424 - # handles linkage correctly in the dynamic & static case. It also just
2425 - # causes us pain: any C++ progs/libs linking with libtool will gain a
2426 - # reference to the full libstdc++.la file which is gcc version specific.
2427 - # libstdc++fs.la: It doesn't link against anything useful.
2428 - # libsupc++.la: This has no dependencies.
2429 - # libcc1.la: There is no static library, only dynamic.
2430 - # libcc1plugin.la: Same as above, and it's loaded via dlopen.
2431 - # libcp1plugin.la: Same as above, and it's loaded via dlopen.
2432 - # libgomp.la: gcc itself handles linkage (libgomp.spec).
2433 - # libgomp-plugin-*.la: Same as above, and it's an internal plugin only
2434 - # loaded via dlopen.
2435 - # libgfortran.la: gfortran itself handles linkage correctly in the
2436 - # dynamic & static case (libgfortran.spec). #573302
2437 - # libgfortranbegin.la: Same as above, and it's an internal lib.
2438 - # libmpx.la: gcc itself handles linkage correctly (libmpx.spec).
2439 - # libmpxwrappers.la: See above.
2440 - # libitm.la: gcc itself handles linkage correctly (libitm.spec).
2441 - # libvtv.la: gcc itself handles linkage correctly.
2442 - # lib*san.la: Sanitizer linkage is handled internally by gcc, and they
2443 - # do not support static linking. #487550 #546700
2444 - find "${D}${LIBPATH}" \
2445 - '(' \
2446 - -name libstdc++.la -o \
2447 - -name libstdc++fs.la -o \
2448 - -name libsupc++.la -o \
2449 - -name libcc1.la -o \
2450 - -name libcc1plugin.la -o \
2451 - -name libcp1plugin.la -o \
2452 - -name 'libgomp.la' -o \
2453 - -name 'libgomp-plugin-*.la' -o \
2454 - -name libgfortran.la -o \
2455 - -name libgfortranbegin.la -o \
2456 - -name libmpx.la -o \
2457 - -name libmpxwrappers.la -o \
2458 - -name libitm.la -o \
2459 - -name libvtv.la -o \
2460 - -name 'lib*san.la' \
2461 - ')' -type f -delete
2462 -
2463 - # Use gid of 0 because some stupid ports don't have
2464 - # the group 'root' set to gid 0. Send to /dev/null
2465 - # for people who are testing as non-root.
2466 - chown -R root:0 "${D}${LIBPATH}" 2>/dev/null
2467 -
2468 - # Move pretty-printers to gdb datadir to shut ldconfig up
2469 - local py gdbdir=/usr/share/gdb/auto-load${LIBPATH/\/lib\//\/$(get_libdir)\/}
2470 - pushd "${D}${LIBPATH}" >/dev/null
2471 - for py in $(find . -name '*-gdb.py') ; do
2472 - local multidir=${py%/*}
2473 - insinto "${gdbdir}/${multidir}"
2474 - sed -i "/^libdir =/s:=.*:= '${LIBPATH}/${multidir}':" "${py}" || die #348128
2475 - doins "${py}" || die
2476 - rm "${py}" || die
2477 - done
2478 - popd >/dev/null
2479 -
2480 - # Don't scan .gox files for executable stacks - false positives
2481 - export QA_EXECSTACK="usr/lib*/go/*/*.gox"
2482 - export QA_WX_LOAD="usr/lib*/go/*/*.gox"
2483 -
2484 - # Disable RANDMMAP so PCH works. #301299
2485 - if tc_version_is_at_least 4.3 ; then
2486 - pax-mark -r "${D}${PREFIX}/libexec/gcc/${CTARGET}/${GCC_CONFIG_VER}/cc1"
2487 - pax-mark -r "${D}${PREFIX}/libexec/gcc/${CTARGET}/${GCC_CONFIG_VER}/cc1plus"
2488 - fi
2489 -
2490 - # Disable MPROTECT so java works. #574808
2491 - if is_gcj ; then
2492 - pax-mark -m "${D}${PREFIX}/libexec/gcc/${CTARGET}/${GCC_CONFIG_VER}/ecj1"
2493 - pax-mark -m "${D}${PREFIX}/${CTARGET}/gcc-bin/${GCC_CONFIG_VER}/gij"
2494 - fi
2495 -}
2496 -
2497 -# Move around the libs to the right location. For some reason,
2498 -# when installing gcc, it dumps internal libraries into /usr/lib
2499 -# instead of the private gcc lib path
2500 -gcc_movelibs() {
2501 - # older versions of gcc did not support --print-multi-os-directory
2502 - tc_version_is_at_least 3.2 || return 0
2503 -
2504 - # For non-target libs which are for CHOST and not CTARGET, we want to
2505 - # move them to the compiler-specific CHOST internal dir. This is stuff
2506 - # that you want to link against when building tools rather than building
2507 - # code to run on the target.
2508 - if tc_version_is_at_least 5 && is_crosscompile ; then
2509 - dodir "${HOSTLIBPATH#${EPREFIX}}"
2510 - mv "${ED}"/usr/$(get_libdir)/libcc1* "${D}${HOSTLIBPATH}" || die
2511 - fi
2512 -
2513 - # For all the libs that are built for CTARGET, move them into the
2514 - # compiler-specific CTARGET internal dir.
2515 - local x multiarg removedirs=""
2516 - for multiarg in $($(XGCC) -print-multi-lib) ; do
2517 - multiarg=${multiarg#*;}
2518 - multiarg=${multiarg//@/ -}
2519 -
2520 - local OS_MULTIDIR=$($(XGCC) ${multiarg} --print-multi-os-directory)
2521 - local MULTIDIR=$($(XGCC) ${multiarg} --print-multi-directory)
2522 - local TODIR="${D}${LIBPATH}"/${MULTIDIR}
2523 - local FROMDIR=
2524 -
2525 - [[ -d ${TODIR} ]] || mkdir -p ${TODIR}
2526 -
2527 - for FROMDIR in \
2528 - "${LIBPATH}"/${OS_MULTIDIR} \
2529 - "${LIBPATH}"/../${MULTIDIR} \
2530 - "${PREFIX}"/lib/${OS_MULTIDIR} \
2531 - "${PREFIX}"/${CTARGET}/lib/${OS_MULTIDIR}
2532 - do
2533 - removedirs="${removedirs} ${FROMDIR}"
2534 - FROMDIR=${D}${FROMDIR}
2535 - if [[ ${FROMDIR} != "${TODIR}" && -d ${FROMDIR} ]] ; then
2536 - local files=$(find "${FROMDIR}" -maxdepth 1 ! -type d 2>/dev/null)
2537 - if [[ -n ${files} ]] ; then
2538 - mv ${files} "${TODIR}" || die
2539 - fi
2540 - fi
2541 - done
2542 - fix_libtool_libdir_paths "${LIBPATH}/${MULTIDIR}"
2543 -
2544 - # SLOT up libgcj.pc if it's available (and let gcc-config worry about links)
2545 - FROMDIR="${PREFIX}/lib/${OS_MULTIDIR}"
2546 - for x in "${D}${FROMDIR}"/pkgconfig/libgcj*.pc ; do
2547 - [[ -f ${x} ]] || continue
2548 - sed -i "/^libdir=/s:=.*:=${LIBPATH}/${MULTIDIR}:" "${x}" || die
2549 - mv "${x}" "${D}${FROMDIR}"/pkgconfig/libgcj-${GCC_PV}.pc || die
2550 - done
2551 - done
2552 -
2553 - # We remove directories separately to avoid this case:
2554 - # mv SRC/lib/../lib/*.o DEST
2555 - # rmdir SRC/lib/../lib/
2556 - # mv SRC/lib/../lib32/*.o DEST # Bork
2557 - for FROMDIR in ${removedirs} ; do
2558 - rmdir "${D}"${FROMDIR} >& /dev/null
2559 - done
2560 - find -depth "${ED}" -type d -exec rmdir {} + >& /dev/null
2561 -}
2562 -
2563 -# make sure the libtool archives have libdir set to where they actually
2564 -# -are-, and not where they -used- to be. also, any dependencies we have
2565 -# on our own .la files need to be updated.
2566 -fix_libtool_libdir_paths() {
2567 - local libpath="$1"
2568 -
2569 - pushd "${D}" >/dev/null
2570 -
2571 - pushd "./${libpath}" >/dev/null
2572 - local dir="${PWD#${D%/}}"
2573 - local allarchives=$(echo *.la)
2574 - allarchives="\(${allarchives// /\\|}\)"
2575 - popd >/dev/null
2576 -
2577 - # The libdir might not have any .la files. #548782
2578 - find "./${dir}" -maxdepth 1 -name '*.la' \
2579 - -exec sed -i -e "/^libdir=/s:=.*:='${dir}':" {} + || die
2580 - # Would be nice to combine these, but -maxdepth can not be specified
2581 - # on sub-expressions.
2582 - find "./${PREFIX}"/lib* -maxdepth 3 -name '*.la' \
2583 - -exec sed -i -e "/^dependency_libs=/s:/[^ ]*/${allarchives}:${libpath}/\1:g" {} + || die
2584 - find "./${dir}/" -maxdepth 1 -name '*.la' \
2585 - -exec sed -i -e "/^dependency_libs=/s:/[^ ]*/${allarchives}:${libpath}/\1:g" {} + || die
2586 -
2587 - popd >/dev/null
2588 -}
2589 -
2590 -create_gcc_env_entry() {
2591 - dodir /etc/env.d/gcc
2592 - local gcc_envd_base="/etc/env.d/gcc/${CTARGET}-${GCC_CONFIG_VER}"
2593 -
2594 - local gcc_specs_file
2595 - local gcc_envd_file="${ED}${gcc_envd_base}"
2596 - if [[ -z $1 ]] ; then
2597 - # I'm leaving the following commented out to remind me that it
2598 - # was an insanely -bad- idea. Stuff broke. GCC_SPECS isnt unset
2599 - # on chroot or in non-toolchain.eclass gcc ebuilds!
2600 - #gcc_specs_file="${LIBPATH}/specs"
2601 - gcc_specs_file=""
2602 - else
2603 - gcc_envd_file+="-$1"
2604 - gcc_specs_file="${LIBPATH}/$1.specs"
2605 - fi
2606 -
2607 - # We want to list the default ABI's LIBPATH first so libtool
2608 - # searches that directory first. This is a temporary
2609 - # workaround for libtool being stupid and using .la's from
2610 - # conflicting ABIs by using the first one in the search path
2611 - local ldpaths mosdirs
2612 - if tc_version_is_at_least 3.2 ; then
2613 - local mdir mosdir abi ldpath
2614 - for abi in $(get_all_abis TARGET) ; do
2615 - mdir=$($(XGCC) $(get_abi_CFLAGS ${abi}) --print-multi-directory)
2616 - ldpath=${LIBPATH}
2617 - [[ ${mdir} != "." ]] && ldpath+="/${mdir}"
2618 - ldpaths="${ldpath}${ldpaths:+:${ldpaths}}"
2619 -
2620 - mosdir=$($(XGCC) $(get_abi_CFLAGS ${abi}) -print-multi-os-directory)
2621 - mosdirs="${mosdir}${mosdirs:+:${mosdirs}}"
2622 - done
2623 - else
2624 - # Older gcc's didn't do multilib, so logic is simple.
2625 - ldpaths=${LIBPATH}
2626 - fi
2627 -
2628 - cat <<-EOF > ${gcc_envd_file}
2629 - PATH="${BINPATH}"
2630 - ROOTPATH="${BINPATH}"
2631 - GCC_PATH="${BINPATH}"
2632 - LDPATH="${ldpaths}"
2633 - MANPATH="${DATAPATH}/man"
2634 - INFOPATH="${DATAPATH}/info"
2635 - STDCXX_INCDIR="${STDCXX_INCDIR##*/}"
2636 - CTARGET="${CTARGET}"
2637 - GCC_SPECS="${gcc_specs_file}"
2638 - MULTIOSDIRS="${mosdirs}"
2639 - EOF
2640 -}
2641 -
2642 -copy_minispecs_gcc_specs() {
2643 - # on gcc 6 we don't need minispecs
2644 - if tc_version_is_at_least 6.0 ; then
2645 - return 0
2646 - fi
2647 -
2648 - # setup the hardenedno* specs files and the vanilla specs file.
2649 - if hardened_gcc_works ; then
2650 - create_gcc_env_entry hardenednopiessp
2651 - fi
2652 - if hardened_gcc_works pie ; then
2653 - create_gcc_env_entry hardenednopie
2654 - fi
2655 - if hardened_gcc_works ssp ; then
2656 - create_gcc_env_entry hardenednossp
2657 - fi
2658 - create_gcc_env_entry vanilla
2659 - insinto ${LIBPATH#${EPREFIX}}
2660 - doins "${WORKDIR}"/specs/*.specs || die "failed to install specs"
2661 - # Build system specs file which, if it exists, must be a complete set of
2662 - # specs as it completely and unconditionally overrides the builtin specs.
2663 - if ! tc_version_is_at_least 4.4 ; then
2664 - $(XGCC) -dumpspecs > "${WORKDIR}"/specs/specs
2665 - cat "${WORKDIR}"/build.specs >> "${WORKDIR}"/specs/specs
2666 - doins "${WORKDIR}"/specs/specs || die "failed to install the specs file"
2667 - fi
2668 -}
2669 -
2670 -gcc_slot_java() {
2671 - local x
2672 -
2673 - # Move Java headers to compiler-specific dir
2674 - for x in "${D}${PREFIX}"/include/gc*.h "${D}${PREFIX}"/include/j*.h ; do
2675 - [[ -f ${x} ]] && mv -f "${x}" "${D}${LIBPATH}"/include/
2676 - done
2677 - for x in gcj gnu java javax org ; do
2678 - if [[ -d ${D}${PREFIX}/include/${x} ]] ; then
2679 - dodir /${LIBPATH#${EPREFIX}}/include/${x}
2680 - mv -f "${D}${PREFIX}"/include/${x}/* "${D}${LIBPATH}"/include/${x}/
2681 - rm -rf "${D}${PREFIX}"/include/${x}
2682 - fi
2683 - done
2684 -
2685 - if [[ -d ${D}${PREFIX}/lib/security ]] || [[ -d ${D}${PREFIX}/$(get_libdir)/security ]] ; then
2686 - dodir /${LIBPATH#${EPREFIX}}/security
2687 - mv -f "${D}${PREFIX}"/lib*/security/* "${D}${LIBPATH}"/security
2688 - rm -rf "${D}${PREFIX}"/lib*/security
2689 - fi
2690 -
2691 - # Move random gcj files to compiler-specific directories
2692 - for x in libgcj.spec logging.properties ; do
2693 - x="${D}${PREFIX}/lib/${x}"
2694 - [[ -f ${x} ]] && mv -f "${x}" "${D}${LIBPATH}"/
2695 - done
2696 -
2697 - # Rename jar because it could clash with Kaffe's jar if this gcc is
2698 - # primary compiler (aka don't have the -<version> extension)
2699 - cd "${D}${BINPATH}"
2700 - [[ -f jar ]] && mv -f jar gcj-jar
2701 -}
2702 -
2703 -#---->> pkg_post* <<----
2704 -
2705 -toolchain_pkg_postinst() {
2706 - do_gcc_config
2707 - if [[ ! ${ROOT%/} && -f ${EPREFIX}/usr/share/eselect/modules/compiler-shadow.eselect ]] ; then
2708 - eselect compiler-shadow update all
2709 - fi
2710 -
2711 - if ! is_crosscompile && [[ ${PN} != "kgcc64" ]] ; then
2712 - echo
2713 - ewarn "If you have issues with packages unable to locate libstdc++.la,"
2714 - ewarn "then try running 'fix_libtool_files.sh' on the old gcc versions."
2715 - echo
2716 - ewarn "You might want to review the GCC upgrade guide when moving between"
2717 - ewarn "major versions (like 4.2 to 4.3):"
2718 - ewarn "https://wiki.gentoo.org/wiki/Upgrading_GCC"
2719 - echo
2720 -
2721 - # Clean up old paths
2722 - rm -f "${EROOT%/}"/*/rcscripts/awk/fixlafiles.awk "${EROOT%/}"/sbin/fix_libtool_files.sh
2723 - rmdir "${EROOT%/}"/*/rcscripts{/awk,} 2>/dev/null
2724 -
2725 - mkdir -p "${EROOT%/}"/usr/{share/gcc-data,sbin,bin}
2726 - # DATAPATH has EPREFIX already, use ROOT with it
2727 - cp "${ROOT%/}${DATAPATH}"/fixlafiles.awk "${EROOT%/}"/usr/share/gcc-data/ || die
2728 - cp "${ROOT%/}${DATAPATH}"/fix_libtool_files.sh "${EROOT%/}"/usr/sbin/ || die
2729 -
2730 - # Since these aren't critical files and portage sucks with
2731 - # handling of binpkgs, don't require these to be found
2732 - cp "${ROOT%/}${DATAPATH}"/c{89,99} "${EROOT%/}"/usr/bin/ 2>/dev/null
2733 - fi
2734 -
2735 - if use ${GCC_EBUILD_TEST_FLAG} ; then
2736 - elog "Testsuite results have been installed into /usr/share/doc/${PF}/testsuite"
2737 - echo
2738 - fi
2739 -
2740 - if [[ -n ${PRERELEASE}${SNAPSHOT} ]] ; then
2741 - einfo "This GCC ebuild is provided for your convenience, and the use"
2742 - einfo "of this compiler is not supported by the Gentoo Developers."
2743 - einfo "Please report bugs to upstream at http://gcc.gnu.org/bugzilla/"
2744 - fi
2745 -}
2746 -
2747 -toolchain_pkg_postrm() {
2748 - if [[ ! ${ROOT%/} && -f ${EPREFIX}/usr/share/eselect/modules/compiler-shadow.eselect ]] ; then
2749 - eselect compiler-shadow clean all
2750 - fi
2751 -
2752 - # to make our lives easier (and saner), we do the fix_libtool stuff here.
2753 - # rather than checking SLOT's and trying in upgrade paths, we just see if
2754 - # the common libstdc++.la exists in the ${LIBPATH} of the gcc that we are
2755 - # unmerging. if it does, that means this was a simple re-emerge.
2756 -
2757 - # clean up the cruft left behind by cross-compilers
2758 - if is_crosscompile ; then
2759 - if [[ -z $(ls "${EROOT%/}"/etc/env.d/gcc/${CTARGET}* 2>/dev/null) ]] ; then
2760 - rm -f "${EROOT%/}"/etc/env.d/gcc/config-${CTARGET}
2761 - rm -f "${EROOT%/}"/etc/env.d/??gcc-${CTARGET}
2762 - rm -f "${EROOT%/}"/usr/bin/${CTARGET}-{gcc,{g,c}++}{,32,64}
2763 - fi
2764 - return 0
2765 - fi
2766 -
2767 - # ROOT isnt handled by the script
2768 - [[ ${ROOT%/} ]] && return 0
2769 -
2770 - if [[ ! -e ${LIBPATH}/libstdc++.so ]] ; then
2771 - # make sure the profile is sane during same-slot upgrade #289403
2772 - do_gcc_config
2773 -
2774 - einfo "Running 'fix_libtool_files.sh ${GCC_RELEASE_VER}'"
2775 - fix_libtool_files.sh ${GCC_RELEASE_VER}
2776 - if [[ -n ${BRANCH_UPDATE} ]] ; then
2777 - einfo "Running 'fix_libtool_files.sh ${GCC_RELEASE_VER}-${BRANCH_UPDATE}'"
2778 - fix_libtool_files.sh ${GCC_RELEASE_VER}-${BRANCH_UPDATE}
2779 - fi
2780 - fi
2781 -
2782 - return 0
2783 -}
2784 -
2785 -do_gcc_config() {
2786 - if ! should_we_gcc_config ; then
2787 - gcc-config --use-old --force
2788 - return 0
2789 - fi
2790 -
2791 - local current_gcc_config target
2792 -
2793 - current_gcc_config=$(gcc-config -c ${CTARGET} 2>/dev/null)
2794 - if [[ -n ${current_gcc_config} ]] ; then
2795 - local current_specs use_specs
2796 - # figure out which specs-specific config is active
2797 - current_specs=$(gcc-config -S ${current_gcc_config} | awk '{print $3}')
2798 - [[ -n ${current_specs} ]] && use_specs=-${current_specs}
2799 -
2800 - if [[ -n ${use_specs} ]] && \
2801 - [[ ! -e ${EROOT%/}/etc/env.d/gcc/${CTARGET}-${GCC_CONFIG_VER}${use_specs} ]]
2802 - then
2803 - ewarn "The currently selected specs-specific gcc config,"
2804 - ewarn "${current_specs}, doesn't exist anymore. This is usually"
2805 - ewarn "due to enabling/disabling hardened or switching to a version"
2806 - ewarn "of gcc that doesnt create multiple specs files. The default"
2807 - ewarn "config will be used, and the previous preference forgotten."
2808 - use_specs=""
2809 - fi
2810 -
2811 - target="${CTARGET}-${GCC_CONFIG_VER}${use_specs}"
2812 - else
2813 - # The curent target is invalid. Attempt to switch to a valid one.
2814 - # Blindly pick the latest version. #529608
2815 - # TODO: Should update gcc-config to accept `-l ${CTARGET}` rather than
2816 - # doing a partial grep like this.
2817 - target=$(gcc-config -l 2>/dev/null | grep " ${CTARGET}-[0-9]" | tail -1 | awk '{print $2}')
2818 - fi
2819 -
2820 - gcc-config "${target}"
2821 -}
2822 -
2823 -should_we_gcc_config() {
2824 - # if the current config is invalid, we definitely want a new one
2825 - # Note: due to bash quirkiness, the following must not be 1 line
2826 - local curr_config
2827 - curr_config=$(gcc-config -c ${CTARGET} 2>&1) || return 0
2828 -
2829 - # if the previously selected config has the same major.minor (branch) as
2830 - # the version we are installing, then it will probably be uninstalled
2831 - # for being in the same SLOT, make sure we run gcc-config.
2832 - local curr_config_ver=$(gcc-config -S ${curr_config} | awk '{print $2}')
2833 -
2834 - local curr_branch_ver=$(ver_cut 1-2 ${curr_config_ver})
2835 -
2836 - if [[ ${curr_branch_ver} == ${GCC_BRANCH_VER} ]] ; then
2837 - return 0
2838 - else
2839 - # if we're installing a genuinely different compiler version,
2840 - # we should probably tell the user -how- to switch to the new
2841 - # gcc version, since we're not going to do it for him/her.
2842 - # We don't want to switch from say gcc-3.3 to gcc-3.4 right in
2843 - # the middle of an emerge operation (like an 'emerge -e world'
2844 - # which could install multiple gcc versions).
2845 - # Only warn if we're installing a pkg as we might be called from
2846 - # the pkg_{pre,post}rm steps. #446830
2847 - if [[ ${EBUILD_PHASE} == *"inst" ]] ; then
2848 - einfo "The current gcc config appears valid, so it will not be"
2849 - einfo "automatically switched for you. If you would like to"
2850 - einfo "switch to the newly installed gcc version, do the"
2851 - einfo "following:"
2852 - echo
2853 - einfo "gcc-config ${CTARGET}-${GCC_CONFIG_VER}"
2854 - einfo "source /etc/profile"
2855 - echo
2856 - fi
2857 - return 1
2858 - fi
2859 -}
2860 -
2861 -#---->> support and misc functions <<----
2862 -
2863 -# This is to make sure we don't accidentally try to enable support for a
2864 -# language that doesnt exist. GCC 3.4 supports f77, while 4.0 supports f95, etc.
2865 -#
2866 -# Also add a hook so special ebuilds (kgcc64) can control which languages
2867 -# exactly get enabled
2868 -gcc-lang-supported() {
2869 - grep ^language=\"${1}\" "${S}"/gcc/*/config-lang.in > /dev/null || return 1
2870 - [[ -z ${TOOLCHAIN_ALLOWED_LANGS} ]] && return 0
2871 - has $1 ${TOOLCHAIN_ALLOWED_LANGS}
2872 -}
2873 -
2874 -is_ada() {
2875 - gcc-lang-supported ada || return 1
2876 - use_if_iuse ada
2877 -}
2878 -
2879 -is_cxx() {
2880 - gcc-lang-supported 'c++' || return 1
2881 - ! is_crosscompile && tc_version_is_at_least 4.8 && return 0
2882 - use_if_iuse cxx
2883 -}
2884 -
2885 -is_d() {
2886 - gcc-lang-supported d || return 1
2887 - use_if_iuse d
2888 -}
2889 -
2890 -is_f77() {
2891 - gcc-lang-supported f77 || return 1
2892 - use_if_iuse fortran
2893 -}
2894 -
2895 -is_f95() {
2896 - gcc-lang-supported f95 || return 1
2897 - use_if_iuse fortran
2898 -}
2899 -
2900 -is_fortran() {
2901 - gcc-lang-supported fortran || return 1
2902 - use_if_iuse fortran
2903 -}
2904 -
2905 -is_gcj() {
2906 - gcc-lang-supported java || return 1
2907 - use_if_iuse cxx && use_if_iuse gcj
2908 -}
2909 -
2910 -is_go() {
2911 - gcc-lang-supported go || return 1
2912 - use_if_iuse cxx && use_if_iuse go
2913 -}
2914 -
2915 -is_jit() {
2916 - gcc-lang-supported jit || return 1
2917 - use_if_iuse jit
2918 -}
2919 -
2920 -is_multilib() {
2921 - tc_version_is_at_least 3 || return 1
2922 - use_if_iuse multilib
2923 -}
2924 -
2925 -is_objc() {
2926 - gcc-lang-supported objc || return 1
2927 - use_if_iuse objc
2928 -}
2929 -
2930 -is_objcxx() {
2931 - gcc-lang-supported 'obj-c++' || return 1
2932 - use_if_iuse cxx && use_if_iuse objc++
2933 -}
2934 -
2935 -# Grab a variable from the build system (taken from linux-info.eclass)
2936 -get_make_var() {
2937 - local var=$1 makefile=${2:-${WORKDIR}/build/Makefile}
2938 - echo -e "e:\\n\\t@echo \$(${var})\\ninclude ${makefile}" | \
2939 - r=${makefile%/*} emake --no-print-directory -s -f - 2>/dev/null
2940 -}
2941 -
2942 -XGCC() { get_make_var GCC_FOR_TARGET ; }
2943 -
2944 -# The gentoo piessp patches allow for 3 configurations:
2945 -# 1) PIE+SSP by default
2946 -# 2) PIE by default
2947 -# 3) SSP by default
2948 -hardened_gcc_works() {
2949 - if [[ $1 == "pie" ]] ; then
2950 - # $gcc_cv_ld_pie is unreliable as it simply take the output of
2951 - # `ld --help | grep -- -pie`, that reports the option in all cases, also if
2952 - # the loader doesn't actually load the resulting executables.
2953 - # To avoid breakage, blacklist FreeBSD here at least
2954 - [[ ${CTARGET} == *-freebsd* ]] && return 1
2955 -
2956 - want_pie || return 1
2957 - use_if_iuse nopie && return 1
2958 - hardened_gcc_is_stable pie
2959 - return $?
2960 - elif [[ $1 == "ssp" ]] ; then
2961 - [[ -n ${SPECS_VER} ]] || return 1
2962 - use_if_iuse nossp && return 1
2963 - hardened_gcc_is_stable ssp
2964 - return $?
2965 - else
2966 - # laziness ;)
2967 - hardened_gcc_works pie || return 1
2968 - hardened_gcc_works ssp || return 1
2969 - return 0
2970 - fi
2971 -}
2972 -
2973 -hardened_gcc_is_stable() {
2974 - local tocheck
2975 - if [[ $1 == "pie" ]] ; then
2976 - if [[ ${CTARGET} == *-uclibc* ]] ; then
2977 - tocheck=${PIE_UCLIBC_STABLE}
2978 - else
2979 - tocheck=${PIE_GLIBC_STABLE}
2980 - fi
2981 - elif [[ $1 == "ssp" ]] ; then
2982 - if [[ ${CTARGET} == *-uclibc* ]] ; then
2983 - tocheck=${SSP_UCLIBC_STABLE}
2984 - elif [[ ${CTARGET} == *-gnu* ]] ; then
2985 - tocheck=${SSP_STABLE}
2986 - fi
2987 - else
2988 - die "hardened_gcc_stable needs to be called with pie or ssp"
2989 - fi
2990 -
2991 - has $(tc-arch) ${tocheck} && return 0
2992 - return 1
2993 -}
2994 -
2995 -want_minispecs() {
2996 - # on gcc 6 we don't need minispecs
2997 - if tc_version_is_at_least 6.0 ; then
2998 - return 0
2999 - fi
3000 - if tc_version_is_at_least 4.3.2 && use_if_iuse hardened ; then
3001 - if ! want_pie ; then
3002 - ewarn "PIE_VER or SPECS_VER is not defined in the GCC ebuild."
3003 - elif use vanilla ; then
3004 - ewarn "You will not get hardened features if you have the vanilla USE-flag."
3005 - elif use_if_iuse nopie && use_if_iuse nossp ; then
3006 - ewarn "You will not get hardened features if you have the nopie and nossp USE-flag."
3007 - elif ! hardened_gcc_works ; then
3008 - ewarn "Your $(tc-arch) arch is not supported."
3009 - else
3010 - return 0
3011 - fi
3012 - ewarn "Hope you know what you are doing. Hardened will not work."
3013 - return 0
3014 - fi
3015 - return 1
3016 -}
3017 -
3018 -want_pie() {
3019 - ! use_if_iuse hardened && [[ -n ${PIE_VER} ]] && use_if_iuse nopie && return 1
3020 - [[ -n ${PIE_VER} ]] && [[ -n ${SPECS_VER} ]] && return 0
3021 - tc_version_is_at_least 4.3.2 && return 1
3022 - [[ -z ${PIE_VER} ]] && return 1
3023 - use_if_iuse nopie || return 0
3024 - return 1
3025 -}
3026 -
3027 -has toolchain_death_notice ${EBUILD_DEATH_HOOKS} || EBUILD_DEATH_HOOKS+=" toolchain_death_notice"
3028 -toolchain_death_notice() {
3029 - if [[ -e "${WORKDIR}"/build ]] ; then
3030 - pushd "${WORKDIR}"/build >/dev/null
3031 - (echo '' | $(tc-getCC ${CTARGET}) ${CFLAGS} -v -E - 2>&1) > gccinfo.log
3032 - [[ -e "${T}"/build.log ]] && cp "${T}"/build.log .
3033 - tar jcf "${WORKDIR}"/gcc-build-logs.tar.bz2 \
3034 - gccinfo.log build.log $(find -name config.log)
3035 - rm gccinfo.log build.log
3036 - eerror
3037 - eerror "Please include ${WORKDIR}/gcc-build-logs.tar.bz2 in your bug report."
3038 - eerror
3039 - popd >/dev/null
3040 - fi
3041 -}
3042 -
3043 -# Note [implicitly enabled flags]
3044 -# -------------------------------
3045 -# Usually configure-based packages handle explicit feature requests
3046 -# like
3047 -# ./configure --enable-foo
3048 -# as explicit request to check for support of 'foo' and bail out at
3049 -# configure time.
3050 -#
3051 -# GCC does not follow this pattern and instead overrides autodetection
3052 -# of the feature and enables it unconditionally.
3053 -# See bugs:
3054 -# https://gcc.gnu.org/PR85663 (libsanitizer on mips)
3055 -# https://bugs.gentoo.org/661252 (libvtv on powerpc64)
3056 -#
3057 -# Thus safer way to enable/disable the feature is to rely on implicit
3058 -# enabled-by-default state:
3059 -# econf $(usex foo '' --disable-foo)