Gentoo Archives: gentoo-commits

From: Magnus Granberg <zorry@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/hardened-dev:master commit in: sys-devel/gcc/, eclass/, sys-devel/gcc/files/awk/, sys-devel/gcc/files/
Date: Tue, 31 Dec 2013 16:11:51
Message-Id: 1388505716.0795ca02a53c0fbf38484cf6e2f77df7674d54da.zorry@gentoo
1 commit: 0795ca02a53c0fbf38484cf6e2f77df7674d54da
2 Author: Magnus Granberg <zorry <AT> gentoo <DOT> org>
3 AuthorDate: Tue Dec 31 16:01:56 2013 +0000
4 Commit: Magnus Granberg <zorry <AT> gentoo <DOT> org>
5 CommitDate: Tue Dec 31 16:01:56 2013 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/hardened-dev.git;a=commit;h=0795ca02
7
8 Add gcc 4.8.2-r1 with default ssp on
9
10 ---
11 eclass/toolchain.eclass | 2103 ++++++++++++++++++++++
12 sys-devel/gcc/files/awk/fixlafiles.awk | 314 ++++
13 sys-devel/gcc/files/awk/fixlafiles.awk-no_gcc_la | 335 ++++
14 sys-devel/gcc/files/c89 | 20 +
15 sys-devel/gcc/files/c99 | 21 +
16 sys-devel/gcc/files/fix_libtool_files.sh | 68 +
17 sys-devel/gcc/files/gcc-configure-LANG.patch | 64 +
18 sys-devel/gcc/files/gcc-configure-texinfo.patch | 16 +
19 sys-devel/gcc/files/gcc-spec-env-r1.patch | 87 +
20 sys-devel/gcc/files/gcc-spec-env.patch | 42 +
21 sys-devel/gcc/files/mkinfodir | 233 +++
22 sys-devel/gcc/gcc-4.8.2-r1.ebuild | 50 +
23 sys-devel/gcc/metadata.xml | 33 +
24 13 files changed, 3386 insertions(+)
25
26 diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass
27 new file mode 100644
28 index 0000000..c95a14d
29 --- /dev/null
30 +++ b/eclass/toolchain.eclass
31 @@ -0,0 +1,2103 @@
32 +# Copyright 1999-2013 Gentoo Foundation
33 +# Distributed under the terms of the GNU General Public License v2
34 +# $Header: /var/cvsroot/gentoo-x86/eclass/toolchain.eclass,v 1.616 2013/12/30 03:24:04 dirtyepic Exp $
35 +
36 +# Maintainer: Toolchain Ninjas <toolchain@g.o>
37 +
38 +DESCRIPTION="The GNU Compiler Collection"
39 +HOMEPAGE="http://gcc.gnu.org/"
40 +LICENSE="GPL-2 LGPL-2.1"
41 +RESTRICT="strip" # cross-compilers need controlled stripping
42 +
43 +inherit eutils fixheadtails flag-o-matic gnuconfig libtool multilib pax-utils toolchain-funcs versionator
44 +
45 +if [[ ${PV} == *_pre9999* ]] ; then
46 + EGIT_REPO_URI="git://gcc.gnu.org/git/gcc.git"
47 + # naming style:
48 + # gcc-4.7.1_pre9999 -> gcc-4_7-branch
49 + # Note that the micro version is required or lots of stuff will break.
50 + # To checkout master set gcc_LIVE_BRANCH="master" in the ebuild before
51 + # inheriting this eclass.
52 + EGIT_BRANCH="${PN}-${PV%.?_pre9999}-branch"
53 + EGIT_BRANCH=${EGIT_BRANCH//./_}
54 + inherit git-2
55 +fi
56 +
57 +FEATURES=${FEATURES/multilib-strict/}
58 +
59 +EXPORTED_FUNCTIONS="pkg_setup src_unpack src_compile src_test src_install pkg_postinst pkg_postrm"
60 +case ${EAPI:-0} in
61 + 0|1) ;;
62 + 2|3) EXPORTED_FUNCTIONS+=" src_prepare src_configure" ;;
63 + 4*|5*) EXPORTED_FUNCTIONS+=" pkg_pretend src_prepare src_configure" ;;
64 + *) die "I don't speak EAPI ${EAPI}."
65 +esac
66 +EXPORT_FUNCTIONS ${EXPORTED_FUNCTIONS}
67 +
68 +#---->> globals <<----
69 +
70 +export CTARGET=${CTARGET:-${CHOST}}
71 +if [[ ${CTARGET} = ${CHOST} ]] ; then
72 + if [[ ${CATEGORY/cross-} != ${CATEGORY} ]] ; then
73 + export CTARGET=${CATEGORY/cross-}
74 + fi
75 +fi
76 +: ${TARGET_ABI:=${ABI}}
77 +: ${TARGET_MULTILIB_ABIS:=${MULTILIB_ABIS}}
78 +: ${TARGET_DEFAULT_ABI:=${DEFAULT_ABI}}
79 +
80 +is_crosscompile() {
81 + [[ ${CHOST} != ${CTARGET} ]]
82 +}
83 +
84 +# General purpose version check. Without a second arg matches up to minor version (x.x.x)
85 +tc_version_is_at_least() {
86 + version_is_at_least "$1" "${2:-${GCC_RELEASE_VER}}"
87 +}
88 +
89 +# General purpose version range check
90 +# Note that it matches up to but NOT including the second version
91 +tc_version_is_between() {
92 + tc_version_is_at_least "${1}" && ! tc_version_is_at_least "${2}"
93 +}
94 +
95 +GCC_PV=${TOOLCHAIN_GCC_PV:-${PV}}
96 +GCC_PVR=${GCC_PV}
97 +[[ ${PR} != "r0" ]] && GCC_PVR=${GCC_PVR}-${PR}
98 +GCC_RELEASE_VER=$(get_version_component_range 1-3 ${GCC_PV})
99 +GCC_BRANCH_VER=$(get_version_component_range 1-2 ${GCC_PV})
100 +GCCMAJOR=$(get_version_component_range 1 ${GCC_PV})
101 +GCCMINOR=$(get_version_component_range 2 ${GCC_PV})
102 +GCCMICRO=$(get_version_component_range 3 ${GCC_PV})
103 +[[ ${BRANCH_UPDATE-notset} == "notset" ]] && \
104 + BRANCH_UPDATE=$(get_version_component_range 4 ${GCC_PV})
105 +
106 +# According to gcc/c-cppbuiltin.c, GCC_CONFIG_VER MUST match this regex.
107 +# ([^0-9]*-)?[0-9]+[.][0-9]+([.][0-9]+)?([- ].*)?
108 +GCC_CONFIG_VER=${GCC_CONFIG_VER:-$(replace_version_separator 3 '-' ${GCC_PV})}
109 +
110 +# Pre-release support
111 +if [[ ${GCC_PV} != ${GCC_PV/_pre/-} ]] ; then
112 + PRERELEASE=${GCC_PV/_pre/-}
113 +fi
114 +
115 +# make _alpha and _beta ebuilds automatically use a snapshot
116 +if [[ ${GCC_PV} == *_alpha* ]] ; then
117 + SNAPSHOT=${GCC_BRANCH_VER}-${GCC_PV##*_alpha}
118 +elif [[ ${GCC_PV} == *_beta* ]] ; then
119 + SNAPSHOT=${GCC_BRANCH_VER}-${GCC_PV##*_beta}
120 +elif [[ ${GCC_PV} == *_rc* ]] ; then
121 + SNAPSHOT=${GCC_PV%_rc*}-RC-${GCC_PV##*_rc}
122 +fi
123 +
124 +export GCC_FILESDIR=${GCC_FILESDIR:-${FILESDIR}}
125 +
126 +PREFIX=${TOOLCHAIN_PREFIX:-/usr}
127 +
128 +if tc_version_is_at_least 3.4.0 ; then
129 + LIBPATH=${TOOLCHAIN_LIBPATH:-${PREFIX}/lib/gcc/${CTARGET}/${GCC_CONFIG_VER}}
130 +else
131 + LIBPATH=${TOOLCHAIN_LIBPATH:-${PREFIX}/lib/gcc-lib/${CTARGET}/${GCC_CONFIG_VER}}
132 +fi
133 +INCLUDEPATH=${TOOLCHAIN_INCLUDEPATH:-${LIBPATH}/include}
134 +
135 +if is_crosscompile ; then
136 + BINPATH=${TOOLCHAIN_BINPATH:-${PREFIX}/${CHOST}/${CTARGET}/gcc-bin/${GCC_CONFIG_VER}}
137 +else
138 + BINPATH=${TOOLCHAIN_BINPATH:-${PREFIX}/${CTARGET}/gcc-bin/${GCC_CONFIG_VER}}
139 +fi
140 +
141 +DATAPATH=${TOOLCHAIN_DATAPATH:-${PREFIX}/share/gcc-data/${CTARGET}/${GCC_CONFIG_VER}}
142 +
143 +# Dont install in /usr/include/g++-v3/, but in gcc internal directory.
144 +# We will handle /usr/include/g++-v3/ with gcc-config ...
145 +STDCXX_INCDIR=${TOOLCHAIN_STDCXX_INCDIR:-${LIBPATH}/include/g++-v${GCC_BRANCH_VER/\.*/}}
146 +
147 +#---->> SLOT+IUSE logic <<----
148 +
149 +IUSE="multislot nls nptl regression-test vanilla"
150 +
151 +if [[ ${PN} != "kgcc64" && ${PN} != gcc-* ]] ; then
152 + IUSE+=" altivec cxx fortran"
153 + [[ -n ${PIE_VER} ]] && IUSE+=" nopie"
154 + [[ -n ${HTB_VER} ]] && IUSE+=" boundschecking"
155 + [[ -n ${D_VER} ]] && IUSE+=" d"
156 + [[ -n ${SPECS_VER} ]] && IUSE+=" nossp"
157 + tc_version_is_at_least 3 && IUSE+=" doc gcj awt hardened multilib objc"
158 + tc_version_is_at_least 4.0 && IUSE+=" objc-gc"
159 + tc_version_is_between 4.0 4.9 && IUSE+=" mudflap"
160 + tc_version_is_at_least 4.1 && IUSE+=" libssp objc++"
161 + tc_version_is_at_least 4.2 && IUSE+=" openmp"
162 + tc_version_is_at_least 4.3 && IUSE+=" fixed-point"
163 + tc_version_is_at_least 4.6 && IUSE+=" graphite"
164 + tc_version_is_at_least 4.7 && IUSE+=" go"
165 +fi
166 +
167 +# Support upgrade paths here or people get pissed
168 +if use multislot ; then
169 + SLOT="${GCC_CONFIG_VER}"
170 +else
171 + SLOT="${GCC_BRANCH_VER}"
172 +fi
173 +
174 +#---->> DEPEND <<----
175 +
176 +RDEPEND="sys-libs/zlib
177 + nls? ( sys-devel/gettext )"
178 +
179 +tc_version_is_at_least 3 && RDEPEND+=" virtual/libiconv"
180 +
181 +if tc_version_is_at_least 4 ; then
182 + GMP_MPFR_DEPS=">=dev-libs/gmp-4.3.2 >=dev-libs/mpfr-2.4.2"
183 + if tc_version_is_at_least 4.3 ; then
184 + RDEPEND+=" ${GMP_MPFR_DEPS}"
185 + elif in_iuse fortran ; then
186 + RDEPEND+=" fortran? ( ${GMP_MPFR_DEPS} )"
187 + fi
188 +fi
189 +
190 +tc_version_is_at_least 4.5 && RDEPEND+=" >=dev-libs/mpc-0.8.1"
191 +
192 +if in_iuse graphite ; then
193 + if tc_version_is_at_least 4.8 ; then
194 + RDEPEND+="
195 + graphite? (
196 + >=dev-libs/cloog-0.18.0
197 + >=dev-libs/isl-0.11.1
198 + )"
199 + else
200 + RDEPEND+="
201 + graphite? (
202 + >=dev-libs/cloog-ppl-0.15.10
203 + >=dev-libs/ppl-0.11
204 + )"
205 + fi
206 +fi
207 +
208 +DEPEND="${RDEPEND}
209 + >=sys-devel/bison-1.875
210 + >=sys-devel/flex-2.5.4
211 + regression-test? (
212 + >=dev-util/dejagnu-1.4.4
213 + >=sys-devel/autogen-5.5.4
214 + )"
215 +
216 +if in_iuse gcj ; then
217 + GCJ_DEPS=">=media-libs/libart_lgpl-2.1"
218 + GCJ_GTK_DEPS="
219 + x11-libs/libXt
220 + x11-libs/libX11
221 + x11-libs/libXtst
222 + x11-proto/xproto
223 + x11-proto/xextproto
224 + =x11-libs/gtk+-2*
225 + virtual/pkgconfig
226 + amd64? ( multilib? (
227 + app-emulation/emul-linux-x86-gtklibs
228 + app-emulation/emul-linux-x86-xlibs
229 + ) )
230 + "
231 + tc_version_is_at_least 3.4 && GCJ_GTK_DEPS+=" x11-libs/pango"
232 + tc_version_is_at_least 4.2 && GCJ_DEPS+=" app-arch/zip app-arch/unzip"
233 + DEPEND+=" gcj? ( awt? ( ${GCJ_GTK_DEPS} ) ${GCJ_DEPS} )"
234 +fi
235 +
236 +PDEPEND=">=sys-devel/gcc-config-1.7"
237 +
238 +#---->> S + SRC_URI essentials <<----
239 +
240 +# Set the source directory depending on whether we're using
241 +# a prerelease, snapshot, or release tarball.
242 +S=$(
243 + if [[ -n ${PRERELEASE} ]] ; then
244 + echo ${WORKDIR}/gcc-${PRERELEASE}
245 + elif [[ -n ${SNAPSHOT} ]] ; then
246 + echo ${WORKDIR}/gcc-${SNAPSHOT}
247 + else
248 + echo ${WORKDIR}/gcc-${GCC_RELEASE_VER}
249 + fi
250 +)
251 +
252 +gentoo_urls() {
253 + local devspace="HTTP~vapier/dist/URI HTTP~dirtyepic/dist/URI
254 + HTTP~halcy0n/patches/URI HTTP~zorry/patches/gcc/URI"
255 + devspace=${devspace//HTTP/http:\/\/dev.gentoo.org\/}
256 + echo mirror://gentoo/$1 ${devspace//URI/$1}
257 +}
258 +
259 +# This function handles the basics of setting the SRC_URI for a gcc ebuild.
260 +# To use, set SRC_URI with:
261 +#
262 +# SRC_URI="$(get_gcc_src_uri)"
263 +#
264 +# Other than the variables normally set by portage, this function's behavior
265 +# can be altered by setting the following:
266 +#
267 +# SNAPSHOT
268 +# If set, this variable signals that we should be using a snapshot of
269 +# gcc. It is expected to be in the format "YYYY-MM-DD". Note that if
270 +# the ebuild has a _pre suffix, this variable is ignored and the
271 +# prerelease tarball is used instead.
272 +#
273 +# BRANCH_UPDATE
274 +# If set, this variable signals that we should be using the main
275 +# release tarball (determined by ebuild version) and applying a
276 +# CVS branch update patch against it. The location of this branch
277 +# update patch is assumed to be in ${GENTOO_TOOLCHAIN_BASE_URI}.
278 +# Just like with SNAPSHOT, this variable is ignored if the ebuild
279 +# has a _pre suffix.
280 +#
281 +# PATCH_VER
282 +# PATCH_GCC_VER
283 +# This should be set to the version of the gentoo patch tarball.
284 +# The resulting filename of this tarball will be:
285 +# gcc-${PATCH_GCC_VER:-${GCC_RELEASE_VER}}-patches-${PATCH_VER}.tar.bz2
286 +#
287 +# PIE_VER
288 +# PIE_GCC_VER
289 +# These variables control patching in various updates for the logic
290 +# controlling Position Independant Executables. PIE_VER is expected
291 +# to be the version of this patch, and PIE_GCC_VER the gcc version of
292 +# the patch:
293 +# An example:
294 +# PIE_VER="8.7.6.5"
295 +# PIE_GCC_VER="3.4.0"
296 +# The resulting filename of this tarball will be:
297 +# gcc-${PIE_GCC_VER:-${GCC_RELEASE_VER}}-piepatches-v${PIE_VER}.tar.bz2
298 +#
299 +# SPECS_VER
300 +# SPECS_GCC_VER
301 +# This is for the minispecs files included in the hardened gcc-4.x
302 +# The specs files for hardenedno*, vanilla and for building the "specs" file.
303 +# SPECS_VER is expected to be the version of this patch, SPECS_GCC_VER
304 +# the gcc version of the patch.
305 +# An example:
306 +# SPECS_VER="8.7.6.5"
307 +# SPECS_GCC_VER="3.4.0"
308 +# The resulting filename of this tarball will be:
309 +# gcc-${SPECS_GCC_VER:-${GCC_RELEASE_VER}}-specs-${SPECS_VER}.tar.bz2
310 +#
311 +# HTB_VER
312 +# HTB_GCC_VER
313 +# These variables control whether or not an ebuild supports Herman
314 +# ten Brugge's bounds-checking patches. If you want to use a patch
315 +# for an older gcc version with a new gcc, make sure you set
316 +# HTB_GCC_VER to that version of gcc.
317 +get_gcc_src_uri() {
318 + export PATCH_GCC_VER=${PATCH_GCC_VER:-${GCC_RELEASE_VER}}
319 + export UCLIBC_GCC_VER=${UCLIBC_GCC_VER:-${PATCH_GCC_VER}}
320 + export PIE_GCC_VER=${PIE_GCC_VER:-${GCC_RELEASE_VER}}
321 + export HTB_GCC_VER=${HTB_GCC_VER:-${GCC_RELEASE_VER}}
322 + export SPECS_GCC_VER=${SPECS_GCC_VER:-${GCC_RELEASE_VER}}
323 +
324 + # Set where to download gcc itself depending on whether we're using a
325 + # prerelease, snapshot, or release tarball.
326 + if [[ -n ${PRERELEASE} ]] ; then
327 + GCC_SRC_URI="ftp://gcc.gnu.org/pub/gcc/prerelease-${PRERELEASE}/gcc-${PRERELEASE}.tar.bz2"
328 + elif [[ -n ${SNAPSHOT} ]] ; then
329 + GCC_SRC_URI="ftp://gcc.gnu.org/pub/gcc/snapshots/${SNAPSHOT}/gcc-${SNAPSHOT}.tar.bz2"
330 + elif [[ ${PV} != *9999* ]] ; then
331 + GCC_SRC_URI="mirror://gnu/gcc/gcc-${GCC_PV}/gcc-${GCC_RELEASE_VER}.tar.bz2"
332 + # we want all branch updates to be against the main release
333 + [[ -n ${BRANCH_UPDATE} ]] && \
334 + GCC_SRC_URI+=" $(gentoo_urls gcc-${GCC_RELEASE_VER}-branch-update-${BRANCH_UPDATE}.patch.bz2)"
335 + fi
336 +
337 + [[ -n ${UCLIBC_VER} ]] && \
338 + GCC_SRC_URI+=" $(gentoo_urls gcc-${UCLIBC_GCC_VER}-uclibc-patches-${UCLIBC_VER}.tar.bz2)"
339 + [[ -n ${PATCH_VER} ]] && \
340 + GCC_SRC_URI+=" $(gentoo_urls gcc-${PATCH_GCC_VER}-patches-${PATCH_VER}.tar.bz2)"
341 +
342 + # strawberry pie, Cappuccino and a Gauloises (it's a good thing)
343 + [[ -n ${PIE_VER} ]] && \
344 + PIE_CORE=${PIE_CORE:-gcc-${PIE_GCC_VER}-piepatches-v${PIE_VER}.tar.bz2} && \
345 + GCC_SRC_URI+=" $(gentoo_urls ${PIE_CORE})"
346 +
347 + # gcc minispec for the hardened gcc 4 compiler
348 + [[ -n ${SPECS_VER} ]] && \
349 + GCC_SRC_URI+=" $(gentoo_urls gcc-${SPECS_GCC_VER}-specs-${SPECS_VER}.tar.bz2)"
350 +
351 + # gcc bounds checking patch
352 + if [[ -n ${HTB_VER} ]] ; then
353 + local HTBFILE="bounds-checking-gcc-${HTB_GCC_VER}-${HTB_VER}.patch.bz2"
354 + GCC_SRC_URI+="
355 + boundschecking? (
356 + mirror://sourceforge/boundschecking/${HTBFILE}
357 + $(gentoo_urls ${HTBFILE})
358 + )"
359 + fi
360 +
361 + [[ -n ${D_VER} ]] && \
362 + GCC_SRC_URI+=" d? ( mirror://sourceforge/dgcc/gdc-${D_VER}-src.tar.bz2 )"
363 +
364 + if in_iuse gcj ; then
365 + if tc_version_is_at_least 4.5 ; then
366 + GCC_SRC_URI+=" gcj? ( ftp://sourceware.org/pub/java/ecj-4.5.jar )"
367 + elif tc_version_is_at_least 4.3 ; then
368 + GCC_SRC_URI+=" gcj? ( ftp://sourceware.org/pub/java/ecj-4.3.jar )"
369 + fi
370 + fi
371 +
372 + echo "${GCC_SRC_URI}"
373 +}
374 +
375 +SRC_URI=$(get_gcc_src_uri)
376 +
377 +#---->> pkg_pretend <<----
378 +
379 +toolchain_pkg_pretend() {
380 + if [[ -n ${PRERELEASE}${SNAPSHOT} || ${PV} == *9999* ]] &&
381 + [[ -z ${I_PROMISE_TO_SUPPLY_PATCHES_WITH_BUGS} ]] ; then
382 + die "Please \`export I_PROMISE_TO_SUPPLY_PATCHES_WITH_BUGS=1\` or define it" \
383 + "in your make.conf if you want to use this version."
384 + fi
385 +
386 + [[ -z ${UCLIBC_VER} ]] && [[ ${CTARGET} == *-uclibc* ]] && \
387 + die "Sorry, this version does not support uClibc"
388 +
389 + if ! use_if_iuse cxx ; then
390 + use_if_iuse go && ewarn 'Go requires a C++ compiler, disabled due to USE="-cxx"'
391 + use_if_iuse objc++ && ewarn 'Obj-C++ requires a C++ compiler, disabled due to USE="-cxx"'
392 + use_if_iuse gcj && ewarn 'GCJ requires a C++ compiler, disabled due to USE="-cxx"'
393 + fi
394 +
395 + want_minispecs
396 +}
397 +
398 +#---->> pkg_setup <<----
399 +
400 +toolchain_pkg_setup() {
401 + case "${EAPI:-0}" in
402 + 0|1|2|3) toolchain_pkg_pretend ;;
403 + esac
404 +
405 + # we dont want to use the installed compiler's specs to build gcc
406 + unset GCC_SPECS
407 + unset LANGUAGES #265283
408 +}
409 +
410 +#---->> src_unpack <<----
411 +
412 +toolchain_src_unpack() {
413 + if [[ ${PV} == *9999* ]]; then
414 + git-2_src_unpack
415 + else
416 + gcc_quick_unpack
417 + fi
418 +
419 + case ${EAPI:-0} in
420 + 0|1) toolchain_src_prepare ;;
421 + esac
422 +}
423 +
424 +gcc_quick_unpack() {
425 + pushd "${WORKDIR}" > /dev/null
426 + export PATCH_GCC_VER=${PATCH_GCC_VER:-${GCC_RELEASE_VER}}
427 + export UCLIBC_GCC_VER=${UCLIBC_GCC_VER:-${PATCH_GCC_VER}}
428 + export PIE_GCC_VER=${PIE_GCC_VER:-${GCC_RELEASE_VER}}
429 + export HTB_GCC_VER=${HTB_GCC_VER:-${GCC_RELEASE_VER}}
430 + export SPECS_GCC_VER=${SPECS_GCC_VER:-${GCC_RELEASE_VER}}
431 +
432 + if [[ -n ${GCC_A_FAKEIT} ]] ; then
433 + unpack ${GCC_A_FAKEIT}
434 + elif [[ -n ${PRERELEASE} ]] ; then
435 + unpack gcc-${PRERELEASE}.tar.bz2
436 + elif [[ -n ${SNAPSHOT} ]] ; then
437 + unpack gcc-${SNAPSHOT}.tar.bz2
438 + elif [[ ${PV} != *9999* ]] ; then
439 + unpack gcc-${GCC_RELEASE_VER}.tar.bz2
440 + # We want branch updates to be against a release tarball
441 + if [[ -n ${BRANCH_UPDATE} ]] ; then
442 + pushd "${S}" > /dev/null
443 + epatch "${DISTDIR}"/gcc-${GCC_RELEASE_VER}-branch-update-${BRANCH_UPDATE}.patch.bz2
444 + popd > /dev/null
445 + fi
446 + fi
447 +
448 + if [[ -n ${D_VER} ]] && use d ; then
449 + pushd "${S}"/gcc > /dev/null
450 + unpack gdc-${D_VER}-src.tar.bz2
451 + cd ..
452 + ebegin "Adding support for the D language"
453 + ./gcc/d/setup-gcc.sh >& "${T}"/dgcc.log
454 + if ! eend $? ; then
455 + eerror "The D GCC package failed to apply"
456 + eerror "Please include this log file when posting a bug report:"
457 + eerror " ${T}/dgcc.log"
458 + die "failed to include the D language"
459 + fi
460 + popd > /dev/null
461 + fi
462 +
463 + [[ -n ${PATCH_VER} ]] && \
464 + unpack gcc-${PATCH_GCC_VER}-patches-${PATCH_VER}.tar.bz2
465 +
466 + [[ -n ${UCLIBC_VER} ]] && \
467 + unpack gcc-${UCLIBC_GCC_VER}-uclibc-patches-${UCLIBC_VER}.tar.bz2
468 +
469 + if want_pie ; then
470 + if [[ -n ${PIE_CORE} ]] ; then
471 + unpack ${PIE_CORE}
472 + else
473 + unpack gcc-${PIE_GCC_VER}-piepatches-v${PIE_VER}.tar.bz2
474 + fi
475 + [[ -n ${SPECS_VER} ]] && \
476 + unpack gcc-${SPECS_GCC_VER}-specs-${SPECS_VER}.tar.bz2
477 + fi
478 +
479 + use_if_iuse boundschecking && unpack "bounds-checking-gcc-${HTB_GCC_VER}-${HTB_VER}.patch.bz2"
480 +
481 + popd > /dev/null
482 +}
483 +
484 +#---->> src_prepare <<----
485 +
486 +toolchain_src_prepare() {
487 + export BRANDING_GCC_PKGVERSION="Gentoo ${GCC_PVR}"
488 + cd "${S}"
489 +
490 + if ! use vanilla ; then
491 + if [[ -n ${PATCH_VER} ]] ; then
492 + guess_patch_type_in_dir "${WORKDIR}"/patch
493 + EPATCH_MULTI_MSG="Applying Gentoo patches ..." \
494 + epatch "${WORKDIR}"/patch
495 + BRANDING_GCC_PKGVERSION="${BRANDING_GCC_PKGVERSION} p${PATCH_VER}"
496 + fi
497 + if [[ -n ${UCLIBC_VER} ]] ; then
498 + guess_patch_type_in_dir "${WORKDIR}"/uclibc
499 + EPATCH_MULTI_MSG="Applying uClibc patches ..." \
500 + epatch "${WORKDIR}"/uclibc
501 + fi
502 + fi
503 + do_gcc_HTB_patches
504 + do_gcc_PIE_patches
505 + epatch_user
506 +
507 + if ( tc_version_is_at_least 4.8 || use hardened ) && ! use vanilla ; then
508 + make_gcc_hard
509 + fi
510 +
511 + # install the libstdc++ python into the right location
512 + # http://gcc.gnu.org/PR51368
513 + if tc_version_is_between 4.5 4.7 ; then
514 + sed -i \
515 + '/^pythondir =/s:=.*:= $(datadir)/python:' \
516 + "${S}"/libstdc++-v3/python/Makefile.in || die
517 + fi
518 +
519 + # make sure the pkg config files install into multilib dirs.
520 + # since we configure with just one --libdir, we can't use that
521 + # (as gcc itself takes care of building multilibs). #435728
522 + find "${S}" -name Makefile.in \
523 + -exec sed -i '/^pkgconfigdir/s:=.*:=$(toolexeclibdir)/pkgconfig:' {} +
524 +
525 + # No idea when this first started being fixed, but let's go with 4.3.x for now
526 + if ! tc_version_is_at_least 4.3 ; then
527 + fix_files=""
528 + for x in contrib/test_summary libstdc++-v3/scripts/check_survey.in ; do
529 + [[ -e ${x} ]] && fix_files="${fix_files} ${x}"
530 + done
531 + ht_fix_file ${fix_files} */configure *.sh */Makefile.in
532 + fi
533 +
534 + setup_multilib_osdirnames
535 + gcc_version_patch
536 +
537 + if tc_version_is_at_least 4.1 ; then
538 + if [[ -n ${SNAPSHOT} || -n ${PRERELEASE} ]] ; then
539 + # BASE-VER must be a three-digit version number
540 + # followed by an optional -pre string
541 + # eg. 4.5.1, 4.6.2-pre20120213, 4.7.0-pre9999
542 + # If BASE-VER differs from ${PV/_/-} then libraries get installed in
543 + # the wrong directory.
544 + echo ${PV/_/-} > "${S}"/gcc/BASE-VER
545 + fi
546 + fi
547 +
548 + # >= gcc-4.3 doesn't bundle ecj.jar, so copy it
549 + if tc_version_is_at_least 4.3 && use gcj ; then
550 + if tc_version_is_at_least 4.5 ; then
551 + einfo "Copying ecj-4.5.jar"
552 + cp -pPR "${DISTDIR}/ecj-4.5.jar" "${S}/ecj.jar" || die
553 + else
554 + einfo "Copying ecj-4.3.jar"
555 + cp -pPR "${DISTDIR}/ecj-4.3.jar" "${S}/ecj.jar" || die
556 + fi
557 + fi
558 +
559 + # disable --as-needed from being compiled into gcc specs
560 + # natively when using a gcc version < 3.4.4
561 + # http://gcc.gnu.org/PR14992
562 + if ! tc_version_is_at_least 3.4.4 ; then
563 + sed -i -e s/HAVE_LD_AS_NEEDED/USE_LD_AS_NEEDED/g "${S}"/gcc/config.in
564 + fi
565 +
566 + # In gcc 3.3.x and 3.4.x, rename the java bins to gcc-specific names
567 + # in line with gcc-4.
568 + if tc_version_is_between 3.3 4.0 ; then
569 + do_gcc_rename_java_bins
570 + fi
571 +
572 + # Prevent libffi from being installed
573 + if tc_version_is_between 3.0 4.8 ; then
574 + sed -i -e 's/\(install.*:\) install-.*recursive/\1/' "${S}"/libffi/Makefile.in || die
575 + sed -i -e 's/\(install-data-am:\).*/\1/' "${S}"/libffi/include/Makefile.in || die
576 + fi
577 +
578 + # Fixup libtool to correctly generate .la files with portage
579 + elibtoolize --portage --shallow --no-uclibc
580 +
581 + gnuconfig_update
582 +
583 + # update configure files
584 + local f
585 + einfo "Fixing misc issues in configure files"
586 + for f in $(grep -l 'autoconf version 2.13' $(find "${S}" -name configure)) ; do
587 + ebegin " Updating ${f/${S}\/} [LANG]"
588 + patch "${f}" "${GCC_FILESDIR}"/gcc-configure-LANG.patch >& "${T}"/configure-patch.log \
589 + || eerror "Please file a bug about this"
590 + eend $?
591 + done
592 + sed -i 's|A-Za-z0-9|[:alnum:]|g' "${S}"/gcc/*.awk #215828
593 +
594 + # Prevent new texinfo from breaking old versions (see #198182, #464008)
595 + tc_version_is_at_least 4.1 && epatch "${GCC_FILESDIR}"/gcc-configure-texinfo.patch
596 +
597 + if [[ -x contrib/gcc_update ]] ; then
598 + einfo "Touching generated files"
599 + ./contrib/gcc_update --touch | \
600 + while read f ; do
601 + einfo " ${f%%...}"
602 + done
603 + fi
604 +}
605 +
606 +guess_patch_type_in_dir() {
607 + [[ -n $(ls "$1"/*.bz2 2>/dev/null) ]] \
608 + && EPATCH_SUFFIX="patch.bz2" \
609 + || EPATCH_SUFFIX="patch"
610 +}
611 +
612 +do_gcc_HTB_patches() {
613 + use_if_iuse boundschecking || return 0
614 +
615 + # modify the bounds checking patch with a regression patch
616 + epatch "${WORKDIR}/bounds-checking-gcc-${HTB_GCC_VER}-${HTB_VER}.patch"
617 + BRANDING_GCC_PKGVERSION="${BRANDING_GCC_PKGVERSION}, HTB-${HTB_GCC_VER}-${HTB_VER}"
618 +}
619 +
620 +do_gcc_PIE_patches() {
621 + want_pie || return 0
622 + use vanilla && return 0
623 +
624 + if tc_version_is_at_least 4.3.2 ; then
625 + guess_patch_type_in_dir "${WORKDIR}"/piepatch/
626 + EPATCH_MULTI_MSG="Applying pie patches ..." \
627 + epatch "${WORKDIR}"/piepatch/
628 + else
629 + guess_patch_type_in_dir "${WORKDIR}"/piepatch/upstream
630 +
631 + # corrects startfile/endfile selection and shared/static/pie flag usage
632 + EPATCH_MULTI_MSG="Applying upstream pie patches ..." \
633 + epatch "${WORKDIR}"/piepatch/upstream
634 + # adds non-default pie support (rs6000)
635 + EPATCH_MULTI_MSG="Applying non-default pie patches ..." \
636 + epatch "${WORKDIR}"/piepatch/nondef
637 + # adds default pie support (rs6000 too) if DEFAULT_PIE[_SSP] is defined
638 + EPATCH_MULTI_MSG="Applying default pie patches ..." \
639 + epatch "${WORKDIR}"/piepatch/def
640 + fi
641 +
642 + BRANDING_GCC_PKGVERSION="${BRANDING_GCC_PKGVERSION}, pie-${PIE_VER}"
643 +}
644 +
645 +# configure to build with the hardened GCC specs as the default
646 +make_gcc_hard() {
647 +
648 + # we want to be able to control the pie patch logic via something other
649 + # than ALL_CFLAGS...
650 + sed -e '/^ALL_CFLAGS/iHARD_CFLAGS = ' \
651 + -e 's|^ALL_CFLAGS = |ALL_CFLAGS = $(HARD_CFLAGS) |' \
652 + -i "${S}"/gcc/Makefile.in
653 + # Need to add HARD_CFLAGS to ALL_CXXFLAGS on >= 4.7
654 + if tc_version_is_at_least 4.7 ; then
655 + sed -e '/^ALL_CXXFLAGS/iHARD_CFLAGS = ' \
656 + -e 's|^ALL_CXXFLAGS = |ALL_CXXFLAGS = $(HARD_CFLAGS) |' \
657 + -i "${S}"/gcc/Makefile.in
658 + fi
659 +
660 + # defaults to enable for all toolchains
661 + local gcc_hard_flags=""
662 + if use hardened ; then
663 + if hardened_gcc_works ; then
664 + einfo "Updating gcc to use automatic PIE + SSP building ..."
665 + gcc_hard_flags+=" -DEFAULT_PIE_SSP"
666 + elif hardened_gcc_works pie ; then
667 + einfo "Updating gcc to use automatic PIE building ..."
668 + ewarn "SSP has not been enabled by default"
669 + gcc_hard_flags+=" -DEFAULT_PIE"
670 + elif hardened_gcc_works ssp ; then
671 + einfo "Updating gcc to use automatic SSP building ..."
672 + ewarn "PIE has not been enabled by default"
673 + gcc_hard_flags+=" -DEFAULT_SSP"
674 + else
675 + # do nothing if hardened isnt supported, but dont die either
676 + ewarn "hardened is not supported for this arch in this gcc version"
677 + ebeep
678 + return 0
679 + fi
680 + # rebrand to make bug reports easier
681 + BRANDING_GCC_PKGVERSION=${BRANDING_GCC_PKGVERSION/Gentoo/Gentoo Hardened}
682 + else
683 + if hardened_gcc_works ssp ; then
684 + einfo "Updating gcc to use automatic SSP building ..."
685 + gcc_hard_flags+=" -DEFAULT_SSP"
686 + fi
687 + fi
688 +
689 + sed -i \
690 + -e "/^HARD_CFLAGS = /s|=|= ${gcc_hard_flags} |" \
691 + "${S}"/gcc/Makefile.in || die
692 +
693 +}
694 +
695 +# This is a historical wart. The original Gentoo/amd64 port used:
696 +# lib32 - 32bit binaries (x86)
697 +# lib64 - 64bit binaries (x86_64)
698 +# lib - "native" binaries (a symlink to lib64)
699 +# Most other distros use the logic (including mainline gcc):
700 +# lib - 32bit binaries (x86)
701 +# lib64 - 64bit binaries (x86_64)
702 +# Over time, Gentoo is migrating to the latter form.
703 +#
704 +# Unfortunately, due to distros picking the lib32 behavior, newer gcc
705 +# versions will dynamically detect whether to use lib or lib32 for its
706 +# 32bit multilib. So, to keep the automagic from getting things wrong
707 +# while people are transitioning from the old style to the new style,
708 +# we always set the MULTILIB_OSDIRNAMES var for relevant targets.
709 +setup_multilib_osdirnames() {
710 + is_multilib || return 0
711 +
712 + local config
713 + local libdirs="../lib64 ../lib32"
714 +
715 + # this only makes sense for some Linux targets
716 + case ${CTARGET} in
717 + x86_64*-linux*) config="i386" ;;
718 + powerpc64*-linux*) config="rs6000" ;;
719 + sparc64*-linux*) config="sparc" ;;
720 + s390x*-linux*) config="s390" ;;
721 + *) return 0 ;;
722 + esac
723 + config+="/t-linux64"
724 +
725 + local sed_args=()
726 + if tc_version_is_at_least 4.6 ; then
727 + sed_args+=( -e 's:$[(]call if_multiarch[^)]*[)]::g' )
728 + fi
729 + if [[ ${SYMLINK_LIB} == "yes" ]] ; then
730 + einfo "updating multilib directories to be: ${libdirs}"
731 + if tc_version_is_at_least 4.6.4 || tc_version_is_at_least 4.7 ; then
732 + sed_args+=( -e '/^MULTILIB_OSDIRNAMES.*lib32/s:[$][(]if.*):../lib32:' )
733 + else
734 + sed_args+=( -e "/^MULTILIB_OSDIRNAMES/s:=.*:= ${libdirs}:" )
735 + fi
736 + else
737 + einfo "using upstream multilib; disabling lib32 autodetection"
738 + sed_args+=( -r -e 's:[$][(]if.*,(.*)[)]:\1:' )
739 + fi
740 + sed -i "${sed_args[@]}" "${S}"/gcc/config/${config} || die
741 +}
742 +
743 +gcc_version_patch() {
744 + # gcc-4.3+ has configure flags (whoo!)
745 + tc_version_is_at_least 4.3 && return 0
746 +
747 + local version_string=${GCC_CONFIG_VER}
748 + [[ -n ${BRANCH_UPDATE} ]] && version_string+=" ${BRANCH_UPDATE}"
749 +
750 + einfo "patching gcc version: ${version_string} (${BRANDING_GCC_PKGVERSION})"
751 +
752 + local gcc_sed=( -e 's:gcc\.gnu\.org/bugs\.html:bugs\.gentoo\.org/:' )
753 + if grep -qs VERSUFFIX "${S}"/gcc/version.c ; then
754 + gcc_sed+=( -e "/VERSUFFIX \"\"/s:\"\":\" (${BRANDING_GCC_PKGVERSION})\":" )
755 + else
756 + version_string="${version_string} (${BRANDING_GCC_PKGVERSION})"
757 + gcc_sed+=( -e "/const char version_string\[\] = /s:= \".*\":= \"${version_string}\":" )
758 + fi
759 + sed -i "${gcc_sed[@]}" "${S}"/gcc/version.c || die
760 +}
761 +
762 +do_gcc_rename_java_bins() {
763 + # bug #139918 - conflict between gcc and java-config-2 for ownership of
764 + # /usr/bin/rmi{c,registry}. Done with mv & sed rather than a patch
765 + # because patches would be large (thanks to the rename of man files),
766 + # and it's clear from the sed invocations that all that changes is the
767 + # rmi{c,registry} names to grmi{c,registry} names.
768 + # Kevin F. Quinn 2006-07-12
769 + einfo "Renaming jdk executables rmic and rmiregistry to grmic and grmiregistry."
770 + # 1) Move the man files if present (missing prior to gcc-3.4)
771 + for manfile in rmic rmiregistry ; do
772 + [[ -f ${S}/gcc/doc/${manfile}.1 ]] || continue
773 + mv "${S}"/gcc/doc/${manfile}.1 "${S}"/gcc/doc/g${manfile}.1
774 + done
775 + # 2) Fixup references in the docs if present (mission prior to gcc-3.4)
776 + for jfile in gcc/doc/gcj.info gcc/doc/grmic.1 gcc/doc/grmiregistry.1 gcc/java/gcj.texi ; do
777 + [[ -f ${S}/${jfile} ]] || continue
778 + sed -i -e 's:rmiregistry:grmiregistry:g' "${S}"/${jfile} ||
779 + die "Failed to fixup file ${jfile} for rename to grmiregistry"
780 + sed -i -e 's:rmic:grmic:g' "${S}"/${jfile} ||
781 + die "Failed to fixup file ${jfile} for rename to grmic"
782 + done
783 + # 3) Fixup Makefiles to build the changed executable names
784 + # These are present in all 3.x versions, and are the important bit
785 + # to get gcc to build with the new names.
786 + for jfile in libjava/Makefile.am libjava/Makefile.in gcc/java/Make-lang.in ; do
787 + sed -i -e 's:rmiregistry:grmiregistry:g' "${S}"/${jfile} ||
788 + die "Failed to fixup file ${jfile} for rename to grmiregistry"
789 + # Careful with rmic on these files; it's also the name of a directory
790 + # which should be left unchanged. Replace occurrences of 'rmic$',
791 + # 'rmic_' and 'rmic '.
792 + sed -i -e 's:rmic\([$_ ]\):grmic\1:g' "${S}"/${jfile} ||
793 + die "Failed to fixup file ${jfile} for rename to grmic"
794 + done
795 +}
796 +
797 +#---->> src_configure <<----
798 +
799 +toolchain_src_configure() {
800 + gcc_do_filter_flags
801 +
802 + einfo "CFLAGS=\"${CFLAGS}\""
803 + einfo "CXXFLAGS=\"${CXXFLAGS}\""
804 + einfo "LDFLAGS=\"${LDFLAGS}\""
805 +
806 + # Force internal zip based jar script to avoid random
807 + # issues with 3rd party jar implementations. #384291
808 + export JAR=no
809 +
810 + # For hardened gcc 4.3 piepatchset to build the hardened specs
811 + # file (build.specs) to use when building gcc.
812 + if ! tc_version_is_at_least 4.4 && want_minispecs ; then
813 + setup_minispecs_gcc_build_specs
814 + fi
815 +
816 + local confgcc=( --host=${CHOST} )
817 +
818 + if is_crosscompile || tc-is-cross-compiler ; then
819 + # Straight from the GCC install doc:
820 + # "GCC has code to correctly determine the correct value for target
821 + # for nearly all native systems. Therefore, we highly recommend you
822 + # not provide a configure target when configuring a native compiler."
823 + confgcc+=( --target=${CTARGET} )
824 + fi
825 + [[ -n ${CBUILD} ]] && confgcc+=( --build=${CBUILD} )
826 +
827 + confgcc+=(
828 + --prefix="${PREFIX}"
829 + --bindir="${BINPATH}"
830 + --includedir="${INCLUDEPATH}"
831 + --datadir="${DATAPATH}"
832 + --mandir="${DATAPATH}/man"
833 + --infodir="${DATAPATH}/info"
834 + --with-gxx-include-dir="${STDCXX_INCDIR}"
835 + )
836 +
837 + # Stick the python scripts in their own slotted directory (bug #279252)
838 + #
839 + # --with-python-dir=DIR
840 + # Specifies where to install the Python modules used for aot-compile. DIR
841 + # should not include the prefix used in installation. For example, if the
842 + # Python modules are to be installed in /usr/lib/python2.5/site-packages,
843 + # then --with-python-dir=/lib/python2.5/site-packages should be passed.
844 + #
845 + # This should translate into "/share/gcc-data/${CTARGET}/${GCC_CONFIG_VER}/python"
846 + if tc_version_is_at_least 4.4 ; then
847 + confgcc+=( --with-python-dir=${DATAPATH/$PREFIX/}/python )
848 + fi
849 +
850 + ### language options
851 +
852 + local GCC_LANG="c"
853 + is_cxx && GCC_LANG+=",c++"
854 + is_d && GCC_LANG+=",d"
855 + is_gcj && GCC_LANG+=",java"
856 + is_go && GCC_LANG+=",go"
857 + if is_objc || is_objcxx ; then
858 + GCC_LANG+=",objc"
859 + if tc_version_is_at_least 4 ; then
860 + use objc-gc && confgcc+=( --enable-objc-gc )
861 + fi
862 + is_objcxx && GCC_LANG+=",obj-c++"
863 + fi
864 + is_treelang && GCC_LANG+=",treelang"
865 +
866 + # fortran support just got sillier! the lang value can be f77 for
867 + # fortran77, f95 for fortran95, or just plain old fortran for the
868 + # currently supported standard depending on gcc version.
869 + is_fortran && GCC_LANG+=",fortran"
870 + is_f77 && GCC_LANG+=",f77"
871 + is_f95 && GCC_LANG+=",f95"
872 +
873 + # We do NOT want 'ADA support' in here!
874 + # is_ada && GCC_LANG+=",ada"
875 +
876 + confgcc+=( --enable-languages=${GCC_LANG} )
877 +
878 + ### general options
879 +
880 + confgcc+=(
881 + --enable-obsolete
882 + --enable-secureplt
883 + --disable-werror
884 + --with-system-zlib
885 + )
886 +
887 + if use nls ; then
888 + confgcc+=( --enable-nls --without-included-gettext )
889 + else
890 + confgcc+=( --disable-nls )
891 + fi
892 +
893 + tc_version_is_at_least 3.4 || confgcc+=( --disable-libunwind-exceptions )
894 +
895 + # Use the default ("release") checking because upstream usually neglects
896 + # to test "disabled" so it has a history of breaking. #317217
897 + if tc_version_is_at_least 4 || [[ -n ${GCC_CHECKS_LIST} ]] ; then
898 + confgcc+=( --enable-checking=${GCC_CHECKS_LIST:-release} )
899 + else
900 + confgcc+=( --disable-checking )
901 + fi
902 +
903 + # Branding
904 + tc_version_is_at_least 4.3 && confgcc+=(
905 + --with-bugurl=https://bugs.gentoo.org/
906 + --with-pkgversion="${BRANDING_GCC_PKGVERSION}"
907 + )
908 +
909 + # If we want hardened support with the newer piepatchset for >=gcc 4.4
910 + if tc_version_is_at_least 4.4 && want_minispecs ; then
911 + confgcc+=( $(use_enable hardened esp) )
912 + fi
913 +
914 + # allow gcc to search for clock funcs in the main C lib.
915 + # if it can't find them, then tough cookies -- we aren't
916 + # going to link in -lrt to all C++ apps. #411681
917 + if tc_version_is_at_least 4.4 && is_cxx ; then
918 + confgcc+=( --enable-libstdcxx-time )
919 + fi
920 +
921 + # newer gcc versions like to bootstrap themselves with C++,
922 + # so we need to manually disable it ourselves
923 + if tc_version_is_between 4.7 4.8 && ! is_cxx ; then
924 + confgcc+=( --disable-build-with-cxx --disable-build-poststage1-with-cxx )
925 + fi
926 +
927 + ### Cross-compiler options
928 + if is_crosscompile ; then
929 + # Enable build warnings by default with cross-compilers when system
930 + # paths are included (e.g. via -I flags).
931 + confgcc+=( --enable-poison-system-directories )
932 +
933 + # When building a stage1 cross-compiler (just C compiler), we have to
934 + # disable a bunch of features or gcc goes boom
935 + local needed_libc=""
936 + case ${CTARGET} in
937 + *-linux) needed_libc=no-fucking-clue;;
938 + *-dietlibc) needed_libc=dietlibc;;
939 + *-elf|*-eabi) needed_libc=newlib;;
940 + *-freebsd*) needed_libc=freebsd-lib;;
941 + *-gnu*) needed_libc=glibc;;
942 + *-klibc) needed_libc=klibc;;
943 + *-musl*) needed_libc=musl;;
944 + *-uclibc*)
945 + if ! echo '#include <features.h>' | \
946 + $(tc-getCPP ${CTARGET}) -E -dD - 2>/dev/null | \
947 + grep -q __HAVE_SHARED__
948 + then #291870
949 + confgcc+=( --disable-shared )
950 + fi
951 + needed_libc=uclibc
952 + ;;
953 + *-cygwin) needed_libc=cygwin;;
954 + x86_64-*-mingw*|\
955 + *-w64-mingw*) needed_libc=mingw64-runtime;;
956 + mingw*|*-mingw*) needed_libc=mingw-runtime;;
957 + avr) confgcc+=( --enable-shared --disable-threads );;
958 + esac
959 + if [[ -n ${needed_libc} ]] ; then
960 + local confgcc_no_libc=( --disable-shared )
961 + tc_version_is_at_least 4.8 && confgcc_no_libc+=( --disable-libatomic )
962 + if ! has_version ${CATEGORY}/${needed_libc} ; then
963 + confgcc+=(
964 + "${confgcc_no_libc[@]}"
965 + --disable-threads
966 + --without-headers
967 + )
968 + elif built_with_use --hidden --missing false ${CATEGORY}/${needed_libc} crosscompile_opts_headers-only ; then
969 + confgcc+=(
970 + "${confgcc_no_libc[@]}"
971 + --with-sysroot=${PREFIX}/${CTARGET}
972 + )
973 + else
974 + confgcc+=( --with-sysroot=${PREFIX}/${CTARGET} )
975 + fi
976 + fi
977 +
978 + tc_version_is_at_least 4.2 && confgcc+=( --disable-bootstrap )
979 + else
980 + if tc-is-static-only ; then
981 + confgcc+=( --disable-shared )
982 + else
983 + confgcc+=( --enable-shared )
984 + fi
985 + case ${CHOST} in
986 + mingw*|*-mingw*|*-cygwin)
987 + confgcc+=( --enable-threads=win32 ) ;;
988 + *)
989 + confgcc+=( --enable-threads=posix ) ;;
990 + esac
991 + fi
992 +
993 + # __cxa_atexit is "essential for fully standards-compliant handling of
994 + # destructors", but apparently requires glibc.
995 + case ${CTARGET} in
996 + *-uclibc*)
997 + confgcc+=(
998 + --disable-__cxa_atexit
999 + $(use_enable nptl tls)
1000 + )
1001 + tc_version_is_between 3.3 3.4 && confgcc+=( --enable-sjlj-exceptions )
1002 + if tc_version_is_between 3.4 4.3 ; then
1003 + confgcc+=( --enable-clocale=uclibc )
1004 + fi
1005 + ;;
1006 + *-elf|*-eabi)
1007 + confgcc+=( --with-newlib )
1008 + ;;
1009 + *-gnu*)
1010 + confgcc+=(
1011 + --enable-__cxa_atexit
1012 + --enable-clocale=gnu
1013 + )
1014 + ;;
1015 + *-freebsd*)
1016 + confgcc+=( --enable-__cxa_atexit )
1017 + ;;
1018 + *-solaris*)
1019 + confgcc+=( --enable-__cxa_atexit )
1020 + ;;
1021 + esac
1022 +
1023 + ### arch options
1024 +
1025 + gcc-multilib-configure
1026 +
1027 + # ppc altivec support
1028 + confgcc+=( $(use_enable altivec) )
1029 +
1030 + # gcc has fixed-point arithmetic support in 4.3 for mips targets that can
1031 + # significantly increase compile time by several hours. This will allow
1032 + # users to control this feature in the event they need the support.
1033 + tc_version_is_at_least 4.3 && confgcc+=( $(use_enable fixed-point) )
1034 +
1035 + case $(tc-is-softfloat) in
1036 + yes) confgcc+=( --with-float=soft ) ;;
1037 + softfp) confgcc+=( --with-float=softfp ) ;;
1038 + *)
1039 + # If they've explicitly opt-ed in, do hardfloat,
1040 + # otherwise let the gcc default kick in.
1041 + [[ ${CTARGET//_/-} == *-hardfloat-* ]] \
1042 + && confgcc+=( --with-float=hard )
1043 + ;;
1044 + esac
1045 +
1046 + local with_abi_map=()
1047 + case $(tc-arch) in
1048 + arm) #264534 #414395
1049 + local a arm_arch=${CTARGET%%-*}
1050 + # Remove trailing endian variations first: eb el be bl b l
1051 + for a in e{b,l} {b,l}e b l ; do
1052 + if [[ ${arm_arch} == *${a} ]] ; then
1053 + arm_arch=${arm_arch%${a}}
1054 + break
1055 + fi
1056 + done
1057 + # Convert armv7{a,r,m} to armv7-{a,r,m}
1058 + [[ ${arm_arch} == armv7? ]] && arm_arch=${arm_arch/7/7-}
1059 + # See if this is a valid --with-arch flag
1060 + if (srcdir=${S}/gcc target=${CTARGET} with_arch=${arm_arch};
1061 + . "${srcdir}"/config.gcc) &>/dev/null
1062 + then
1063 + confgcc+=( --with-arch=${arm_arch} )
1064 + fi
1065 +
1066 + # Make default mode thumb for microcontroller classes #418209
1067 + [[ ${arm_arch} == *-m ]] && confgcc+=( --with-mode=thumb )
1068 +
1069 + # Enable hardvfp
1070 + if [[ $(tc-is-softfloat) == "no" ]] && \
1071 + [[ ${CTARGET} == armv[67]* ]] && \
1072 + tc_version_is_at_least 4.5
1073 + then
1074 + # Follow the new arm hardfp distro standard by default
1075 + confgcc+=( --with-float=hard )
1076 + case ${CTARGET} in
1077 + armv6*) confgcc+=( --with-fpu=vfp ) ;;
1078 + armv7*) confgcc+=( --with-fpu=vfpv3-d16 ) ;;
1079 + esac
1080 + fi
1081 + ;;
1082 + mips)
1083 + # Add --with-abi flags to set default ABI
1084 + confgcc+=( --with-abi=$(gcc-abi-map ${TARGET_DEFAULT_ABI}) )
1085 + ;;
1086 + amd64)
1087 + # drop the older/ABI checks once this get's merged into some
1088 + # version of gcc upstream
1089 + if tc_version_is_at_least 4.7 && has x32 $(get_all_abis TARGET) ; then
1090 + confgcc+=( --with-abi=$(gcc-abi-map ${TARGET_DEFAULT_ABI}) )
1091 + fi
1092 + ;;
1093 + x86)
1094 + # Default arch for x86 is normally i386, lets give it a bump
1095 + # since glibc will do so based on CTARGET anyways
1096 + confgcc+=( --with-arch=${CTARGET%%-*} )
1097 + ;;
1098 + hppa)
1099 + # Enable sjlj exceptions for backward compatibility on hppa
1100 + [[ ${GCCMAJOR} == "3" ]] && confgcc+=( --enable-sjlj-exceptions )
1101 + ;;
1102 + ppc)
1103 + # Set up defaults based on current CFLAGS
1104 + is-flagq -mfloat-gprs=double && confgcc+=( --enable-e500-double )
1105 + [[ ${CTARGET//_/-} == *-e500v2-* ]] && confgcc+=( --enable-e500-double )
1106 + ;;
1107 + esac
1108 +
1109 + # if the target can do biarch (-m32/-m64), enable it. overhead should
1110 + # be small, and should simplify building of 64bit kernels in a 32bit
1111 + # userland by not needing sys-devel/kgcc64. #349405
1112 + case $(tc-arch) in
1113 + ppc|ppc64) tc_version_is_at_least 3.4 && confgcc+=( --enable-targets=all ) ;;
1114 + sparc) tc_version_is_at_least 4.4 && confgcc+=( --enable-targets=all ) ;;
1115 + amd64|x86) tc_version_is_at_least 4.3 && confgcc+=( --enable-targets=all ) ;;
1116 + esac
1117 +
1118 + # On Darwin we need libdir to be set in order to get correct install names
1119 + # for things like libobjc-gnu, libgcj and libfortran. If we enable it on
1120 + # non-Darwin we screw up the behaviour this eclass relies on. We in
1121 + # particular need this over --libdir for bug #255315.
1122 + [[ ${CTARGET} == *-darwin* ]] && \
1123 + confgcc+=( --enable-version-specific-runtime-libs )
1124 +
1125 + ### library options
1126 +
1127 + if ! is_gcj ; then
1128 + confgcc+=( --disable-libgcj )
1129 + elif use awt ; then
1130 + confgcc+=( --enable-java-awt=gtk )
1131 + fi
1132 +
1133 + if tc_version_is_at_least 4.2 ; then
1134 + if in_iuse openmp ; then
1135 + # Make sure target has pthreads support. #326757 #335883
1136 + # There shouldn't be a chicken & egg problem here as openmp won't
1137 + # build without a C library, and you can't build that w/out
1138 + # already having a compiler ...
1139 + if ! is_crosscompile || \
1140 + $(tc-getCPP ${CTARGET}) -E - <<<"#include <pthread.h>" >& /dev/null
1141 + then
1142 + confgcc+=( $(use_enable openmp libgomp) )
1143 + else
1144 + # Force disable as the configure script can be dumb #359855
1145 + confgcc+=( --disable-libgomp )
1146 + fi
1147 + else
1148 + # For gcc variants where we don't want openmp (e.g. kgcc)
1149 + confgcc+=( --disable-libgomp )
1150 + fi
1151 + fi
1152 +
1153 + if tc_version_is_at_least 4.0 ; then
1154 + if in_iuse mudflap ; then
1155 + confgcc+=( $(use_enable mudflap libmudflap) )
1156 + else
1157 + confgcc+=( --disable-libmudflap )
1158 + fi
1159 +
1160 + if use_if_iuse libssp ; then
1161 + confgcc+=( --enable-libssp )
1162 + else
1163 + export gcc_cv_libc_provides_ssp=yes
1164 + confgcc+=( --disable-libssp )
1165 + fi
1166 +
1167 + fi
1168 +
1169 + # newer gcc's come with libquadmath, but only fortran uses
1170 + # it, so auto punt it when we don't care
1171 + if tc_version_is_at_least 4.6 && ! is_fortran ; then
1172 + confgcc+=( --disable-libquadmath )
1173 + fi
1174 +
1175 + if tc_version_is_at_least 4.6 ; then
1176 + confgcc+=( --enable-lto )
1177 + elif tc_version_is_at_least 4.5 ; then
1178 + confgcc+=( --disable-lto )
1179 + fi
1180 +
1181 + # graphite was added in 4.4 but we only support it in 4.6+ due to external
1182 + # library issues. 4.6/4.7 uses cloog-ppl which is a fork of CLooG with a
1183 + # PPL backend. 4.8+ uses upstream CLooG with the ISL backend. We install
1184 + # cloog-ppl into a non-standard location to prevent collisions.
1185 + if tc_version_is_at_least 4.8 ; then
1186 + confgcc+=( $(use_with graphite cloog) )
1187 + use graphite && confgcc+=( --disable-isl-version-check )
1188 + elif tc_version_is_at_least 4.6 ; then
1189 + confgcc+=( $(use_with graphite cloog) )
1190 + confgcc+=( $(use_with graphite ppl) )
1191 + use graphite && confgcc+=( --with-cloog-include=/usr/include/cloog-ppl )
1192 + use graphite && confgcc+=( --disable-ppl-version-check )
1193 + elif tc_version_is_at_least 4.4 ; then
1194 + confgcc+=( --without-cloog )
1195 + confgcc+=( --without-ppl )
1196 + fi
1197 +
1198 + # Disable gcc info regeneration -- it ships with generated info pages
1199 + # already. Our custom version/urls/etc... trigger it. #464008
1200 + export gcc_cv_prog_makeinfo_modern=no
1201 +
1202 + # Do not let the X detection get in our way. We know things can be found
1203 + # via system paths, so no need to hardcode things that'll break multilib.
1204 + # Older gcc versions will detect ac_x_libraries=/usr/lib64 which ends up
1205 + # killing the 32bit builds which want /usr/lib.
1206 + export ac_cv_have_x='have_x=yes ac_x_includes= ac_x_libraries='
1207 +
1208 + confgcc+=( "$@" ${EXTRA_ECONF} )
1209 +
1210 + # Nothing wrong with a good dose of verbosity
1211 + echo
1212 + einfo "PREFIX: ${PREFIX}"
1213 + einfo "BINPATH: ${BINPATH}"
1214 + einfo "LIBPATH: ${LIBPATH}"
1215 + einfo "DATAPATH: ${DATAPATH}"
1216 + einfo "STDCXX_INCDIR: ${STDCXX_INCDIR}"
1217 + echo
1218 + einfo "Languages: ${GCC_LANG}"
1219 + echo
1220 + einfo "Configuring GCC with: ${confgcc[@]//--/\n\t--}"
1221 + echo
1222 +
1223 + # Build in a separate build tree
1224 + mkdir -p "${WORKDIR}"/build
1225 + pushd "${WORKDIR}"/build > /dev/null
1226 +
1227 + # and now to do the actual configuration
1228 + addwrite /dev/zero
1229 + echo "${S}"/configure "${confgcc[@]}"
1230 + "${S}"/configure "${confgcc[@]}" || die "failed to run configure"
1231 +
1232 + # return to whatever directory we were in before
1233 + popd > /dev/null
1234 +}
1235 +
1236 +gcc_do_filter_flags() {
1237 + strip-flags
1238 + replace-flags -O? -O2
1239 +
1240 + # dont want to funk ourselves
1241 + filter-flags '-mabi*' -m31 -m32 -m64
1242 +
1243 + filter-flags '-frecord-gcc-switches' # 490738
1244 +
1245 + if tc_version_is_between 3.2 3.4 ; then
1246 + # XXX: this is so outdated it's barely useful, but it don't hurt...
1247 + replace-cpu-flags k8 athlon64 opteron x86-64
1248 + replace-cpu-flags pentium-m pentium3m pentium3
1249 + replace-cpu-flags G3 750
1250 + replace-cpu-flags G4 7400
1251 + replace-cpu-flags G5 7400
1252 +
1253 + case $(tc-arch) in
1254 + amd64)
1255 + replace-cpu-flags core2 nocona
1256 + filter-flags '-mtune=*'
1257 + ;;
1258 + x86)
1259 + replace-cpu-flags core2 prescott
1260 + filter-flags '-mtune=*'
1261 + ;;
1262 + esac
1263 +
1264 + # XXX: should add a sed or something to query all supported flags
1265 + # from the gcc source and trim everything else ...
1266 + filter-flags -f{no-,}unit-at-a-time -f{no-,}web -mno-tls-direct-seg-refs
1267 + filter-flags -f{no-,}stack-protector{,-all}
1268 + filter-flags -fvisibility-inlines-hidden -fvisibility=hidden
1269 + fi
1270 +
1271 + if tc_version_is_at_least 3.4 ; then
1272 + case $(tc-arch) in
1273 + amd64|x86)
1274 + filter-flags '-mcpu=*'
1275 + if tc_version_is_between 4.6 4.7 ; then
1276 + # https://bugs.gentoo.org/411333
1277 + # https://bugs.gentoo.org/466454
1278 + replace-cpu-flags c3-2 pentium2 pentium3 pentium3m pentium-m i686
1279 + fi
1280 + ;;
1281 + alpha)
1282 + # https://bugs.gentoo.org/454426
1283 + append-ldflags -Wl,--no-relax
1284 + ;;
1285 + sparc)
1286 + # temporary workaround for random ICEs reproduced by multiple users
1287 + # https://bugs.gentoo.org/457062
1288 + tc_version_is_between 4.6 4.8 && MAKEOPTS+=" -j1"
1289 + ;;
1290 + *-macos)
1291 + # http://gcc.gnu.org/PR25127
1292 + tc_version_is_between 4.0 4.2 && \
1293 + filter-flags '-mcpu=*' '-march=*' '-mtune=*'
1294 + ;;
1295 + esac
1296 + fi
1297 +
1298 + strip-unsupported-flags
1299 +
1300 + # these are set here so we have something sane at configure time
1301 + if is_crosscompile ; then
1302 + # Set this to something sane for both native and target
1303 + CFLAGS="-O2 -pipe"
1304 + FFLAGS=${CFLAGS}
1305 + FCFLAGS=${CFLAGS}
1306 +
1307 + local VAR="CFLAGS_"${CTARGET//-/_}
1308 + CXXFLAGS=${!VAR}
1309 + fi
1310 +
1311 + export GCJFLAGS=${GCJFLAGS:-${CFLAGS}}
1312 +}
1313 +
1314 +setup_minispecs_gcc_build_specs() {
1315 + # Setup the "build.specs" file for gcc 4.3 to use when building.
1316 + if hardened_gcc_works pie ; then
1317 + cat "${WORKDIR}"/specs/pie.specs >> "${WORKDIR}"/build.specs
1318 + fi
1319 + if hardened_gcc_works ssp ; then
1320 + for s in ssp sspall ; do
1321 + cat "${WORKDIR}"/specs/${s}.specs >> "${WORKDIR}"/build.specs
1322 + done
1323 + fi
1324 + for s in nostrict znow ; do
1325 + cat "${WORKDIR}"/specs/${s}.specs >> "${WORKDIR}"/build.specs
1326 + done
1327 + export GCC_SPECS="${WORKDIR}"/build.specs
1328 +}
1329 +
1330 +gcc-multilib-configure() {
1331 + if ! is_multilib ; then
1332 + confgcc+=( --disable-multilib )
1333 + # Fun times: if we are building for a target that has multiple
1334 + # possible ABI formats, and the user has told us to pick one
1335 + # that isn't the default, then not specifying it via the list
1336 + # below will break that on us.
1337 + else
1338 + confgcc+=( --enable-multilib )
1339 + fi
1340 +
1341 + # translate our notion of multilibs into gcc's
1342 + local abi list
1343 + for abi in $(get_all_abis TARGET) ; do
1344 + local l=$(gcc-abi-map ${abi})
1345 + [[ -n ${l} ]] && list+=",${l}"
1346 + done
1347 + if [[ -n ${list} ]] ; then
1348 + case ${CTARGET} in
1349 + x86_64*)
1350 + tc_version_is_at_least 4.7 && confgcc+=( --with-multilib-list=${list:1} )
1351 + ;;
1352 + esac
1353 + fi
1354 +}
1355 +
1356 +gcc-abi-map() {
1357 + # Convert the ABI name we use in Gentoo to what gcc uses
1358 + local map=()
1359 + case ${CTARGET} in
1360 + mips*) map=("o32 32" "n32 n32" "n64 64") ;;
1361 + x86_64*) map=("amd64 m64" "x86 m32" "x32 mx32") ;;
1362 + esac
1363 +
1364 + local m
1365 + for m in "${map[@]}" ; do
1366 + l=( ${m} )
1367 + [[ $1 == ${l[0]} ]] && echo ${l[1]} && break
1368 + done
1369 +}
1370 +
1371 +#----> src_compile <----
1372 +
1373 +toolchain_src_compile() {
1374 + case ${EAPI:-0} in
1375 + 0|1) toolchain_src_configure ;;
1376 + esac
1377 +
1378 + touch "${S}"/gcc/c-gperf.h
1379 +
1380 + # Do not make manpages if we do not have perl ...
1381 + [[ ! -x /usr/bin/perl ]] \
1382 + && find "${WORKDIR}"/build -name '*.[17]' | xargs touch
1383 +
1384 + einfo "Compiling ${PN} ..."
1385 + gcc_do_make ${GCC_MAKE_TARGET}
1386 +}
1387 +
1388 +gcc_do_make() {
1389 + # This function accepts one optional argument, the make target to be used.
1390 + # If omitted, gcc_do_make will try to guess whether it should use all,
1391 + # profiledbootstrap, or bootstrap-lean depending on CTARGET and arch. An
1392 + # example of how to use this function:
1393 + #
1394 + # gcc_do_make all-target-libstdc++-v3
1395 + #
1396 + # Set make target to $1 if passed
1397 + [[ -n ${1} ]] && GCC_MAKE_TARGET=${1}
1398 + # default target
1399 + if is_crosscompile || tc-is-cross-compiler ; then
1400 + # 3 stage bootstrapping doesnt quite work when you cant run the
1401 + # resulting binaries natively ^^;
1402 + GCC_MAKE_TARGET=${GCC_MAKE_TARGET-all}
1403 + else
1404 + GCC_MAKE_TARGET=${GCC_MAKE_TARGET-bootstrap-lean}
1405 + fi
1406 +
1407 + # the gcc docs state that parallel make isnt supported for the
1408 + # profiledbootstrap target, as collisions in profile collecting may occur.
1409 + # boundschecking also seems to introduce parallel build issues.
1410 + if [[ ${GCC_MAKE_TARGET} == "profiledbootstrap" ]] ||
1411 + use_if_iuse boundschecking
1412 + then
1413 + export MAKEOPTS="${MAKEOPTS} -j1"
1414 + fi
1415 +
1416 + if [[ ${GCC_MAKE_TARGET} == "all" ]] ; then
1417 + STAGE1_CFLAGS=${STAGE1_CFLAGS-"${CFLAGS}"}
1418 + elif [[ $(gcc-version) == "3.4" && ${GCC_BRANCH_VER} == "3.4" ]] && gcc-specs-ssp ; then
1419 + # See bug #79852
1420 + STAGE1_CFLAGS=${STAGE1_CFLAGS-"-O2"}
1421 + fi
1422 +
1423 + if is_crosscompile; then
1424 + # In 3.4, BOOT_CFLAGS is never used on a crosscompile...
1425 + # but I'll leave this in anyways as someone might have had
1426 + # some reason for putting it in here... --eradicator
1427 + BOOT_CFLAGS=${BOOT_CFLAGS-"-O2"}
1428 + else
1429 + # we only want to use the system's CFLAGS if not building a
1430 + # cross-compiler.
1431 + BOOT_CFLAGS=${BOOT_CFLAGS-"$(get_abi_CFLAGS ${TARGET_DEFAULT_ABI}) ${CFLAGS}"}
1432 + fi
1433 +
1434 + pushd "${WORKDIR}"/build >/dev/null
1435 +
1436 + emake \
1437 + LDFLAGS="${LDFLAGS}" \
1438 + STAGE1_CFLAGS="${STAGE1_CFLAGS}" \
1439 + LIBPATH="${LIBPATH}" \
1440 + BOOT_CFLAGS="${BOOT_CFLAGS}" \
1441 + ${GCC_MAKE_TARGET} \
1442 + || die "emake failed with ${GCC_MAKE_TARGET}"
1443 +
1444 + if ! is_crosscompile && use cxx && use_if_iuse doc ; then
1445 + if type -p doxygen > /dev/null ; then
1446 + if tc_version_is_at_least 4.3 ; then
1447 + cd "${CTARGET}"/libstdc++-v3/doc
1448 + emake doc-man-doxygen || ewarn "failed to make docs"
1449 + elif tc_version_is_at_least 3.0 ; then
1450 + cd "${CTARGET}"/libstdc++-v3
1451 + emake doxygen-man || ewarn "failed to make docs"
1452 + fi
1453 + else
1454 + ewarn "Skipping libstdc++ manpage generation since you don't have doxygen installed"
1455 + fi
1456 + fi
1457 +
1458 + popd >/dev/null
1459 +}
1460 +
1461 +#---->> src_test <<----
1462 +
1463 +toolchain_src_test() {
1464 + if use regression-test ; then
1465 + cd "${WORKDIR}"/build
1466 + emake -k check
1467 + fi
1468 +}
1469 +
1470 +#---->> src_install <<----
1471 +
1472 +toolchain_src_install() {
1473 + cd "${WORKDIR}"/build
1474 +
1475 + # Do allow symlinks in private gcc include dir as this can break the build
1476 + find gcc/include*/ -type l -delete
1477 +
1478 + # Copy over the info pages. We disabled their generation earlier, but the
1479 + # build system only expects to install out of the build dir, not the source. #464008
1480 + mkdir -p gcc/doc
1481 + local x=
1482 + for x in "${S}"/gcc/doc/*.info* ; do
1483 + if [[ -f ${x} ]] ; then
1484 + cp "${x}" gcc/doc/ || die
1485 + fi
1486 + done
1487 +
1488 + # Remove generated headers, as they can cause things to break
1489 + # (ncurses, openssl, etc).
1490 + while read x ; do
1491 + grep -q 'It has been auto-edited by fixincludes from' "${x}" \
1492 + && rm -f "${x}"
1493 + done < <(find gcc/include*/ -name '*.h')
1494 +
1495 + # Do the 'make install' from the build directory
1496 + S="${WORKDIR}"/build emake -j1 DESTDIR="${D}" install || die
1497 +
1498 + # Punt some tools which are really only useful while building gcc
1499 + find "${D}" -name install-tools -prune -type d -exec rm -rf "{}" \;
1500 + # This one comes with binutils
1501 + find "${D}" -name libiberty.a -delete
1502 +
1503 + # Move the libraries to the proper location
1504 + gcc_movelibs
1505 +
1506 + # Basic sanity check
1507 + if ! is_crosscompile ; then
1508 + local EXEEXT
1509 + eval $(grep ^EXEEXT= "${WORKDIR}"/build/gcc/config.log)
1510 + [[ -r ${D}${BINPATH}/gcc${EXEEXT} ]] || die "gcc not found in ${D}"
1511 + fi
1512 +
1513 + dodir /etc/env.d/gcc
1514 + create_gcc_env_entry
1515 +
1516 + # Setup the gcc_env_entry for hardened gcc 4 with minispecs
1517 + want_minispecs && copy_minispecs_gcc_specs
1518 +
1519 + # Make sure we dont have stuff lying around that
1520 + # can nuke multiple versions of gcc
1521 + gcc_slot_java
1522 +
1523 + dodir /usr/bin
1524 + cd "${D}"${BINPATH}
1525 + # Ugh: we really need to auto-detect this list.
1526 + # It's constantly out of date.
1527 + for x in cpp gcc g++ c++ gcov g77 gcj gcjh gfortran gccgo ; do
1528 + # For some reason, g77 gets made instead of ${CTARGET}-g77...
1529 + # this should take care of that
1530 + [[ -f ${x} ]] && mv ${x} ${CTARGET}-${x}
1531 +
1532 + if [[ -f ${CTARGET}-${x} ]] ; then
1533 + if ! is_crosscompile ; then
1534 + ln -sf ${CTARGET}-${x} ${x}
1535 + dosym ${BINPATH}/${CTARGET}-${x} \
1536 + /usr/bin/${x}-${GCC_CONFIG_VER}
1537 + fi
1538 + # Create versioned symlinks
1539 + dosym ${BINPATH}/${CTARGET}-${x} \
1540 + /usr/bin/${CTARGET}-${x}-${GCC_CONFIG_VER}
1541 + fi
1542 +
1543 + if [[ -f ${CTARGET}-${x}-${GCC_CONFIG_VER} ]] ; then
1544 + rm -f ${CTARGET}-${x}-${GCC_CONFIG_VER}
1545 + ln -sf ${CTARGET}-${x} ${CTARGET}-${x}-${GCC_CONFIG_VER}
1546 + fi
1547 + done
1548 +
1549 + # Now do the fun stripping stuff
1550 + env RESTRICT="" CHOST=${CHOST} prepstrip "${D}${BINPATH}"
1551 + env RESTRICT="" CHOST=${CTARGET} prepstrip "${D}${LIBPATH}"
1552 + # gcc used to install helper binaries in lib/ but then moved to libexec/
1553 + [[ -d ${D}${PREFIX}/libexec/gcc ]] && \
1554 + env RESTRICT="" CHOST=${CHOST} prepstrip "${D}${PREFIX}/libexec/gcc/${CTARGET}/${GCC_CONFIG_VER}"
1555 +
1556 + cd "${S}"
1557 + if is_crosscompile; then
1558 + rm -rf "${D}"/usr/share/{man,info}
1559 + rm -rf "${D}"${DATAPATH}/{man,info}
1560 + else
1561 + if tc_version_is_at_least 3.0 ; then
1562 + local cxx_mandir=$(find "${WORKDIR}/build/${CTARGET}/libstdc++-v3" -name man)
1563 + if [[ -d ${cxx_mandir} ]] ; then
1564 + # clean bogus manpages #113902
1565 + find "${cxx_mandir}" -name '*_build_*' -exec rm {} \;
1566 + cp -r "${cxx_mandir}"/man? "${D}/${DATAPATH}"/man/
1567 + fi
1568 + fi
1569 + has noinfo ${FEATURES} \
1570 + && rm -r "${D}/${DATAPATH}"/info \
1571 + || prepinfo "${DATAPATH}"
1572 + has noman ${FEATURES} \
1573 + && rm -r "${D}/${DATAPATH}"/man \
1574 + || prepman "${DATAPATH}"
1575 + fi
1576 + # prune empty dirs left behind
1577 + find "${D}" -depth -type d -delete 2>/dev/null
1578 +
1579 + # install testsuite results
1580 + if use regression-test; then
1581 + docinto testsuite
1582 + find "${WORKDIR}"/build -type f -name "*.sum" -print0 | xargs -0 dodoc
1583 + find "${WORKDIR}"/build -type f -path "*/testsuite/*.log" -print0 \
1584 + | xargs -0 dodoc
1585 + fi
1586 +
1587 + # Rather install the script, else portage with changing $FILESDIR
1588 + # between binary and source package borks things ....
1589 + if ! is_crosscompile ; then
1590 + insinto "${DATAPATH}"
1591 + if tc_version_is_at_least 4.0 ; then
1592 + newins "${GCC_FILESDIR}"/awk/fixlafiles.awk-no_gcc_la fixlafiles.awk || die
1593 + find "${D}/${LIBPATH}" -name libstdc++.la -type f -exec rm "{}" \;
1594 + find "${D}/${LIBPATH}" -name "lib?san.la" -type f -exec rm "{}" \; # 487550
1595 + else
1596 + doins "${GCC_FILESDIR}"/awk/fixlafiles.awk || die
1597 + fi
1598 + exeinto "${DATAPATH}"
1599 + doexe "${GCC_FILESDIR}"/fix_libtool_files.sh || die
1600 + doexe "${GCC_FILESDIR}"/c{89,99} || die
1601 + fi
1602 +
1603 + # Use gid of 0 because some stupid ports don't have
1604 + # the group 'root' set to gid 0. Send to /dev/null
1605 + # for people who are testing as non-root.
1606 + chown -R root:0 "${D}"${LIBPATH} 2>/dev/null
1607 +
1608 + # Move pretty-printers to gdb datadir to shut ldconfig up
1609 + local py gdbdir=/usr/share/gdb/auto-load${LIBPATH/\/lib\//\/$(get_libdir)\/}
1610 + pushd "${D}"${LIBPATH} >/dev/null
1611 + for py in $(find . -name '*-gdb.py') ; do
1612 + local multidir=${py%/*}
1613 + insinto "${gdbdir}/${multidir}"
1614 + sed -i "/^libdir =/s:=.*:= '${LIBPATH}/${multidir}':" "${py}" || die #348128
1615 + doins "${py}" || die
1616 + rm "${py}" || die
1617 + done
1618 + popd >/dev/null
1619 +
1620 + # Don't scan .gox files for executable stacks - false positives
1621 + export QA_EXECSTACK="usr/lib*/go/*/*.gox"
1622 + export QA_WX_LOAD="usr/lib*/go/*/*.gox"
1623 +
1624 + # Disable RANDMMAP so PCH works. #301299
1625 + if tc_version_is_at_least 4.3 ; then
1626 + pax-mark -r "${D}${PREFIX}/libexec/gcc/${CTARGET}/${GCC_CONFIG_VER}/cc1"
1627 + pax-mark -r "${D}${PREFIX}/libexec/gcc/${CTARGET}/${GCC_CONFIG_VER}/cc1plus"
1628 + fi
1629 +}
1630 +
1631 +# Move around the libs to the right location. For some reason,
1632 +# when installing gcc, it dumps internal libraries into /usr/lib
1633 +# instead of the private gcc lib path
1634 +gcc_movelibs() {
1635 + # older versions of gcc did not support --print-multi-os-directory
1636 + tc_version_is_at_least 3.2 || return 0
1637 +
1638 + local x multiarg removedirs=""
1639 + for multiarg in $($(XGCC) -print-multi-lib) ; do
1640 + multiarg=${multiarg#*;}
1641 + multiarg=${multiarg//@/ -}
1642 +
1643 + local OS_MULTIDIR=$($(XGCC) ${multiarg} --print-multi-os-directory)
1644 + local MULTIDIR=$($(XGCC) ${multiarg} --print-multi-directory)
1645 + local TODIR=${D}${LIBPATH}/${MULTIDIR}
1646 + local FROMDIR=
1647 +
1648 + [[ -d ${TODIR} ]] || mkdir -p ${TODIR}
1649 +
1650 + for FROMDIR in \
1651 + ${LIBPATH}/${OS_MULTIDIR} \
1652 + ${LIBPATH}/../${MULTIDIR} \
1653 + ${PREFIX}/lib/${OS_MULTIDIR} \
1654 + ${PREFIX}/${CTARGET}/lib/${OS_MULTIDIR}
1655 + do
1656 + removedirs="${removedirs} ${FROMDIR}"
1657 + FROMDIR=${D}${FROMDIR}
1658 + if [[ ${FROMDIR} != "${TODIR}" && -d ${FROMDIR} ]] ; then
1659 + local files=$(find "${FROMDIR}" -maxdepth 1 ! -type d 2>/dev/null)
1660 + if [[ -n ${files} ]] ; then
1661 + mv ${files} "${TODIR}"
1662 + fi
1663 + fi
1664 + done
1665 + fix_libtool_libdir_paths "${LIBPATH}/${MULTIDIR}"
1666 +
1667 + # SLOT up libgcj.pc if it's available (and let gcc-config worry about links)
1668 + FROMDIR="${PREFIX}/lib/${OS_MULTIDIR}"
1669 + for x in "${D}${FROMDIR}"/pkgconfig/libgcj*.pc ; do
1670 + [[ -f ${x} ]] || continue
1671 + sed -i "/^libdir=/s:=.*:=${LIBPATH}/${MULTIDIR}:" "${x}"
1672 + mv "${x}" "${D}${FROMDIR}"/pkgconfig/libgcj-${GCC_PV}.pc || die
1673 + done
1674 + done
1675 +
1676 + # We remove directories separately to avoid this case:
1677 + # mv SRC/lib/../lib/*.o DEST
1678 + # rmdir SRC/lib/../lib/
1679 + # mv SRC/lib/../lib32/*.o DEST # Bork
1680 + for FROMDIR in ${removedirs} ; do
1681 + rmdir "${D}"${FROMDIR} >& /dev/null
1682 + done
1683 + find "${D}" -type d | xargs rmdir >& /dev/null
1684 +}
1685 +
1686 +# make sure the libtool archives have libdir set to where they actually
1687 +# -are-, and not where they -used- to be. also, any dependencies we have
1688 +# on our own .la files need to be updated.
1689 +fix_libtool_libdir_paths() {
1690 + pushd "${D}" >/dev/null
1691 +
1692 + pushd "./${1}" >/dev/null
1693 + local dir="${PWD#${D%/}}"
1694 + local allarchives=$(echo *.la)
1695 + allarchives="\(${allarchives// /\\|}\)"
1696 + popd >/dev/null
1697 +
1698 + sed -i \
1699 + -e "/^libdir=/s:=.*:='${dir}':" \
1700 + ./${dir}/*.la
1701 + sed -i \
1702 + -e "/^dependency_libs=/s:/[^ ]*/${allarchives}:${LIBPATH}/\1:g" \
1703 + $(find ./${PREFIX}/lib* -maxdepth 3 -name '*.la') \
1704 + ./${dir}/*.la
1705 +
1706 + popd >/dev/null
1707 +}
1708 +
1709 +create_gcc_env_entry() {
1710 + dodir /etc/env.d/gcc
1711 + local gcc_envd_base="/etc/env.d/gcc/${CTARGET}-${GCC_CONFIG_VER}"
1712 +
1713 + local gcc_specs_file
1714 + local gcc_envd_file="${D}${gcc_envd_base}"
1715 + if [[ -z $1 ]] ; then
1716 + # I'm leaving the following commented out to remind me that it
1717 + # was an insanely -bad- idea. Stuff broke. GCC_SPECS isnt unset
1718 + # on chroot or in non-toolchain.eclass gcc ebuilds!
1719 + #gcc_specs_file="${LIBPATH}/specs"
1720 + gcc_specs_file=""
1721 + else
1722 + gcc_envd_file+="-$1"
1723 + gcc_specs_file="${LIBPATH}/$1.specs"
1724 + fi
1725 +
1726 + # We want to list the default ABI's LIBPATH first so libtool
1727 + # searches that directory first. This is a temporary
1728 + # workaround for libtool being stupid and using .la's from
1729 + # conflicting ABIs by using the first one in the search path
1730 + local ldpaths mosdirs
1731 + if tc_version_is_at_least 3.2 ; then
1732 + local mdir mosdir abi ldpath
1733 + for abi in $(get_all_abis TARGET) ; do
1734 + mdir=$($(XGCC) $(get_abi_CFLAGS ${abi}) --print-multi-directory)
1735 + ldpath=${LIBPATH}
1736 + [[ ${mdir} != "." ]] && ldpath+="/${mdir}"
1737 + ldpaths="${ldpath}${ldpaths:+:${ldpaths}}"
1738 +
1739 + mosdir=$($(XGCC) $(get_abi_CFLAGS ${abi}) -print-multi-os-directory)
1740 + mosdirs="${mosdir}${mosdirs:+:${mosdirs}}"
1741 + done
1742 + else
1743 + # Older gcc's didn't do multilib, so logic is simple.
1744 + ldpaths=${LIBPATH}
1745 + fi
1746 +
1747 + cat <<-EOF > ${gcc_envd_file}
1748 + PATH="${BINPATH}"
1749 + ROOTPATH="${BINPATH}"
1750 + GCC_PATH="${BINPATH}"
1751 + LDPATH="${ldpaths}"
1752 + MANPATH="${DATAPATH}/man"
1753 + INFOPATH="${DATAPATH}/info"
1754 + STDCXX_INCDIR="${STDCXX_INCDIR##*/}"
1755 + CTARGET="${CTARGET}"
1756 + GCC_SPECS="${gcc_specs_file}"
1757 + MULTIOSDIRS="${mosdirs}"
1758 + EOF
1759 +}
1760 +
1761 +copy_minispecs_gcc_specs() {
1762 + # setup the hardenedno* specs files and the vanilla specs file.
1763 + if hardened_gcc_works ; then
1764 + create_gcc_env_entry hardenednopiessp
1765 + fi
1766 + if hardened_gcc_works pie ; then
1767 + create_gcc_env_entry hardenednopie
1768 + fi
1769 + if hardened_gcc_works ssp ; then
1770 + create_gcc_env_entry hardenednossp
1771 + fi
1772 + create_gcc_env_entry vanilla
1773 + insinto ${LIBPATH}
1774 + doins "${WORKDIR}"/specs/*.specs || die "failed to install specs"
1775 + # Build system specs file which, if it exists, must be a complete set of
1776 + # specs as it completely and unconditionally overrides the builtin specs.
1777 + if ! tc_version_is_at_least 4.4 ; then
1778 + $(XGCC) -dumpspecs > "${WORKDIR}"/specs/specs
1779 + cat "${WORKDIR}"/build.specs >> "${WORKDIR}"/specs/specs
1780 + doins "${WORKDIR}"/specs/specs || die "failed to install the specs file"
1781 + fi
1782 +}
1783 +
1784 +gcc_slot_java() {
1785 + local x
1786 +
1787 + # Move Java headers to compiler-specific dir
1788 + for x in "${D}"${PREFIX}/include/gc*.h "${D}"${PREFIX}/include/j*.h ; do
1789 + [[ -f ${x} ]] && mv -f "${x}" "${D}"${LIBPATH}/include/
1790 + done
1791 + for x in gcj gnu java javax org ; do
1792 + if [[ -d ${D}${PREFIX}/include/${x} ]] ; then
1793 + dodir /${LIBPATH}/include/${x}
1794 + mv -f "${D}"${PREFIX}/include/${x}/* "${D}"${LIBPATH}/include/${x}/
1795 + rm -rf "${D}"${PREFIX}/include/${x}
1796 + fi
1797 + done
1798 +
1799 + if [[ -d ${D}${PREFIX}/lib/security ]] || [[ -d ${D}${PREFIX}/$(get_libdir)/security ]] ; then
1800 + dodir /${LIBPATH}/security
1801 + mv -f "${D}"${PREFIX}/lib*/security/* "${D}"${LIBPATH}/security
1802 + rm -rf "${D}"${PREFIX}/lib*/security
1803 + fi
1804 +
1805 + # Move random gcj files to compiler-specific directories
1806 + for x in libgcj.spec logging.properties ; do
1807 + x="${D}${PREFIX}/lib/${x}"
1808 + [[ -f ${x} ]] && mv -f "${x}" "${D}"${LIBPATH}/
1809 + done
1810 +
1811 + # Rename jar because it could clash with Kaffe's jar if this gcc is
1812 + # primary compiler (aka don't have the -<version> extension)
1813 + cd "${D}"${BINPATH}
1814 + [[ -f jar ]] && mv -f jar gcj-jar
1815 +}
1816 +
1817 +#---->> pkg_post* <<----
1818 +
1819 +toolchain_pkg_postinst() {
1820 + do_gcc_config
1821 +
1822 + if ! is_crosscompile ; then
1823 + echo
1824 + ewarn "If you have issues with packages unable to locate libstdc++.la,"
1825 + ewarn "then try running 'fix_libtool_files.sh' on the old gcc versions."
1826 + echo
1827 + ewarn "You might want to review the GCC upgrade guide when moving between"
1828 + ewarn "major versions (like 4.2 to 4.3):"
1829 + ewarn "http://www.gentoo.org/doc/en/gcc-upgrading.xml"
1830 + echo
1831 +
1832 + # Clean up old paths
1833 + rm -f "${ROOT}"/*/rcscripts/awk/fixlafiles.awk "${ROOT}"/sbin/fix_libtool_files.sh
1834 + rmdir "${ROOT}"/*/rcscripts{/awk,} 2>/dev/null
1835 +
1836 + mkdir -p "${ROOT}"/usr/{share/gcc-data,sbin,bin}
1837 + cp "${ROOT}/${DATAPATH}"/fixlafiles.awk "${ROOT}"/usr/share/gcc-data/ || die
1838 + cp "${ROOT}/${DATAPATH}"/fix_libtool_files.sh "${ROOT}"/usr/sbin/ || die
1839 +
1840 + # Since these aren't critical files and portage sucks with
1841 + # handling of binpkgs, don't require these to be found
1842 + cp "${ROOT}/${DATAPATH}"/c{89,99} "${ROOT}"/usr/bin/ 2>/dev/null
1843 + fi
1844 +
1845 + if use regression-test ; then
1846 + elog "Testsuite results have been installed into /usr/share/doc/${PF}/testsuite"
1847 + echo
1848 + fi
1849 +}
1850 +
1851 +toolchain_pkg_postrm() {
1852 + # to make our lives easier (and saner), we do the fix_libtool stuff here.
1853 + # rather than checking SLOT's and trying in upgrade paths, we just see if
1854 + # the common libstdc++.la exists in the ${LIBPATH} of the gcc that we are
1855 + # unmerging. if it does, that means this was a simple re-emerge.
1856 +
1857 + # clean up the cruft left behind by cross-compilers
1858 + if is_crosscompile ; then
1859 + if [[ -z $(ls "${ROOT}"/etc/env.d/gcc/${CTARGET}* 2>/dev/null) ]] ; then
1860 + rm -f "${ROOT}"/etc/env.d/gcc/config-${CTARGET}
1861 + rm -f "${ROOT}"/etc/env.d/??gcc-${CTARGET}
1862 + rm -f "${ROOT}"/usr/bin/${CTARGET}-{gcc,{g,c}++}{,32,64}
1863 + fi
1864 + return 0
1865 + fi
1866 +
1867 + # ROOT isnt handled by the script
1868 + [[ ${ROOT} != "/" ]] && return 0
1869 +
1870 + if [[ ! -e ${LIBPATH}/libstdc++.so ]] ; then
1871 + # make sure the profile is sane during same-slot upgrade #289403
1872 + do_gcc_config
1873 +
1874 + einfo "Running 'fix_libtool_files.sh ${GCC_RELEASE_VER}'"
1875 + /usr/sbin/fix_libtool_files.sh ${GCC_RELEASE_VER}
1876 + if [[ -n ${BRANCH_UPDATE} ]] ; then
1877 + einfo "Running 'fix_libtool_files.sh ${GCC_RELEASE_VER}-${BRANCH_UPDATE}'"
1878 + /usr/sbin/fix_libtool_files.sh ${GCC_RELEASE_VER}-${BRANCH_UPDATE}
1879 + fi
1880 + fi
1881 +
1882 + return 0
1883 +}
1884 +
1885 +do_gcc_config() {
1886 + if ! should_we_gcc_config ; then
1887 + env -i ROOT="${ROOT}" gcc-config --use-old --force
1888 + return 0
1889 + fi
1890 +
1891 + local current_gcc_config="" current_specs="" use_specs=""
1892 +
1893 + current_gcc_config=$(env -i ROOT="${ROOT}" gcc-config -c ${CTARGET} 2>/dev/null)
1894 + if [[ -n ${current_gcc_config} ]] ; then
1895 + # figure out which specs-specific config is active
1896 + current_specs=$(gcc-config -S ${current_gcc_config} | awk '{print $3}')
1897 + [[ -n ${current_specs} ]] && use_specs=-${current_specs}
1898 + fi
1899 + if [[ -n ${use_specs} ]] && \
1900 + [[ ! -e ${ROOT}/etc/env.d/gcc/${CTARGET}-${GCC_CONFIG_VER}${use_specs} ]]
1901 + then
1902 + ewarn "The currently selected specs-specific gcc config,"
1903 + ewarn "${current_specs}, doesn't exist anymore. This is usually"
1904 + ewarn "due to enabling/disabling hardened or switching to a version"
1905 + ewarn "of gcc that doesnt create multiple specs files. The default"
1906 + ewarn "config will be used, and the previous preference forgotten."
1907 + use_specs=""
1908 + fi
1909 +
1910 + gcc-config ${CTARGET}-${GCC_CONFIG_VER}${use_specs}
1911 +}
1912 +
1913 +should_we_gcc_config() {
1914 + # if the current config is invalid, we definitely want a new one
1915 + # Note: due to bash quirkiness, the following must not be 1 line
1916 + local curr_config
1917 + curr_config=$(env -i ROOT="${ROOT}" gcc-config -c ${CTARGET} 2>&1) || return 0
1918 +
1919 + # if the previously selected config has the same major.minor (branch) as
1920 + # the version we are installing, then it will probably be uninstalled
1921 + # for being in the same SLOT, make sure we run gcc-config.
1922 + local curr_config_ver=$(env -i ROOT="${ROOT}" gcc-config -S ${curr_config} | awk '{print $2}')
1923 +
1924 + local curr_branch_ver=$(get_version_component_range 1-2 ${curr_config_ver})
1925 +
1926 + # If we're using multislot, just run gcc-config if we're installing
1927 + # to the same profile as the current one.
1928 + use multislot && return $([[ ${curr_config_ver} == ${GCC_CONFIG_VER} ]])
1929 +
1930 + if [[ ${curr_branch_ver} == ${GCC_BRANCH_VER} ]] ; then
1931 + return 0
1932 + else
1933 + # if we're installing a genuinely different compiler version,
1934 + # we should probably tell the user -how- to switch to the new
1935 + # gcc version, since we're not going to do it for him/her.
1936 + # We don't want to switch from say gcc-3.3 to gcc-3.4 right in
1937 + # the middle of an emerge operation (like an 'emerge -e world'
1938 + # which could install multiple gcc versions).
1939 + # Only warn if we're installing a pkg as we might be called from
1940 + # the pkg_{pre,post}rm steps. #446830
1941 + if [[ ${EBUILD_PHASE} == *"inst" ]] ; then
1942 + einfo "The current gcc config appears valid, so it will not be"
1943 + einfo "automatically switched for you. If you would like to"
1944 + einfo "switch to the newly installed gcc version, do the"
1945 + einfo "following:"
1946 + echo
1947 + einfo "gcc-config ${CTARGET}-${GCC_CONFIG_VER}"
1948 + einfo "source /etc/profile"
1949 + echo
1950 + fi
1951 + return 1
1952 + fi
1953 +}
1954 +
1955 +#---->> support and misc functions <<----
1956 +
1957 +# This is to make sure we don't accidentally try to enable support for a
1958 +# language that doesnt exist. GCC 3.4 supports f77, while 4.0 supports f95, etc.
1959 +#
1960 +# Also add a hook so special ebuilds (kgcc64) can control which languages
1961 +# exactly get enabled
1962 +gcc-lang-supported() {
1963 + grep ^language=\"${1}\" "${S}"/gcc/*/config-lang.in > /dev/null || return 1
1964 + [[ -z ${TOOLCHAIN_ALLOWED_LANGS} ]] && return 0
1965 + has $1 ${TOOLCHAIN_ALLOWED_LANGS}
1966 +}
1967 +
1968 +is_ada() {
1969 + gcc-lang-supported ada || return 1
1970 + use ada
1971 +}
1972 +
1973 +is_cxx() {
1974 + gcc-lang-supported 'c++' || return 1
1975 + tc_version_is_at_least 4.8 && return 0
1976 + use cxx
1977 +}
1978 +
1979 +is_d() {
1980 + gcc-lang-supported d || return 1
1981 + use_if_iuse d
1982 +}
1983 +
1984 +is_f77() {
1985 + gcc-lang-supported f77 || return 1
1986 + use fortran
1987 +}
1988 +
1989 +is_f95() {
1990 + gcc-lang-supported f95 || return 1
1991 + use fortran
1992 +}
1993 +
1994 +is_fortran() {
1995 + gcc-lang-supported fortran || return 1
1996 + use fortran
1997 +}
1998 +
1999 +is_gcj() {
2000 + gcc-lang-supported java || return 1
2001 + use cxx && use_if_iuse gcj
2002 +}
2003 +
2004 +is_go() {
2005 + gcc-lang-supported go || return 1
2006 + use cxx && use_if_iuse go
2007 +}
2008 +
2009 +is_multilib() {
2010 + tc_version_is_at_least 3 || return 1
2011 + use multilib
2012 +}
2013 +
2014 +is_objc() {
2015 + gcc-lang-supported objc || return 1
2016 + use_if_iuse objc
2017 +}
2018 +
2019 +is_objcxx() {
2020 + gcc-lang-supported 'obj-c++' || return 1
2021 + use cxx && use_if_iuse objc++
2022 +}
2023 +
2024 +is_treelang() {
2025 + use_if_iuse boundschecking && return 1 #260532
2026 + is_crosscompile && return 1 #199924
2027 + gcc-lang-supported treelang || return 1
2028 + #use treelang
2029 + return 0
2030 +}
2031 +
2032 +# Grab a variable from the build system (taken from linux-info.eclass)
2033 +get_make_var() {
2034 + local var=$1 makefile=${2:-${WORKDIR}/build/Makefile}
2035 + echo -e "e:\\n\\t@echo \$(${var})\\ninclude ${makefile}" | \
2036 + r=${makefile%/*} emake --no-print-directory -s -f - 2>/dev/null
2037 +}
2038 +
2039 +XGCC() { get_make_var GCC_FOR_TARGET ; }
2040 +
2041 +# The gentoo piessp patches allow for 3 configurations:
2042 +# 1) PIE+SSP by default
2043 +# 2) PIE by default
2044 +# 3) SSP by default
2045 +hardened_gcc_works() {
2046 + if [[ $1 == "pie" ]] ; then
2047 + # $gcc_cv_ld_pie is unreliable as it simply take the output of
2048 + # `ld --help | grep -- -pie`, that reports the option in all cases, also if
2049 + # the loader doesn't actually load the resulting executables.
2050 + # To avoid breakage, blacklist FreeBSD here at least
2051 + [[ ${CTARGET} == *-freebsd* ]] && return 1
2052 +
2053 + want_pie || return 1
2054 + use_if_iuse nopie && return 1
2055 + hardened_gcc_is_stable pie
2056 + return $?
2057 + elif [[ $1 == "ssp" ]] ; then
2058 + [[ -n ${SPECS_VER} ]] || return 1
2059 + use_if_iuse nossp && return 1
2060 + hardened_gcc_is_stable ssp
2061 + return $?
2062 + else
2063 + # laziness ;)
2064 + hardened_gcc_works pie || return 1
2065 + hardened_gcc_works ssp || return 1
2066 + return 0
2067 + fi
2068 +}
2069 +
2070 +hardened_gcc_is_stable() {
2071 + local tocheck
2072 + if [[ $1 == "pie" ]] ; then
2073 + if [[ ${CTARGET} == *-uclibc* ]] ; then
2074 + tocheck=${PIE_UCLIBC_STABLE}
2075 + else
2076 + tocheck=${PIE_GLIBC_STABLE}
2077 + fi
2078 + elif [[ $1 == "ssp" ]] ; then
2079 + if [[ ${CTARGET} == *-uclibc* ]] ; then
2080 + tocheck=${SSP_UCLIBC_STABLE}
2081 + else
2082 + tocheck=${SSP_STABLE}
2083 + fi
2084 + else
2085 + die "hardened_gcc_stable needs to be called with pie or ssp"
2086 + fi
2087 +
2088 + has $(tc-arch) ${tocheck} && return 0
2089 + return 1
2090 +}
2091 +
2092 +want_minispecs() {
2093 + if tc_version_is_at_least 4.3.2 && use hardened ; then
2094 + if ! want_pie ; then
2095 + ewarn "PIE_VER or SPECS_VER is not defined in the GCC ebuild."
2096 + elif use vanilla ; then
2097 + ewarn "You will not get hardened features if you have the vanilla USE-flag."
2098 + elif use nopie && use nossp ; then
2099 + ewarn "You will not get hardened features if you have the nopie and nossp USE-flag."
2100 + elif ! hardened_gcc_works ; then
2101 + ewarn "Your $(tc-arch) arch is not supported."
2102 + else
2103 + return 0
2104 + fi
2105 + ewarn "Hope you know what you are doing. Hardened will not work."
2106 + return 0
2107 + fi
2108 + return 1
2109 +}
2110 +
2111 +want_pie() {
2112 + ! use hardened && [[ -n ${PIE_VER} ]] && use nopie && return 1
2113 + [[ -n ${PIE_VER} ]] && [[ -n ${SPECS_VER} ]] && return 0
2114 + tc_version_is_at_least 4.3.2 && return 1
2115 + [[ -z ${PIE_VER} ]] && return 1
2116 + use !nopie && return 0
2117 + return 1
2118 +}
2119 +
2120 +has toolchain_death_notice ${EBUILD_DEATH_HOOKS} || EBUILD_DEATH_HOOKS+=" toolchain_death_notice"
2121 +toolchain_death_notice() {
2122 + if [[ -e "${WORKDIR}"/build ]] ; then
2123 + pushd "${WORKDIR}"/build >/dev/null
2124 + (echo '' | $(tc-getCC ${CTARGET}) ${CFLAGS} -v -E - 2>&1) > gccinfo.log
2125 + [[ -e "${T}"/build.log ]] && cp "${T}"/build.log .
2126 + tar jcf "${WORKDIR}"/gcc-build-logs.tar.bz2 \
2127 + gccinfo.log build.log $(find -name config.log)
2128 + rm gccinfo.log build.log
2129 + eerror
2130 + eerror "Please include ${WORKDIR}/gcc-build-logs.tar.bz2 in your bug report."
2131 + eerror
2132 + popd >/dev/null
2133 + fi
2134 +}
2135
2136 diff --git a/sys-devel/gcc/files/awk/fixlafiles.awk b/sys-devel/gcc/files/awk/fixlafiles.awk
2137 new file mode 100644
2138 index 0000000..ffade96
2139 --- /dev/null
2140 +++ b/sys-devel/gcc/files/awk/fixlafiles.awk
2141 @@ -0,0 +1,314 @@
2142 +# Copyright 1999-2005 Gentoo Foundation
2143 +# Distributed under the terms of the GNU General Public License v2
2144 +# $Header: /var/cvsroot/gentoo-x86/sys-devel/gcc/files/awk/fixlafiles.awk,v 1.15 2008/02/19 05:47:29 vapier Exp $
2145 +
2146 +#
2147 +# Helper functions
2148 +#
2149 +function printn(string) {
2150 + printf("%s", string)
2151 +}
2152 +function einfo(string) {
2153 + printf(" \033[32;01m*\033[0m %s\n", string)
2154 +}
2155 +function einfon(string) {
2156 + printf(" \033[32;01m*\033[0m %s", string)
2157 +}
2158 +function ewarn(string) {
2159 + printf(" \033[33;01m*\033[0m %s\n", string)
2160 +}
2161 +function ewarnn(string) {
2162 + printf(" \033[33;01m*\033[0m %s", string)
2163 +}
2164 +function eerror(string) {
2165 + printf(" \033[31;01m*\033[0m %s\n", string)
2166 +}
2167 +
2168 +#
2169 +# assert(condition, errmsg)
2170 +# assert that a condition is true. Otherwise exit.
2171 +#
2172 +function assert(condition, string) {
2173 + if (! condition) {
2174 + printf("%s:%d: assertion failed: %s\n",
2175 + FILENAME, FNR, string) > "/dev/stderr"
2176 + _assert_exit = 1
2177 + exit 1
2178 + }
2179 +}
2180 +
2181 +#
2182 +# system(command, return)
2183 +# wrapper that normalizes return codes ...
2184 +#
2185 +function dosystem(command, ret) {
2186 + ret = 0
2187 + ret = system(command)
2188 + if (ret == 0)
2189 + return 1
2190 + else
2191 + return 0
2192 +}
2193 +
2194 +BEGIN {
2195 + #
2196 + # Get our variables from environment
2197 + #
2198 + OLDVER = ENVIRON["OLDVER"]
2199 + OLDCHOST = ENVIRON["OLDCHOST"]
2200 +
2201 + if (OLDVER == "") {
2202 + eerror("Could not get OLDVER!");
2203 + exit 1
2204 + }
2205 +
2206 + # Setup some sane defaults
2207 + LIBCOUNT = 2
2208 + HAVE_GCC34 = 0
2209 + DIRLIST[1] = "/lib"
2210 + DIRLIST[2] = "/usr/lib"
2211 +
2212 + #
2213 + # Walk /etc/ld.so.conf to discover all our library paths
2214 + #
2215 + pipe = "cat /etc/ld.so.conf | sort 2>/dev/null"
2216 + while(((pipe) | getline ldsoconf_data) > 0) {
2217 + if (ldsoconf_data !~ /^[[:space:]]*#/) {
2218 + if (ldsoconf_data == "") continue
2219 +
2220 + # Remove any trailing comments
2221 + sub(/#.*$/, "", ldsoconf_data)
2222 + # Remove any trailing spaces
2223 + sub(/[[:space:]]+$/, "", ldsoconf_data)
2224 +
2225 + # If there's more than one path per line, split
2226 + # it up as if they were sep lines
2227 + split(ldsoconf_data, nodes, /[:,[:space:]]/)
2228 +
2229 + # Now add the rest from ld.so.conf
2230 + for (x in nodes) {
2231 + # wtf does this line do ?
2232 + sub(/=.*/, "", nodes[x])
2233 + # Prune trailing /
2234 + sub(/\/$/, "", nodes[x])
2235 +
2236 + if (nodes[x] == "") continue
2237 +
2238 + #
2239 + # Drop the directory if its a child directory of
2240 + # one that was already added ...
2241 + # For example, if we have:
2242 + # /usr/lib /usr/libexec /usr/lib/mozilla /usr/lib/nss
2243 + # We really just want to save /usr/lib /usr/libexec
2244 + #
2245 + CHILD = 0
2246 + for (y in DIRLIST) {
2247 + if (nodes[x] ~ "^" DIRLIST[y] "(/|$)") {
2248 + CHILD = 1
2249 + break
2250 + }
2251 + }
2252 + if (CHILD) continue
2253 +
2254 + DIRLIST[++LIBCOUNT] = nodes[x]
2255 + }
2256 + }
2257 + }
2258 + close(pipe)
2259 +
2260 + #
2261 + # Get line from gcc's output containing CHOST
2262 + #
2263 + pipe = "gcc -print-file-name=libgcc.a 2>/dev/null"
2264 + if ((!((pipe) | getline TMP_CHOST)) || (TMP_CHOST == "")) {
2265 + close(pipe)
2266 +
2267 + # If we fail to get the CHOST, see if we can get the CHOST
2268 + # portage thinks we are using ...
2269 + pipe = "/usr/bin/portageq envvar 'CHOST'"
2270 + assert(((pipe) | getline CHOST), "(" pipe ") | getline CHOST")
2271 + } else {
2272 + # Check pre gcc-3.4.x versions
2273 + CHOST = gensub("^.+lib/gcc-lib/([^/]+)/[0-9]+.+$", "\\1", 1, TMP_CHOST)
2274 +
2275 + if (CHOST == TMP_CHOST || CHOST == "") {
2276 + # Check gcc-3.4.x or later
2277 + CHOST = gensub("^.+lib/gcc/([^/]+)/[0-9]+.+$", "\\1", 1, TMP_CHOST);
2278 +
2279 + if (CHOST == TMP_CHOST || CHOST == "")
2280 + CHOST = ""
2281 + else
2282 + HAVE_GCC34 = 1
2283 + }
2284 + }
2285 + close(pipe)
2286 +
2287 + if (CHOST == "") {
2288 + eerror("Could not get gcc's CHOST!")
2289 + exit 1
2290 + }
2291 +
2292 + if (OLDCHOST != "")
2293 + if (OLDCHOST == CHOST)
2294 + OLDCHOST = ""
2295 +
2296 + GCCLIBPREFIX_OLD = "/usr/lib/gcc-lib/"
2297 + GCCLIBPREFIX_NEW = "/usr/lib/gcc/"
2298 +
2299 + if (HAVE_GCC34)
2300 + GCCLIBPREFIX = GCCLIBPREFIX_NEW
2301 + else
2302 + GCCLIBPREFIX = GCCLIBPREFIX_OLD
2303 +
2304 + GCCLIB = GCCLIBPREFIX CHOST
2305 +
2306 + if (OLDCHOST != "") {
2307 + OLDGCCLIB1 = GCCLIBPREFIX_OLD OLDCHOST
2308 + OLDGCCLIB2 = GCCLIBPREFIX_NEW OLDCHOST
2309 + }
2310 +
2311 + # Get current gcc's version
2312 + pipe = "gcc -dumpversion"
2313 + assert(((pipe) | getline NEWVER), "(" pipe ") | getline NEWVER)")
2314 + close(pipe)
2315 +
2316 + if (NEWVER == "") {
2317 + eerror("Could not get gcc's version!")
2318 + exit 1
2319 + }
2320 +
2321 + # Nothing to do ?
2322 + if ((OLDVER == NEWVER) && (OLDCHOST == ""))
2323 + exit 0
2324 +
2325 + #
2326 + # Ok, now let's scan for the .la files and actually fix them up
2327 + #
2328 + for (x = 1; x <= LIBCOUNT; x++) {
2329 + # Do nothing if the target dir is gcc's internal library path
2330 + if (DIRLIST[x] ~ GCCLIBPREFIX_OLD ||
2331 + DIRLIST[x] ~ GCCLIBPREFIX_NEW)
2332 + continue
2333 +
2334 + einfo(" [" x "/" LIBCOUNT "] Scanning " DIRLIST[x] " ...")
2335 +
2336 + pipe = "find " DIRLIST[x] "/ -name '*.la' 2>/dev/null"
2337 + while (((pipe) | getline la_files) > 0) {
2338 +
2339 + # Do nothing if the .la file is located in gcc's internal lib path
2340 + if (la_files ~ GCCLIBPREFIX_OLD ||
2341 + la_files ~ GCCLIBPREFIX_NEW)
2342 + continue
2343 +
2344 + CHANGED = 0
2345 + CHOST_CHANGED = 0
2346 +
2347 + # See if we need to fix the .la file
2348 + while ((getline la_data < (la_files)) > 0) {
2349 + if (OLDCHOST != "") {
2350 + if ((gsub(OLDGCCLIB1 "[/[:space:]]+",
2351 + GCCLIB, la_data) > 0) ||
2352 + (gsub(OLDGCCLIB2 "[/[:space:]]+",
2353 + GCCLIB, la_data) > 0)) {
2354 + CHANGED = 1
2355 + CHOST_CHANGED = 1
2356 + }
2357 + }
2358 + if (OLDVER != NEWVER) {
2359 + if ((gsub(GCCLIBPREFIX_OLD CHOST "/" OLDVER "[/[:space:]]*",
2360 + GCCLIB "/" NEWVER, la_data) > 0) ||
2361 + (gsub(GCCLIBPREFIX_NEW CHOST "/" OLDVER "[/[:space:]]*",
2362 + GCCLIB "/" NEWVER, la_data) > 0))
2363 + CHANGED = 1
2364 + }
2365 + }
2366 + close(la_files)
2367 +
2368 + # Do the actual changes in a second loop, as we can then
2369 + # verify that CHOST_CHANGED among things is correct ...
2370 + if (CHANGED) {
2371 + ewarnn(" FIXING: " la_files " ...")
2372 +
2373 + if (CHANGED)
2374 + printn("[")
2375 +
2376 + # Clear the temp file (removing rather than '>foo' is better
2377 + # out of a security point of view?)
2378 + dosystem("rm -f " la_files ".new")
2379 +
2380 + while ((getline la_data < (la_files)) > 0) {
2381 + if (OLDCHOST != "") {
2382 + tmpstr = gensub(OLDGCCLIB1 "([/[:space:]]+)",
2383 + GCCLIB "\\1", "g", la_data)
2384 + tmpstr = gensub(OLDGCCLIB2 "([/[:space:]]+)",
2385 + GCCLIB "\\1", "g", tmpstr)
2386 +
2387 + if (la_data != tmpstr) {
2388 + printn("c")
2389 + la_data = tmpstr
2390 + }
2391 +
2392 + if (CHOST_CHANGED > 0) {
2393 + # We try to be careful about CHOST changes outside
2394 + # the gcc library path (meaning we cannot match it
2395 + # via /GCCLIBPREFIX CHOST/) ...
2396 +
2397 + # Catch:
2398 + #
2399 + # dependency_libs=' -L/usr/CHOST/{bin,lib}'
2400 + #
2401 + gsub("-L/usr/" OLDCHOST "/",
2402 + "-L/usr/" CHOST "/", la_data)
2403 + # Catch:
2404 + #
2405 + # dependency_libs=' -L/usr/lib/gcc-lib/CHOST/VER/../../../../CHOST/lib'
2406 + #
2407 + la_data = gensub("(" GCCLIB "/[^[:space:]]+)/" OLDCHOST "/",
2408 + "\\1/" CHOST "/", "g", la_data)
2409 + }
2410 + }
2411 +
2412 + if (OLDVER != NEWVER) {
2413 + # Catch:
2414 + #
2415 + # dependency_libs=' -L/usr/lib/gcc/CHOST/VER'
2416 + #
2417 + tmpstr = gensub(GCCLIBPREFIX_OLD CHOST "/" OLDVER "([/[:space:]]+)",
2418 + GCCLIB "/" NEWVER "\\1", "g", la_data)
2419 + tmpstr = gensub(GCCLIBPREFIX_NEW CHOST "/" OLDVER "([/[:space:]]+)",
2420 + GCCLIB "/" NEWVER "\\1", "g", tmpstr)
2421 +
2422 + if (la_data != tmpstr) {
2423 + # Catch:
2424 + #
2425 + # dependency_libs=' -L/usr/lib/gcc-lib/../../CHOST/lib'
2426 + #
2427 + # in cases where we have gcc34
2428 + tmpstr = gensub(GCCLIBPREFIX_OLD "(../../" CHOST "/lib)",
2429 + GCCLIBPREFIX "\\1", "g", tmpstr)
2430 + tmpstr = gensub(GCCLIBPREFIX_NEW "(../../" CHOST "/lib)",
2431 + GCCLIBPREFIX "\\1", "g", tmpstr)
2432 + printn("v")
2433 + la_data = tmpstr
2434 + }
2435 + }
2436 +
2437 + print la_data >> (la_files ".new")
2438 + }
2439 +
2440 + if (CHANGED)
2441 + print "]"
2442 +
2443 + close(la_files)
2444 + close(la_files ".new")
2445 +
2446 + assert(dosystem("mv -f " la_files ".new " la_files),
2447 + "dosystem(\"mv -f " la_files ".new " la_files "\")")
2448 + }
2449 + }
2450 +
2451 + close(pipe)
2452 + }
2453 +}
2454 +
2455 +# vim:ts=4
2456
2457 diff --git a/sys-devel/gcc/files/awk/fixlafiles.awk-no_gcc_la b/sys-devel/gcc/files/awk/fixlafiles.awk-no_gcc_la
2458 new file mode 100644
2459 index 0000000..346bd16
2460 --- /dev/null
2461 +++ b/sys-devel/gcc/files/awk/fixlafiles.awk-no_gcc_la
2462 @@ -0,0 +1,335 @@
2463 +# Copyright 1999-2005 Gentoo Foundation
2464 +# Distributed under the terms of the GNU General Public License v2
2465 +# $Header: /var/cvsroot/gentoo-x86/sys-devel/gcc/files/awk/fixlafiles.awk-no_gcc_la,v 1.4 2010/03/19 23:53:07 vapier Exp $
2466 +
2467 +#
2468 +# Helper functions
2469 +#
2470 +function printn(string) {
2471 + printf("%s", string)
2472 +}
2473 +function einfo(string) {
2474 + printf(" \033[32;01m*\033[0m %s\n", string)
2475 +}
2476 +function einfon(string) {
2477 + printf(" \033[32;01m*\033[0m %s", string)
2478 +}
2479 +function ewarn(string) {
2480 + printf(" \033[33;01m*\033[0m %s\n", string)
2481 +}
2482 +function ewarnn(string) {
2483 + printf(" \033[33;01m*\033[0m %s", string)
2484 +}
2485 +function eerror(string) {
2486 + printf(" \033[31;01m*\033[0m %s\n", string)
2487 +}
2488 +
2489 +#
2490 +# assert(condition, errmsg)
2491 +# assert that a condition is true. Otherwise exit.
2492 +#
2493 +function assert(condition, string) {
2494 + if (! condition) {
2495 + printf("%s:%d: assertion failed: %s\n",
2496 + FILENAME, FNR, string) > "/dev/stderr"
2497 + _assert_exit = 1
2498 + exit 1
2499 + }
2500 +}
2501 +
2502 +#
2503 +# system(command, return)
2504 +# wrapper that normalizes return codes ...
2505 +#
2506 +function dosystem(command, ret) {
2507 + ret = 0
2508 + ret = system(command)
2509 + if (ret == 0)
2510 + return 1
2511 + else
2512 + return 0
2513 +}
2514 +
2515 +#
2516 +# parse_ld_conf(config_file)
2517 +#
2518 +function parse_ld_conf(conf, pipe, ldsoconf_data, CHILD, y) {
2519 + pipe = "cd /etc; cat " conf " | sort 2>/dev/null"
2520 + while(((pipe) | getline ldsoconf_data) > 0) {
2521 + if (ldsoconf_data ~ /^[[:space:]]*#/)
2522 + continue
2523 + if (ldsoconf_data == "")
2524 + continue
2525 +
2526 + # Handle the "include" keyword
2527 + if (ldsoconf_data ~ /^include /) {
2528 + sub(/^include /, "", ldsoconf_data)
2529 + parse_ld_conf(ldsoconf_data)
2530 + continue
2531 + }
2532 +
2533 + # Remove any trailing comments
2534 + sub(/#.*$/, "", ldsoconf_data)
2535 + # Remove any trailing spaces
2536 + sub(/[[:space:]]+$/, "", ldsoconf_data)
2537 + # Eat duplicate slashes
2538 + sub(/\/\//, "/", ldsoconf_data)
2539 + # Prune trailing /
2540 + sub(/\/$/, "", ldsoconf_data)
2541 +
2542 + #
2543 + # Drop the directory if its a child directory of
2544 + # one that was already added ...
2545 + # For example, if we have:
2546 + # /usr/lib /usr/libexec /usr/lib/mozilla /usr/lib/nss
2547 + # We really just want to save /usr/lib /usr/libexec
2548 + #
2549 + CHILD = 0
2550 + for (y in DIRLIST) {
2551 + if (ldsoconf_data ~ "^" DIRLIST[y] "(/|$)") {
2552 + CHILD = 1
2553 + break
2554 + }
2555 + }
2556 + if (CHILD) continue
2557 +
2558 + DIRLIST[++LIBCOUNT] = ldsoconf_data
2559 + }
2560 + close(pipe)
2561 +}
2562 +
2563 +BEGIN {
2564 + #
2565 + # Get our variables from environment
2566 + #
2567 + OLDVER = ENVIRON["OLDVER"]
2568 + OLDCHOST = ENVIRON["OLDCHOST"]
2569 +
2570 + if (OLDVER == "") {
2571 + eerror("Could not get OLDVER!");
2572 + exit 1
2573 + }
2574 +
2575 + # Setup some sane defaults
2576 + LIBCOUNT = 2
2577 + HAVE_GCC34 = 0
2578 + DIRLIST[1] = "/lib"
2579 + DIRLIST[2] = "/usr/lib"
2580 +
2581 + #
2582 + # Walk /etc/ld.so.conf to discover all our library paths
2583 + #
2584 + parse_ld_conf("/etc/ld.so.conf")
2585 +
2586 + #
2587 + # Get line from gcc's output containing CHOST
2588 + #
2589 + pipe = "gcc -print-file-name=libgcc.a 2>/dev/null"
2590 + if ((!((pipe) | getline TMP_CHOST)) || (TMP_CHOST == "")) {
2591 + close(pipe)
2592 +
2593 + # If we fail to get the CHOST, see if we can get the CHOST
2594 + # portage thinks we are using ...
2595 + pipe = "/usr/bin/portageq envvar 'CHOST'"
2596 + assert(((pipe) | getline CHOST), "(" pipe ") | getline CHOST")
2597 + } else {
2598 + # Check pre gcc-3.4.x versions
2599 + CHOST = gensub("^.+lib/gcc-lib/([^/]+)/[0-9]+.+$", "\\1", 1, TMP_CHOST)
2600 +
2601 + if (CHOST == TMP_CHOST || CHOST == "") {
2602 + # Check gcc-3.4.x or later
2603 + CHOST = gensub("^.+lib/gcc/([^/]+)/[0-9]+.+$", "\\1", 1, TMP_CHOST);
2604 +
2605 + if (CHOST == TMP_CHOST || CHOST == "")
2606 + CHOST = ""
2607 + else
2608 + HAVE_GCC34 = 1
2609 + }
2610 + }
2611 + close(pipe)
2612 +
2613 + if (CHOST == "") {
2614 + eerror("Could not get gcc's CHOST!")
2615 + exit 1
2616 + }
2617 +
2618 + if (OLDCHOST != "")
2619 + if (OLDCHOST == CHOST)
2620 + OLDCHOST = ""
2621 +
2622 + GCCLIBPREFIX_OLD = "/usr/lib/gcc-lib/"
2623 + GCCLIBPREFIX_NEW = "/usr/lib/gcc/"
2624 +
2625 + if (HAVE_GCC34)
2626 + GCCLIBPREFIX = GCCLIBPREFIX_NEW
2627 + else
2628 + GCCLIBPREFIX = GCCLIBPREFIX_OLD
2629 +
2630 + GCCLIB = GCCLIBPREFIX CHOST
2631 +
2632 + if (OLDCHOST != "") {
2633 + OLDGCCLIB1 = GCCLIBPREFIX_OLD OLDCHOST
2634 + OLDGCCLIB2 = GCCLIBPREFIX_NEW OLDCHOST
2635 + }
2636 +
2637 + # Get current gcc's version
2638 + pipe = "gcc -dumpversion"
2639 + assert(((pipe) | getline NEWVER), "(" pipe ") | getline NEWVER)")
2640 + close(pipe)
2641 +
2642 + if (NEWVER == "") {
2643 + eerror("Could not get gcc's version!")
2644 + exit 1
2645 + }
2646 +
2647 + # Nothing to do ?
2648 + # NB: Do not check for (OLDVER == NEWVER) anymore, as we might need to
2649 + # replace libstdc++.la ....
2650 + if ((OLDVER == "") && (OLDCHOST == ""))
2651 + exit 0
2652 +
2653 + #
2654 + # Ok, now let's scan for the .la files and actually fix them up
2655 + #
2656 + for (x = 1; x <= LIBCOUNT; x++) {
2657 + # Do nothing if the target dir is gcc's internal library path
2658 + if (DIRLIST[x] ~ GCCLIBPREFIX_OLD ||
2659 + DIRLIST[x] ~ GCCLIBPREFIX_NEW)
2660 + continue
2661 +
2662 + einfo(" [" x "/" LIBCOUNT "] Scanning " DIRLIST[x] " ...")
2663 +
2664 + pipe = "find " DIRLIST[x] "/ -name '*.la' 2>/dev/null"
2665 + while (((pipe) | getline la_files) > 0) {
2666 +
2667 + # Do nothing if the .la file is located in gcc's internal lib path
2668 + if (la_files ~ GCCLIBPREFIX_OLD ||
2669 + la_files ~ GCCLIBPREFIX_NEW)
2670 + continue
2671 +
2672 + CHANGED = 0
2673 + CHOST_CHANGED = 0
2674 +
2675 + # See if we need to fix the .la file
2676 + while ((getline la_data < (la_files)) > 0) {
2677 + if (OLDCHOST != "") {
2678 + if ((gsub(OLDGCCLIB1 "[/[:space:]]+",
2679 + GCCLIB, la_data) > 0) ||
2680 + (gsub(OLDGCCLIB2 "[/[:space:]]+",
2681 + GCCLIB, la_data) > 0)) {
2682 + CHANGED = 1
2683 + CHOST_CHANGED = 1
2684 + }
2685 + }
2686 + if (OLDVER != NEWVER) {
2687 + if ((gsub(GCCLIBPREFIX_OLD CHOST "/" OLDVER "[/[:space:]]*",
2688 + GCCLIB "/" NEWVER, la_data) > 0) ||
2689 + (gsub(GCCLIBPREFIX_NEW CHOST "/" OLDVER "[/[:space:]]*",
2690 + GCCLIB "/" NEWVER, la_data) > 0))
2691 + CHANGED = 1
2692 + }
2693 + # We now check if we have libstdc++.la, as we remove the
2694 + # libtool linker scripts for gcc ...
2695 + # We do this last, as we only match the new paths
2696 + if (gsub(GCCLIB "/" NEWVER "/libstdc\\+\\+\\.la",
2697 + "-lstdc++", la_data) > 0)
2698 + CHANGED = 1
2699 + }
2700 + close(la_files)
2701 +
2702 + # Do the actual changes in a second loop, as we can then
2703 + # verify that CHOST_CHANGED among things is correct ...
2704 + if (CHANGED) {
2705 + ewarnn(" FIXING: " la_files " ...[")
2706 +
2707 + # Clear the temp file (removing rather than '>foo' is better
2708 + # out of a security point of view?)
2709 + dosystem("rm -f " la_files ".new")
2710 +
2711 + while ((getline la_data < (la_files)) > 0) {
2712 + if (OLDCHOST != "") {
2713 + tmpstr = gensub(OLDGCCLIB1 "([/[:space:]]+)",
2714 + GCCLIB "\\1", "g", la_data)
2715 + tmpstr = gensub(OLDGCCLIB2 "([/[:space:]]+)",
2716 + GCCLIB "\\1", "g", tmpstr)
2717 +
2718 + if (la_data != tmpstr) {
2719 + printn("c")
2720 + la_data = tmpstr
2721 + }
2722 +
2723 + if (CHOST_CHANGED > 0) {
2724 + # We try to be careful about CHOST changes outside
2725 + # the gcc library path (meaning we cannot match it
2726 + # via /GCCLIBPREFIX CHOST/) ...
2727 +
2728 + # Catch:
2729 + #
2730 + # dependency_libs=' -L/usr/CHOST/{bin,lib}'
2731 + #
2732 + gsub("-L/usr/" OLDCHOST "/",
2733 + "-L/usr/" CHOST "/", la_data)
2734 + # Catch:
2735 + #
2736 + # dependency_libs=' -L/usr/lib/gcc-lib/CHOST/VER/../../../../CHOST/lib'
2737 + #
2738 + la_data = gensub("(" GCCLIB "/[^[:space:]]+)/" OLDCHOST "/",
2739 + "\\1/" CHOST "/", "g", la_data)
2740 + }
2741 + }
2742 +
2743 + if (OLDVER != NEWVER) {
2744 + # Catch:
2745 + #
2746 + # dependency_libs=' -L/usr/lib/gcc/CHOST/VER'
2747 + #
2748 + tmpstr = gensub(GCCLIBPREFIX_OLD CHOST "/" OLDVER "([/[:space:]]+)",
2749 + GCCLIB "/" NEWVER "\\1", "g", la_data)
2750 + tmpstr = gensub(GCCLIBPREFIX_NEW CHOST "/" OLDVER "([/[:space:]]+)",
2751 + GCCLIB "/" NEWVER "\\1", "g", tmpstr)
2752 +
2753 + if (la_data != tmpstr) {
2754 + # Catch:
2755 + #
2756 + # dependency_libs=' -L/usr/lib/gcc-lib/../../CHOST/lib'
2757 + #
2758 + # in cases where we have gcc34
2759 + tmpstr = gensub(GCCLIBPREFIX_OLD "(../../" CHOST "/lib)",
2760 + GCCLIBPREFIX "\\1", "g", tmpstr)
2761 + tmpstr = gensub(GCCLIBPREFIX_NEW "(../../" CHOST "/lib)",
2762 + GCCLIBPREFIX "\\1", "g", tmpstr)
2763 + printn("v")
2764 + la_data = tmpstr
2765 + }
2766 + }
2767 +
2768 + # We now check if we have libstdc++.la, as we remove the
2769 + # libtool linker scripts for gcc and any referencese in any
2770 + # libtool linker scripts.
2771 + # We do this last, as we only match the new paths
2772 + tmpstr = gensub(GCCLIB "/" NEWVER "/libstdc\\+\\+\\.la",
2773 + "-lstdc++", "g", la_data);
2774 + if (la_data != tmpstr) {
2775 + printn("l")
2776 + la_data = tmpstr
2777 + }
2778 +
2779 + print la_data >> (la_files ".new")
2780 + }
2781 +
2782 + if (CHANGED)
2783 + print "]"
2784 +
2785 + close(la_files)
2786 + close(la_files ".new")
2787 +
2788 + assert(dosystem("mv -f " la_files ".new " la_files),
2789 + "dosystem(\"mv -f " la_files ".new " la_files "\")")
2790 + }
2791 + }
2792 +
2793 + close(pipe)
2794 + }
2795 +}
2796 +
2797 +# vim:ts=4
2798
2799 diff --git a/sys-devel/gcc/files/c89 b/sys-devel/gcc/files/c89
2800 new file mode 100755
2801 index 0000000..cee0325
2802 --- /dev/null
2803 +++ b/sys-devel/gcc/files/c89
2804 @@ -0,0 +1,20 @@
2805 +#! /bin/sh
2806 +
2807 +# Call the appropriate C compiler with options to accept ANSI/ISO C
2808 +# The following options are the same (as of gcc-2.95):
2809 +# -ansi
2810 +# -std=c89
2811 +# -std=iso9899:1990
2812 +
2813 +for i; do
2814 + case "$i" in
2815 + -ansi|-std=c89|-std=iso9899:1990)
2816 + ;;
2817 + -std=*)
2818 + echo >&2 "`basename $0` called with non ANSI/ISO C90 option $i"
2819 + exit 1
2820 + ;;
2821 + esac
2822 +done
2823 +
2824 +exec gcc -std=c89 -pedantic -U_FORTIFY_SOURCE "$@"
2825
2826 diff --git a/sys-devel/gcc/files/c99 b/sys-devel/gcc/files/c99
2827 new file mode 100755
2828 index 0000000..c954209
2829 --- /dev/null
2830 +++ b/sys-devel/gcc/files/c99
2831 @@ -0,0 +1,21 @@
2832 +#! /bin/sh
2833 +
2834 +# Call the appropriate C compiler with options to accept ANSI/ISO C
2835 +# The following options are the same (as of gcc-3.3):
2836 +# -std=c99
2837 +# -std=c9x
2838 +# -std=iso9899:1999
2839 +# -std=iso9899:199x
2840 +
2841 +for i; do
2842 + case "$i" in
2843 + -std=c9[9x]|-std=iso9899:199[9x])
2844 + ;;
2845 + -ansi|-std=*)
2846 + echo >&2 "`basename $0` called with non ANSI/ISO C99 option $i"
2847 + exit 1
2848 + ;;
2849 + esac
2850 +done
2851 +
2852 +exec gcc -std=c99 -pedantic -U_FORTIFY_SOURCE ${1+"$@"}
2853
2854 diff --git a/sys-devel/gcc/files/fix_libtool_files.sh b/sys-devel/gcc/files/fix_libtool_files.sh
2855 new file mode 100644
2856 index 0000000..c55250b
2857 --- /dev/null
2858 +++ b/sys-devel/gcc/files/fix_libtool_files.sh
2859 @@ -0,0 +1,68 @@
2860 +#!/bin/sh
2861 +# Copyright 1999-2012 Gentoo Foundation
2862 +# Distributed under the terms of the GNU General Public License v2
2863 +# $Header: /var/cvsroot/gentoo-x86/sys-devel/gcc/files/fix_libtool_files.sh,v 1.16 2012/05/18 21:28:56 vapier Exp $
2864 +
2865 +usage() {
2866 +cat << "USAGE_END"
2867 +Usage: fix_libtool_files.sh <old-gcc-version> [--oldarch <old-CHOST>]
2868 +
2869 + Where <old-gcc-version> is the version number of the
2870 + previous gcc version. For example, if you updated to
2871 + gcc-3.2.1, and you had gcc-3.2 installed, run:
2872 +
2873 + # fix_libtool_files.sh 3.2
2874 +
2875 + If you updated to gcc-3.2.3, and the old CHOST was i586-pc-linux-gnu
2876 + but you now have CHOST as i686-pc-linux-gnu, run:
2877 +
2878 + # fix_libtool_files.sh 3.2 --oldarch i586-pc-linux-gnu
2879 +
2880 + Note that if only the CHOST and not the version changed, you can run
2881 + it with the current version and the '--oldarch <old-CHOST>' arguments,
2882 + and it will do the expected:
2883 +
2884 + # fix_libtool_files.sh `gcc -dumpversion` --oldarch i586-pc-linux-gnu
2885 +
2886 +USAGE_END
2887 + exit 1
2888 +}
2889 +
2890 +case $2 in
2891 +--oldarch) [ $# -ne 3 ] && usage ;;
2892 +*) [ $# -ne 1 ] && usage ;;
2893 +esac
2894 +
2895 +ARGV1=$1
2896 +ARGV2=$2
2897 +ARGV3=$3
2898 +
2899 +. /etc/profile || exit 1
2900 +. /etc/init.d/functions.sh || exit 1
2901 +
2902 +if [ ${EUID:-0} -ne 0 ] ; then
2903 + eerror "${0##*/}: Must be root."
2904 + exit 1
2905 +fi
2906 +
2907 +# make sure the files come out sane
2908 +umask 0022
2909 +
2910 +OLDCHOST=
2911 +[ "${ARGV2}" = "--oldarch" ] && OLDCHOST=${ARGV3}
2912 +
2913 +AWKDIR="/usr/share/gcc-data"
2914 +
2915 +if [ ! -r "${AWKDIR}/fixlafiles.awk" ] ; then
2916 + eerror "${0##*/}: ${AWKDIR}/fixlafiles.awk does not exist!"
2917 + exit 1
2918 +fi
2919 +
2920 +OLDVER=${ARGV1}
2921 +
2922 +export OLDVER OLDCHOST
2923 +
2924 +einfo "Scanning libtool files for hardcoded gcc library paths..."
2925 +exec gawk -f "${AWKDIR}/fixlafiles.awk"
2926 +
2927 +# vim:ts=4
2928
2929 diff --git a/sys-devel/gcc/files/gcc-configure-LANG.patch b/sys-devel/gcc/files/gcc-configure-LANG.patch
2930 new file mode 100644
2931 index 0000000..d1b1b03
2932 --- /dev/null
2933 +++ b/sys-devel/gcc/files/gcc-configure-LANG.patch
2934 @@ -0,0 +1,64 @@
2935 +The LANG vars aren't reset early enough so when sed tries to use [a-zA-Z] in
2936 +option parsing, it may break.
2937 +
2938 +http://bugs.gentoo.org/103483
2939 +
2940 +--- configure
2941 ++++ configure
2942 +@@ -54,6 +54,19 @@
2943 + infodir='${prefix}/info'
2944 + mandir='${prefix}/man'
2945 +
2946 ++# NLS nuisances.
2947 ++for as_var in \
2948 ++ LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \
2949 ++ LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \
2950 ++ LC_TELEPHONE LC_TIME
2951 ++do
2952 ++ if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then
2953 ++ eval $as_var=C; export $as_var
2954 ++ else
2955 ++ unset $as_var
2956 ++ fi
2957 ++done
2958 ++
2959 + # Initialize some other variables.
2960 + subdirs=
2961 + MFLAGS= MAKEFLAGS=
2962 +@@ -452,16 +463,6 @@
2963 + esac
2964 + done
2965 +
2966 +-# NLS nuisances.
2967 +-# Only set these to C if already set. These must not be set unconditionally
2968 +-# because not all systems understand e.g. LANG=C (notably SCO).
2969 +-# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'!
2970 +-# Non-C LC_CTYPE values break the ctype check.
2971 +-if test "${LANG+set}" = set; then LANG=C; export LANG; fi
2972 +-if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi
2973 +-if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi
2974 +-if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi
2975 +-
2976 + # confdefs.h avoids OS command line length limits that DEFS can exceed.
2977 + rm -rf conftest* confdefs.h
2978 + # AIX cpp loses on an empty file, so make sure it contains at least a newline.
2979 +@@ -1850,6 +1850,19 @@
2980 + # Compiler output produced by configure, useful for debugging
2981 + # configure, is in ./config.log if it exists.
2982 +
2983 ++# NLS nuisances.
2984 ++for as_var in \
2985 ++ LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \
2986 ++ LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \
2987 ++ LC_TELEPHONE LC_TIME
2988 ++do
2989 ++ if (set +x; test -z "`(eval \$as_var=C; export \$as_var) 2>&1`"); then
2990 ++ eval \$as_var=C; export \$as_var
2991 ++ else
2992 ++ unset \$as_var
2993 ++ fi
2994 ++done
2995 ++
2996 + ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]"
2997 + for ac_option
2998 + do
2999
3000 diff --git a/sys-devel/gcc/files/gcc-configure-texinfo.patch b/sys-devel/gcc/files/gcc-configure-texinfo.patch
3001 new file mode 100644
3002 index 0000000..ddc098d
3003 --- /dev/null
3004 +++ b/sys-devel/gcc/files/gcc-configure-texinfo.patch
3005 @@ -0,0 +1,16 @@
3006 +Chances are quite good that the installed makeinfo is sufficient.
3007 +So ignore false positives where the makeinfo installed is so new
3008 +that it violates the cheesy version grep.
3009 +
3010 +http://bugs.gentoo.org/198182
3011 +
3012 +--- configure
3013 ++++ configure
3014 +@@ -3573,6 +3573,6 @@
3015 + :
3016 + else
3017 +- MAKEINFO="$MISSING makeinfo"
3018 ++ :
3019 + fi
3020 + ;;
3021 +
3022
3023 diff --git a/sys-devel/gcc/files/gcc-spec-env-r1.patch b/sys-devel/gcc/files/gcc-spec-env-r1.patch
3024 new file mode 100644
3025 index 0000000..a589268
3026 --- /dev/null
3027 +++ b/sys-devel/gcc/files/gcc-spec-env-r1.patch
3028 @@ -0,0 +1,87 @@
3029 +2013-08-22 Magnus Granberg <zorry@g.o>
3030 +
3031 + * gcc/gcc.c (main): Add support for external spec file via the GCC_SPECS env var
3032 + and move the process of the user specifed specs.
3033 +
3034 + This allows us to easily control pie/ssp defaults with gcc-config profiles.
3035 + Original patch by Rob Holland
3036 + Extended to support multiple entries separated by ':' by Kevin F. Quinn
3037 + Modified to use getenv instead of poisoned GET_ENVIRONMENT by Ryan Hill
3038 + Modified to process the GCC_SPECS env var befor DRIVER_SELF_SPECS by Magnus Granberg
3039 +
3040 +--- gcc-4.8-20130210/gcc/gcc.c 2013-02-05 16:55:31.000000000 +0100
3041 ++++ gcc-4.8-20130210-work/gcc/gcc.c 2013-07-26 02:32:14.625089864 +0200
3042 +@@ -6427,6 +6428,48 @@ main (int argc, char **argv)
3043 + do_option_spec (option_default_specs[i].name,
3044 + option_default_specs[i].spec);
3045 +
3046 ++#if !(defined (__MSDOS__) || defined (OS2) || defined (VMS) || defined (WIN32))
3047 ++ /* Add specs listed in GCC_SPECS. Note; in the process of separating
3048 ++ * each spec listed, the string is overwritten at token boundaries
3049 ++ * (':') with '\0', an effect of strtok_r().
3050 ++ */
3051 ++ specs_file = getenv ("GCC_SPECS");
3052 ++ if (specs_file && (strlen(specs_file) > 0))
3053 ++ {
3054 ++ char *spec, *saveptr;
3055 ++ for (spec=strtok_r(specs_file,":",&saveptr);
3056 ++ spec!=NULL;
3057 ++ spec=strtok_r(NULL,":",&saveptr))
3058 ++ {
3059 ++ struct user_specs *user = (struct user_specs *)
3060 ++ xmalloc (sizeof (struct user_specs));
3061 ++ user->next = (struct user_specs *) 0;
3062 ++ user->filename = spec;
3063 ++ if (user_specs_tail)
3064 ++ user_specs_tail->next = user;
3065 ++ else
3066 ++ user_specs_head = user;
3067 ++ user_specs_tail = user;
3068 ++ }
3069 ++ }
3070 ++#endif
3071 ++ /* Process any user specified specs in the order given on the command
3072 ++ * line. */
3073 ++ for (uptr = user_specs_head; uptr; uptr = uptr->next)
3074 ++ {
3075 ++ char *filename = find_a_file (&startfile_prefixes, uptr->filename,
3076 ++ R_OK, true);
3077 ++ read_specs (filename ? filename : uptr->filename, false, true);
3078 ++ }
3079 ++ /* Process any user self specs. */
3080 ++ {
3081 ++ struct spec_list *sl;
3082 ++ for (sl = specs; sl; sl = sl->next)
3083 ++ if (sl->name_len == sizeof "self_spec" - 1
3084 ++ && !strcmp (sl->name, "self_spec"))
3085 ++ do_self_spec (*sl->ptr_spec);
3086 ++ }
3087 ++
3088 + /* Process DRIVER_SELF_SPECS, adding any new options to the end
3089 + of the command line. */
3090 +
3091 +@@ -6535,24 +6578,6 @@ main (int argc, char **argv)
3092 + PREFIX_PRIORITY_LAST, 0, 1);
3093 + }
3094 +
3095 +- /* Process any user specified specs in the order given on the command
3096 +- line. */
3097 +- for (uptr = user_specs_head; uptr; uptr = uptr->next)
3098 +- {
3099 +- char *filename = find_a_file (&startfile_prefixes, uptr->filename,
3100 +- R_OK, true);
3101 +- read_specs (filename ? filename : uptr->filename, false, true);
3102 +- }
3103 +-
3104 +- /* Process any user self specs. */
3105 +- {
3106 +- struct spec_list *sl;
3107 +- for (sl = specs; sl; sl = sl->next)
3108 +- if (sl->name_len == sizeof "self_spec" - 1
3109 +- && !strcmp (sl->name, "self_spec"))
3110 +- do_self_spec (*sl->ptr_spec);
3111 +- }
3112 +-
3113 + if (compare_debug)
3114 + {
3115 + enum save_temps save;
3116
3117 diff --git a/sys-devel/gcc/files/gcc-spec-env.patch b/sys-devel/gcc/files/gcc-spec-env.patch
3118 new file mode 100644
3119 index 0000000..57e7567
3120 --- /dev/null
3121 +++ b/sys-devel/gcc/files/gcc-spec-env.patch
3122 @@ -0,0 +1,42 @@
3123 + Add support for external spec file via the GCC_SPECS env var. This
3124 + allows us to easily control pie/ssp defaults with gcc-config profiles.
3125 +
3126 + Original patch by Rob Holland
3127 + Extended to support multiple entries separated by ':' by Kevin F. Quinn
3128 + Modified to use getenv instead of poisoned GET_ENVIRONMENT by Ryan Hill
3129 +
3130 +--- gcc-4/gcc/gcc.c
3131 ++++ gcc-4/gcc/gcc.c
3132 +@@ -6482,6 +6482,32 @@
3133 +
3134 + /* Process any user specified specs in the order given on the command
3135 + line. */
3136 ++#if !(defined (__MSDOS__) || defined (OS2) || defined (VMS) || defined (WIN32))
3137 ++ /* Add specs listed in GCC_SPECS. Note; in the process of separating
3138 ++ * each spec listed, the string is overwritten at token boundaries
3139 ++ * (':') with '\0', an effect of strtok_r().
3140 ++ */
3141 ++ specs_file = getenv ("GCC_SPECS");
3142 ++ if (specs_file && (strlen(specs_file) > 0))
3143 ++ {
3144 ++ char *spec, *saveptr;
3145 ++ for (spec=strtok_r(specs_file,":",&saveptr);
3146 ++ spec!=NULL;
3147 ++ spec=strtok_r(NULL,":",&saveptr))
3148 ++ {
3149 ++ struct user_specs *user = (struct user_specs *)
3150 ++ xmalloc (sizeof (struct user_specs));
3151 ++
3152 ++ user->next = (struct user_specs *) 0;
3153 ++ user->filename = spec;
3154 ++ if (user_specs_tail)
3155 ++ user_specs_tail->next = user;
3156 ++ else
3157 ++ user_specs_head = user;
3158 ++ user_specs_tail = user;
3159 ++ }
3160 ++ }
3161 ++#endif
3162 + for (uptr = user_specs_head; uptr; uptr = uptr->next)
3163 + {
3164 + char *filename = find_a_file (&startfile_prefixes, uptr->filename,
3165
3166 diff --git a/sys-devel/gcc/files/mkinfodir b/sys-devel/gcc/files/mkinfodir
3167 new file mode 100644
3168 index 0000000..a62840e
3169 --- /dev/null
3170 +++ b/sys-devel/gcc/files/mkinfodir
3171 @@ -0,0 +1,233 @@
3172 +#!/bin/bash
3173 +# $Id: mkinfodir,v 1.1 2001/09/01 07:56:19 drobbins Exp $
3174 +# Generate the top-level Info node, given a directory of Info files
3175 +# and (optionally) a skeleton file. The output will be suitable for a
3176 +# top-level dir file. The skeleton file contains info topic names in the
3177 +# order they should appear in the output. There are three special
3178 +# lines that alter the behavior: a line consisting of just "--" causes
3179 +# the next line to be echoed verbatim to the output. A line
3180 +# containing just "%%" causes all the remaining filenames (wildcards
3181 +# allowed) in the rest of the file to be ignored. A line containing
3182 +# just "!!" exits the script when reached (unless preceded by a line
3183 +# containing just "--"). Once the script reaches the end of the
3184 +# skeleton file, it goes through the remaining files in the directory
3185 +# in order, putting their entries at the end. The script will use the
3186 +# ENTRY information in each info file if it exists. Otherwise it will
3187 +# make a minimal entry.
3188 +
3189 +# sent by Jeffrey Osier <jeffrey@××××××.com>, who thinks it came from
3190 +# zoo@×××××××××.com (david d `zoo' zuhn)
3191 +
3192 +# modified 7 April 1995 by Joe Harrington <jh@××××××××××××××××.gov> to
3193 +# take special flags
3194 +
3195 +INFODIR=$1
3196 +if [ $# = 2 ] ; then
3197 + SKELETON=$2
3198 +else
3199 + SKELETON=/dev/null
3200 +fi
3201 +
3202 +skip=
3203 +
3204 +if [ $# -gt 2 ] ; then
3205 + echo usage: $0 info-directory [ skeleton-file ] 1>&2
3206 + exit 1
3207 +elif [ -z "${INFODIR}" ] ; then
3208 + INFODIR="%%DEFAULT_INFO_DIR%%"
3209 +else
3210 + true
3211 +fi
3212 +
3213 +if [ ! -d ${INFODIR} ] ; then
3214 + echo "$0: first argument must specify a directory"
3215 + exit 1
3216 +fi
3217 +
3218 +### output the dir header
3219 +echo "-*- Text -*-"
3220 +echo "This file was generated automatically by $0."
3221 +echo "This version was generated on `date`"
3222 +echo "by `whoami`@`hostname` for `(cd ${INFODIR}; pwd)`"
3223 +
3224 +cat << moobler
3225 +\$Id: mkinfodir,v 1.1 2001/09/01 07:56:19 drobbins Exp $
3226 +This is the file .../info/dir, which contains the topmost node of the
3227 +Info hierarchy. The first time you invoke Info you start off
3228 +looking at that node, which is (dir)Top.
3229 +
3230 +File: dir Node: Top This is the top of the INFO tree
3231 +
3232 + This (the Directory node) gives a menu of major topics.
3233 + Typing "q" exits, "?" lists all Info commands, "d" returns here,
3234 + "h" gives a primer for first-timers,
3235 + "mEmacs<Return>" visits the Emacs topic, etc.
3236 +
3237 + In Emacs, you can click mouse button 2 on a menu item or cross reference
3238 + to select it.
3239 +
3240 +* Menu: The list of major topics begins on the next line.
3241 +
3242 +moobler
3243 +
3244 +### go through the list of files in the skeleton. If an info file
3245 +### exists, grab the ENTRY information from it. If an entry exists
3246 +### use it, otherwise create a minimal dir entry.
3247 +###
3248 +### Then remove that file from the list of existing files. If any
3249 +### additional files remain (ones that don't have a skeleton entry),
3250 +### then generate entries for those in the same way, putting the info for
3251 +### those at the end....
3252 +
3253 +infofiles=`(cd ${INFODIR}; /bin/ls | grep -v '\-[0-9]*\.gz$' | grep -v '\-[0-9]*$' | egrep -v '^dir$|^dir\.info$|^dir\.orig$')`
3254 +
3255 +# echoing gets clobbered by backquotes; we do it the hard way...
3256 +lines=`wc $SKELETON | awk '{print $1}'`
3257 +line=1
3258 +while [ $lines -ge $line ] ; do
3259 + # Read one line from the file. This is so that we can echo lines with
3260 + # whitespace and quoted characters in them.
3261 + fileline=`awk NR==$line $SKELETON`
3262 +
3263 + # flag fancy features
3264 + if [ ! -z "$echoline" ] ; then # echo line
3265 + echo "$fileline"
3266 + fileline=
3267 + echoline=
3268 + elif [ "${fileline}" = "--" ] ; then # should we echo the next line?
3269 + echoline=1
3270 + elif [ "${fileline}" = "%%" ] ; then # eliminate remaining files from dir?
3271 + skip=1
3272 + elif [ "${fileline}" = "!!" ] ; then # quit now
3273 + exit 0
3274 + fi
3275 +
3276 + # handle files if they exist
3277 + for file in $fileline"" ; do # expand wildcards ("" handles blank lines)
3278 +
3279 + fname=
3280 +
3281 + if [ -z "$echoline" -a ! -z "$file" ] ; then
3282 +
3283 + # Find the file to operate upon. Check both possible names.
3284 + infoname=`echo $file | sed 's/\.gz$//'`
3285 + infoname=`echo $infoname | sed 's/\.info$//'`
3286 + noext=
3287 + ext=
3288 + if [ -f ${INFODIR}/$infoname ] ; then
3289 + noext=$infoname
3290 + fi
3291 + if [ -f ${INFODIR}/${infoname}.info ] ; then
3292 + ext=${infoname}.info
3293 + fi
3294 + if [ -f ${INFODIR}/${infoname}.info.gz ] ; then
3295 + ext=${infoname}.info.gz
3296 + fi
3297 + # If it exists with both names take what was said in the file.
3298 + if [ ! -z "$ext" -a ! -z "$noext" ]; then
3299 + fname=$file
3300 + warn="### Warning: $ext and $noext both exist! Using ${file}. ###"
3301 + elif [ ! \( -z "$ext" -a -z "$noext" \) ]; then
3302 + # just take the name if it exists only once
3303 + fname=${noext}${ext}
3304 + fi
3305 +
3306 + # if we found something and aren't skipping, do the entry
3307 + if [ ! -z "$fname" ] ; then
3308 + if [ -z "$skip" ] ; then
3309 +
3310 + if [ ! -z "$warn" ] ; then # issue any warning
3311 + echo $warn
3312 + warn=
3313 + fi
3314 + if [ "${fname##*.}" = "gz" ] ; then
3315 + entry=`zcat ${INFODIR}/${fname} | sed -e '1,/START-INFO-DIR-ENTRY/d' \
3316 + -e '/END-INFO-DIR-ENTRY/,$d' `
3317 + else
3318 + entry=`sed -e '1,/START-INFO-DIR-ENTRY/d' \
3319 + -e '/END-INFO-DIR-ENTRY/,$d' ${INFODIR}/$fname`
3320 + fi
3321 + if [ ! -z "${entry}" ] ; then
3322 + echo "${entry}"
3323 + else
3324 + echo "* ${infoname}: (${infoname})."
3325 + fi
3326 + fi
3327 +
3328 + # remove the name from the directory listing
3329 + infofiles=`echo "" ${infofiles} "" | sed -e "s/ ${fname} / /" -e "s/ / /g"`
3330 +
3331 + fi
3332 +
3333 + fi
3334 +
3335 + done
3336 +
3337 + line=`expr $line + 1`
3338 +done
3339 +
3340 +if [ -z "${infofiles}" ] ; then
3341 + exit 0
3342 +elif [ $lines -gt 0 ]; then
3343 + echo
3344 +fi
3345 +
3346 +# Sort remaining files by INFO-DIR-SECTION.
3347 +prevsect=
3348 +filesectdata=`(cd ${INFODIR}; fgrep INFO-DIR-SECTION /dev/null ${infofiles} | \
3349 + fgrep -v 'INFO-DIR-SECTION Miscellaneous' | \
3350 + sort -t: -k2 -k1 | tr ' ' '_')`
3351 +for sectdata in ${filesectdata}; do
3352 + file=`echo ${sectdata} | cut -d: -f1`
3353 + section=`sed -n -e 's/^INFO-DIR-SECTION //p' ${INFODIR}/${file}`
3354 + infofiles=`echo "" ${infofiles} "" | sed -e "s/ ${file} / /" -e "s/ / /g"`
3355 +
3356 + if [ "${prevsect}" != "${section}" ] ; then
3357 + if [ ! -z "${prevsect}" ] ; then
3358 + echo ""
3359 + fi
3360 + echo "${section}"
3361 + prevsect="${section}"
3362 + fi
3363 + infoname=`echo $file | sed 's/\.gz$//'`
3364 + infoname=`echo $infoname | sed 's/\.info$//'`
3365 + if [ "${file##*.}" = "gz" ] ; then
3366 + entry=`zcat ${INFODIR}/$file | sed -e '1,/START-INFO-DIR-ENTRY/d' \
3367 + -e '/END-INFO-DIR-ENTRY/,$d' `
3368 + else
3369 + entry=`sed -e '1,/START-INFO-DIR-ENTRY/d' \
3370 + -e '/END-INFO-DIR-ENTRY/,$d' ${INFODIR}/$file`
3371 + fi
3372 + if [ ! -z "${entry}" ] ; then
3373 + echo "${entry}"
3374 + elif [ ! -d "${INFODIR}/${file}" ] ; then
3375 + echo "* ${infoname}: (${infoname})."
3376 + fi
3377 +done
3378 +
3379 +# Process miscellaneous files.
3380 +for file in ${infofiles}; do
3381 + if [ ! -z "${prevsect}" ] ; then
3382 + echo ""
3383 + echo "Miscellaneous"
3384 + prevsect=""
3385 + fi
3386 +
3387 + infoname=`echo $file | sed 's/\.gz$//'`
3388 + infoname=`echo $infoname | sed 's/\.info$//'`
3389 + if [ "${file##*.}" = "gz" ] ; then
3390 + entry=`zcat ${INFODIR}/${file} | sed -e '1,/START-INFO-DIR-ENTRY/d' \
3391 + -e '/END-INFO-DIR-ENTRY/,$d'`
3392 + else
3393 + entry=`sed -e '1,/START-INFO-DIR-ENTRY/d' \
3394 + -e '/END-INFO-DIR-ENTRY/,$d' ${INFODIR}/$file`
3395 + fi
3396 +
3397 +
3398 + if [ ! -z "${entry}" ] ; then
3399 + echo "${entry}"
3400 + elif [ ! -d "${INFODIR}/${file}" ] ; then
3401 + echo "* ${infoname}: (${infoname})."
3402 + fi
3403 +done
3404 +
3405
3406 diff --git a/sys-devel/gcc/gcc-4.8.2-r1.ebuild b/sys-devel/gcc/gcc-4.8.2-r1.ebuild
3407 new file mode 100644
3408 index 0000000..8a41c30
3409 --- /dev/null
3410 +++ b/sys-devel/gcc/gcc-4.8.2-r1.ebuild
3411 @@ -0,0 +1,50 @@
3412 +# Copyright 1999-2013 Gentoo Foundation
3413 +# Distributed under the terms of the GNU General Public License v2
3414 +# $Header: /var/cvsroot/gentoo-x86/sys-devel/gcc/gcc-4.8.2.ebuild,v 1.3 2013/12/30 01:24:06 dirtyepic Exp $
3415 +
3416 +PATCH_VER="1.3"
3417 +UCLIBC_VER="1.0"
3418 +
3419 +# Hardened gcc 4 stuff
3420 +PIE_VER="0.5.9"
3421 +SPECS_VER="0.2.0"
3422 +SPECS_GCC_VER="4.4.3"
3423 +# arch/libc configurations known to be stable with {PIE,SSP}-by-default
3424 +PIE_GLIBC_STABLE="x86 amd64 mips ppc ppc64 arm ia64"
3425 +PIE_UCLIBC_STABLE="x86 arm amd64 mips ppc ppc64"
3426 +SSP_STABLE="amd64 x86 mips ppc ppc64 arm"
3427 +# uclibc need tls and nptl support for SSP support
3428 +# uclibc need to be >= 0.9.33
3429 +SSP_UCLIBC_STABLE="x86 amd64 mips ppc ppc64 arm"
3430 +#end Hardened stuff
3431 +
3432 +inherit toolchain
3433 +
3434 +DESCRIPTION="The GNU Compiler Collection"
3435 +
3436 +LICENSE="GPL-3+ LGPL-3+ || ( GPL-3+ libgcc libstdc++ gcc-runtime-library-exception-3.1 ) FDL-1.3+"
3437 +
3438 +KEYWORDS="~alpha ~amd64 ~arm ~hppa ~mips ~x86 ~amd64-fbsd ~x86-fbsd"
3439 +
3440 +RDEPEND=""
3441 +DEPEND="${RDEPEND}
3442 + elibc_glibc? ( >=sys-libs/glibc-2.8 )
3443 + >=${CATEGORY}/binutils-2.20"
3444 +
3445 +if [[ ${CATEGORY} != cross-* ]] ; then
3446 + PDEPEND="${PDEPEND} elibc_glibc? ( >=sys-libs/glibc-2.8 )"
3447 +fi
3448 +
3449 +src_unpack() {
3450 + if has_version '<sys-libs/glibc-2.12' ; then
3451 + ewarn "Your host glibc is too old; disabling automatic fortify."
3452 + ewarn "Please rebuild gcc after upgrading to >=glibc-2.12 #362315"
3453 + EPATCH_EXCLUDE+=" 10_all_default-fortify-source.patch"
3454 + fi
3455 +
3456 + toolchain_src_unpack
3457 +
3458 + use vanilla && return 0
3459 + #Use -r1 for newer piepatchet that use DRIVER_SELF_SPECS for the hardened specs.
3460 + [[ ${CHOST} == ${CTARGET} ]] && epatch "${FILESDIR}"/gcc-spec-env-r1.patch
3461 +}
3462
3463 diff --git a/sys-devel/gcc/metadata.xml b/sys-devel/gcc/metadata.xml
3464 new file mode 100644
3465 index 0000000..cc0d5da
3466 --- /dev/null
3467 +++ b/sys-devel/gcc/metadata.xml
3468 @@ -0,0 +1,33 @@
3469 +<?xml version="1.0" encoding="UTF-8"?>
3470 +<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
3471 +<pkgmetadata>
3472 + <herd>toolchain</herd>
3473 + <use>
3474 + <flag name="awt">Useful only when building GCJ, this enables Abstract Window Toolkit
3475 + (AWT) peer support on top of GTK+</flag>
3476 + <flag name="d">Enable support for the D programming language</flag>
3477 + <flag name="fixed-point">Enable fixed-point arithmetic support for MIPS targets
3478 + in gcc (Warning: significantly increases compile time!)</flag>
3479 + <flag name="go">Build the GCC Go language frontend.</flag>
3480 + <flag name="graphite">Add support for the framework for loop
3481 + optimizations based on a polyhedral intermediate representation</flag>
3482 + <flag name="ip28">Enable building a compiler capable of building a kernel
3483 + for SGI Indigo2 Impact R10000 (IP28)</flag>
3484 + <flag name="ip32r10k">Enable building a compiler capable of building an
3485 + experimental kernel for SGI O2 w/ R1x000 CPUs (IP32)</flag>
3486 + <flag name="libssp">Build SSP support into a dedicated library rather than use the
3487 + code in the C library (DO NOT ENABLE THIS IF YOU DON'T KNOW WHAT IT DOES)</flag>
3488 + <flag name="mudflap">Add support for mudflap, a pointer use checking library</flag>
3489 + <flag name="multislot">Allow for SLOTs to include minor version (3.3.4
3490 + instead of just 3.3)</flag>
3491 + <flag name="n32">Enable n32 ABI support on mips</flag>
3492 + <flag name="n64">Enable n64 ABI support on mips</flag>
3493 + <flag name="nopie">Disable PIE support (NOT FOR GENERAL USE)</flag>
3494 + <flag name="nossp">Disable SSP support (NOT FOR GENERAL USE)</flag>
3495 + <flag name="objc">Build support for the Objective C code language</flag>
3496 + <flag name="objc++">Build support for the Objective C++ language</flag>
3497 + <flag name="objc-gc">Build support for the Objective C code language Garbage
3498 + Collector</flag>
3499 + <flag name="regression-test">Run the testsuite and install the results (requires FEATURES=test)</flag>
3500 + </use>
3501 +</pkgmetadata>