Gentoo Archives: gentoo-commits

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