Gentoo Archives: gentoo-commits

From: Magnus Granberg <zorry@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/hardened-dev:testing commit in: /, eclass/
Date: Sat, 07 Apr 2012 19:15:36
Message-Id: 1333826091.7858d67c0b5c450b10ea0398a50cdf34055db997.zorry@gentoo
1 commit: 7858d67c0b5c450b10ea0398a50cdf34055db997
2 Author: Magnus Granberg <zorry <AT> gentoo <DOT> org>
3 AuthorDate: Sat Apr 7 19:14:51 2012 +0000
4 Commit: Magnus Granberg <zorry <AT> gentoo <DOT> org>
5 CommitDate: Sat Apr 7 19:14:51 2012 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/hardened-dev.git;a=commit;h=7858d67c
7
8 Updated the README
9
10 ---
11 README | 2 +-
12 eclass/toolchain2.eclass | 1705 ----------------------------------------------
13 2 files changed, 1 insertions(+), 1706 deletions(-)
14
15 diff --git a/README b/README
16 index e2a1079..3ef1e51 100644
17 --- a/README
18 +++ b/README
19 @@ -1,4 +1,4 @@
20 -2012-04-06 Magnus Granberg <zorry@g.o>
21 +2012-04-07 Magnus Granberg <zorry@g.o>
22 This overlay is for the work of gcc-4.8 upstream patches.
23
24
25
26 diff --git a/eclass/toolchain2.eclass b/eclass/toolchain2.eclass
27 deleted file mode 100644
28 index 41c5ffb..0000000
29 --- a/eclass/toolchain2.eclass
30 +++ /dev/null
31 @@ -1,1705 +0,0 @@
32 -# Copyright 1999-2012 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.532 2012/03/22 06:07:08 dirtyepic Exp $
35 -
36 -#---->> eclass stuff <<----
37 -HOMEPAGE="http://gcc.gnu.org/"
38 -LICENSE="GPL-2 LGPL-2.1"
39 -RESTRICT="strip" # cross-compilers need controlled stripping
40 -
41 -inherit eutils versionator libtool toolchain-funcs flag-o-matic gnuconfig multilib fixheadtails pax-utils
42 -
43 -f [[ ${PV} == *_pre9999* ]] ; then
44 - EGIT_REPO_URI="git://gcc.gnu.org/git/gcc.git"
45 - # naming style:
46 - # gcc-4.7.1_pre9999 -> gcc-4_7-branch
47 - # Note that the micro version is required or lots of stuff will break.
48 - # To checkout master set gcc_LIVE_BRANCH="master" in the ebuild before
49 - # inheriting this eclass.
50 - EGIT_BRANCH="${PN}-${PV%.?_pre9999}-branch"
51 - EGIT_BRANCH=${EGIT_BRANCH//./_}
52 - inherit git-2
53 -fi
54 -
55 -EXPORT_FUNCTIONS pkg_setup src_unpack src_prepare src_configure src_compile src_test pkg_preinst src_install pkg_postinst pkg_prerm pkg_postrm
56 -DESCRIPTION="The GNU Compiler Collection"
57 -FEATURES=${FEATURES/multilib-strict/}
58 -#----<< eclass stuff >>----
59 -
60 -#---->> globals <<----
61 -export CTARGET=${CTARGET:-${CHOST}}
62 -if [[ ${CTARGET} = ${CHOST} ]] ; then
63 - if [[ ${CATEGORY/cross-} != ${CATEGORY} ]] ; then
64 - export CTARGET=${CATEGORY/cross-}
65 - fi
66 -fi
67 -is_crosscompile() {
68 - [[ ${CHOST} != ${CTARGET} ]]
69 -}
70 -
71 -tc_version_is_at_least() { version_is_at_least "$1" "${2:-${GCC_RELEASE_VER}}" ; }
72 -
73 -GCC_PV=${TOOLCHAIN_GCC_PV:-${PV}}
74 -GCC_PVR=${GCC_PV}
75 -[[ ${PR} != "r0" ]] && GCC_PVR=${GCC_PVR}-${PR}
76 -GCC_RELEASE_VER=$(get_version_component_range 1-3 ${GCC_PV})
77 -GCC_BRANCH_VER=$(get_version_component_range 1-2 ${GCC_PV})
78 -GCCMAJOR=$(get_version_component_range 1 ${GCC_PV})
79 -GCCMINOR=$(get_version_component_range 2 ${GCC_PV})
80 -GCCMICRO=$(get_version_component_range 3 ${GCC_PV})
81 -[[ ${BRANCH_UPDATE-notset} == "notset" ]] && BRANCH_UPDATE=$(get_version_component_range 4 ${GCC_PV})
82 -
83 -# According to gcc/c-cppbuiltin.c, GCC_CONFIG_VER MUST match this regex.
84 -# ([^0-9]*-)?[0-9]+[.][0-9]+([.][0-9]+)?([- ].*)?
85 -GCC_CONFIG_VER=${GCC_CONFIG_VER:-$(replace_version_separator 3 '-' ${GCC_PV})}
86 -
87 -# Pre-release support
88 -if [[ ${GCC_PV} != ${GCC_PV/_pre/-} ]] ; then
89 - PRERELEASE=${GCC_PV/_pre/-}
90 -fi
91 -# make _alpha and _beta ebuilds automatically use a snapshot
92 -if [[ ${GCC_PV} == *_alpha* ]] ; then
93 - SNAPSHOT=${GCC_BRANCH_VER}-${GCC_PV##*_alpha}
94 -elif [[ ${GCC_PV} == *_beta* ]] ; then
95 - SNAPSHOT=${GCC_BRANCH_VER}-${GCC_PV##*_beta}
96 -elif [[ ${GCC_PV} == *_rc* ]] ; then
97 - SNAPSHOT=${GCC_PV%_rc*}-RC-${GCC_PV##*_rc}
98 -fi
99 -export GCC_FILESDIR=${GCC_FILESDIR:-${FILESDIR}}
100 -
101 -PREFIX=${TOOLCHAIN_PREFIX:-/usr}
102 -
103 -LIBPATH=${TOOLCHAIN_LIBPATH:-${PREFIX}/lib/gcc/${CTARGET}/${GCC_CONFIG_VER}}
104 -
105 -INCLUDEPATH=${TOOLCHAIN_INCLUDEPATH:-${LIBPATH}/include}
106 -if is_crosscompile ; then
107 - BINPATH=${TOOLCHAIN_BINPATH:-${PREFIX}/${CHOST}/${CTARGET}/gcc-bin/${GCC_CONFIG_VER}}
108 -else
109 - BINPATH=${TOOLCHAIN_BINPATH:-${PREFIX}/${CTARGET}/gcc-bin/${GCC_CONFIG_VER}}
110 -fi
111 -DATAPATH=${TOOLCHAIN_DATAPATH:-${PREFIX}/share/gcc-data/${CTARGET}/${GCC_CONFIG_VER}}
112 -# Dont install in /usr/include/g++-v3/, but in gcc internal directory.
113 -# We will handle /usr/include/g++-v3/ with gcc-config ...
114 -STDCXX_INCDIR=${TOOLCHAIN_STDCXX_INCDIR:-${LIBPATH}/include/g++-v${GCC_BRANCH_VER/\.*/}}
115 -
116 -#----<< globals >>----
117 -
118 -#---->> SLOT+IUSE logic <<----
119 -IUSE="build multislot nls nptl test vanilla bootstrap doc gcj gtk hardened multilib objc objc-gc mudflap"
120 -IUSE+=" objc++ openmp fixed-point graphite ito go"
121 -
122 -if [[ ${PN} != "kgcc64" && ${PN} != gcc-* ]] ; then
123 - IUSE+=" altivec cxx fortran nocxx"
124 - [[ -n ${PIE_VER} ]] && IUSE+=" nopie"
125 - [[ -n ${HTB_VER} ]] && IUSE+=" boundschecking"
126 - [[ -n ${D_VER} ]] && IUSE+=" d"
127 - [[ -n ${SPECS_VER} ]] && IUSE+=" nossp"
128 -fi
129 -
130 -# Support upgrade paths here or people get pissed
131 -if use multislot ; then
132 - SLOT="${CTARGET}-${GCC_CONFIG_VER}"
133 -elif is_crosscompile; then
134 - SLOT="${CTARGET}-${GCC_BRANCH_VER}"
135 -else
136 - SLOT="${GCC_BRANCH_VER}"
137 -fi
138 -#----<< SLOT+IUSE logic >>----
139 -
140 -#---->> DEPEND <<----
141 -
142 -RDEPEND="sys-libs/zlib
143 - !build? (
144 - nls? ( sys-devel/gettext )
145 - )"
146 -RDEPEND+=" virtual/libiconv"
147 -RDEPEND+=" ${GMP_MPFR_DEPS}"
148 -in_iuse fortran && RDEPEND+=" fortran? ( ${GMP_MPFR_DEPS} )"
149 -RDEPEND+=" >=dev-libs/mpc-0.8.1"
150 -in_iuse lto && RDEPEND+=" lto? ( || ( >=dev-libs/elfutils-0.143 dev-libs/libelf ) )"
151 -
152 -if in_iuse graphite ; then
153 - RDEPEND+="
154 - graphite? (
155 - >=dev-libs/cloog-ppl-0.15.10
156 - >=dev-libs/ppl-0.11
157 - )"
158 -fi
159 -
160 -DEPEND="${RDEPEND}
161 - >=sys-apps/texinfo-4.8
162 - >=sys-devel/bison-1.875
163 - >=sys-devel/flex-2.5.4
164 - test? (
165 - >=dev-util/dejagnu-1.4.4
166 - >=sys-devel/autogen-5.5.4
167 - )"
168 -if in_iuse gcj ; then
169 - GCJ_GTK_DEPS="
170 - x11-libs/libXt
171 - x11-libs/libX11
172 - x11-libs/libXtst
173 - x11-proto/xproto
174 - x11-proto/xextproto
175 - =x11-libs/gtk+-2*"
176 - tc_version_is_at_least 3.4 && GCJ_GTK_DEPS+=" x11-libs/pango"
177 - GCJ_DEPS=">=media-libs/libart_lgpl-2.1"
178 - tc_version_is_at_least 4.2 && GCJ_DEPS+=" app-arch/zip app-arch/unzip"
179 - DEPEND+=" gcj? ( gtk? ( ${GCJ_GTK_DEPS} ) ${GCJ_DEPS} )"
180 -fi
181 -
182 -PDEPEND=">=sys-devel/gcc-config-1.5"
183 -
184 -#----<< DEPEND >>----
185 -
186 -#---->> S + SRC_URI essentials <<----
187 -
188 -# Set the source directory depending on whether we're using
189 -# a prerelease, snapshot, or release tarball.
190 -S=$(
191 - if [[ -n ${PRERELEASE} ]] ; then
192 - echo ${WORKDIR}/gcc-${PRERELEASE}
193 - elif [[ -n ${SNAPSHOT} ]] ; then
194 - echo ${WORKDIR}/gcc-${SNAPSHOT}
195 - else
196 - echo ${WORKDIR}/gcc-${GCC_RELEASE_VER}
197 - fi
198 -)
199 -
200 -# This function handles the basics of setting the SRC_URI for a gcc ebuild.
201 -# To use, set SRC_URI with:
202 -#
203 -# SRC_URI="$(get_gcc_src_uri)"
204 -#
205 -# Other than the variables normally set by portage, this function's behavior
206 -# can be altered by setting the following:
207 -#
208 -# SNAPSHOT
209 -# If set, this variable signals that we should be using a snapshot
210 -# of gcc from ftp://sources.redhat.com/pub/gcc/snapshots/. It is
211 -# expected to be in the format "YYYY-MM-DD". Note that if the ebuild
212 -# has a _pre suffix, this variable is ignored and the prerelease
213 -# tarball is used instead.
214 -#
215 -# BRANCH_UPDATE
216 -# If set, this variable signals that we should be using the main
217 -# release tarball (determined by ebuild version) and applying a
218 -# CVS branch update patch against it. The location of this branch
219 -# update patch is assumed to be in ${GENTOO_TOOLCHAIN_BASE_URI}.
220 -# Just like with SNAPSHOT, this variable is ignored if the ebuild
221 -# has a _pre suffix.
222 -#
223 -# PATCH_VER
224 -# PATCH_GCC_VER
225 -# This should be set to the version of the gentoo patch tarball.
226 -# The resulting filename of this tarball will be:
227 -# gcc-${PATCH_GCC_VER:-${GCC_RELEASE_VER}}-patches-${PATCH_VER}.tar.bz2
228 -#
229 -# PIE_VER
230 -# PIE_GCC_VER
231 -# These variables control patching in various updates for the logic
232 -# controlling Position Independant Executables. PIE_VER is expected
233 -# to be the version of this patch, and PIE_GCC_VER the gcc version of
234 -# the patch:
235 -# An example:
236 -# PIE_VER="8.7.6.5"
237 -# PIE_GCC_VER="3.4.0"
238 -# The resulting filename of this tarball will be:
239 -# gcc-${PIE_GCC_VER:-${GCC_RELEASE_VER}}-piepatches-v${PIE_VER}.tar.bz2
240 -#
241 -# SPECS_VER
242 -# SPECS_GCC_VER
243 -# This is for the minispecs files included in the hardened gcc-4.x
244 -# The specs files for hardenedno*, vanilla and for building the "specs" file.
245 -# SPECS_VER is expected to be the version of this patch, SPECS_GCC_VER
246 -# the gcc version of the patch.
247 -# An example:
248 -# SPECS_VER="8.7.6.5"
249 -# SPECS_GCC_VER="3.4.0"
250 -# The resulting filename of this tarball will be:
251 -# gcc-${SPECS_GCC_VER:-${GCC_RELEASE_VER}}-specs-${SPECS_VER}.tar.bz2
252 -#
253 -# HTB_VER
254 -# HTB_GCC_VER
255 -# These variables control whether or not an ebuild supports Herman
256 -# ten Brugge's bounds-checking patches. If you want to use a patch
257 -# for an older gcc version with a new gcc, make sure you set
258 -# HTB_GCC_VER to that version of gcc.
259 -#
260 -gentoo_urls() {
261 - local devspace="HTTP~vapier/dist/URI HTTP~dirtyepic/dist/URI
262 - HTTP~halcy0n/patches/URI HTTP~zorry/patches/gcc/URI"
263 - devspace=${devspace//HTTP/http:\/\/dev.gentoo.org\/}
264 - echo mirror://gentoo/$1 ${devspace//URI/$1}
265 -}
266 -
267 -get_gcc_src_uri() {
268 - export PATCH_GCC_VER=${PATCH_GCC_VER:-${GCC_RELEASE_VER}}
269 - export UCLIBC_GCC_VER=${UCLIBC_GCC_VER:-${PATCH_GCC_VER}}
270 - export PIE_GCC_VER=${PIE_GCC_VER:-${GCC_RELEASE_VER}}
271 - export HTB_GCC_VER=${HTB_GCC_VER:-${GCC_RELEASE_VER}}
272 - export SPECS_GCC_VER=${SPECS_GCC_VER:-${GCC_RELEASE_VER}}
273 -
274 - # Set where to download gcc itself depending on whether we're using a
275 - # prerelease, snapshot, or release tarball.
276 - if [[ -n ${PRERELEASE} ]] ; then
277 - GCC_SRC_URI="ftp://gcc.gnu.org/pub/gcc/prerelease-${PRERELEASE}/gcc-${PRERELEASE}.tar.bz2"
278 - elif [[ -n ${SNAPSHOT} ]] ; then
279 - GCC_SRC_URI="ftp://sources.redhat.com/pub/gcc/snapshots/${SNAPSHOT}/gcc-${SNAPSHOT}.tar.bz2"
280 - elif [[ ${PV} != *9999* ]] ; then
281 - GCC_SRC_URI="mirror://gnu/gcc/gcc-${GCC_PV}/gcc-${GCC_RELEASE_VER}.tar.bz2"
282 - # we want all branch updates to be against the main release
283 - [[ -n ${BRANCH_UPDATE} ]] && \
284 - GCC_SRC_URI+=" $(gentoo_urls gcc-${GCC_RELEASE_VER}-branch-update-${BRANCH_UPDATE}.patch.bz2)"
285 - fi
286 -
287 - [[ -n ${UCLIBC_VER} ]] && GCC_SRC_URI+=" $(gentoo_urls gcc-${UCLIBC_GCC_VER}-uclibc-patches-${UCLIBC_VER}.tar.bz2)"
288 - [[ -n ${PATCH_VER} ]] && GCC_SRC_URI+=" $(gentoo_urls gcc-${PATCH_GCC_VER}-patches-${PATCH_VER}.tar.bz2)"
289 -
290 - # strawberry pie, Cappuccino and a Gauloises (it's a good thing)
291 - [[ -n ${PIE_VER} ]] && \
292 - PIE_CORE=${PIE_CORE:-gcc-${PIE_GCC_VER}-piepatches-v${PIE_VER}.tar.bz2} && \
293 - GCC_SRC_URI+=" $(gentoo_urls ${PIE_CORE})"
294 -
295 - # gcc minispec for the hardened gcc 4 compiler
296 - [[ -n ${SPECS_VER} ]] && GCC_SRC_URI+=" $(gentoo_urls gcc-${SPECS_GCC_VER}-specs-${SPECS_VER}.tar.bz2)"
297 -
298 - # gcc bounds checking patch
299 - if [[ -n ${HTB_VER} ]] ; then
300 - local HTBFILE="bounds-checking-gcc-${HTB_GCC_VER}-${HTB_VER}.patch.bz2"
301 - GCC_SRC_URI+="
302 - boundschecking? (
303 - mirror://sourceforge/boundschecking/${HTBFILE}
304 - $(gentoo_urls ${HTBFILE})
305 - )"
306 - fi
307 -
308 - [[ -n ${D_VER} ]] && GCC_SRC_URI+=" d? ( mirror://sourceforge/dgcc/gdc-${D_VER}-src.tar.bz2 )"
309 -
310 - # >= gcc-4.3 uses ecj.jar and we only add gcj as a use flag under certain
311 - # conditions
312 - if [[ ${PN} != "kgcc64" && ${PN} != gcc-* ]] ; then
313 - if tc_version_is_at_least "4.5" ; then
314 - GCC_SRC_URI+=" gcj? ( ftp://sourceware.org/pub/java/ecj-4.5.jar )"
315 - elif tc_version_is_at_least "4.3" ; then
316 - GCC_SRC_URI+=" gcj? ( ftp://sourceware.org/pub/java/ecj-4.3.jar )"
317 - fi
318 - fi
319 -
320 - echo "${GCC_SRC_URI}"
321 -}
322 -SRC_URI=$(get_gcc_src_uri)
323 -#---->> S + SRC_URI essentials >>----
324 -
325 -
326 -#---->> support checks <<----
327 -
328 -# Grab a variable from the build system (taken from linux-info.eclass)
329 -get_make_var() {
330 - local var=$1 makefile=${2:-${WORKDIR}/build/Makefile}
331 - echo -e "e:\\n\\t@echo \$(${var})\\ninclude ${makefile}" | \
332 - r=${makefile%/*} emake --no-print-directory -s -f - 2>/dev/null
333 -}
334 -XGCC() { get_make_var GCC_FOR_TARGET ; }
335 -
336 -# This is to make sure we don't accidentally try to enable support for a
337 -# language that doesnt exist. GCC 3.4 supports f77, while 4.0 supports f95, etc.
338 -#
339 -# Also add a hook so special ebuilds (kgcc64) can control which languages
340 -# exactly get enabled
341 -gcc-lang-supported() {
342 - grep ^language=\"${1}\" "${S}"/gcc/*/config-lang.in > /dev/null || return 1
343 - [[ -z ${TOOLCHAIN_ALLOWED_LANGS} ]] && return 0
344 - has $1 ${TOOLCHAIN_ALLOWED_LANGS}
345 -}
346 -
347 -#----<< support checks >>---
348 -#---->> specs + env.d logic <<----
349 -
350 -create_gcc_env_entry() {
351 - dodir /etc/env.d/gcc
352 - local gcc_envd_base="/etc/env.d/gcc/${CTARGET}-${GCC_CONFIG_VER}"
353 -
354 - if [[ -z $1 ]] ; then
355 - gcc_envd_file="${D}${gcc_envd_base}"
356 - # I'm leaving the following commented out to remind me that it
357 - # was an insanely -bad- idea. Stuff broke. GCC_SPECS isnt unset
358 - # on chroot or in non-toolchain.eclass gcc ebuilds!
359 - #gcc_specs_file="${LIBPATH}/specs"
360 - gcc_specs_file=""
361 - else
362 - gcc_envd_file="${D}${gcc_envd_base}-$1"
363 - gcc_specs_file="${LIBPATH}/$1.specs"
364 - fi
365 -
366 - # phase PATH/ROOTPATH out ...
367 - echo "PATH=\"${BINPATH}\"" > ${gcc_envd_file}
368 - echo "ROOTPATH=\"${BINPATH}\"" >> ${gcc_envd_file}
369 - echo "GCC_PATH=\"${BINPATH}\"" >> ${gcc_envd_file}
370 -
371 - # We want to list the default ABI's LIBPATH first so libtool
372 - # searches that directory first. This is a temporary
373 - # workaround for libtool being stupid and using .la's from
374 - # conflicting ABIs by using the first one in the search path
375 - local abi=${DEFAULT_ABI}
376 - local MULTIDIR=$($(XGCC) $(get_abi_CFLAGS ${abi}) --print-multi-directory)
377 - local LDPATH=${LIBPATH}
378 - [[ ${MULTIDIR} != "." ]] && LDPATH+=/${MULTIDIR}
379 - for abi in $(get_all_abis) ; do
380 - [[ ${abi} == ${DEFAULT_ABI} ]] && continue
381 -
382 - MULTIDIR=$($(XGCC) $(get_abi_CFLAGS ${abi}) --print-multi-directory)
383 - LDPATH+=:${LIBPATH}
384 - [[ ${MULTIDIR} != "." ]] && LDPATH+=/${MULTIDIR}
385 - done
386 -
387 - echo "LDPATH=\"${LDPATH}\"" >> ${gcc_envd_file}
388 - echo "MANPATH=\"${DATAPATH}/man\"" >> ${gcc_envd_file}
389 - echo "INFOPATH=\"${DATAPATH}/info\"" >> ${gcc_envd_file}
390 - echo "STDCXX_INCDIR=\"${STDCXX_INCDIR##*/}\"" >> ${gcc_envd_file}
391 -
392 - is_crosscompile && echo "CTARGET=${CTARGET}" >> ${gcc_envd_file}
393 -
394 - # Set which specs file to use
395 - [[ -n ${gcc_specs_file} ]] && echo "GCC_SPECS=\"${gcc_specs_file}\"" >> ${gcc_envd_file}
396 -}
397 -
398 -#----<< specs + env.d logic >>----
399 -
400 -#---->> pkg_* <<----
401 -pkg_setup() {
402 - if [[ -n ${PRERELEASE}${SNAPSHOT} || ${PV} == *9999* ]] &&
403 - [[ -z ${I_PROMISE_TO_SUPPLY_PATCHES_WITH_BUGS} ]]
404 - then
405 - die "Please \`export I_PROMISE_TO_SUPPLY_PATCHES_WITH_BUGS=1\` or define it in your make.conf if you want to use this version." \
406 - "This is to try and cut down on people filing bugs for a compiler we do not currently support."
407 - fi
408 -
409 - # Setup variables which would normally be in the profile
410 - if is_crosscompile ; then
411 - multilib_env ${CTARGET}
412 - if ! is_multilib ; then
413 - MULTILIB_ABIS=${DEFAULT_ABI}
414 - fi
415 - fi
416 -
417 - # we dont want to use the installed compiler's specs to build gcc!
418 - unset GCC_SPECS
419 -
420 - if ! use_if_iuse cxx ; then
421 - use_if_iuse go && ewarn 'Go requires a C++ compiler, disabled due to USE="-cxx"'
422 - use_if_iuse objc++ && ewarn 'Obj-C++ requires a C++ compiler, disabled due to USE="-cxx"'
423 - use_if_iuse gcj && ewarn 'GCJ requires a C++ compiler, disabled due to USE="-cxx"'
424 - fi
425 -
426 -
427 - unset LANGUAGES #265283
428 -}
429 -
430 -pkg_preinst() {
431 - :
432 -}
433 -
434 -pkg_postinst() {
435 - do_gcc_config
436 -
437 - if ! is_crosscompile ; then
438 - echo
439 - ewarn "If you have issues with packages unable to locate libstdc++.la,"
440 - ewarn "then try running 'fix_libtool_files.sh' on the old gcc versions."
441 - echo
442 - ewarn "You might want to review the GCC upgrade guide when moving between"
443 - ewarn "major versions (like 4.2 to 4.3):"
444 - ewarn "http://www.gentoo.org/doc/en/gcc-upgrading.xml"
445 - echo
446 - fi
447 -
448 - # If our gcc-config version doesn't like '-' in it's version string,
449 - # tell our users that gcc-config will yell at them, but it's all good.
450 - if ! has_version '>=sys-devel/gcc-config-1.3.10-r1' && [[ ${GCC_CONFIG_VER/-/} != ${GCC_CONFIG_VER} ]] ; then
451 - ewarn "Your version of gcc-config will issue about having an invalid profile"
452 - ewarn "when switching to this profile. It is safe to ignore this warning,"
453 - ewarn "and this problem has been corrected in >=sys-devel/gcc-config-1.3.10-r1."
454 - fi
455 -
456 - if ! is_crosscompile ; then
457 - # hack to prevent collisions between SLOT
458 - [[ ! -d ${ROOT}/$(get_libdir)/rcscripts/awk ]] \
459 - && mkdir -p "${ROOT}"/$(get_libdir)/rcscripts/awk
460 - [[ ! -d ${ROOT}/sbin ]] \
461 - && mkdir -p "${ROOT}"/sbin
462 - cp "${ROOT}/${DATAPATH}"/fixlafiles.awk "${ROOT}"/$(get_libdir)/rcscripts/awk/ || die "installing fixlafiles.awk"
463 - cp "${ROOT}/${DATAPATH}"/fix_libtool_files.sh "${ROOT}"/sbin/ || die "installing fix_libtool_files.sh"
464 -
465 - [[ ! -d ${ROOT}/usr/bin ]] \
466 - && mkdir -p "${ROOT}"/usr/bin
467 - # Since these aren't critical files and portage sucks with
468 - # handling of binpkgs, don't require these to be found
469 - for x in "${ROOT}/${DATAPATH}"/c{89,99} ; do
470 - if [[ -e ${x} ]]; then
471 - cp ${x} "${ROOT}"/usr/bin/ || die "installing c89/c99"
472 - fi
473 - done
474 - fi
475 -}
476 -
477 -pkg_prerm() {
478 - # Don't let these files be uninstalled #87647
479 - touch -c "${ROOT}"/sbin/fix_libtool_files.sh \
480 - "${ROOT}"/$(get_libdir)/rcscripts/awk/fixlafiles.awk
481 -}
482 -
483 -pkg_postrm() {
484 - # to make our lives easier (and saner), we do the fix_libtool stuff here.
485 - # rather than checking SLOT's and trying in upgrade paths, we just see if
486 - # the common libstdc++.la exists in the ${LIBPATH} of the gcc that we are
487 - # unmerging. if it does, that means this was a simple re-emerge.
488 -
489 - # clean up the cruft left behind by cross-compilers
490 - if is_crosscompile ; then
491 - if [[ -z $(ls "${ROOT}"/etc/env.d/gcc/${CTARGET}* 2>/dev/null) ]] ; then
492 - rm -f "${ROOT}"/etc/env.d/gcc/config-${CTARGET}
493 - rm -f "${ROOT}"/etc/env.d/??gcc-${CTARGET}
494 - rm -f "${ROOT}"/usr/bin/${CTARGET}-{gcc,{g,c}++}{,32,64}
495 - fi
496 - return 0
497 - fi
498 -
499 - # ROOT isnt handled by the script
500 - [[ ${ROOT} != "/" ]] && return 0
501 -
502 - if [[ ! -e ${LIBPATH}/libstdc++.so ]] ; then
503 - # make sure the profile is sane during same-slot upgrade #289403
504 - do_gcc_config
505 -
506 - einfo "Running 'fix_libtool_files.sh ${GCC_RELEASE_VER}'"
507 - /sbin/fix_libtool_files.sh ${GCC_RELEASE_VER}
508 - if [[ -n ${BRANCH_UPDATE} ]] ; then
509 - einfo "Running 'fix_libtool_files.sh ${GCC_RELEASE_VER}-${BRANCH_UPDATE}'"
510 - /sbin/fix_libtool_files.sh ${GCC_RELEASE_VER}-${BRANCH_UPDATE}
511 - fi
512 - fi
513 -
514 - return 0
515 -}
516 -
517 -#---->> pkg_* <<----
518 -
519 -#---->> src_* <<----
520 -
521 -guess_patch_type_in_dir() {
522 - [[ -n $(ls "$1"/*.bz2 2>/dev/null) ]] \
523 - && EPATCH_SUFFIX="patch.bz2" \
524 - || EPATCH_SUFFIX="patch"
525 -}
526 -do_gcc_rename_java_bins() {
527 - # bug #139918 - conflict between gcc and java-config-2 for ownership of
528 - # /usr/bin/rmi{c,registry}. Done with mv & sed rather than a patch
529 - # because patches would be large (thanks to the rename of man files),
530 - # and it's clear from the sed invocations that all that changes is the
531 - # rmi{c,registry} names to grmi{c,registry} names.
532 - # Kevin F. Quinn 2006-07-12
533 - einfo "Renaming jdk executables rmic and rmiregistry to grmic and grmiregistry."
534 - # 1) Move the man files if present (missing prior to gcc-3.4)
535 - for manfile in rmic rmiregistry; do
536 - [[ -f ${S}/gcc/doc/${manfile}.1 ]] || continue
537 - mv "${S}"/gcc/doc/${manfile}.1 "${S}"/gcc/doc/g${manfile}.1
538 - done
539 - # 2) Fixup references in the docs if present (mission prior to gcc-3.4)
540 - for jfile in gcc/doc/gcj.info gcc/doc/grmic.1 gcc/doc/grmiregistry.1 gcc/java/gcj.texi; do
541 - [[ -f ${S}/${jfile} ]] || continue
542 - sed -i -e 's:rmiregistry:grmiregistry:g' "${S}"/${jfile} ||
543 - die "Failed to fixup file ${jfile} for rename to grmiregistry"
544 - sed -i -e 's:rmic:grmic:g' "${S}"/${jfile} ||
545 - die "Failed to fixup file ${jfile} for rename to grmic"
546 - done
547 - # 3) Fixup Makefiles to build the changed executable names
548 - # These are present in all 3.x versions, and are the important bit
549 - # to get gcc to build with the new names.
550 - for jfile in libjava/Makefile.am libjava/Makefile.in gcc/java/Make-lang.in; do
551 - sed -i -e 's:rmiregistry:grmiregistry:g' "${S}"/${jfile} ||
552 - die "Failed to fixup file ${jfile} for rename to grmiregistry"
553 - # Careful with rmic on these files; it's also the name of a directory
554 - # which should be left unchanged. Replace occurrences of 'rmic$',
555 - # 'rmic_' and 'rmic '.
556 - sed -i -e 's:rmic\([$_ ]\):grmic\1:g' "${S}"/${jfile} ||
557 - die "Failed to fixup file ${jfile} for rename to grmic"
558 - done
559 -}
560 -src_unpack() {
561 - [[ -z ${UCLIBC_VER} ]] && [[ ${CTARGET} == *-uclibc* ]] && die "Sorry, this version does not support uClibc"
562 -
563 - if [[ ${PV} == *9999* ]]; then
564 - git-2_src_unpack
565 - else
566 - gcc_quick_unpack
567 - fi
568 -
569 - export BRANDING_GCC_PKGVERSION="Gentoo ${GCC_PVR}"
570 - cd "${S}"
571 -
572 - if ! use vanilla ; then
573 - if [[ -n ${PATCH_VER} ]] ; then
574 - guess_patch_type_in_dir "${WORKDIR}"/patch
575 - EPATCH_MULTI_MSG="Applying Gentoo patches ..." \
576 - epatch "${WORKDIR}"/patch
577 - BRANDING_GCC_PKGVERSION="${BRANDING_GCC_PKGVERSION} p${PATCH_VER}"
578 - fi
579 - if [[ -n ${UCLIBC_VER} ]] ; then
580 - guess_patch_type_in_dir "${WORKDIR}"/uclibc
581 - EPATCH_MULTI_MSG="Applying uClibc patches ..." \
582 - epatch "${WORKDIR}"/uclibc
583 - fi
584 - fi
585 - do_gcc_HTB_patches
586 - do_gcc_PIE_patches
587 - epatch_user
588 -
589 - if use hardened ; then
590 - BRANDING_GCC_PKGVERSION=${BRANDING_GCC_PKGVERSION/Gentoo/Gentoo Hardened}
591 - fi
592 -
593 - # install the libstdc++ python into the right location
594 - # http://gcc.gnu.org/PR51368
595 - sed -i \
596 - '/^pythondir =/s:=.*:= $(datadir)/python:' \
597 - "${S}"/libstdc++-v3/python/Makefile.in || die
598 -
599 -
600 - setup_multilib_osdirnames
601 -
602 - gcc_version_patch
603 - if [[ -n ${SNAPSHOT} || -n ${PRERELEASE} ]] ; then
604 - # BASE-VER must be a three-digit version number
605 - # followed by an optional -pre string
606 - # eg. 4.5.1, 4.6.2-pre20120213, 4.7.0-pre9999
607 - # If BASE-VER differs from ${PV/_/-} then libraries get installed in
608 - # the wrong directory.
609 - echo ${PV/_/-} > "${S}"/gcc/BASE-VER
610 - fi
611 - if use gcj ; then
612 - einfo "Copying ecj-4.5.jar"
613 - cp -pPR "${DISTDIR}/ecj-4.5.jar" "${S}/ecj.jar" || die
614 - fi
615 -
616 - # Prevent libffi from being installed
617 - sed -i -e 's/\(install.*:\) install-.*recursive/\1/' "${S}"/libffi/Makefile.in
618 - sed -i -e 's/\(install-data-am:\).*/\1/' "${S}"/libffi/include/Makefile.in
619 -
620 - # Fixup libtool to correctly generate .la files with portage
621 - cd "${S}"
622 - elibtoolize --portage --shallow --no-uclibc
623 -
624 - gnuconfig_update
625 -
626 - # update configure files
627 - local f
628 - einfo "Fixing misc issues in configure files"
629 - epatch "${GCC_FILESDIR}"/gcc-configure-texinfo.patch
630 - for f in $(grep -l 'autoconf version 2.13' $(find "${S}" -name configure)) ; do
631 - ebegin " Updating ${f/${S}\/} [LANG]"
632 - patch "${f}" "${GCC_FILESDIR}"/gcc-configure-LANG.patch >& "${T}"/configure-patch.log \
633 - || eerror "Please file a bug about this"
634 - eend $?
635 - done
636 - sed -i 's|A-Za-z0-9|[:alnum:]|g' "${S}"/gcc/*.awk #215828
637 -
638 - if [[ -x contrib/gcc_update ]] ; then
639 - einfo "Touching generated files"
640 - ./contrib/gcc_update --touch | \
641 - while read f ; do
642 - einfo " ${f%%...}"
643 - done
644 - fi
645 -
646 - disable_multilib_libjava || die "failed to disable multilib java"
647 -}
648 -
649 -gcc-abi-map() {
650 - # Convert the ABI name we use in Gentoo to what gcc uses
651 - local map=()
652 - case ${CTARGET} in
653 - mips*) map=("o32 32" "n32 n32" "n64 64") ;;
654 - x86_64*) map=("amd64 m64" "x86 m32" "x32 mx32") ;;
655 - esac
656 -
657 - local m
658 - for m in "${map[@]}" ; do
659 - l=( ${m} )
660 - [[ $1 == ${l[0]} ]] && echo ${l[1]} && break
661 - done
662 -}
663 -
664 -gcc-multilib-configure() {
665 - # if multilib is disabled, get out quick!
666 - if ! is_multilib ; then
667 - confgcc+=" --disable-multilib"
668 - return
669 - else
670 - confgcc+=" --enable-multilib"
671 - fi
672 -
673 - # translate our notion of multilibs into gcc's
674 - local abi list
675 - for abi in $(get_all_abis) ; do
676 - local l=$(gcc-abi-map ${abi})
677 - [[ -n ${l} ]] && list+=",${l}"
678 - done
679 - if [[ -n ${list} ]] ; then
680 - case ${CTARGET} in
681 - x86_64*)
682 - confgcc+=" --with-multilib-list=${list:1}"
683 - ;;
684 - esac
685 - fi
686 -}
687 -
688 -gcc-compiler-configure() {
689 - gcc-multilib-configure
690 -
691 - if in_iuse mudflap ; then
692 - confgcc+=" $(use_enable mudflap libmudflap)"
693 - else
694 - confgcc+=" --disable-libmudflap"
695 - fi
696 -
697 - # If we want hardened support (espf)
698 - confgcc+=" $(use_enable hardened espf)"
699 -
700 - if in_iuse openmp ; then
701 - # Make sure target has pthreads support. #326757 #335883
702 - # There shouldn't be a chicken&egg problem here as openmp won't
703 - # build without a C library, and you can't build that w/out
704 - # already having a compiler ...
705 - if ! is_crosscompile || \
706 - $(tc-getCPP ${CTARGET}) -E - <<<"#include <pthread.h>" >& /dev/null
707 - then
708 - confgcc+=" $(use_enable openmp libgomp)"
709 - else
710 - # Force disable as the configure script can be dumb #359855
711 - confgcc+=" --disable-libgomp"
712 - fi
713 - else
714 - # For gcc variants where we don't want openmp (e.g. kgcc)
715 - confgcc+=" --disable-libgomp"
716 - fi
717 -
718 - # Stick the python scripts in their own slotted directory
719 - # bug #279252
720 - #
721 - # --with-python-dir=DIR
722 - # Specifies where to install the Python modules used for aot-compile. DIR
723 - # should not include the prefix used in installation. For example, if the
724 - # Python modules are to be installed in /usr/lib/python2.5/site-packages,
725 - # then --with-python-dir=/lib/python2.5/site-packages should be passed.
726 - #
727 - # This should translate into "/share/gcc-data/${CTARGET}/${GCC_CONFIG_VER}/python"
728 - confgcc+=" --with-python-dir=${DATAPATH/$PREFIX/}/python"
729 -
730 - # For newer versions of gcc, use the default ("release"), because no
731 - # one (even upstream apparently) tests with it disabled. #317217
732 - if tc_version_is_at_least 4 || [[ -n ${GCC_CHECKS_LIST} ]] ; then
733 - confgcc+=" --enable-checking=${GCC_CHECKS_LIST:-release}"
734 - else
735 - confgcc+=" --disable-checking"
736 - fi
737 -
738 - # GTK+ is preferred over xlib in 3.4.x (xlib is unmaintained
739 - # right now). Much thanks to <csm@×××.org> for the heads up.
740 - # Travis Tilley <lv@g.o> (11 Jul 2004)
741 - if ! is_gcj ; then
742 - confgcc+=" --disable-libgcj"
743 - elif use gtk ; then
744 - confgcc+=" --enable-java-awt=gtk"
745 - fi
746 -
747 - # newer gcc versions like to bootstrap themselves with C++,
748 - # so we need to manually disable it ourselves
749 - if ! is_cxx ; then
750 - confgcc+=" --disable-build-with-cxx --disable-build-poststage1-with-cxx"
751 - fi
752 -
753 - # newer gcc's come with libquadmath, but only fortran uses
754 - # it, so auto punt it when we don't care
755 - if ! is_fortran ; then
756 - confgcc+=" --disable-libquadmath"
757 - fi
758 -
759 - local with_abi_map=()
760 - case $(tc-arch) in
761 - arm) #264534
762 - local arm_arch="${CTARGET%%-*}"
763 - # Only do this if arm_arch is armv*
764 - if [[ ${arm_arch} == armv* ]] ; then
765 - # Convert armv7{a,r,m} to armv7-{a,r,m}
766 - [[ ${arm_arch} == armv7? ]] && arm_arch=${arm_arch/7/7-}
767 - # Remove endian ('l' / 'eb')
768 - [[ ${arm_arch} == *l ]] && arm_arch=${arm_arch%l}
769 - [[ ${arm_arch} == *eb ]] && arm_arch=${arm_arch%eb}
770 - confgcc+=" --with-arch=${arm_arch}"
771 - fi
772 -
773 - # Enable hardvfp
774 - if [[ ${CTARGET##*-} == *eabi ]] && [[ $(tc-is-hardfloat) == yes ]] && \
775 - confgcc+=" --with-float=hard"
776 - fi
777 - ;;
778 - # Add --with-abi flags to set default ABI
779 - mips)
780 - confgcc+=" --with-abi=$(gcc-abi-map ${DEFAULT_ABI})"
781 - ;;
782 - amd64)
783 - # drop the older/ABI checks once this get's merged into some
784 - # version of gcc upstream
785 - if [[ ${PV} == "4.6.2" ]] && has x32 $(get_all_abis) ; then
786 - confgcc+=" --with-abi=$(gcc-abi-map ${DEFAULT_ABI})"
787 - fi
788 - ;;
789 - # Default arch for x86 is normally i386, lets give it a bump
790 - # since glibc will do so based on CTARGET anyways
791 - x86)
792 - confgcc+=" --with-arch=${CTARGET%%-*}"
793 - ;;
794 - # Enable sjlj exceptions for backward compatibility on hppa
795 - hppa)
796 - [[ ${GCCMAJOR} == "3" ]] && confgcc+=" --enable-sjlj-exceptions"
797 - ;;
798 - # Set up defaults based on current CFLAGS
799 - ppc)
800 - is-flagq -mfloat-gprs=double && confgcc+=" --enable-e500-double"
801 - [[ ${CTARGET//_/-} == *-e500v2-* ]] && confgcc+=" --enable-e500-double"
802 - ;;
803 - esac
804 -
805 - local GCC_LANG="c"
806 - is_cxx && GCC_LANG+=",c++"
807 - is_d && GCC_LANG+=",d"
808 - is_gcj && GCC_LANG+=",java"
809 - is_go && GCC_LANG+=",go"
810 - if is_objc || is_objcxx ; then
811 - GCC_LANG+=",objc"
812 - use objc-gc && confgcc+=" --enable-objc-gc"
813 - is_objcxx && GCC_LANG+=",obj-c++"
814 - fi
815 - is_treelang && GCC_LANG+=",treelang"
816 -
817 - # fortran support just got sillier! the lang value can be f77 for
818 - # fortran77, f95 for fortran95, or just plain old fortran for the
819 - # currently supported standard depending on gcc version.
820 - is_fortran && GCC_LANG+=",fortran"
821 - is_f77 && GCC_LANG+=",f77"
822 - is_f95 && GCC_LANG+=",f95"
823 -
824 - # We do NOT want 'ADA support' in here!
825 - # is_ada && GCC_LANG+=",ada"
826 -
827 - einfo "configuring for GCC_LANG: ${GCC_LANG}"
828 - confgcc+=" --enable-languages=${GCC_LANG}"
829 -}
830 -
831 -src_configure() {
832 - local confgcc
833 -
834 - # Sanity check for USE=nocxx -> USE=cxx migration
835 - if in_iuse cxx && in_iuse nocxx ; then
836 - if (use cxx && use nocxx) || (use !cxx && use !nocxx) ; then
837 - eerror "We are migrating USE=nocxx to USE=cxx, but your USE settings do not make"
838 - eerror "sense. Please make sure these two flags line up logically in your setup."
839 - die "USE='cxx nocxx' and USE='-cxx -nocxx' make no sense"
840 - fi
841 - fi
842 -
843 - # Set configuration based on path variables
844 - confgcc+=" \
845 - --prefix=${PREFIX} \
846 - --bindir=${BINPATH} \
847 - --includedir=${INCLUDEPATH} \
848 - --datadir=${DATAPATH} \
849 - --mandir=${DATAPATH}/man \
850 - --infodir=${DATAPATH}/info \
851 - --with-gxx-include-dir=${STDCXX_INCDIR}"
852 - # On Darwin we need libdir to be set in order to get correct install names
853 - # for things like libobjc-gnu, libgcj and libfortran. If we enable it on
854 - # non-Darwin we screw up the behaviour this eclass relies on. We in
855 - # particular need this over --libdir for bug #255315.
856 - [[ ${CTARGET} == *-darwin* ]] && \
857 - confgcc+=" --enable-version-specific-runtime-libs"
858 -
859 - # All our cross-compile logic goes here ! woo !
860 - confgcc+=" --host=${CHOST}"
861 - if is_crosscompile || tc-is-cross-compiler ; then
862 - # Straight from the GCC install doc:
863 - # "GCC has code to correctly determine the correct value for target
864 - # for nearly all native systems. Therefore, we highly recommend you
865 - # not provide a configure target when configuring a native compiler."
866 - confgcc+=" --target=${CTARGET}"
867 - fi
868 - [[ -n ${CBUILD} ]] && confgcc+=" --build=${CBUILD}"
869 -
870 - # ppc altivec support
871 - confgcc+=" $(use_enable altivec)"
872 -
873 - # gcc has fixed-point arithmetic support in 4.3 for mips targets that can
874 - # significantly increase compile time by several hours. This will allow
875 - # users to control this feature in the event they need the support.
876 - confgcc+=" $(use_enable fixed-point)"
877 -
878 - # Graphite support was added in 4.4, which depends on external libraries
879 - # for optimizations. Current versions use cloog-ppl (cloog fork with Parma
880 - # PPL backend). Sometime in the future we will use upstream cloog with the
881 - # ISL backend (note: PPL will still be a requirement). cloog-ppl's include
882 - # path was modified to prevent collisions between the two packages (library
883 - # names are different).
884 - #
885 - # We disable the PPL version check so we can use >=ppl-0.11.
886 - confgcc+=" $(use_with graphite ppl)"
887 - confgcc+=" $(use_with graphite cloog)"
888 - if use graphite; then
889 - confgcc+=" --disable-ppl-version-check"
890 - confgcc+=" --with-cloog-include=/usr/include/cloog-ppl"
891 - fi
892 -
893 - # LTO support was added in 4.5, which depends upon elfutils. This allows
894 - # users to enable that option, and pull in the additional library. In 4.6,
895 - # the dependency is no longer required.
896 - confgcc+=" --enable-lto"
897 -
898 - [[ $(tc-is-softfloat) == "yes" ]] && confgcc+=" --with-float=soft"
899 - [[ $(tc-is-hardfloat) == "yes" ]] && confgcc+=" --with-float=hard"
900 -
901 - # Native Language Support
902 - if use nls ; then
903 - confgcc+=" --enable-nls --without-included-gettext"
904 - else
905 - confgcc+=" --disable-nls"
906 - fi
907 -
908 - # reasonably sane globals (hopefully)
909 - confgcc+=" \
910 - --with-system-zlib \
911 - --disable-werror \
912 - --enable-secureplt"
913 -
914 - gcc-compiler-configure || die
915 -
916 - if is_crosscompile ; then
917 - # When building a stage1 cross-compiler (just C compiler), we have to
918 - # disable a bunch of features or gcc goes boom
919 - local needed_libc=""
920 - case ${CTARGET} in
921 - *-linux) needed_libc=no-fucking-clue;;
922 - *-dietlibc) needed_libc=dietlibc;;
923 - *-elf|*-eabi) needed_libc=newlib;;
924 - *-freebsd*) needed_libc=freebsd-lib;;
925 - *-gnu*) needed_libc=glibc;;
926 - *-klibc) needed_libc=klibc;;
927 - *-uclibc*) needed_libc=uclibc;;
928 - *-cygwin) needed_libc=cygwin;;
929 - mingw*|*-mingw*) needed_libc=mingw-runtime;;
930 - avr) confgcc+=" --enable-shared --disable-threads";;
931 - esac
932 - if [[ -n ${needed_libc} ]] ; then
933 - if ! has_version ${CATEGORY}/${needed_libc} ; then
934 - confgcc+=" --disable-shared --disable-threads --without-headers"
935 - elif built_with_use --hidden --missing false ${CATEGORY}/${needed_libc} crosscompile_opts_headers-only ; then
936 - confgcc+=" --disable-shared --with-sysroot=${PREFIX}/${CTARGET}"
937 - else
938 - confgcc+=" --with-sysroot=${PREFIX}/${CTARGET}"
939 - fi
940 - fi
941 -
942 - confgcc+=" --disable-bootstrap"
943 - else
944 - if tc-is-static-only ; then
945 - confgcc+=" --disable-shared"
946 - else
947 - confgcc+=" --enable-shared"
948 - fi
949 - case ${CHOST} in
950 - mingw*|*-mingw*|*-cygwin)
951 - confgcc+=" --enable-threads=win32" ;;
952 - *)
953 - confgcc+=" --enable-threads=posix" ;;
954 - esac
955 - fi
956 - # __cxa_atexit is "essential for fully standards-compliant handling of
957 - # destructors", but apparently requires glibc.
958 - case ${CTARGET} in
959 - *-uclibc*)
960 - confgcc+=" --disable-__cxa_atexit --enable-target-optspace $(use_enable nptl tls)"
961 - [[ ${GCCMAJOR}.${GCCMINOR} == 3.3 ]] && confgcc+=" --enable-sjlj-exceptions"
962 - if tc_version_is_at_least 3.4 && ! tc_version_is_at_least 4.3 ; then
963 - confgcc+=" --enable-clocale=uclibc"
964 - fi
965 - ;;
966 - *-elf|*-eabi)
967 - confgcc+=" --with-newlib"
968 - ;;
969 - *-gnu*)
970 - confgcc+=" --enable-__cxa_atexit"
971 - confgcc+=" --enable-clocale=gnu"
972 - ;;
973 - *-freebsd*)
974 - confgcc+=" --enable-__cxa_atexit"
975 - ;;
976 - *-solaris*)
977 - confgcc+=" --enable-__cxa_atexit"
978 - ;;
979 - esac
980 - tc_version_is_at_least 3.4 || confgcc+=" --disable-libunwind-exceptions"
981 -
982 - # if the target can do biarch (-m32/-m64), enable it. overhead should
983 - # be small, and should simplify building of 64bit kernels in a 32bit
984 - # userland by not needing sys-devel/kgcc64. #349405
985 - case $(tc-arch) in
986 - ppc|ppc64) confgcc+=" --enable-targets=all" ;;
987 - sparc) confgcc+=" --enable-targets=all" ;;
988 - amd64|x86) confgcc+=" --enable-targets=all" ;;
989 - esac
990 -
991 - set -- "$@" \
992 - --with-bugurl=http://bugs.gentoo.org/ \
993 - --with-pkgversion="${BRANDING_GCC_PKGVERSION}"
994 - set -- ${confgcc} "$@" ${EXTRA_ECONF}
995 -
996 - # Nothing wrong with a good dose of verbosity
997 - echo
998 - einfo "PREFIX: ${PREFIX}"
999 - einfo "BINPATH: ${BINPATH}"
1000 - einfo "LIBPATH: ${LIBPATH}"
1001 - einfo "DATAPATH: ${DATAPATH}"
1002 - einfo "STDCXX_INCDIR: ${STDCXX_INCDIR}"
1003 - echo
1004 - einfo "Configuring GCC with: ${@//--/\n\t--}"
1005 - echo
1006 -
1007 - # Build in a separate build tree
1008 - mkdir -p "${WORKDIR}"/build
1009 - pushd "${WORKDIR}"/build > /dev/null
1010 -
1011 - # and now to do the actual configuration
1012 - addwrite /dev/zero
1013 - echo "${S}"/configure "$@"
1014 - "${S}"/configure "$@" || die "failed to run configure"
1015 -
1016 - # return to whatever directory we were in before
1017 - popd > /dev/null
1018 -
1019 - touch "${S}"/gcc/c-gperf.h
1020 -}
1021 -
1022 -has toolchain_death_notice ${EBUILD_DEATH_HOOKS} || EBUILD_DEATH_HOOKS+=" toolchain_death_notice"
1023 -toolchain_death_notice() {
1024 - pushd "${WORKDIR}"/build >/dev/null
1025 - tar jcf gcc-build-logs.tar.bz2 $(find -name config.log)
1026 - eerror
1027 - eerror "Please include ${PWD}/gcc-build-logs.tar.bz2 in your bug report"
1028 - eerror
1029 - popd >/dev/null
1030 -}
1031 -
1032 -# This function accepts one optional argument, the make target to be used.
1033 -# If ommitted, gcc_do_make will try to guess whether it should use all,
1034 -# profiledbootstrap, or bootstrap-lean depending on CTARGET and arch. An
1035 -# example of how to use this function:
1036 -#
1037 -# gcc_do_make all-target-libstdc++-v3
1038 -#
1039 -# In addition to the target to be used, the following variables alter the
1040 -# behavior of this function:
1041 -#
1042 -# LDFLAGS
1043 -# Flags to pass to ld
1044 -#
1045 -# STAGE1_CFLAGS
1046 -# CFLAGS to use during stage1 of a gcc bootstrap
1047 -#
1048 -# BOOT_CFLAGS
1049 -# CFLAGS to use during stages 2+3 of a gcc bootstrap.
1050 -#
1051 -# Travis Tilley <lv@g.o> (04 Sep 2004)
1052 -#
1053 -gcc_do_make() {
1054 - # Fix for libtool-portage.patch
1055 - local OLDS=${S}
1056 - S=${WORKDIR}/build
1057 -
1058 - # Set make target to $1 if passed
1059 - [[ -n $1 ]] && GCC_MAKE_TARGET=$1
1060 - # default target
1061 - if is_crosscompile || tc-is-cross-compiler ; then
1062 - # 3 stage bootstrapping doesnt quite work when you cant run the
1063 - # resulting binaries natively ^^;
1064 - GCC_MAKE_TARGET=${GCC_MAKE_TARGET-all}
1065 - else
1066 - GCC_MAKE_TARGET=${GCC_MAKE_TARGET-bootstrap-lean}
1067 - fi
1068 -
1069 - # the gcc docs state that parallel make isnt supported for the
1070 - # profiledbootstrap target, as collisions in profile collecting may occur.
1071 - # boundschecking also seems to introduce parallel build issues.
1072 - if [[ ${GCC_MAKE_TARGET} == "profiledbootstrap" ]] ||
1073 - use_if_iuse boundschecking
1074 - then
1075 - export MAKEOPTS="${MAKEOPTS} -j1"
1076 - fi
1077 -
1078 - if [[ ${GCC_MAKE_TARGET} == "all" ]] ; then
1079 - STAGE1_CFLAGS=${STAGE1_CFLAGS-"${CFLAGS}"}
1080 - fi
1081 -
1082 - if is_crosscompile; then
1083 - # In 3.4, BOOT_CFLAGS is never used on a crosscompile...
1084 - # but I'll leave this in anyways as someone might have had
1085 - # some reason for putting it in here... --eradicator
1086 - BOOT_CFLAGS=${BOOT_CFLAGS-"-O2"}
1087 - else
1088 - # we only want to use the system's CFLAGS if not building a
1089 - # cross-compiler.
1090 - BOOT_CFLAGS=${BOOT_CFLAGS-"$(get_abi_CFLAGS) ${CFLAGS}"}
1091 - fi
1092 -
1093 - pushd "${WORKDIR}"/build
1094 -
1095 - emake \
1096 - LDFLAGS="${LDFLAGS}" \
1097 - STAGE1_CFLAGS="${STAGE1_CFLAGS}" \
1098 - LIBPATH="${LIBPATH}" \
1099 - BOOT_CFLAGS="${BOOT_CFLAGS}" \
1100 - ${GCC_MAKE_TARGET} \
1101 - || die "emake failed with ${GCC_MAKE_TARGET}"
1102 -
1103 - if ! is_crosscompile && use cxx && use doc ; then
1104 - if type -p doxygen > /dev/null ; then
1105 - cd "${CTARGET}"/libstdc++-v3/doc
1106 - emake doc-man-doxygen || ewarn "failed to make docs"
1107 - else
1108 - ewarn "Skipping libstdc++ manpage generation since you don't have doxygen installed"
1109 - fi
1110 - fi
1111 -
1112 - popd
1113 -}
1114 -
1115 -# This is mostly a stub function to be overwritten in an ebuild
1116 -gcc_do_filter_flags() {
1117 - strip-flags
1118 -
1119 - # In general gcc does not like optimization, and add -O2 where
1120 - # it is safe. This is especially true for gcc 3.3 + 3.4
1121 - replace-flags -O? -O2
1122 -
1123 - # ... sure, why not?
1124 - strip-unsupported-flags
1125 -
1126 - # dont want to funk ourselves
1127 - filter-flags '-mabi*' -m31 -m32 -m64
1128 -
1129 - case ${GCC_BRANCH_VER} in
1130 - 4.*)
1131 - case $(tc-arch) in
1132 - x86|amd64) filter-flags '-mcpu=*';;
1133 - *-macos)
1134 - # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25127
1135 - [[ ${GCC_BRANCH_VER} == 4.0 || ${GCC_BRANCH_VER} == 4.1 ]] && \
1136 - filter-flags '-mcpu=*' '-march=*' '-mtune=*'
1137 - ;;
1138 - esac
1139 - ;;
1140 - esac
1141 -
1142 - # Compile problems with these (bug #6641 among others)...
1143 - #filter-flags "-fno-exceptions -fomit-frame-pointer -fforce-addr"
1144 -
1145 - # CFLAGS logic (verified with 3.4.3):
1146 - # CFLAGS:
1147 - # This conflicts when creating a crosscompiler, so set to a sane
1148 - # default in this case:
1149 - # used in ./configure and elsewhere for the native compiler
1150 - # used by gcc when creating libiberty.a
1151 - # used by xgcc when creating libstdc++ (and probably others)!
1152 - # this behavior should be removed...
1153 - #
1154 - # CXXFLAGS:
1155 - # used by xgcc when creating libstdc++
1156 - #
1157 - # STAGE1_CFLAGS (not used in creating a crosscompile gcc):
1158 - # used by ${CHOST}-gcc for building stage1 compiler
1159 - #
1160 - # BOOT_CFLAGS (not used in creating a crosscompile gcc):
1161 - # used by xgcc for building stage2/3 compiler
1162 -
1163 - if is_crosscompile ; then
1164 - # Set this to something sane for both native and target
1165 - CFLAGS="-O2 -pipe"
1166 -
1167 - local VAR="CFLAGS_"${CTARGET//-/_}
1168 - CXXFLAGS=${!VAR}
1169 - fi
1170 -
1171 - export GCJFLAGS=${GCJFLAGS:-${CFLAGS}}
1172 -}
1173 -src_prepare() {
1174 - multilib_env ${CTARGET}
1175 - gcc_do_filter_flags
1176 - einfo "CFLAGS=\"${CFLAGS}\""
1177 - einfo "CXXFLAGS=\"${CXXFLAGS}\""
1178 -
1179 - # Force internal zip based jar script to avoid random
1180 - # issues with 3rd party jar implementations. #384291
1181 - export JAR=no
1182 -
1183 - # Build in a separate build tree
1184 - mkdir -p "${WORKDIR}"/build
1185 - pushd "${WORKDIR}"/build > /dev/null
1186 -}
1187 -src_compile() {
1188 - touch "${S}"/gcc/c-gperf.h
1189 -
1190 - # Do not make manpages if we do not have perl ...
1191 - [[ ! -x /usr/bin/perl ]] \
1192 - && find "${WORKDIR}"/build -name '*.[17]' | xargs touch
1193 -
1194 - einfo "Compiling ${PN} ..."
1195 - gcc_do_make ${GCC_MAKE_TARGET}
1196 -
1197 - popd > /dev/null
1198 -}
1199 -
1200 -src_test() {
1201 - cd "${WORKDIR}"/build
1202 - emake -k check || ewarn "check failed and that sucks :("
1203 -}
1204 -
1205 -src_install() {
1206 - local x=
1207 -
1208 - cd "${WORKDIR}"/build
1209 - # Do allow symlinks in private gcc include dir as this can break the build
1210 - find gcc/include*/ -type l -print0 | xargs -0 rm -f
1211 - # Remove generated headers, as they can cause things to break
1212 - # (ncurses, openssl, etc).
1213 - for x in $(find gcc/include*/ -name '*.h') ; do
1214 - grep -q 'It has been auto-edited by fixincludes from' "${x}" \
1215 - && rm -f "${x}"
1216 - done
1217 - # Do the 'make install' from the build directory
1218 - S=${WORKDIR}/build \
1219 - emake -j1 DESTDIR="${D}" install || die
1220 - # Punt some tools which are really only useful while building gcc
1221 - find "${D}" -name install-tools -prune -type d -exec rm -rf "{}" \;
1222 - # This one comes with binutils
1223 - find "${D}" -name libiberty.a -exec rm -f "{}" \;
1224 -
1225 - # Move the libraries to the proper location
1226 - gcc_movelibs
1227 -
1228 - # Basic sanity check
1229 - if ! is_crosscompile ; then
1230 - local EXEEXT
1231 - eval $(grep ^EXEEXT= "${WORKDIR}"/build/gcc/config.log)
1232 - [[ -r ${D}${BINPATH}/gcc${EXEEXT} ]] || die "gcc not found in ${D}"
1233 - fi
1234 -
1235 - dodir /etc/env.d/gcc
1236 - create_gcc_env_entry
1237 -
1238 - gcc_slot_java
1239 -
1240 - # These should be symlinks
1241 - dodir /usr/bin
1242 - cd "${D}"${BINPATH}
1243 - # Ugh: we really need to auto-detect this list.
1244 - # It's constantly out of date.
1245 - for x in cpp gcc g++ c++ gcov g77 gcj gcjh gfortran gccgo ; do
1246 - # For some reason, g77 gets made instead of ${CTARGET}-g77...
1247 - # this should take care of that
1248 - [[ -f ${x} ]] && mv ${x} ${CTARGET}-${x}
1249 -
1250 - if [[ -f ${CTARGET}-${x} ]] ; then
1251 - if ! is_crosscompile ; then
1252 - ln -sf ${CTARGET}-${x} ${x}
1253 - dosym ${BINPATH}/${CTARGET}-${x} \
1254 - /usr/bin/${x}-${GCC_CONFIG_VER}
1255 - fi
1256 -
1257 - # Create version-ed symlinks
1258 - dosym ${BINPATH}/${CTARGET}-${x} \
1259 - /usr/bin/${CTARGET}-${x}-${GCC_CONFIG_VER}
1260 - fi
1261 -
1262 - if [[ -f ${CTARGET}-${x}-${GCC_CONFIG_VER} ]] ; then
1263 - rm -f ${CTARGET}-${x}-${GCC_CONFIG_VER}
1264 - ln -sf ${CTARGET}-${x} ${CTARGET}-${x}-${GCC_CONFIG_VER}
1265 - fi
1266 - done
1267 -
1268 - # Now do the fun stripping stuff
1269 - env RESTRICT="" CHOST=${CHOST} prepstrip "${D}${BINPATH}"
1270 - env RESTRICT="" CHOST=${CTARGET} prepstrip "${D}${LIBPATH}"
1271 - # gcc used to install helper binaries in lib/ but then moved to libexec/
1272 - [[ -d ${D}${PREFIX}/libexec/gcc ]] && \
1273 - env RESTRICT="" CHOST=${CHOST} prepstrip "${D}${PREFIX}/libexec/gcc/${CTARGET}/${GCC_CONFIG_VER}"
1274 -
1275 - cd "${S}"
1276 - if is_crosscompile; then
1277 - rm -rf "${D}"/usr/share/{man,info}
1278 - rm -rf "${D}"${DATAPATH}/{man,info}
1279 - else
1280 - local cxx_mandir=$(find "${WORKDIR}/build/${CTARGET}/libstdc++-v3" -name man)
1281 - if [[ -d ${cxx_mandir} ]] ; then
1282 - # clean bogus manpages #113902
1283 - find "${cxx_mandir}" -name '*_build_*' -exec rm {} \;
1284 - cp -r "${cxx_mandir}"/man? "${D}/${DATAPATH}"/man/
1285 - fi
1286 - has noinfo ${FEATURES} \
1287 - && rm -r "${D}/${DATAPATH}"/info \
1288 - || prepinfo "${DATAPATH}"
1289 - has noman ${FEATURES} \
1290 - && rm -r "${D}/${DATAPATH}"/man \
1291 - || prepman "${DATAPATH}"
1292 - fi
1293 - # prune empty dirs left behind
1294 - find "${D}" -depth -type d -delete 2>/dev/null
1295 -
1296 - # install testsuite results
1297 - if use test; then
1298 - docinto testsuite
1299 - find "${WORKDIR}"/build -type f -name "*.sum" -print0 | xargs -0 dodoc
1300 - find "${WORKDIR}"/build -type f -path "*/testsuite/*.log" -print0 \
1301 - | xargs -0 dodoc
1302 - fi
1303 -
1304 - # Rather install the script, else portage with changing $FILESDIR
1305 - # between binary and source package borks things ....
1306 - if ! is_crosscompile ; then
1307 - insinto "${DATAPATH}"
1308 - newins "${GCC_FILESDIR}"/awk/fixlafiles.awk-no_gcc_la fixlafiles.awk || die
1309 - find "${D}/${LIBPATH}" -name libstdc++.la -type f -exec rm "{}" \;
1310 - exeinto "${DATAPATH}"
1311 - doexe "${GCC_FILESDIR}"/fix_libtool_files.sh || die
1312 - doexe "${GCC_FILESDIR}"/c{89,99} || die
1313 - fi
1314 -
1315 - # Use gid of 0 because some stupid ports don't have
1316 - # the group 'root' set to gid 0. Send to /dev/null
1317 - # for people who are testing as non-root.
1318 - chown -R root:0 "${D}"${LIBPATH} 2>/dev/null
1319 -
1320 - # Move pretty-printers to gdb datadir to shut ldconfig up
1321 - local py gdbdir=/usr/share/gdb/auto-load${LIBPATH/\/lib\//\/$(get_libdir)\/}
1322 - pushd "${D}"${LIBPATH} >/dev/null
1323 - for py in $(find . -name '*-gdb.py') ; do
1324 - local multidir=${py%/*}
1325 - insinto "${gdbdir}/${multidir}"
1326 - sed -i "/^libdir =/s:=.*:= '${LIBPATH}/${multidir}':" "${py}" || die #348128
1327 - doins "${py}" || die
1328 - rm "${py}" || die
1329 - done
1330 - popd >/dev/null
1331 -
1332 - # Don't scan .gox files for executable stacks - false positives
1333 - export QA_EXECSTACK="usr/lib*/go/*/*.gox"
1334 - export QA_WX_LOAD="usr/lib*/go/*/*.gox"
1335 -
1336 - # Disable RANDMMAP so PCH works. #301299
1337 - pax-mark -r "${D}${PREFIX}/libexec/gcc/${CTARGET}/${GCC_CONFIG_VER}/cc1"
1338 - pax-mark -r "${D}${PREFIX}/libexec/gcc/${CTARGET}/${GCC_CONFIG_VER}/cc1plus"
1339 -
1340 -}
1341 -
1342 -gcc_slot_java() {
1343 - local x
1344 -
1345 - # Move Java headers to compiler-specific dir
1346 - for x in "${D}"${PREFIX}/include/gc*.h "${D}"${PREFIX}/include/j*.h ; do
1347 - [[ -f ${x} ]] && mv -f "${x}" "${D}"${LIBPATH}/include/
1348 - done
1349 - for x in gcj gnu java javax org ; do
1350 - if [[ -d ${D}${PREFIX}/include/${x} ]] ; then
1351 - dodir /${LIBPATH}/include/${x}
1352 - mv -f "${D}"${PREFIX}/include/${x}/* "${D}"${LIBPATH}/include/${x}/
1353 - rm -rf "${D}"${PREFIX}/include/${x}
1354 - fi
1355 - done
1356 -
1357 - if [[ -d ${D}${PREFIX}/lib/security ]] || [[ -d ${D}${PREFIX}/$(get_libdir)/security ]] ; then
1358 - dodir /${LIBPATH}/security
1359 - mv -f "${D}"${PREFIX}/lib*/security/* "${D}"${LIBPATH}/security
1360 - rm -rf "${D}"${PREFIX}/lib*/security
1361 - fi
1362 -
1363 - # Move random gcj files to compiler-specific directories
1364 - for x in libgcj.spec logging.properties ; do
1365 - x="${D}${PREFIX}/lib/${x}"
1366 - [[ -f ${x} ]] && mv -f "${x}" "${D}"${LIBPATH}/
1367 - done
1368 -
1369 - # SLOT up libgcj.pc if it's available (and let gcc-config worry about links)
1370 - for x in "${D}"${PREFIX}/lib*/pkgconfig/libgcj*.pc ; do
1371 - [[ -f ${x} ]] || continue
1372 - sed -i "/^libdir=/s:=.*:=${LIBPATH}:" "${x}"
1373 - mv "${x}" "${D}"/usr/lib/pkgconfig/libgcj-${GCC_PV}.pc || die
1374 - done
1375 -
1376 - # Rename jar because it could clash with Kaffe's jar if this gcc is
1377 - # primary compiler (aka don't have the -<version> extension)
1378 - cd "${D}"${BINPATH}
1379 - [[ -f jar ]] && mv -f jar gcj-jar
1380 -}
1381 -
1382 -# Move around the libs to the right location. For some reason,
1383 -# when installing gcc, it dumps internal libraries into /usr/lib
1384 -# instead of the private gcc lib path
1385 -gcc_movelibs() {
1386 -
1387 - local multiarg removedirs=""
1388 - for multiarg in $($(XGCC) -print-multi-lib) ; do
1389 - multiarg=${multiarg#*;}
1390 - multiarg=${multiarg//@/ -}
1391 -
1392 - local OS_MULTIDIR=$($(XGCC) ${multiarg} --print-multi-os-directory)
1393 - local MULTIDIR=$($(XGCC) ${multiarg} --print-multi-directory)
1394 - local TODIR=${D}${LIBPATH}/${MULTIDIR}
1395 - local FROMDIR=
1396 -
1397 - [[ -d ${TODIR} ]] || mkdir -p ${TODIR}
1398 -
1399 - for FROMDIR in \
1400 - ${LIBPATH}/${OS_MULTIDIR} \
1401 - ${LIBPATH}/../${MULTIDIR} \
1402 - ${PREFIX}/lib/${OS_MULTIDIR} \
1403 - ${PREFIX}/${CTARGET}/lib/${OS_MULTIDIR}
1404 - do
1405 - removedirs="${removedirs} ${FROMDIR}"
1406 - FROMDIR=${D}${FROMDIR}
1407 - if [[ ${FROMDIR} != "${TODIR}" && -d ${FROMDIR} ]] ; then
1408 - local files=$(find "${FROMDIR}" -maxdepth 1 ! -type d 2>/dev/null)
1409 - if [[ -n ${files} ]] ; then
1410 - mv ${files} "${TODIR}"
1411 - fi
1412 - fi
1413 - done
1414 - fix_libtool_libdir_paths "${LIBPATH}/${MULTIDIR}"
1415 - done
1416 -
1417 - # We remove directories separately to avoid this case:
1418 - # mv SRC/lib/../lib/*.o DEST
1419 - # rmdir SRC/lib/../lib/
1420 - # mv SRC/lib/../lib32/*.o DEST # Bork
1421 - for FROMDIR in ${removedirs} ; do
1422 - rmdir "${D}"${FROMDIR} >& /dev/null
1423 - done
1424 - find "${D}" -type d | xargs rmdir >& /dev/null
1425 -}
1426 -
1427 -#----<< src_* >>----
1428 -
1429 -#---->> unorganized crap in need of refactoring follows
1430 -
1431 -# gcc_quick_unpack will unpack the gcc tarball and patches in a way that is
1432 -# consistant with the behavior of get_gcc_src_uri. The only patch it applies
1433 -# itself is the branch update if present.
1434 -#
1435 -# Travis Tilley <lv@g.o> (03 Sep 2004)
1436 -#
1437 -gcc_quick_unpack() {
1438 - pushd "${WORKDIR}" > /dev/null
1439 - export PATCH_GCC_VER=${PATCH_GCC_VER:-${GCC_RELEASE_VER}}
1440 - export UCLIBC_GCC_VER=${UCLIBC_GCC_VER:-${PATCH_GCC_VER}}
1441 - export PIE_GCC_VER=${PIE_GCC_VER:-${GCC_RELEASE_VER}}
1442 - export HTB_GCC_VER=${HTB_GCC_VER:-${GCC_RELEASE_VER}}
1443 - export SPECS_GCC_VER=${SPECS_GCC_VER:-${GCC_RELEASE_VER}}
1444 -
1445 - if [[ -n ${GCC_A_FAKEIT} ]] ; then
1446 - unpack ${GCC_A_FAKEIT}
1447 - elif [[ -n ${PRERELEASE} ]] ; then
1448 - unpack gcc-${PRERELEASE}.tar.bz2
1449 - elif [[ -n ${SNAPSHOT} ]] ; then
1450 - unpack gcc-${SNAPSHOT}.tar.bz2
1451 - elif [[ ${PV} != *9999* ]] ; then
1452 - unpack gcc-${GCC_RELEASE_VER}.tar.bz2
1453 - # We want branch updates to be against a release tarball
1454 - if [[ -n ${BRANCH_UPDATE} ]] ; then
1455 - pushd "${S}" > /dev/null
1456 - epatch "${DISTDIR}"/gcc-${GCC_RELEASE_VER}-branch-update-${BRANCH_UPDATE}.patch.bz2
1457 - popd > /dev/null
1458 - fi
1459 - fi
1460 -
1461 - if [[ -n ${D_VER} ]] && use d ; then
1462 - pushd "${S}"/gcc > /dev/null
1463 - unpack gdc-${D_VER}-src.tar.bz2
1464 - cd ..
1465 - ebegin "Adding support for the D language"
1466 - ./gcc/d/setup-gcc.sh >& "${T}"/dgcc.log
1467 - if ! eend $? ; then
1468 - eerror "The D gcc package failed to apply"
1469 - eerror "Please include this log file when posting a bug report:"
1470 - eerror " ${T}/dgcc.log"
1471 - die "failed to include the D language"
1472 - fi
1473 - popd > /dev/null
1474 - fi
1475 -
1476 - [[ -n ${PATCH_VER} ]] && \
1477 - unpack gcc-${PATCH_GCC_VER}-patches-${PATCH_VER}.tar.bz2
1478 -
1479 - [[ -n ${UCLIBC_VER} ]] && \
1480 - unpack gcc-${UCLIBC_GCC_VER}-uclibc-patches-${UCLIBC_VER}.tar.bz2
1481 -
1482 - if want_pie ; then
1483 - unpack gcc-${PIE_GCC_VER}-piepatches-v${PIE_VER}.tar.bz2
1484 - [[ -n ${SPECS_VER} ]] && \
1485 - unpack gcc-${SPECS_GCC_VER}-specs-${SPECS_VER}.tar.bz2
1486 - fi
1487 -
1488 - use_if_iuse boundschecking && unpack "bounds-checking-gcc-${HTB_GCC_VER}-${HTB_VER}.patch.bz2"
1489 -
1490 - popd > /dev/null
1491 -}
1492 -
1493 -do_gcc_HTB_patches() {
1494 - use_if_iuse boundschecking || return 0
1495 -
1496 - # modify the bounds checking patch with a regression patch
1497 - epatch "${WORKDIR}/bounds-checking-gcc-${HTB_GCC_VER}-${HTB_VER}.patch"
1498 - BRANDING_GCC_PKGVERSION="${BRANDING_GCC_PKGVERSION}, HTB-${HTB_GCC_VER}-${HTB_VER}"
1499 -}
1500 -
1501 -# do various updates to PIE logic
1502 -do_gcc_PIE_patches() {
1503 - want_pie || return 0
1504 -
1505 - use vanilla && return 0
1506 -
1507 - guess_patch_type_in_dir "${WORKDIR}"/piepatch/
1508 - EPATCH_MULTI_MSG="Applying pie patches ..." \
1509 - epatch "${WORKDIR}"/piepatch/
1510 -
1511 - BRANDING_GCC_PKGVERSION="${BRANDING_GCC_PKGVERSION}, pie-${PIE_VER}"
1512 -}
1513 -
1514 -should_we_gcc_config() {
1515 - # we always want to run gcc-config if we're bootstrapping, otherwise
1516 - # we might get stuck with the c-only stage1 compiler
1517 - use bootstrap && return 0
1518 - use build && return 0
1519 -
1520 - # if the current config is invalid, we definitely want a new one
1521 - # Note: due to bash quirkiness, the following must not be 1 line
1522 - local curr_config
1523 - curr_config=$(env -i ROOT="${ROOT}" gcc-config -c ${CTARGET} 2>&1) || return 0
1524 -
1525 - # if the previously selected config has the same major.minor (branch) as
1526 - # the version we are installing, then it will probably be uninstalled
1527 - # for being in the same SLOT, make sure we run gcc-config.
1528 - local curr_config_ver=$(env -i ROOT="${ROOT}" gcc-config -S ${curr_config} | awk '{print $2}')
1529 -
1530 - local curr_branch_ver=$(get_version_component_range 1-2 ${curr_config_ver})
1531 -
1532 - # If we're using multislot, just run gcc-config if we're installing
1533 - # to the same profile as the current one.
1534 - use multislot && return $([[ ${curr_config_ver} == ${GCC_CONFIG_VER} ]])
1535 -
1536 - if [[ ${curr_branch_ver} == ${GCC_BRANCH_VER} ]] ; then
1537 - return 0
1538 - else
1539 - # if we're installing a genuinely different compiler version,
1540 - # we should probably tell the user -how- to switch to the new
1541 - # gcc version, since we're not going to do it for him/her.
1542 - # We don't want to switch from say gcc-3.3 to gcc-3.4 right in
1543 - # the middle of an emerge operation (like an 'emerge -e world'
1544 - # which could install multiple gcc versions).
1545 - einfo "The current gcc config appears valid, so it will not be"
1546 - einfo "automatically switched for you. If you would like to"
1547 - einfo "switch to the newly installed gcc version, do the"
1548 - einfo "following:"
1549 - echo
1550 - einfo "gcc-config ${CTARGET}-${GCC_CONFIG_VER}"
1551 - einfo "source /etc/profile"
1552 - echo
1553 - ebeep
1554 - return 1
1555 - fi
1556 -}
1557 -
1558 -do_gcc_config() {
1559 - if ! should_we_gcc_config ; then
1560 - env -i ROOT="${ROOT}" gcc-config --use-old --force
1561 - return 0
1562 - fi
1563 -
1564 - local current_gcc_config="" current_specs="" use_specs=""
1565 -
1566 - current_gcc_config=$(env -i ROOT="${ROOT}" gcc-config -c ${CTARGET} 2>/dev/null)
1567 - if [[ -n ${current_gcc_config} ]] ; then
1568 - # figure out which specs-specific config is active
1569 - current_specs=$(gcc-config -S ${current_gcc_config} | awk '{print $3}')
1570 - [[ -n ${current_specs} ]] && use_specs=-${current_specs}
1571 - fi
1572 - if [[ -n ${use_specs} ]] && \
1573 - [[ ! -e ${ROOT}/etc/env.d/gcc/${CTARGET}-${GCC_CONFIG_VER}${use_specs} ]]
1574 - then
1575 - ewarn "The currently selected specs-specific gcc config,"
1576 - ewarn "${current_specs}, doesn't exist anymore. This is usually"
1577 - ewarn "due to enabling/disabling hardened or switching to a version"
1578 - ewarn "of gcc that doesnt create multiple specs files. The default"
1579 - ewarn "config will be used, and the previous preference forgotten."
1580 - ebeep
1581 - epause
1582 - use_specs=""
1583 - fi
1584 -
1585 - gcc-config ${CTARGET}-${GCC_CONFIG_VER}${use_specs}
1586 -}
1587 -
1588 -gcc_version_patch() {
1589 - # gcc-4.3+ has configure flags (whoo!)
1590 - tc_version_is_at_least 4.3 && return 0
1591 -}
1592 -
1593 -# This is a historical wart. The original Gentoo/amd64 port used:
1594 -# lib32 - 32bit binaries (x86)
1595 -# lib64 - 64bit binaries (x86_64)
1596 -# lib - "native" binaries (a symlink to lib64)
1597 -# Most other distros use the logic (including mainline gcc):
1598 -# lib - 32bit binaries (x86)
1599 -# lib64 - 64bit binaries (x86_64)
1600 -# Over time, Gentoo is migrating to the latter form.
1601 -#
1602 -# Unfortunately, due to distros picking the lib32 behavior, newer gcc
1603 -# versions will dynamically detect whether to use lib or lib32 for its
1604 -# 32bit multilib. So, to keep the automagic from getting things wrong
1605 -# while people are transitioning from the old style to the new style,
1606 -# we always set the MULTILIB_OSDIRNAMES var for relevant targets.
1607 -setup_multilib_osdirnames() {
1608 - is_multilib || return 0
1609 -
1610 - local config
1611 - local libdirs="../lib64 ../lib32"
1612 -
1613 - # this only makes sense for some Linux targets
1614 - case ${CTARGET} in
1615 - x86_64*-linux*) config="i386" ;;
1616 - powerpc64*-linux*) config="rs6000" ;;
1617 - sparc64*-linux*) config="sparc" ;;
1618 - s390x*-linux*) config="s390" ;;
1619 - *) return 0 ;;
1620 - esac
1621 - config+="/t-linux64"
1622 -
1623 - if [[ ${SYMLINK_LIB} == "yes" ]] ; then
1624 - einfo "updating multilib directories to be: ${libdirs}"
1625 - # drop the 4.6.2 stuff once 4.7 goes stable
1626 - if tc_version_is_at_least 4.7 ||
1627 - ( tc_version_is_at_least 4.6.2 && has x32 $(get_all_abis) )
1628 - then
1629 - set -- -e '/^MULTILIB_OSDIRNAMES.*lib32/s:[$][(]if.*):../lib32:'
1630 - else
1631 - set -- -e "/^MULTILIB_OSDIRNAMES/s:=.*:= ${libdirs}:"
1632 - fi
1633 - else
1634 - einfo "using upstream multilib; disabling lib32 autodetection"
1635 - set -- -r -e 's:[$][(]if.*,(.*)[)]:\1:'
1636 - fi
1637 - sed -i "$@" "${S}"/gcc/config/${config} || die
1638 -}
1639 -
1640 -disable_multilib_libjava() {
1641 - # We dont want a multilib libjava, so lets use this hack taken from fedora
1642 - sed -i -r \
1643 - -e 's/^((all:) all-redirect)/ifeq (\$(MULTISUBDIR),)\n\1\nelse\n\2\n\techo Multilib libjava disabled\nendif/' \
1644 - -e 's/^((install:) install-redirect)/ifeq (\$(MULTISUBDIR),)\n\1\nelse\n\2\n\techo Multilib libjava disabled\nendif/' \
1645 - -e 's/^((check:) check-redirect)/ifeq (\$(MULTISUBDIR),)\n\1\nelse\n\2\n\techo Multilib libjava disabled\nendif/' \
1646 - -e 's/^((all:) all-recursive)/ifeq (\$(MULTISUBDIR),)\n\1\nelse\n\2\n\techo Multilib libjava disabled\nendif/' \
1647 - -e 's/^((install:) install-recursive)/ifeq (\$(MULTISUBDIR),)\n\1\nelse\n\2\n\techo Multilib libjava disabled\nendif/' \
1648 - -e 's/^((check:) check-recursive)/ifeq (\$(MULTISUBDIR),)\n\1\nelse\n\2\n\techo Multilib libjava disabled\nendif/' \
1649 - "${S}"/libjava/Makefile.in || die
1650 -}
1651 -
1652 -# make sure the libtool archives have libdir set to where they actually
1653 -# -are-, and not where they -used- to be. also, any dependencies we have
1654 -# on our own .la files need to be updated.
1655 -fix_libtool_libdir_paths() {
1656 - pushd "${D}" >/dev/null
1657 -
1658 - pushd "./${1}" >/dev/null
1659 - local dir="${PWD#${D%/}}"
1660 - local allarchives=$(echo *.la)
1661 - allarchives="\(${allarchives// /\\|}\)"
1662 - popd >/dev/null
1663 -
1664 - sed -i \
1665 - -e "/^libdir=/s:=.*:='${dir}':" \
1666 - ./${dir}/*.la
1667 - sed -i \
1668 - -e "/^dependency_libs=/s:/[^ ]*/${allarchives}:${LIBPATH}/\1:g" \
1669 - $(find ./${PREFIX}/lib* -maxdepth 3 -name '*.la') \
1670 - ./${dir}/*.la
1671 -
1672 - popd >/dev/null
1673 -}
1674 -
1675 -is_multilib() {
1676 - tc_version_is_at_least 3 || return 1
1677 - use multilib
1678 -}
1679 -
1680 -is_cxx() {
1681 - gcc-lang-supported 'c++' || return 1
1682 - use cxx
1683 -}
1684 -
1685 -is_d() {
1686 - gcc-lang-supported d || return 1
1687 - use_if_iuse d
1688 -}
1689 -
1690 -is_f77() {
1691 - gcc-lang-supported f77 || return 1
1692 - use fortran
1693 -}
1694 -
1695 -is_f95() {
1696 - gcc-lang-supported f95 || return 1
1697 - use fortran
1698 -}
1699 -
1700 -is_fortran() {
1701 - gcc-lang-supported fortran || return 1
1702 - use fortran
1703 -}
1704 -
1705 -is_gcj() {
1706 - gcc-lang-supported java || return 1
1707 - use cxx && use_if_iuse gcj
1708 -}
1709 -
1710 -is_go() {
1711 - gcc-lang-supported go || return 1
1712 - use cxx && use_if_iuse go
1713 -}
1714 -
1715 -is_objc() {
1716 - gcc-lang-supported objc || return 1
1717 - use_if_iuse objc
1718 -}
1719 -
1720 -is_objcxx() {
1721 - gcc-lang-supported 'obj-c++' || return 1
1722 - use cxx && use_if_iuse objc++
1723 -}
1724 -
1725 -is_ada() {
1726 - gcc-lang-supported ada || return 1
1727 - use ada
1728 -}
1729 -
1730 -is_treelang() {
1731 - use_if_iuse boundschecking && return 1 #260532
1732 - is_crosscompile && return 1 #199924
1733 - gcc-lang-supported treelang || return 1
1734 - #use treelang
1735 - return 0
1736 -}