/[gentoo-alt]/trunk/prefix/eclass/toolchain.eclass
Gentoo

Contents of /trunk/prefix/eclass/toolchain.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 963 - (show annotations) (download)
Wed Jan 25 20:22:45 2006 UTC (8 years, 7 months ago) by grobian
File size: 70647 byte(s)
Fixing toolchain eclasses for prefix use.  It works better if the linker
looks in the prefix for libraries...


1 # Copyright 1999-2005 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/eclass/toolchain.eclass,v 1.232 2005/12/12 17:47:19 vapier Exp $
4
5 HOMEPAGE="http://www.gnu.org/software/gcc/gcc.html"
6 LICENSE="GPL-2 LGPL-2.1"
7 RESTRICT="nostrip" # cross-compilers need controlled stripping
8
9 #---->> eclass stuff <<----
10 inherit eutils versionator libtool toolchain-funcs flag-o-matic gnuconfig multilib fixheadtails
11
12 EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_test pkg_preinst src_install pkg_postinst pkg_prerm pkg_postrm
13 DESCRIPTION="Based on the ${ECLASS} eclass"
14
15 FEATURES=${FEATURES/multilib-strict/}
16
17 toolchain_pkg_setup() {
18 gcc_pkg_setup
19 }
20 toolchain_src_unpack() {
21 gcc_src_unpack
22 }
23 toolchain_src_compile() {
24 gcc_src_compile
25 }
26 toolchain_src_test() {
27 gcc_src_test
28 }
29 toolchain_pkg_preinst() {
30 ${ETYPE}_pkg_preinst
31 }
32 toolchain_src_install() {
33 ${ETYPE}_src_install
34 }
35 toolchain_pkg_postinst() {
36 ${ETYPE}_pkg_postinst
37 }
38 toolchain_pkg_prerm() {
39 ${ETYPE}_pkg_prerm
40 }
41 toolchain_pkg_postrm() {
42 ${ETYPE}_pkg_postrm
43 }
44 #----<< eclass stuff >>----
45
46
47 #---->> globals <<----
48 export CTARGET=${CTARGET:-${CHOST}}
49 if [[ ${CTARGET} = ${CHOST} ]] ; then
50 if [[ ${CATEGORY/cross-} != ${CATEGORY} ]] ; then
51 export CTARGET=${CATEGORY/cross-}
52 fi
53 fi
54 is_crosscompile() {
55 [[ ${CHOST} != ${CTARGET} ]]
56 }
57
58 GCC_RELEASE_VER=$(get_version_component_range 1-3)
59 GCC_BRANCH_VER=$(get_version_component_range 1-2)
60 GCCMAJOR=$(get_version_component_range 1)
61 GCCMINOR=$(get_version_component_range 2)
62 GCCMICRO=$(get_version_component_range 3)
63 [[ ${BRANCH_UPDATE-notset} == "notset" ]] && BRANCH_UPDATE=$(get_version_component_range 4)
64
65 # According to gcc/c-cppbuiltin.c, GCC_CONFIG_VER MUST match this regex.
66 # ([^0-9]*-)?[0-9]+[.][0-9]+([.][0-9]+)?([- ].*)?
67 GCC_CONFIG_VER=${GCC_CONFIG_VER:-"$(replace_version_separator 3 '-')"}
68
69 # Pre-release support
70 if [[ ${PV} != ${PV/_pre/-} ]] ; then
71 PRERELEASE=${PV/_pre/-}
72 fi
73 # make _alpha and _beta ebuilds automatically use a snapshot
74 if [[ ${PV} != ${PV/_alpha/} ]] ; then
75 SNAPSHOT=${GCC_BRANCH_VER}-${PV##*_alpha}
76 elif [[ ${PV} != ${PV/_beta/} ]] ; then
77 SNAPSHOT=${GCC_BRANCH_VER}-${PV##*_beta}
78 fi
79 export GCC_FILESDIR=${GCC_FILESDIR:-${FILESDIR}}
80
81 if [[ ${ETYPE} == "gcc-library" ]] ; then
82 GCC_VAR_TYPE=${GCC_VAR_TYPE:-non-versioned}
83 GCC_LIB_COMPAT_ONLY=${GCC_LIB_COMPAT_ONLY:-true}
84 GCC_TARGET_NO_MULTILIB=${GCC_TARGET_NO_MULTILIB:-true}
85 else
86 GCC_VAR_TYPE=${GCC_VAR_TYPE:-versioned}
87 GCC_LIB_COMPAT_ONLY="false"
88 GCC_TARGET_NO_MULTILIB=${GCC_TARGET_NO_MULTILIB:-false}
89 fi
90
91 TC_PREFIX=${TOOLCHAIN_PREFIX:-/usr}
92
93 if [[ ${GCC_VAR_TYPE} == "versioned" ]] ; then
94 if version_is_at_least 3.4.0 ; then
95 LIBPATH=${TOOLCHAIN_LIBPATH:-${TC_PREFIX}/lib/gcc/${CTARGET}/${GCC_CONFIG_VER}}
96 else
97 LIBPATH=${TOOLCHAIN_LIBPATH:-${TC_PREFIX}/lib/gcc-lib/${CTARGET}/${GCC_CONFIG_VER}}
98 fi
99 LIBEXECPATH=${TOOLCHAIN_LIBEXE:-${TC_PREFIX}/libexec/gcc/${CTARGET}/${GCC_CONFIG_VER}}
100 INCLUDEPATH=${TOOLCHAIN_INCLUDEPATH:-${LIBPATH}/include}
101 BINPATH=${TOOLCHAIN_BINPATH:-${TC_PREFIX}/${CTARGET}/gcc-bin/${GCC_CONFIG_VER}}
102 DATAPATH=${TOOLCHAIN_DATAPATH:-${TC_PREFIX}/share/gcc-data/${CTARGET}/${GCC_CONFIG_VER}}
103 # Dont install in /usr/include/g++-v3/, but in gcc internal directory.
104 # We will handle /usr/include/g++-v3/ with gcc-config ...
105 STDCXX_INCDIR=${TOOLCHAIN_STDCXX_INCDIR:-${LIBPATH}/include/g++-v${GCC_BRANCH_VER/\.*/}}
106 elif [[ ${GCC_VAR_TYPE} == "non-versioned" ]] ; then
107 # using non-versioned directories to install gcc, like what is currently
108 # done for ppc64 and 3.3.3_pre, is a BAD IDEA. DO NOT do it!! However...
109 # setting up variables for non-versioned directories might be useful for
110 # specific gcc targets, like libffi. Note that we dont override the value
111 # returned by get_libdir here.
112 LIBPATH=${TOOLCHAIN_LIBPATH:-${TC_PREFIX}/$(get_libdir)}
113 LIBEXECPATH=${TOOLCHAIN_LIBEXE:-${TC_PREFIX}/libexec/gcc}
114 INCLUDEPATH=${TOOLCHAIN_INCLUDEPATH:-${TC_PREFIX}/include}
115 BINPATH=${TOOLCHAIN_BINPATH:-${TC_PREFIX}/bin}
116 DATAPATH=${TOOLCHAIN_DATAPATH:-${TC_PREFIX}/share}
117 STDCXX_INCDIR=${TOOLCHAIN_STDCXX_INCDIR:-${TC_PREFIX}/include/g++-v3}
118 fi
119
120 XGCC="${WORKDIR}/build/gcc/xgcc -B${WORKDIR}/build/gcc"
121 #----<< globals >>----
122
123
124 #---->> SLOT+IUSE logic <<----
125 if [[ ${ETYPE} == "gcc-library" ]] ; then
126 IUSE="nls build"
127 SLOT="${CTARGET}-${SO_VERSION_SLOT:-5}"
128 else
129 IUSE="altivec bootstrap build fortran gcj gtk hardened ip28 multilib multislot n32 n64 nls nocxx objc objc-gc vanilla mudflap"
130 [[ -n ${PIE_VER} ]] && IUSE="${IUSE} nopie"
131 [[ -n ${PP_VER} ]] && IUSE="${IUSE} nossp"
132 [[ -n ${HTB_VER} ]] && IUSE="${IUSE} boundschecking"
133 # Support upgrade paths here or people get pissed
134 if use multislot ; then
135 SLOT="${CTARGET}-${GCC_CONFIG_VER}"
136 elif is_crosscompile; then
137 SLOT="${CTARGET}-${GCC_BRANCH_VER}"
138 else
139 SLOT="${GCC_BRANCH_VER}"
140 fi
141 fi
142 #----<< SLOT+IUSE logic >>----
143
144
145 #---->> S + SRC_URI essentials <<----
146
147 # This function sets the source directory depending on whether we're using
148 # a prerelease, snapshot, or release tarball. To use it, just set S with:
149 #
150 # S="$(gcc_get_s_dir)"
151 #
152 # Travis Tilley <lv@gentoo.org> (03 Sep 2004)
153 #
154 gcc_get_s_dir() {
155 if [[ -n ${PRERELEASE} ]] ; then
156 GCC_S=${WORKDIR}/gcc-${PRERELEASE}
157 elif [[ -n ${SNAPSHOT} ]] ; then
158 GCC_S=${WORKDIR}/gcc-${SNAPSHOT}
159 else
160 GCC_S=${WORKDIR}/gcc-${GCC_RELEASE_VER}
161 fi
162
163 echo "${GCC_S}"
164 }
165
166 # This function handles the basics of setting the SRC_URI for a gcc ebuild.
167 # To use, set SRC_URI with:
168 #
169 # SRC_URI="$(get_gcc_src_uri)"
170 #
171 # Other than the variables normally set by portage, this function's behavior
172 # can be altered by setting the following:
173 #
174 # SNAPSHOT
175 # If set, this variable signals that we should be using a snapshot
176 # of gcc from ftp://sources.redhat.com/pub/gcc/snapshots/. It is
177 # expected to be in the format "YYYY-MM-DD". Note that if the ebuild
178 # has a _pre suffix, this variable is ignored and the prerelease
179 # tarball is used instead.
180 #
181 # BRANCH_UPDATE
182 # If set, this variable signals that we should be using the main
183 # release tarball (determined by ebuild version) and applying a
184 # CVS branch update patch against it. The location of this branch
185 # update patch is assumed to be in ${GENTOO_TOOLCHAIN_BASE_URI}.
186 # Just like with SNAPSHOT, this variable is ignored if the ebuild
187 # has a _pre suffix.
188 #
189 # PATCH_VER
190 # PATCH_GCC_VER
191 # This should be set to the version of the gentoo patch tarball.
192 # The resulting filename of this tarball will be:
193 # gcc-${PATCH_GCC_VER:-${GCC_RELEASE_VER}}-patches-${PATCH_VER}.tar.bz2
194 #
195 # PIE_VER
196 # PIE_GCC_VER
197 # obsoleted: PIE_CORE
198 # These variables control patching in various updates for the logic
199 # controlling Position Independant Executables. PIE_VER is expected
200 # to be the version of this patch, PIE_GCC_VER the gcc version of
201 # the patch, and PIE_CORE (obsoleted) the actual filename of the patch.
202 # An example:
203 # PIE_VER="8.7.6.5"
204 # PIE_GCC_VER="3.4.0"
205 # The resulting filename of this tarball will be:
206 # gcc-${PIE_GCC_VER:-${GCC_RELEASE_VER}}-piepatches-v${PIE_VER}.tar.bz2
207 # old syntax (do not define PIE_CORE anymore):
208 # PIE_CORE="gcc-3.4.0-piepatches-v${PIE_VER}.tar.bz2"
209 #
210 # PP_VER
211 # PP_GCC_VER
212 # obsoleted: PP_FVER
213 # These variables control patching in stack smashing protection
214 # support. They both control the version of ProPolice to download.
215 #
216 # PP_VER / PP_GCC_VER
217 # Used to roll our own custom tarballs of ssp.
218 # PP_FVER / PP_VER
219 # Used for mirroring ssp straight from IBM.
220 # PP_VER sets the version of the directory in which to find the
221 # patch, and PP_FVER sets the version of the patch itself. For
222 # example:
223 # PP_VER="3_4"
224 # PP_FVER="${PP_VER//_/.}-2"
225 # would download gcc3_4/protector-3.4-2.tar.gz
226 #
227 # HTB_VER
228 # HTB_GCC_VER
229 # These variables control whether or not an ebuild supports Herman
230 # ten Brugge's bounds-checking patches. If you want to use a patch
231 # for an older gcc version with a new gcc, make sure you set
232 # HTB_GCC_VER to that version of gcc.
233 #
234 # MAN_VER
235 # The version of gcc for which we will download manpages. This will
236 # default to ${GCC_RELEASE_VER}, but we may not want to pre-generate man pages
237 # for prerelease test ebuilds for example. This allows you to
238 # continue using pre-generated manpages from the last stable release.
239 # If set to "none", this will prevent the downloading of manpages,
240 # which is useful for individual library targets.
241 #
242 gentoo_urls() {
243 local devspace="HTTP~lv/GCC/URI HTTP~eradicator/gcc/URI HTTP~vapier/dist/URI
244 HTTP~halcy0n/patches/URI"
245 devspace=${devspace//HTTP/http:\/\/dev.gentoo.org\/}
246 echo mirror://gentoo/$1 ${devspace//URI/$1}
247 }
248 get_gcc_src_uri() {
249 export PATCH_GCC_VER=${PATCH_GCC_VER:-${GCC_RELEASE_VER}}
250 export UCLIBC_GCC_VER=${UCLIBC_GCC_VER:-${PATCH_GCC_VER}}
251 export PIE_GCC_VER=${PIE_GCC_VER:-${GCC_RELEASE_VER}}
252 export PP_GCC_VER=${PP_GCC_VER:-${GCC_RELEASE_VER}}
253 export HTB_GCC_VER=${HTB_GCC_VER:-${GCC_RELEASE_VER}}
254
255 [[ -n ${PIE_VER} ]] && \
256 PIE_CORE=${PIE_CORE:-gcc-${PIE_GCC_VER}-piepatches-v${PIE_VER}.tar.bz2}
257
258 # Set where to download gcc itself depending on whether we're using a
259 # prerelease, snapshot, or release tarball.
260 if [[ -n ${PRERELEASE} ]] ; then
261 GCC_SRC_URI="ftp://gcc.gnu.org/pub/gcc/prerelease-${PRERELEASE}/gcc-${PRERELEASE}.tar.bz2"
262 elif [[ -n ${SNAPSHOT} ]] ; then
263 GCC_SRC_URI="ftp://sources.redhat.com/pub/gcc/snapshots/${SNAPSHOT}/gcc-${SNAPSHOT}.tar.bz2"
264 else
265 GCC_SRC_URI="mirror://gnu/gcc/gcc-${PV}/gcc-${GCC_RELEASE_VER}.tar.bz2"
266 # we want all branch updates to be against the main release
267 [[ -n ${BRANCH_UPDATE} ]] && \
268 GCC_SRC_URI="${GCC_SRC_URI} $(gentoo_urls gcc-${GCC_RELEASE_VER}-branch-update-${BRANCH_UPDATE}.patch.bz2)"
269 fi
270
271 # propolice aka stack smashing protection
272 if [[ -n ${PP_VER} ]] ; then
273 if [[ -n ${PP_FVER} ]] ; then
274 GCC_SRC_URI="${GCC_SRC_URI}
275 !nossp? (
276 http://www.research.ibm.com/trl/projects/security/ssp/gcc${PP_VER}/protector-${PP_FVER}.tar.gz
277 $(gentoo_urls protector-${PP_FVER}.tar.gz)
278 )"
279 else
280 GCC_SRC_URI="${GCC_SRC_URI} $(gentoo_urls gcc-${PP_GCC_VER}-ssp-${PP_VER}.tar.bz2)"
281 fi
282 fi
283
284 # uclibc lovin
285 [[ -n ${UCLIBC_VER} ]] && \
286 GCC_SRC_URI="${GCC_SRC_URI} $(gentoo_urls gcc-${UCLIBC_GCC_VER}-uclibc-patches-${UCLIBC_VER}.tar.bz2)"
287
288 # PERL cannot be present at bootstrap, and is used to build the man pages.
289 # So... lets include some pre-generated ones, shall we?
290 [[ -n ${MAN_VER} ]] && \
291 GCC_SRC_URI="${GCC_SRC_URI} $(gentoo_urls gcc-${MAN_VER}-manpages.tar.bz2)"
292
293 # various gentoo patches
294 [[ -n ${PATCH_VER} ]] && \
295 GCC_SRC_URI="${GCC_SRC_URI} $(gentoo_urls gcc-${PATCH_GCC_VER}-patches-${PATCH_VER}.tar.bz2)"
296
297 # strawberry pie, Cappuccino and a Gauloises (it's a good thing)
298 [[ -n ${PIE_VER} ]] && \
299 GCC_SRC_URI="${GCC_SRC_URI} !nopie? ( $(gentoo_urls ${PIE_CORE}) )"
300
301 # gcc bounds checking patch
302 if [[ -n ${HTB_VER} ]] ; then
303 local HTBFILE="bounds-checking-gcc-${HTB_GCC_VER}-${HTB_VER}.patch.bz2"
304 GCC_SRC_URI="${GCC_SRC_URI}
305 boundschecking? (
306 mirror://sourceforge/boundschecking/${HTBFILE}
307 http://web.inter.nl.net/hcc/Haj.Ten.Brugge/${HTBFILE}
308 $(gentoo_urls ${HTBFILE})
309 )"
310 fi
311
312 echo "${GCC_SRC_URI}"
313 }
314 S=$(gcc_get_s_dir)
315 SRC_URI=$(get_gcc_src_uri)
316 #---->> S + SRC_URI essentials >>----
317
318
319 #---->> support checks <<----
320
321 # The gentoo piessp patches allow for 3 configurations:
322 # 1) PIE+SSP by default
323 # 2) PIE by default
324 # 3) SSP by default
325 hardened_gcc_works() {
326 if [[ $1 == "pie" ]] ; then
327 want_pie || return 1
328 hardened_gcc_is_stable pie && return 0
329 if has ~$(tc-arch) ${ACCEPT_KEYWORDS} ; then
330 hardened_gcc_check_unsupported pie && return 1
331 ewarn "Allowing pie-by-default for an unstable arch ($(tc-arch))"
332 return 0
333 fi
334 return 1
335 elif [[ $1 == "ssp" ]] ; then
336 [[ -z ${PP_VER} ]] && return 1
337 hardened_gcc_is_stable ssp && return 0
338 if has ~$(tc-arch) ${ACCEPT_KEYWORDS} ; then
339 hardened_gcc_check_unsupported ssp && return 1
340 ewarn "Allowing ssp-by-default for an unstable arch ($(tc-arch))"
341 return 0
342 fi
343 return 1
344 else
345 # laziness ;)
346 hardened_gcc_works pie || return 1
347 hardened_gcc_works ssp || return 1
348 return 0
349 fi
350 }
351
352 hardened_gcc_is_stable() {
353 if [[ $1 == "pie" ]] ; then
354 # HARDENED_* variables are deprecated and here for compatibility
355 local tocheck="${HARDENED_PIE_WORKS} ${HARDENED_GCC_WORKS}"
356 if is_uclibc ; then
357 tocheck="${tocheck} ${PIE_UCLIBC_STABLE}"
358 else
359 tocheck="${tocheck} ${PIE_GLIBC_STABLE}"
360 fi
361 elif [[ $1 == "ssp" ]] ; then
362 # ditto
363 local tocheck="${HARDENED_SSP_WORKS} ${HARDENED_GCC_WORKS}"
364 if is_uclibc ; then
365 tocheck="${tocheck} ${SSP_UCLIBC_STABLE}"
366 else
367 tocheck="${tocheck} ${SSP_STABLE}"
368 fi
369 else
370 die "hardened_gcc_stable needs to be called with pie or ssp"
371 fi
372
373 hasq $(tc-arch) ${tocheck} && return 0
374 return 1
375 }
376
377 hardened_gcc_check_unsupported() {
378 local tocheck=""
379 # if a variable is unset, we assume that all archs are unsupported. since
380 # this function is never called if hardened_gcc_is_stable returns true,
381 # this shouldn't cause problems... however, allowing this logic to work
382 # even with the variables unset will break older ebuilds that dont use them.
383 if [[ $1 == "pie" ]] ; then
384 if is_uclibc ; then
385 [[ -z ${PIE_UCLIBC_UNSUPPORTED} ]] && return 0
386 tocheck="${tocheck} ${PIE_UCLIBC_UNSUPPORTED}"
387 else
388 [[ -z ${PIE_GLIBC_UNSUPPORTED} ]] && return 0
389 tocheck="${tocheck} ${PIE_GLIBC_UNSUPPORTED}"
390 fi
391 elif [[ $1 == "ssp" ]] ; then
392 if is_uclibc ; then
393 [[ -z ${SSP_UCLIBC_UNSUPPORTED} ]] && return 0
394 tocheck="${tocheck} ${SSP_UCLIBC_UNSUPPORTED}"
395 else
396 [[ -z ${SSP_UNSUPPORTED} ]] && return 0
397 tocheck="${tocheck} ${SSP_UNSUPPORTED}"
398 fi
399 else
400 die "hardened_gcc_check_unsupported needs to be called with pie or ssp"
401 fi
402
403 hasq $(tc-arch) ${tocheck} && return 0
404 return 1
405 }
406
407 has_libssp() {
408 [[ -e /$(get_libdir)/libssp.so ]] && return 0
409 return 1
410 }
411
412 want_libssp() {
413 [[ ${GCC_LIBSSP_SUPPORT} == "true" ]] || return 1
414 has_libssp || return 1
415 [[ -n ${PP_VER} ]] || return 1
416 return 0
417 }
418
419 _want_stuff() {
420 local var=$1 flag=$2
421 [[ -z ${!var} ]] && return 1
422 use ${flag} && return 0
423 return 1
424 }
425 want_boundschecking() { _want_stuff HTB_VER boundschecking ; }
426 want_pie() { _want_stuff PIE_VER !nopie ; }
427 want_ssp() { _want_stuff PP_VER !nossp ; }
428
429 want_split_specs() {
430 [[ ${SPLIT_SPECS} == "true" ]] && want_pie
431 }
432
433 # This function checks whether or not glibc has the support required to build
434 # Position Independant Executables with gcc.
435 glibc_have_pie() {
436 if [[ ! -f ${ROOT}/usr/$(get_libdir)/Scrt1.o ]] ; then
437 echo
438 ewarn "Your glibc does not have support for pie, the file Scrt1.o is missing"
439 ewarn "Please update your glibc to a proper version or disable hardened"
440 echo
441 return 1
442 fi
443 }
444
445 # This function determines whether or not libc has been patched with stack
446 # smashing protection support.
447 libc_has_ssp() {
448 local libc_prefix
449 [[ $(tc-arch) == "ppc64" ]] && [[ -z ${ABI} ]] && libc_prefix="lib64"
450 libc_prefix=${libc_prefix:-$(get_libdir)}
451 libc_prefix=${libc_prefix:-lib}
452
453 echo 'int main(){}' > "${T}"/libctest.c
454 gcc "${T}"/libctest.c -lc -o libctest
455 local libc_file=$(readelf -d libctest | grep 'NEEDED.*\[libc\.so[0-9\.]*\]' | awk '{print $NF}')
456 libc_file=${libc_file:1:${#libc_file}-2}
457
458 local my_libc=${ROOT}/${libc_prefix}/${libc_file}
459
460 # Check for the libc to have the __guard symbols
461 if [[ -n $(readelf -s "${my_libc}" 2>/dev/null | \
462 grep 'OBJECT.*GLOBAL.*__guard') ]] && \
463 [[ -n $(readelf -s "${my_libc}" 2>/dev/null | \
464 grep 'FUNC.*GLOBAL.*__stack_smash_handler') ]]
465 then
466 return 0
467 elif is_crosscompile ; then
468 die "'${my_libc}' was detected w/out ssp, that sucks (a lot)"
469 else
470 return 1
471 fi
472 }
473
474 # This is to make sure we don't accidentally try to enable support for a
475 # language that doesnt exist. GCC 3.4 supports f77, while 4.0 supports f95, etc.
476 #
477 # Travis Tilley <lv@gentoo.org> (26 Oct 2004)
478 #
479 gcc-lang-supported() {
480 grep ^language=\"${1}\" ${S}/gcc/*/config-lang.in > /dev/null && return 0
481 return 1
482 }
483
484 #----<< support checks >>----
485
486 #---->> specs + env.d logic <<----
487
488 # defaults to enable for all hardened toolchains
489 gcc_common_hard="-DEFAULT_RELRO -DEFAULT_BIND_NOW"
490
491 # configure to build with the hardened GCC specs as the default
492 make_gcc_hard() {
493 if hardened_gcc_works ; then
494 einfo "Updating gcc to use automatic PIE + SSP building ..."
495 sed -e "s|^HARD_CFLAGS = |HARD_CFLAGS = -DEFAULT_PIE_SSP ${gcc_common_hard} |" \
496 -i ${S}/gcc/Makefile.in || die "Failed to update gcc!"
497 elif hardened_gcc_works pie ; then
498 einfo "Updating gcc to use automatic PIE building ..."
499 ewarn "SSP has not been enabled by default"
500 sed -e "s|^HARD_CFLAGS = |HARD_CFLAGS = -DEFAULT_PIE ${gcc_common_hard} |" \
501 -i ${S}/gcc/Makefile.in || die "Failed to update gcc!"
502 elif hardened_gcc_works ssp ; then
503 einfo "Updating gcc to use automatic SSP building ..."
504 ewarn "PIE has not been enabled by default"
505 sed -e "s|^HARD_CFLAGS = |HARD_CFLAGS = -DEFAULT_SSP ${gcc_common_hard} |" \
506 -i ${S}/gcc/Makefile.in || die "Failed to update gcc!"
507 else
508 # do nothing if hardened isnt supported, but dont die either
509 ewarn "hardened is not supported for this arch in this gcc version"
510 ebeep
511 return 0
512 fi
513
514 # rebrand to make bug reports easier
515 release_version="${release_version/Gentoo/Gentoo Hardened}"
516 }
517
518 create_vanilla_specs_file() {
519 pushd ${WORKDIR}/build/gcc > /dev/null
520 if use hardened ; then
521 # if using hardened, then we need to move xgcc out of the way
522 # and recompile it
523 cp Makefile Makefile.orig
524 sed -i -e 's/^HARD_CFLAGS.*/HARD_CFLAGS = /g' Makefile
525 mv xgcc xgcc.hard
526 mv gcc.o gcc.o.hard
527 make xgcc
528 einfo "Creating a vanilla gcc specs file"
529 ./xgcc -dumpspecs > ${WORKDIR}/build/vanilla.specs
530 # restore everything to normal
531 mv gcc.o.hard gcc.o
532 mv xgcc.hard xgcc
533 mv Makefile.orig Makefile
534 else
535 einfo "Creating a vanilla gcc specs file"
536 ./xgcc -dumpspecs > ${WORKDIR}/build/vanilla.specs
537 fi
538 popd > /dev/null
539 }
540
541 create_hardened_specs_file() {
542 pushd ${WORKDIR}/build/gcc > /dev/null
543 if ! use hardened ; then
544 # if not using hardened, then we need to move xgcc out of the way
545 # and recompile it
546 cp Makefile Makefile.orig
547 sed -i -e "s/^HARD_CFLAGS.*/HARD_CFLAGS = -DEFAULT_PIE_SSP ${gcc_common_hard}/g" Makefile
548 mv xgcc xgcc.vanilla
549 mv gcc.o gcc.o.vanilla
550 make xgcc
551 einfo "Creating a hardened gcc specs file"
552 ./xgcc -dumpspecs > ${WORKDIR}/build/hardened.specs
553 # restore everything to normal
554 mv gcc.o.vanilla gcc.o
555 mv xgcc.vanilla xgcc
556 mv Makefile.orig Makefile
557 else
558 einfo "Creating a hardened gcc specs file"
559 ./xgcc -dumpspecs > ${WORKDIR}/build/hardened.specs
560 fi
561 popd > /dev/null
562 }
563
564 create_hardenednossp_specs_file() {
565 pushd ${WORKDIR}/build/gcc > /dev/null
566 cp Makefile Makefile.orig
567 sed -i -e "s/^HARD_CFLAGS.*/HARD_CFLAGS = -DEFAULT_PIE ${gcc_common_hard}/g" Makefile
568 mv xgcc xgcc.moo
569 mv gcc.o gcc.o.moo
570 make xgcc
571 einfo "Creating a hardened no-ssp gcc specs file"
572 ./xgcc -dumpspecs > ${WORKDIR}/build/hardenednossp.specs
573 # restore everything to normal
574 mv gcc.o.moo gcc.o
575 mv xgcc.moo xgcc
576 mv Makefile.orig Makefile
577 popd > /dev/null
578 }
579
580 create_hardenednopie_specs_file() {
581 pushd ${WORKDIR}/build/gcc > /dev/null
582 cp Makefile Makefile.orig
583 sed -i -e "s/^HARD_CFLAGS.*/HARD_CFLAGS = -DEFAULT_SSP ${gcc_common_hard}/g" Makefile
584 mv xgcc xgcc.moo
585 mv gcc.o gcc.o.moo
586 make xgcc
587 einfo "Creating a hardened no-pie gcc specs file"
588 ./xgcc -dumpspecs > ${WORKDIR}/build/hardenednopie.specs
589 # restore everything to normal
590 mv gcc.o.moo gcc.o
591 mv xgcc.moo xgcc
592 mv Makefile.orig Makefile
593 popd > /dev/null
594 }
595
596 create_hardenednopiessp_specs_file() {
597 pushd ${WORKDIR}/build/gcc > /dev/null
598 cp Makefile Makefile.orig
599 sed -i -e "s/^HARD_CFLAGS.*/HARD_CFLAGS = ${gcc_common_hard}/g" Makefile
600 mv xgcc xgcc.moo
601 mv gcc.o gcc.o.moo
602 make xgcc
603 einfo "Creating a hardened no-pie no-ssp gcc specs file"
604 ./xgcc -dumpspecs > ${WORKDIR}/build/hardenednopiessp.specs
605 # restore everything to normal
606 mv gcc.o.moo gcc.o
607 mv xgcc.moo xgcc
608 mv Makefile.orig Makefile
609 popd > /dev/null
610 }
611
612 split_out_specs_files() {
613 if hardened_gcc_works ; then
614 create_hardened_specs_file
615 create_vanilla_specs_file
616 create_hardenednossp_specs_file
617 create_hardenednopie_specs_file
618 elif hardened_gcc_works pie ; then
619 create_vanilla_specs_file
620 create_hardenednossp_specs_file
621 elif hardened_gcc_works ssp ; then
622 create_vanilla_specs_file
623 create_hardenednopie_specs_file
624 fi
625 create_hardenednopiessp_specs_file
626 }
627
628 create_gcc_env_entry() {
629 dodir /etc/env.d/gcc
630 local gcc_envd_base="/etc/env.d/gcc/${CTARGET}-${GCC_CONFIG_VER}"
631
632 if [[ -z $1 ]] ; then
633 gcc_envd_file="${D}${gcc_envd_base}"
634 # I'm leaving the following commented out to remind me that it
635 # was an insanely -bad- idea. Stuff broke. GCC_SPECS isnt unset
636 # on chroot or in non-toolchain.eclass gcc ebuilds!
637 #gcc_specs_file="${LIBPATH}/specs"
638 gcc_specs_file=""
639 else
640 gcc_envd_file="${D}${gcc_envd_base}-$1"
641 gcc_specs_file="${LIBPATH}/$1.specs"
642 fi
643
644 echo "PATH=\"${BINPATH}\"" > ${gcc_envd_file}
645 echo "ROOTPATH=\"${BINPATH}\"" >> ${gcc_envd_file}
646
647 if use multilib && ! has_multilib_profile; then
648 LDPATH="${LIBPATH}"
649 for path in 32 64 o32 ; do
650 [[ -d ${LIBPATH}/${path} ]] && LDPATH="${LDPATH}:${LIBPATH}/${path}"
651 done
652 else
653 local MULTIDIR
654 LDPATH="${LIBPATH}"
655
656 # We want to list the default ABI's LIBPATH first so libtool
657 # searches that directory first. This is a temporary
658 # workaround for libtool being stupid and using .la's from
659 # conflicting ABIs by using the first one in the search path
660
661 # XXX: This breaks when cross-compiling a native compiler (CBUILD != CHOST)
662
663 local abi=${DEFAULT_ABI}
664 local MULTIDIR=$(${XGCC} -B./ $(get_abi_CFLAGS ${abi}) --print-multi-directory)
665 if [[ ${MULTIDIR} == "." ]] ; then
666 LDPATH=${LIBPATH}
667 else
668 LDPATH=${LIBPATH}/${MULTIDIR}
669 fi
670
671 for abi in $(get_all_abis) ; do
672 [[ ${abi} == ${DEFAULT_ABI} ]] && continue
673
674 MULTIDIR=$(${XGCC} -B./ $(get_abi_CFLAGS ${abi}) --print-multi-directory)
675 if [[ ${MULTIDIR} == "." ]] ; then
676 LDPATH=${LDPATH}:${LIBPATH}
677 else
678 LDPATH=${LDPATH}:${LIBPATH}/${MULTIDIR}
679 fi
680 done
681 fi
682
683 echo "LDPATH=\"${LDPATH}\"" >> ${gcc_envd_file}
684
685 local mbits
686 CC=${XGCC} has_m32 && mbits="${mbits:+${mbits} }32"
687 CC=${XGCC} has_m64 && mbits="${mbits:+${mbits} }64"
688 echo "GCCBITS=\"${mbits}\"" >> ${gcc_envd_file}
689
690 echo "MANPATH=\"${DATAPATH}/man\"" >> ${gcc_envd_file}
691 echo "INFOPATH=\"${DATAPATH}/info\"" >> ${gcc_envd_file}
692 echo "STDCXX_INCDIR=\"${STDCXX_INCDIR##*/}\"" >> ${gcc_envd_file}
693
694 is_crosscompile && echo "CTARGET=${CTARGET}" >> ${gcc_envd_file}
695
696 # Set which specs file to use
697 [[ -n ${gcc_specs_file} ]] && echo "GCC_SPECS=\"${gcc_specs_file}\"" >> ${gcc_envd_file}
698 }
699
700 add_profile_eselect_conf() {
701 local compiler_config_file=$1
702 local abi=$2
703 local specs=$3
704 local gcc_specs_file
705 local var
706
707 if [[ -z ${specs} ]] ; then
708 # I'm leaving the following commented out to remind me that it
709 # was an insanely -bad- idea. Stuff broke. GCC_SPECS isnt unset
710 # on chroot or in non-toolchain.eclass gcc ebuilds!
711 #gcc_specs_file="${LIBPATH}/specs"
712 gcc_specs_file=""
713
714 if use hardened ; then
715 specs="hardened"
716 else
717 specs="vanilla"
718 fi
719 else
720 gcc_specs_file="${LIBPATH}/${specs}.specs"
721 fi
722
723 echo >> ${compiler_config_file}
724 if ! is_multilib ; then
725 echo "[${specs}]" >> ${compiler_config_file}
726 echo " ctarget=${CTARGET}" >> ${compiler_config_file}
727 else
728 echo "[${abi}-${specs}]" >> ${compiler_config_file}
729 var="CTARGET_${abi}"
730 if [[ -n ${!var} ]] ; then
731 echo " ctarget=${!var}" >> ${compiler_config_file}
732 else
733 var="CHOST_${abi}"
734 if [[ -n ${!var} ]] ; then
735 echo " ctarget=${!var}" >> ${compiler_config_file}
736 else
737 echo " ctarget=${CTARGET}" >> ${compiler_config_file}
738 fi
739 fi
740 fi
741
742 local MULTIDIR=$(${XGCC} -B./ $(get_abi_CFLAGS ${abi}) --print-multi-directory)
743 local LDPATH=${LIBPATH}
744 if [[ ${MULTIDIR} != "." ]] ; then
745 LDPATH="${LIBPATH}/${MULTIDIR}"
746 fi
747
748 echo " ldpath=${LDPATH}" >> ${compiler_config_file}
749
750 if [[ -n ${gcc_specs_file} ]] ; then
751 echo " specs=${gcc_specs_file}" >> ${compiler_config_file}
752 fi
753
754 var="CFLAGS_${abi}"
755 if [[ -n ${!var} ]] ; then
756 echo " cflags=${!var}" >> ${compiler_config_file}
757 fi
758 }
759
760 create_eselect_conf() {
761 local config_dir="/etc/eselect/compiler"
762 local compiler_config_file="${D}/${config_dir}/${CTARGET}-${GCC_CONFIG_VER}.conf"
763 local abi
764
765 dodir ${config_dir}
766
767 echo "[global]" > ${compiler_config_file}
768 echo " version=${CTARGET}-${GCC_CONFIG_VER}" >> ${compiler_config_file}
769 echo " binpath=${BINPATH}" >> ${compiler_config_file}
770 echo " manpath=${DATAPATH}/man" >> ${compiler_config_file}
771 echo " infopath=${DATAPATH}/info" >> ${compiler_config_file}
772 echo " alias_cc=gcc" >> ${compiler_config_file}
773 echo " stdcxx_incdir=${STDCXX_INCDIR##*/}" >> ${compiler_config_file}
774 echo " bin_prefix=${CTARGET}" >> ${compiler_config_file}
775
776 if [[ -x "${D}/${BINPATH}/${CTARGET}-g77" ]] ; then
777 echo " alias_gfortran=g77" >> ${compiler_config_file}
778 elif [[ -x "${D}/${BINPATH}/${CTARGET}-gfortran" ]] ; then
779 echo " alias_g77=gfortran" >> ${compiler_config_file}
780 fi
781
782 for abi in $(get_all_abis) ; do
783 add_profile_eselect_conf "${compiler_config_file}" "${abi}"
784
785 if want_split_specs ; then
786 if use hardened ; then
787 add_profile_eselect_conf "${compiler_config_file}" "${abi}" vanilla
788 elif hardened_gcc_works ; then
789 add_profile_eselect_conf "${compiler_config_file}" "${abi}" hardened
790 fi
791
792 if hardened_gcc_works || hardened_gcc_works pie ; then
793 add_profile_eselect_conf "${compiler_config_file}" "${abi}" hardenednossp
794 fi
795
796 if hardened_gcc_works || hardened_gcc_works ssp ; then
797 add_profile_eselect_conf "${compiler_config_file}" "${abi}" hardenednopie
798 fi
799
800 add_profile_eselect_conf "${compiler_config_file}" "${abi}" hardenednopiessp
801 fi
802 done
803 }
804
805 #----<< specs + env.d logic >>----
806
807 #---->> pkg_* <<----
808 gcc_pkg_setup() {
809 if [[ ( $(tc-arch) == "amd64" || $(tc-arch) == "ppc64" ) && ( ${LD_PRELOAD} == "/lib/libsandbox.so" || ${LD_PRELOAD} == "/usr/lib/libsandbox.so" ) ]] && is_multilib ; then
810 eerror "Sandbox in your installed portage does not support compilation."
811 eerror "of a multilib gcc. Please set FEATURES=-sandbox and try again."
812 eerror "After you have a multilib gcc, re-emerge portage to have a working sandbox."
813 die "No 32bit sandbox. Retry with FEATURES=-sandbox."
814 fi
815
816 if [[ ${ETYPE} == "gcc-compiler" ]] ; then
817 case $(tc-arch) in
818 mips)
819 # Must compile for mips64-linux target if we want n32/n64 support
820 case "${CTARGET}" in
821 mips64*) ;;
822 *)
823 if use n32 || use n64; then
824 eerror "n32/n64 can only be used when target host is mips64*-*-linux-*";
825 die "Invalid USE flags for CTARGET ($CTARGET)";
826 fi
827 ;;
828 esac
829
830 #cannot have both n32 & n64 without multilib
831 if use n32 && use n64 && ! is_multilib; then
832 eerror "Please enable multilib if you want to use both n32 & n64";
833 die "Invalid USE flag combination";
834 fi
835 ;;
836 esac
837
838 # Setup variables which would normally be in the profile
839 if is_crosscompile ; then
840 multilib_env ${CTARGET}
841 if ! use multilib ; then
842 MULTILIB_ABIS=${DEFAULT_ABI}
843 fi
844 fi
845
846 # we dont want to use the installed compiler's specs to build gcc!
847 unset GCC_SPECS
848 fi
849
850 want_libssp && libc_has_ssp && \
851 die "libssp cannot be used with a glibc that has been patched to provide ssp symbols"
852 }
853
854 gcc-compiler_pkg_preinst() {
855 :
856 }
857
858 gcc-compiler_pkg_postinst() {
859 export LD_LIBRARY_PATH=${LIBPATH}:${LD_LIBRARY_PATH}
860 do_gcc_config
861
862 echo
863 einfo "If you have issues with packages unable to locate libstdc++.la,"
864 einfo "then try running 'fix_libtool_files.sh' on the old gcc versions."
865 echo
866
867 # If our gcc-config version doesn't like '-' in it's version string,
868 # tell our users that gcc-config will yell at them, but it's all good.
869 if ! has_version '>=sys-devel/gcc-config-1.3.10-r1' && [[ ${GCC_CONFIG_VER/-/} != ${GCC_CONFIG_VER} ]] ; then
870 ewarn "Your version of gcc-config will issue about having an invalid profile"
871 ewarn "when switching to this profile. It is safe to ignore this warning,"
872 ewarn "and this problem has been corrected in >=sys-devel/gcc-config-1.3.10-r1."
873 fi
874
875 if ! is_crosscompile && ! use multislot && [[ ${GCCMAJOR}.${GCCMINOR} == 3.4 ]] ; then
876 echo
877 einfo "You should make sure to rebuild all your C++ packages when"
878 einfo "upgrading between different versions of gcc. For example,"
879 einfo "when moving to gcc-3.4 from gcc-3.3, emerge gentoolkit and run:"
880 einfo " # revdep-rebuild --library libstdc++.so.5"
881 echo
882 einfo "For more information on the steps to take when upgrading "
883 einfo "from gcc-3.3 please refer to: "
884 einfo "http://www.gentoo.org/proj/en/base/x86/gcc-upgrading-guide.xml"
885 echo
886 fi
887 }
888
889 gcc-compiler_pkg_prerm() {
890 # TODO: flesh this out when I care
891 return 0
892 }
893
894 gcc-compiler_pkg_postrm() {
895 # to make our lives easier (and saner), we do the fix_libtool stuff here.
896 # rather than checking SLOT's and trying in upgrade paths, we just see if
897 # the common libstdc++.la exists in the ${LIBPATH} of the gcc that we are
898 # unmerging. if it does, that means this was a simple re-emerge.
899
900 # clean up the cruft left behind by cross-compilers
901 if is_crosscompile ; then
902 if [[ -z $(ls "${ROOT}"/etc/env.d/gcc/${CTARGET}* 2>/dev/null) ]] ; then
903 rm -f "${ROOT}"/etc/env.d/gcc/config-${CTARGET}
904 rm -f "${ROOT}"/etc/env.d/??gcc-${CTARGET}
905 rm -f "${ROOT}"/usr/bin/${CTARGET}-{gcc,{g,c}++}{,32,64}
906 fi
907 return 0
908 fi
909
910 # ROOT isnt handled by the script
911 [[ ${ROOT} != "/" ]] && return 0
912
913 if [[ ! -e ${LIBPATH}/libstdc++.la ]] ; then
914 /sbin/fix_libtool_files.sh ${GCC_RELEASE_VER}
915 [[ -z ${BRANCH_UPDATE} ]] || /sbin/fix_libtool_files.sh ${GCC_RELEASE_VER}-${BRANCH_UPDATE}
916 fi
917
918 return 0
919 }
920
921 #---->> pkg_* <<----
922
923 #---->> src_* <<----
924
925 # generic GCC src_unpack, to be called from the ebuild's src_unpack.
926 # BIG NOTE regarding hardened support: ebuilds with support for hardened are
927 # expected to export the following variable:
928 #
929 # HARDENED_GCC_WORKS
930 # This variable should be set to the archs on which hardened should
931 # be allowed. For example: HARDENED_GCC_WORKS="x86 sparc amd64"
932 # This allows for additional archs to be supported by hardened when
933 # ready.
934 #
935 # Travis Tilley <lv@gentoo.org> (03 Sep 2004)
936 #
937 gcc-compiler_src_unpack() {
938 # fail if using pie patches, building hardened, and glibc doesnt have
939 # the necessary support
940 want_pie && use hardened && glibc_have_pie
941
942 if use hardened ; then
943 einfo "updating configuration to build hardened GCC"
944 make_gcc_hard || die "failed to make gcc hard"
945 fi
946 }
947 gcc-library_src_unpack() {
948 :
949 }
950 guess_patch_type_in_dir() {
951 [[ -n $(ls "$1"/*.bz2 2>/dev/null) ]] \
952 && EPATCH_SUFFIX="patch.bz2" \
953 || EPATCH_SUFFIX="patch"
954 }
955 gcc_src_unpack() {
956 local release_version="Gentoo ${PVR}"
957
958 [[ -z ${UCLIBC_VER} ]] && is_uclibc && die "Sorry, this version does not support uClibc"
959
960 gcc_quick_unpack
961 exclude_gcc_patches
962
963 cd ${S:=$(gcc_get_s_dir)}
964
965 if ! use vanilla ; then
966 if [[ -n ${PATCH_VER} ]] ; then
967 guess_patch_type_in_dir "${WORKDIR}"/patch
968 EPATCH_MULTI_MSG="Applying Gentoo patches ..." \
969 epatch "${WORKDIR}"/patch
970 fi
971 if [[ -n ${UCLIBC_VER} ]] ; then
972 guess_patch_type_in_dir "${WORKDIR}"/uclibc
973 EPATCH_MULTI_MSG="Applying uClibc patches ..." \
974 epatch "${WORKDIR}"/uclibc
975 fi
976 do_gcc_HTB_boundschecking_patches
977 do_gcc_SSP_patches
978 do_gcc_PIE_patches
979 fi
980
981 ${ETYPE}_src_unpack || die "failed to ${ETYPE}_src_unpack"
982
983 fix_files=""
984 for x in contrib/test_summary libstdc++-v3/scripts/check_survey.in ; do
985 [[ -e ${x} ]] && fix_files="${fix_files} ${x}"
986 done
987 ht_fix_file ${fix_files} */configure *.sh
988
989 if ! is_crosscompile && is_multilib && \
990 [[ ( $(tc-arch) == "amd64" || $(tc-arch) == "ppc64" ) && -z ${SKIP_MULTILIB_HACK} ]] ; then
991 disgusting_gcc_multilib_HACK || die "multilib hack failed"
992 fi
993
994 local version_string="${GCC_CONFIG_VER}"
995
996 # Backwards support... add the BRANCH_UPDATE for 3.3.5-r1 and 3.4.3-r1
997 # which set it directly rather than using ${PV}
998 if [[ ${PVR} == "3.3.5-r1" || ${PVR} = "3.4.3-r1" ]] ; then
999 version_string="${version_string} ${BRANCH_UPDATE}"
1000 fi
1001
1002 version_string="${version_string} (${release_version})"
1003 einfo "patching gcc version: ${version_string}"
1004 gcc_version_patch "${version_string}"
1005
1006 # Misdesign in libstdc++ (Redhat)
1007 if [[ ${GCCMAJOR} -ge 3 ]] && [[ -e ${S}/libstdc++-v3/config/cpu/i486/atomicity.h ]] ; then
1008 cp -pPR "${S}"/libstdc++-v3/config/cpu/i{4,3}86/atomicity.h
1009 fi
1010
1011 # disable --as-needed from being compiled into gcc specs
1012 # natively when using a gcc version < 3.4.4
1013 # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14992
1014 if [[ ${GCCMAJOR} < 3 ]] || \
1015 [[ ${GCCMAJOR}.${GCCMINOR} < 3.4 ]] || \
1016 [[ ${GCCMAJOR}.${GCCMINOR}.${GCCMICRO} < 3.4.4 ]]
1017 then
1018 sed -i -e s/HAVE_LD_AS_NEEDED/USE_LD_AS_NEEDED/g "${S}"/gcc/config.in
1019 fi
1020
1021 # Fixup libtool to correctly generate .la files with portage
1022 cd "${S}"
1023 elibtoolize --portage --shallow --no-uclibc
1024
1025 gnuconfig_update
1026
1027 # update configure files
1028 einfo "Fixing misc issues in configure files"
1029 for f in $(grep -l 'autoconf version 2.13' $(find "${S}" -name configure)) ; do
1030 ebegin " Updating ${f/${S}\/}"
1031 patch "${f}" "${GCC_FILESDIR}"/gcc-configure-LANG.patch >& "${T}"/configure-patch.log \
1032 || eerror "Please file a bug about this"
1033 eend $?
1034 done
1035
1036 ./contrib/gcc_update --touch &> /dev/null
1037
1038 disable_multilib_libjava || die "failed to disable multilib java"
1039 }
1040
1041 gcc-library-configure() {
1042 # multilib support
1043 [[ ${GCC_TARGET_NO_MULTILIB} == "true" ]] \
1044 && confgcc="${confgcc} --disable-multilib" \
1045 || confgcc="${confgcc} --enable-multilib"
1046 }
1047
1048 gcc-compiler-configure() {
1049 # multilib support
1050 if is_multilib || [[ ${CTARGET} == "avr" ]] ; then
1051 confgcc="${confgcc} --enable-multilib"
1052 else
1053 confgcc="${confgcc} --disable-multilib"
1054 fi
1055
1056 confgcc="${confgcc} $(use_enable mudflap libmudflap)"
1057
1058 # GTK+ is preferred over xlib in 3.4.x (xlib is unmaintained
1059 # right now). Much thanks to <csm@gnu.org> for the heads up.
1060 # Travis Tilley <lv@gentoo.org> (11 Jul 2004)
1061 if ! is_gcj ; then
1062 confgcc="${confgcc} --disable-libgcj"
1063 elif use gtk ; then
1064 confgcc="${confgcc} --enable-java-awt=gtk"
1065 fi
1066
1067 case $(tc-arch) in
1068 # Add --with-abi flags to set default MIPS ABI
1069 mips)
1070 local mips_abi=""
1071 use n64 && mips_abi="--with-abi=64"
1072 use n32 && mips_abi="--with-abi=n32"
1073 [[ -n ${mips_abi} ]] && confgcc="${confgcc} ${mips_abi}"
1074 ;;
1075 # Enable sjlj exceptions for backward compatibility on hppa
1076 hppa)
1077 [[ ${PV:0:1} == "3" ]] && \
1078 confgcc="${confgcc} --enable-sjlj-exceptions"
1079 ;;
1080 esac
1081
1082 GCC_LANG="c"
1083 is_cxx && GCC_LANG="${GCC_LANG},c++"
1084 is_gcj && GCC_LANG="${GCC_LANG},java"
1085 if is_objc ; then
1086 GCC_LANG="${GCC_LANG},objc"
1087 use objc-gc && confgcc="${confgcc} --enable-objc-gc"
1088 fi
1089
1090 # fortran support just got sillier! the lang value can be f77 for
1091 # fortran77, f95 for fortran95, or just plain old fortran for the
1092 # currently supported standard depending on gcc version.
1093 is_fortran && GCC_LANG="${GCC_LANG},fortran"
1094 is_f77 && GCC_LANG="${GCC_LANG},f77"
1095 is_f95 && GCC_LANG="${GCC_LANG},f95"
1096
1097 # We do NOT want 'ADA support' in here!
1098 # is_ada && GCC_LANG="${GCC_LANG},ada"
1099
1100 einfo "configuring for GCC_LANG: ${GCC_LANG}"
1101 }
1102
1103 # Other than the variables described for gcc_setup_variables, the following
1104 # will alter tha behavior of gcc_do_configure:
1105 #
1106 # CTARGET
1107 # CBUILD
1108 # Enable building for a target that differs from CHOST
1109 #
1110 # GCC_TARGET_NO_MULTILIB
1111 # Disable multilib. Useful when building single library targets.
1112 #
1113 # GCC_LANG
1114 # Enable support for ${GCC_LANG} languages. defaults to just "c"
1115 #
1116 # Travis Tilley <lv@gentoo.org> (04 Sep 2004)
1117 #
1118 gcc_do_configure() {
1119 local confgcc
1120
1121 # Set configuration based on path variables
1122 confgcc="${confgcc} \
1123 --prefix=${PREFIX} \
1124 --bindir=${BINPATH} \
1125 --includedir=${INCLUDEPATH} \
1126 --datadir=${DATAPATH} \
1127 --mandir=${DATAPATH}/man \
1128 --infodir=${DATAPATH}/info \
1129 --with-gxx-include-dir=${STDCXX_INCDIR}"
1130
1131 # All our cross-compile logic goes here ! woo !
1132 confgcc="${confgcc} --host=${CHOST}"
1133 if is_crosscompile || tc-is-cross-compiler ; then
1134 # Straight from the GCC install doc:
1135 # "GCC has code to correctly determine the correct value for target
1136 # for nearly all native systems. Therefore, we highly recommend you
1137 # not provide a configure target when configuring a native compiler."
1138 confgcc="${confgcc} --target=${CTARGET}"
1139 fi
1140 [[ -n ${CBUILD} ]] && confgcc="${confgcc} --build=${CBUILD}"
1141
1142 # ppc altivec support
1143 confgcc="${confgcc} $(use_enable altivec)"
1144
1145 [[ ${CTARGET} == *-softfloat-* ]] && confgcc="${confgcc} --with-float=soft"
1146
1147 # Native Language Support
1148 if use nls && ! use build ; then
1149 confgcc="${confgcc} --enable-nls --without-included-gettext"
1150 else
1151 confgcc="${confgcc} --disable-nls"
1152 fi
1153
1154 # reasonably sane globals (hopefully)
1155 # --disable-libunwind-exceptions needed till unwind sections get fixed. see ps.m for details
1156 confgcc="${confgcc} \
1157 --with-system-zlib \
1158 --disable-checking \
1159 --disable-werror \
1160 --disable-libunwind-exceptions"
1161
1162 # etype specific configuration
1163 einfo "running ${ETYPE}-configure"
1164 ${ETYPE}-configure || die
1165
1166 # if not specified, assume we are building for a target that only
1167 # requires C support
1168 GCC_LANG=${GCC_LANG:-c}
1169 confgcc="${confgcc} --enable-languages=${GCC_LANG}"
1170
1171 if is_crosscompile ; then
1172 # When building a stage1 cross-compiler (just C compiler), we have to
1173 # disable a bunch of features or gcc goes boom
1174 local needed_libc=""
1175 case ${CTARGET} in
1176 *-dietlibc) needed_libc=dietlibc;;
1177 *-freebsd*) needed_libc=freebsd-lib;;
1178 *-gnu) needed_libc=glibc;;
1179 *-klibc) needed_libc=klibc;;
1180 *-uclibc) needed_libc=uclibc;;
1181 avr) confgcc="${confgcc} --enable-shared --disable-threads";;
1182 esac
1183 if [[ -n ${needed_libc} ]] ; then
1184 if ! has_version ${CATEGORY}/${needed_libc} ; then
1185 confgcc="${confgcc} --disable-shared --disable-threads --without-headers"
1186 elif built_with_use ${CATEGORY}/${needed_libc} _E_CROSS_HEADERS_ONLY ; then
1187 confgcc="${confgcc} --disable-shared --with-sysroot=${TC_PREFIX}/${CTARGET}"
1188 else
1189 confgcc="${confgcc} --with-sysroot=${TC_PREFIX}/${CTARGET}"
1190 fi
1191 fi
1192 else
1193 confgcc="${confgcc} --enable-shared --enable-threads=posix"
1194 fi
1195 # __cxa_atexit is "essential for fully standards-compliant handling of
1196 # destructors", but apparently requires glibc.
1197 # --enable-sjlj-exceptions : currently the unwind stuff seems to work
1198 # for statically linked apps but not dynamic
1199 # so use setjmp/longjmp exceptions by default
1200 if is_uclibc ; then
1201 confgcc="${confgcc} --disable-__cxa_atexit --enable-target-optspace"
1202 [[ ${GCCMAJOR}.${GCCMINOR} == 3.3 ]] && \
1203 confgcc="${confgcc} --enable-sjlj-exceptions"
1204 else
1205 confgcc="${confgcc} --enable-__cxa_atexit"
1206 fi
1207 [[ ${CTARGET} == *-gnu* ]] && confgcc="${confgcc} --enable-clocale=gnu"
1208 [[ ${CTARGET} == *-uclibc* ]] && [[ ${GCCMAJOR}.${GCCMINOR} > 3.3 ]] \
1209 && confgcc="${confgcc} --enable-clocale=uclibc"
1210
1211 # Nothing wrong with a good dose of verbosity
1212 echo
1213 einfo "TC_PREFIX: ${PREFIX}"
1214 einfo "BINPATH: ${BINPATH}"
1215 einfo "LIBPATH: ${LIBPATH}"
1216 einfo "DATAPATH: ${DATAPATH}"
1217 einfo "STDCXX_INCDIR: ${STDCXX_INCDIR}"
1218 echo
1219 einfo "Configuring GCC with: ${confgcc//--/\n\t--} ${@} ${EXTRA_ECONF}"
1220 echo
1221
1222 # Build in a separate build tree
1223 mkdir -p "${WORKDIR}"/build
1224 pushd "${WORKDIR}"/build > /dev/null
1225
1226 # and now to do the actual configuration
1227 addwrite /dev/zero
1228 "${S}"/configure ${confgcc} $@ ${EXTRA_ECONF} \
1229 || die "failed to run configure"
1230
1231 # return to whatever directory we were in before
1232 popd > /dev/null
1233 }
1234
1235 # This function accepts one optional argument, the make target to be used.
1236 # If ommitted, gcc_do_make will try to guess whether it should use all,
1237 # profiledbootstrap, or bootstrap-lean depending on CTARGET and arch. An
1238 # example of how to use this function:
1239 #
1240 # gcc_do_make all-target-libstdc++-v3
1241 #
1242 # In addition to the target to be used, the following variables alter the
1243 # behavior of this function:
1244 #
1245 # LDFLAGS
1246 # Flags to pass to ld
1247 #
1248 # STAGE1_CFLAGS
1249 # CFLAGS to use during stage1 of a gcc bootstrap
1250 #
1251 # BOOT_CFLAGS
1252 # CFLAGS to use during stages 2+3 of a gcc bootstrap.
1253 #
1254 # Travis Tilley <lv@gentoo.org> (04 Sep 2004)
1255 #
1256 gcc_do_make() {
1257 # Fix for libtool-portage.patch
1258 local OLDS=${S}
1259 S=${WORKDIR}/build
1260
1261 # Set make target to $1 if passed
1262 [[ -n $1 ]] && GCC_MAKE_TARGET="$1"
1263 # default target
1264 if is_crosscompile || tc-is-cross-compiler ; then
1265 # 3 stage bootstrapping doesnt quite work when you cant run the
1266 # resulting binaries natively ^^;
1267 GCC_MAKE_TARGET=${GCC_MAKE_TARGET-all}
1268 elif [[ $(tc-arch) == "x86" || $(tc-arch) == "amd64" || $(tc-arch) == "ppc64" ]] \
1269 && [[ ${GCCMAJOR}.${GCCMINOR} > 3.3 ]]
1270 then
1271 GCC_MAKE_TARGET=${GCC_MAKE_TARGET-profiledbootstrap}
1272 else
1273 GCC_MAKE_TARGET=${GCC_MAKE_TARGET-bootstrap-lean}
1274 fi
1275
1276 # the gcc docs state that parallel make isnt supported for the
1277 # profiledbootstrap target, as collisions in profile collecting may occur.
1278 [[ ${GCC_MAKE_TARGET} == "profiledbootstrap" ]] && export MAKEOPTS="${MAKEOPTS} -j1"
1279
1280 # boundschecking seems to introduce parallel build issues
1281 want_boundschecking && export MAKEOPTS="${MAKEOPTS} -j1"
1282
1283 if [[ ${GCC_MAKE_TARGET} == "all" ]] ; then
1284 STAGE1_CFLAGS=${STAGE1_CFLAGS-"${CFLAGS}"}
1285 elif [[ $(gcc-version) == "3.4" && ${GCC_BRANCH_VER} == "3.4" ]] && has_hardened ; then
1286 # See bug #79852
1287 STAGE1_CFLAGS=${STAGE1_CFLAGS-"-O2"}
1288 else
1289 STAGE1_CFLAGS=${STAGE1_CFLAGS-"-O"}
1290 fi
1291
1292 if is_crosscompile; then
1293 # In 3.4, BOOT_CFLAGS is never used on a crosscompile...
1294 # but I'll leave this in anyways as someone might have had
1295 # some reason for putting it in here... --eradicator
1296 BOOT_CFLAGS=${BOOT_CFLAGS-"-O2"}
1297 else
1298 # we only want to use the system's CFLAGS if not building a
1299 # cross-compiler.
1300 BOOT_CFLAGS=${BOOT_CFLAGS-"$(get_abi_CFLAGS) ${CFLAGS}"}
1301 fi
1302
1303 pushd ${WORKDIR}/build
1304 einfo "Running make LDFLAGS=\"${LDFLAGS}\" STAGE1_CFLAGS=\"${STAGE1_CFLAGS}\" LIBPATH=\"${LIBPATH}\" BOOT_CFLAGS=\"${BOOT_CFLAGS}\" ${GCC_MAKE_TARGET}"
1305
1306 emake \
1307 LDFLAGS="${LDFLAGS}" \
1308 STAGE1_CFLAGS="${STAGE1_CFLAGS}" \
1309 LIBPATH="${LIBPATH}" \
1310 BOOT_CFLAGS="${BOOT_CFLAGS}" \
1311 ${GCC_MAKE_TARGET} \
1312 || die "emake failed with ${GCC_MAKE_TARGET}"
1313
1314 if ! use build && ! is_crosscompile && ! use nocxx ; then
1315 if type -p doxygen > /dev/null ; then
1316 cd "${CTARGET}"/libstdc++-v3
1317 make doxygen-man || ewarn "failed to make docs"
1318 else
1319 ewarn "Skipping libstdc++ manpage generation since you don't have doxygen installed"
1320 fi
1321 fi
1322
1323 popd
1324 }
1325
1326 # This function will add ${GCC_CONFIG_VER} to the names of all shared libraries in the
1327 # directory specified to avoid filename collisions between multiple slotted
1328 # non-versioned gcc targets. If no directory is specified, it is assumed that
1329 # you want -all- shared objects to have ${GCC_CONFIG_VER} added. Example
1330 #
1331 # add_version_to_shared ${D}/usr/$(get_libdir)
1332 #
1333 # Travis Tilley <lv@gentoo.org> (05 Sep 2004)
1334 #
1335 add_version_to_shared() {
1336 local sharedlib sharedlibdir
1337 [[ -z $1 ]] \
1338 && sharedlibdir=${D} \
1339 || sharedlibdir=$1
1340
1341 for sharedlib in $(find ${sharedlibdir} -name *.so.*) ; do
1342 if [[ ! -L ${sharedlib} ]] ; then
1343 einfo "Renaming `basename "${sharedlib}"` to `basename "${sharedlib/.so*/}-${GCC_CONFIG_VER}.so.${sharedlib/*.so./}"`"
1344 mv "${sharedlib}" "${sharedlib/.so*/}-${GCC_CONFIG_VER}.so.${sharedlib/*.so./}" \
1345 || die
1346 pushd `dirname "${sharedlib}"` > /dev/null || die
1347 ln -sf "`basename "${sharedlib/.so*/}-${GCC_CONFIG_VER}.so.${sharedlib/*.so./}"`" \
1348 "`basename "${sharedlib}"`" || die
1349 popd > /dev/null || die
1350 fi
1351 done
1352 }
1353
1354 # This is mostly a stub function to be overwritten in an ebuild
1355 gcc_do_filter_flags() {
1356 strip-flags
1357
1358 # In general gcc does not like optimization, and add -O2 where
1359 # it is safe. This is especially true for gcc 3.3 + 3.4
1360 replace-flags -O? -O2
1361
1362 # ... sure, why not?
1363 strip-unsupported-flags
1364
1365 # dont want to funk ourselves
1366 filter-flags '-mabi*' -m31 -m32 -m64
1367
1368 case ${GCC_BRANCH_VER} in
1369 3.2|3.3)
1370 case $(tc-arch) in
1371 x86) filter-flags '-mtune=*';;
1372 amd64) filter-flags '-mtune=*'
1373 replace-cpu-flags k8 athlon64 opteron i686;;
1374 esac
1375 ;;
1376 3.4|4.*)
1377 case $(tc-arch) in
1378 x86|amd64) filter-flags '-mcpu=*';;
1379 esac
1380 ;;
1381 esac
1382
1383 # Compile problems with these (bug #6641 among others)...
1384 #filter-flags "-fno-exceptions -fomit-frame-pointer -fforce-addr"
1385
1386 # CFLAGS logic (verified with 3.4.3):
1387 # CFLAGS:
1388 # This conflicts when creating a crosscompiler, so set to a sane
1389 # default in this case:
1390 # used in ./configure and elsewhere for the native compiler
1391 # used by gcc when creating libiberty.a
1392 # used by xgcc when creating libstdc++ (and probably others)!
1393 # this behavior should be removed...
1394 #
1395 # CXXFLAGS:
1396 # used by xgcc when creating libstdc++
1397 #
1398 # STAGE1_CFLAGS (not used in creating a crosscompile gcc):
1399 # used by ${CHOST}-gcc for building stage1 compiler
1400 #
1401 # BOOT_CFLAGS (not used in creating a crosscompile gcc):
1402 # used by xgcc for building stage2/3 compiler
1403
1404 if is_crosscompile ; then
1405 # Set this to something sane for both native and target
1406 CFLAGS="-O2 -pipe"
1407
1408 local VAR="CFLAGS_"${CTARGET//-/_}
1409 CXXFLAGS=${!VAR}
1410 fi
1411
1412 export GCJFLAGS=${GCJFLAGS:-${CFLAGS}}
1413 }
1414
1415 gcc_src_compile() {
1416 gcc_do_filter_flags
1417 einfo "CFLAGS=\"${CFLAGS}\""
1418 einfo "CXXFLAGS=\"${CXXFLAGS}\""
1419
1420 # Build in a separate build tree
1421 mkdir -p ${WORKDIR}/build
1422 pushd ${WORKDIR}/build > /dev/null
1423
1424 # Install our pre generated manpages if we do not have perl ...
1425 [[ ! -x /usr/bin/perl ]] && [[ -n ${MAN_VER} ]] && \
1426 unpack gcc-${MAN_VER}-manpages.tar.bz2
1427
1428 einfo "Configuring ${PN} ..."
1429 gcc_do_configure
1430
1431 touch ${S}/gcc/c-gperf.h
1432
1433 # Do not make manpages if we do not have perl ...
1434 [[ ! -x /usr/bin/perl ]] \
1435 && find "${WORKDIR}"/build -name '*.[17]' | xargs touch
1436
1437 einfo "Compiling ${PN} ..."
1438 gcc_do_make ${GCC_MAKE_TARGET}
1439
1440 # Do not create multiple specs files for PIE+SSP if boundschecking is in
1441 # USE, as we disable PIE+SSP when it is.
1442 if [[ ${ETYPE} == "gcc-compiler" ]] && want_split_specs ; then
1443 split_out_specs_files || die "failed to split out specs"
1444 fi
1445
1446 popd > /dev/null
1447 }
1448
1449 gcc_src_test() {
1450 cd "${WORKDIR}"/build
1451 make check || ewarn "check failed and that sucks :("
1452 }
1453
1454 gcc-library_src_install() {
1455 einfo "Installing ${PN} ..."
1456 # Do the 'make install' from the build directory
1457 cd "${WORKDIR}"/build
1458 S=${WORKDIR}/build \
1459 make DESTDIR="${D}" \
1460 prefix=${TC_PREFIX} \
1461 bindir=${BINPATH} \
1462 includedir=${LIBPATH}/include \
1463 datadir=${DATAPATH} \
1464 mandir=${DATAPATH}/man \
1465 infodir=${DATAPATH}/info \
1466 LIBPATH="${LIBPATH}" \
1467 ${GCC_INSTALL_TARGET} || die
1468
1469 if [[ ${GCC_LIB_COMPAT_ONLY} == "true" ]] ; then
1470 rm -rf "${D}"${INCLUDEPATH}
1471 rm -rf "${D}"${DATAPATH}
1472 pushd "${D}"${LIBPATH}/
1473 rm *.a *.la *.so
1474 popd
1475 fi
1476
1477 if [[ -n ${GCC_LIB_USE_SUBDIR} ]] ; then
1478 mkdir -p ${WORKDIR}/${GCC_LIB_USE_SUBDIR}/
1479 mv "${D}"${LIBPATH}/* ${WORKDIR}/${GCC_LIB_USE_SUBDIR}/
1480 mv ${WORKDIR}/${GCC_LIB_USE_SUBDIR}/ "${D}"${LIBPATH}
1481
1482 dodir /etc/env.d
1483 echo "LDPATH=\"${LIBPATH}/${GCC_LIB_USE_SUBDIR}/\"" >> "${D}"/etc/env.d/99${PN}
1484 fi
1485
1486 if [[ ${GCC_VAR_TYPE} == "non-versioned" ]] ; then
1487 # if we're not using versioned directories, we need to use versioned
1488 # filenames.
1489 add_version_to_shared
1490 fi
1491 }
1492
1493 gcc-compiler_src_install() {
1494 local x=
1495
1496 # Do allow symlinks in ${TC_PREFIX}/lib/gcc-lib/${CHOST}/${GCC_CONFIG_VER}/include as
1497 # this can break the build.
1498 for x in "${WORKDIR}"/build/gcc/include/* ; do
1499 [[ -L ${x} ]] && rm -f "${x}"
1500 done
1501 # Remove generated headers, as they can cause things to break
1502 # (ncurses, openssl, etc).
1503 for x in $(find "${WORKDIR}"/build/gcc/include/ -name '*.h') ; do
1504 grep -q 'It has been auto-edited by fixincludes from' "${x}" \
1505 && rm -f "${x}"
1506 done
1507
1508 einfo "Installing GCC..."
1509 # Do the 'make install' from the build directory
1510 cd ${WORKDIR}/build
1511 S=${WORKDIR}/build \
1512 make DESTDIR="${D}" install || die
1513 # Punt some tools which are really only useful while building gcc
1514 rm -r "${D}${LIBEXECPATH}"/install-tools
1515 # This one comes with binutils
1516 find "${D}" -name libiberty.a -exec rm -f {} \;
1517
1518 # Move the libraries to the proper location
1519 gcc_movelibs
1520
1521 # Now do the fun stripping stuff
1522 env RESTRICT="" STRIP=${CHOST}-strip prepstrip "${D}${BINPATH}" "${D}${LIBEXECPATH}"
1523 env RESTRICT="" STRIP=${CTARGET}-strip prepstrip "${D}${LIBPATH}"
1524
1525 # Basic sanity check
1526 is_crosscompile || [[ -r ${D}${BINPATH}/gcc ]] || die "gcc not found in ${D}"
1527
1528 dodir /lib /usr/bin
1529 dodir /etc/env.d/gcc
1530 create_gcc_env_entry
1531
1532 if want_split_specs ; then
1533 if use hardened ; then
1534 create_gcc_env_entry vanilla
1535 fi
1536 ! use hardened && hardened_gcc_works && create_gcc_env_entry hardened
1537 if hardened_gcc_works || hardened_gcc_works pie ; then
1538 create_gcc_env_entry hardenednossp
1539 fi
1540 if hardened_gcc_works || hardened_gcc_works ssp ; then
1541 create_gcc_env_entry hardenednopie
1542 fi
1543 create_gcc_env_entry hardenednopiessp
1544
1545 cp ${WORKDIR}/build/*.specs "${D}"${LIBPATH}
1546 fi
1547
1548 # Make sure we dont have stuff lying around that
1549 # can nuke multiple versions of gcc
1550 if ! use build ; then
1551 cd ${D}${LIBPATH}
1552
1553 # Move Java headers to compiler-specific dir
1554 for x in ${D}${TC_PREFIX}/include/gc*.h ${D}${PREFIX}/include/j*.h ; do
1555 [[ -f ${x} ]] && mv -f "${x}" ${D}${LIBPATH}/include/
1556 done
1557 for x in gcj gnu java javax org ; do
1558 if [[ -d ${D}${TC_PREFIX}/include/${x} ]] ; then
1559 dodir /${LIBPATH}/include/${x}
1560 mv -f ${D}${TC_PREFIX}/include/${x}/* ${D}${LIBPATH}/include/${x}/
1561 rm -rf ${D}${TC_PREFIX}/include/${x}
1562 fi
1563 done
1564
1565 if [[ -d ${D}${TC_PREFIX}/lib/security ]] ; then
1566 dodir /${LIBPATH}/security
1567 mv -f ${D}${TC_PREFIX}/lib/security/* ${D}${LIBPATH}/security
1568 rm -rf ${D}${TC_PREFIX}/lib/security
1569 fi
1570
1571 # Move libgcj.spec to compiler-specific directories
1572 [[ -f ${D}${TC_PREFIX}/lib/libgcj.spec ]] && \
1573 mv -f ${D}${TC_PREFIX}/lib/libgcj.spec ${D}${LIBPATH}/libgcj.spec
1574
1575 # Rename jar because it could clash with Kaffe's jar if this gcc is
1576 # primary compiler (aka don't have the -<version> extension)
1577 cd ${D}${TC_PREFIX}/${CTARGET}/gcc-bin/${GCC_CONFIG_VER}
1578 [[ -f jar ]] && mv -f jar gcj-jar
1579
1580 # Move <cxxabi.h> to compiler-specific directories
1581 [[ -f ${D}${STDCXX_INCDIR}/cxxabi.h ]] && \
1582 mv -f ${D}${STDCXX_INCDIR}/cxxabi.h ${D}${LIBPATH}/include/
1583
1584 # These should be symlinks
1585 dodir /usr/bin
1586 cd "${D}"${BINPATH}
1587 for x in gcc g++ c++ g77 gcj gcjh gfortran ; do
1588 # For some reason, g77 gets made instead of ${CTARGET}-g77...
1589 # this should take care of that
1590 [[ -f ${x} ]] && mv ${x} ${CTARGET}-${x}
1591
1592 if [[ -f ${CTARGET}-${x} ]] && ! is_crosscompile; then
1593 ln -sf ${CTARGET}-${x} ${x}
1594
1595 # Create version-ed symlinks
1596 dosym ${BINPATH}/${CTARGET}-${x} \
1597 /usr/bin/${CTARGET}-${x}-${GCC_CONFIG_VER}
1598 dosym ${BINPATH}/${CTARGET}-${x} \
1599 /usr/bin/${x}-${GCC_CONFIG_VER}
1600 fi
1601
1602 if [[ -f ${CTARGET}-${x}-${GCC_CONFIG_VER} ]] ; then
1603 rm -f ${CTARGET}-${x}-${GCC_CONFIG_VER}
1604 ln -sf ${CTARGET}-${x} ${CTARGET}-${x}-${GCC_CONFIG_VER}
1605 fi
1606 done
1607
1608 # I do not know if this will break gcj stuff, so I'll only do it for
1609 # objc for now; basically "ffi.h" is the correct file to include,
1610 # but it gets installed in .../GCCVER/include and yet it does
1611 # "#include <ffitarget.h>" which (correctly, as it's an "extra" file)
1612 # is installed in .../GCCVER/include/libffi; the following fixes
1613 # ffi.'s include of ffitarget.h - Armando Di Cianno <fafhrd@gentoo.org>
1614 if is_objc && ! is_gcj ; then
1615 #dosed "s:<ffitarget.h>:<libffi/ffitarget.h>:g" /${LIBPATH}/include/ffi.h
1616 mv "${D}"${LIBPATH}/include/libffi/* "${D}"${LIBPATH}/include
1617 rm -Rf "${D}"${LIBPATH}/include/libffi
1618 fi
1619 fi
1620
1621 cd "${S}"
1622 if use build || is_crosscompile; then
1623 rm -rf "${D}"/usr/share/{man,info}
1624 rm -rf "${D}"${DATAPATH}/{man,info}
1625 else
1626 local cxx_mandir=${WORKDIR}/build/${CTARGET}/libstdc++-v3/docs/doxygen/man
1627 if [[ -d ${cxx_mandir} ]] ; then
1628 # clean bogus manpages #113902
1629 find "${cxx_mandir}" -name '*_build_*' -exec rm {} \;
1630 cp -r "${cxx_mandir}"/man? "${D}/${DATAPATH}"/man/
1631 fi
1632 has noinfo ${FEATURES} \
1633 && rm -r "${D}/${DATAPATH}"/info \
1634 || prepinfo "${DATAPATH}"
1635 has noman ${FEATURES} \
1636 && rm -f "${D}/${DATAPATH}"/man \
1637 || prepman "${DATAPATH}"
1638 fi
1639
1640 # Rather install the script, else portage with changing $FILESDIR
1641 # between binary and source package borks things ....
1642 if ! is_crosscompile; then
1643 insinto /lib/rcscripts/awk
1644 doins "${GCC_FILESDIR}"/awk/fixlafiles.awk
1645 exeinto /sbin
1646 doexe "${GCC_FILESDIR}"/fix_libtool_files.sh
1647 fi
1648
1649 # use gid of 0 because some stupid ports don't have
1650 # the group 'root' set to gid 0
1651 chown -R root:0 "${D}"${LIBPATH}
1652
1653 # Create config files for eselect-compiler
1654 create_eselect_conf
1655 }
1656
1657 # Move around the libs to the right location. For some reason,
1658 # when installing gcc, it dumps internal libraries into /usr/lib
1659 # instead of the private gcc lib path
1660 gcc_movelibs() {
1661 # XXX: This breaks when cross-compiling a native compiler (CBUILD != CHOST)
1662
1663 local multiarg
1664 for multiarg in $(${XGCC} -print-multi-lib) ; do
1665 multiarg=${multiarg#*;}
1666 multiarg=${multiarg//@/ -}
1667
1668 local OS_MULTIDIR=$(${XGCC} -B./ ${multiarg} --print-multi-os-directory)
1669 local MULTIDIR=$(${XGCC} -B./ ${multiarg} --print-multi-directory)
1670 local TODIR=${D}${LIBPATH}/${MULTIDIR}
1671 local FROMDIR=
1672
1673 [[ -d ${TODIR} ]] || mkdir -p ${TODIR}
1674
1675 for FROMDIR in \
1676 ${LIBPATH}/${OS_MULTIDIR} \
1677 ${LIBPATH}/../${MULTIDIR} \
1678 ${TC_PREFIX}/lib/${OS_MULTIDIR} \
1679 ${TC_PREFIX}/${CTARGET}/lib/${OS_MULTIDIR} \
1680 ${TC_PREFIX}/lib/${MULTIDIR}
1681 do
1682 FROMDIR=${D}${FROMDIR}
1683 if [[ ${FROMDIR} != "${TODIR}" && -d ${FROMDIR} ]] ; then
1684 local files=$(find "${FROMDIR}" -maxdepth 1 ! -type d 2>/dev/null)
1685 if [[ -n ${files} ]] ; then
1686 mv ${files} "${TODIR}"
1687 rmdir "${FROMDIR}" 2>/dev/null
1688 fi
1689 fi
1690 done
1691 done
1692
1693 # make sure the libtool archives have libdir set to where they actually
1694 # -are-, and not where they -used- to be.
1695 fix_libtool_libdir_paths "$(find ${D}${LIBPATH} -name *.la)"
1696 }
1697
1698 #----<< src_* >>----
1699
1700 #---->> unorganized crap in need of refactoring follows
1701
1702 # gcc_quick_unpack will unpack the gcc tarball and patches in a way that is
1703 # consistant with the behavior of get_gcc_src_uri. The only patch it applies
1704 # itself is the branch update if present.
1705 #
1706 # Travis Tilley <lv@gentoo.org> (03 Sep 2004)
1707 #
1708 gcc_quick_unpack() {
1709 pushd ${WORKDIR} > /dev/null
1710 export PATCH_GCC_VER=${PATCH_GCC_VER:-${GCC_RELEASE_VER}}
1711 export UCLIBC_GCC_VER=${UCLIBC_GCC_VER:-${PATCH_GCC_VER}}
1712 export PIE_GCC_VER=${PIE_GCC_VER:-${GCC_RELEASE_VER}}
1713 export PP_GCC_VER=${PP_GCC_VER:-${GCC_RELEASE_VER}}
1714 export HTB_GCC_VER=${HTB_GCC_VER:-${GCC_RELEASE_VER}}
1715
1716 if [[ -n ${GCC_A_FAKEIT} ]] ; then
1717 unpack ${GCC_A_FAKEIT}.tar.bz2
1718 mv ${GCC_A_FAKEIT} "${S}"
1719 elif [[ -n ${PRERELEASE} ]] ; then
1720 unpack gcc-${PRERELEASE}.tar.bz2
1721 elif [[ -n ${SNAPSHOT} ]] ; then
1722 unpack gcc-${SNAPSHOT}.tar.bz2
1723 else
1724 unpack gcc-${GCC_RELEASE_VER}.tar.bz2
1725 # We want branch updates to be against a release tarball
1726 if [[ -n ${BRANCH_UPDATE} ]] ; then
1727 pushd ${S:-"$(gcc_get_s_dir)"} > /dev/null
1728 epatch ${DISTDIR}/gcc-${GCC_RELEASE_VER}-branch-update-${BRANCH_UPDATE}.patch.bz2
1729 popd > /dev/null
1730 fi
1731 fi
1732
1733 [[ -n ${PATCH_VER} ]] && \
1734 unpack gcc-${PATCH_GCC_VER}-patches-${PATCH_VER}.tar.bz2
1735
1736 [[ -n ${UCLIBC_VER} ]] && \
1737 unpack gcc-${UCLIBC_GCC_VER}-uclibc-patches-${UCLIBC_VER}.tar.bz2
1738
1739 if want_ssp ; then
1740 if [[ -n ${PP_FVER} ]] ; then
1741 # The gcc 3.4 propolice versions are meant to be unpacked to ${S}
1742 pushd ${S:-$(gcc_get_s_dir)} > /dev/null
1743 unpack protector-${PP_FVER}.tar.gz
1744 popd > /dev/null
1745 else
1746 unpack gcc-${PP_GCC_VER}-ssp-${PP_VER}.tar.bz2
1747 fi
1748 fi
1749
1750 if want_pie ; then
1751 if [[ -n ${PIE_CORE} ]] ; then
1752 unpack ${PIE_CORE}
1753 else
1754 unpack gcc-${PIE_GCC_VER}-piepatches-v${PIE_VER}.tar.bz2
1755 fi
1756 fi
1757
1758 # pappy@gentoo.org - Fri Oct 1 23:24:39 CEST 2004
1759 want_boundschecking && \
1760 unpack "bounds-checking-gcc-${HTB_GCC_VER}-${HTB_VER}.patch.bz2"
1761
1762 popd > /dev/null
1763 }
1764
1765 # Exclude any unwanted patches, as specified by the following variables:
1766 #
1767 # GENTOO_PATCH_EXCLUDE
1768 # List of filenames, relative to ${WORKDIR}/patch/
1769 #
1770 # PIEPATCH_EXCLUDE
1771 # List of filenames, relative to ${WORKDIR}/piepatch/
1772 #
1773 # Travis Tilley <lv@gentoo.org> (03 Sep 2004)
1774 #
1775 exclude_gcc_patches() {
1776 local i
1777 for i in ${GENTOO_PATCH_EXCLUDE} ; do
1778 if [[ -f ${WORKDIR}/patch/${i} ]] ; then
1779 einfo "Excluding patch ${i}"
1780 rm -f ${WORKDIR}/patch/${i} || die "failed to delete ${i}"
1781 fi
1782 done
1783 for i in ${PIEPATCH_EXCLUDE} ; do
1784 if [[ -f ${WORKDIR}/piepatch/${i} ]] ; then
1785 einfo "Excluding piepatch ${i}"
1786 rm -f ${WORKDIR}/piepatch/${i} || die "failed to delete ${i}"
1787 fi
1788 done
1789 }
1790
1791 # Try to apply some stub patches so that gcc won't error out when
1792 # passed parameters like -fstack-protector but no ssp is found
1793 do_gcc_stub() {
1794 local v stub_patch=""
1795 for v in ${GCC_RELEASE_VER} ${GCC_BRANCH_VER} ; do
1796 stub_patch=${GCC_FILESDIR}/stubs/gcc-${v}-$1-stub.patch
1797 if [[ -e ${stub_patch} ]] ; then
1798 EPATCH_SINGLE_MSG="Applying stub patch for $1 ..." \
1799 epatch "${stub_patch}"
1800 return 0
1801 fi
1802 done
1803 }
1804
1805 do_gcc_HTB_boundschecking_patches() {
1806 if ! want_boundschecking || \
1807 (want_ssp && [[ ${HTB_EXCLUSIVE} == "true" ]])
1808 then
1809 do_gcc_stub htb
1810 return 0
1811 fi
1812
1813 # modify the bounds checking patch with a regression patch
1814 epatch "${WORKDIR}/bounds-checking-gcc-${HTB_GCC_VER}-${HTB_VER}.patch"
1815 release_version="${release_version}, HTB-${HTB_GCC_VER}-${HTB_VER}"
1816 }
1817
1818 # patch in ProPolice Stack Smashing protection
1819 do_gcc_SSP_patches() {
1820 # PARISC has no love ... it's our stack :(
1821 if [[ $(tc-arch) == "hppa" ]] || \
1822 ! want_ssp || \
1823 (want_boundschecking && [[ ${HTB_EXCLUSIVE} == "true" ]])
1824 then
1825 do_gcc_stub ssp
1826 return 0
1827 fi
1828
1829 local ssppatch
1830 local sspdocs
1831
1832 if [[ -n ${PP_FVER} ]] ; then
1833 # Etoh keeps changing where files are and what the patch is named
1834 if version_is_at_least 3.4.1 ; then
1835 # >3.4.1 uses version in patch name, and also includes docs
1836 ssppatch="${S}/gcc_${PP_VER}.dif"
1837 sspdocs="yes"
1838 elif version_is_at_least 3.4.0 ; then
1839 # >3.4 put files where they belong and 3_4 uses old patch name
1840 ssppatch="${S}/protector.dif"
1841 sspdocs="no"
1842 elif version_is_at_least 3.2.3 ; then
1843 # earlier versions have no directory structure or docs
1844 mv ${S}/protector.{c,h} ${S}/gcc
1845 ssppatch="${S}/protector.dif"
1846 sspdocs="no"
1847 fi
1848 else
1849 # Just start packaging the damn thing ourselves
1850 mv "${WORKDIR}"/ssp/protector.{c,h} "${S}"/gcc/
1851 ssppatch=${WORKDIR}/ssp/gcc-${PP_GCC_VER}-ssp.patch
1852 # allow boundschecking and ssp to get along
1853 (want_boundschecking && [[ -e ${WORKDIR}/ssp/htb-ssp.patch ]]) \
1854 && patch -s "${ssppatch}" "${WORKDIR}"/ssp/htb-ssp.patch
1855 fi
1856
1857 [[ -z ${ssppatch} ]] && die "Sorry, SSP is not supported in this version"
1858 epatch ${ssppatch}
1859
1860 if [[ ${PN} == "gcc" && ${sspdocs} == "no" ]] ; then
1861 epatch "${GCC_FILESDIR}"/pro-police-docs.patch
1862 fi
1863
1864 # Don't build crtbegin/end with ssp
1865 sed -e 's|^CRTSTUFF_CFLAGS = |CRTSTUFF_CFLAGS = -fno-stack-protector |'\
1866 -i gcc/Makefile.in || die "Failed to update crtstuff!"
1867
1868 # if gcc in a stage3 defaults to ssp, is version 3.4.0 and a stage1 is built
1869 # the build fails building timevar.o w/:
1870 # cc1: stack smashing attack in function ix86_split_to_parts()
1871 if use build && version_is_at_least 3.4.0 ; then
1872 if gcc -dumpspecs | grep -q "fno-stack-protector:" ; then
1873 epatch "${GCC_FILESDIR}"/3.4.0/gcc-3.4.0-cc1-no-stack-protector.patch
1874 fi
1875 fi
1876
1877 release_version="${release_version}, ssp-${PP_FVER:-${PP_GCC_VER}-${PP_VER}}"
1878 if want_libssp ; then
1879 update_gcc_for_libssp
1880 else
1881 update_gcc_for_libc_ssp
1882 fi
1883
1884 # Don't build libgcc with ssp
1885 sed -e 's|^\(LIBGCC2_CFLAGS.*\)$|\1 -fno-stack-protector|' \
1886 -i gcc/Makefile.in || die "Failed to update gcc!"
1887 }
1888
1889 # If glibc or uclibc has been patched to provide the necessary symbols itself,
1890 # then lets use those for SSP instead of libgcc.
1891 update_gcc_for_libc_ssp() {
1892 if libc_has_ssp ; then
1893 einfo "Updating gcc to use SSP from libc ..."
1894 sed -e 's|^\(LIBGCC2_CFLAGS.*\)$|\1 -D_LIBC_PROVIDES_SSP_|' \
1895 -i ${S}/gcc/Makefile.in || die "Failed to update gcc!"
1896 fi
1897 }
1898
1899 # a split out non-libc non-libgcc ssp requires additional spec logic changes
1900 update_gcc_for_libssp() {
1901 einfo "Updating gcc to use SSP from libssp..."
1902 sed -e 's|^\(INTERNAL_CFLAGS.*\)$|\1 -D_LIBSSP_PROVIDES_SSP_|' \
1903 -i ${S}/gcc/Makefile.in || die "Failed to update gcc!"
1904 }
1905
1906 # do various updates to PIE logic
1907 do_gcc_PIE_patches() {
1908 if ! want_pie || \
1909 (want_boundschecking && [[ ${HTB_EXCLUSIVE} == "true" ]])
1910 then
1911 return 0
1912 fi
1913
1914 want_boundschecking \
1915 && rm -f "${WORKDIR}"/piepatch/*/*-boundschecking-no.patch* \
1916 || rm -f "${WORKDIR}"/piepatch/*/*-boundschecking-yes.patch*
1917
1918 guess_patch_type_in_dir "${WORKDIR}"/piepatch/upstream
1919
1920 # corrects startfile/endfile selection and shared/static/pie flag usage
1921 EPATCH_MULTI_MSG="Applying upstream pie patches ..." \
1922 epatch "${WORKDIR}"/piepatch/upstream
1923 # adds non-default pie support (rs6000)
1924 EPATCH_MULTI_MSG="Applying non-default pie patches ..." \
1925 epatch "${WORKDIR}"/piepatch/nondef
1926 # adds default pie support (rs6000 too) if DEFAULT_PIE[_SSP] is defined
1927 EPATCH_MULTI_MSG="Applying default pie patches ..." \
1928 epatch "${WORKDIR}"/piepatch/def
1929
1930 # we want to be able to control the pie patch logic via something other
1931 # than ALL_CFLAGS...
1932 sed -e '/^ALL_CFLAGS/iHARD_CFLAGS = ' \
1933 -e 's|^ALL_CFLAGS = |ALL_CFLAGS = $(HARD_CFLAGS) |' \
1934 -i ${S}/gcc/Makefile.in
1935
1936 release_version="${release_version}, pie-${PIE_VER}"
1937 }
1938
1939 should_we_gcc_config() {
1940 # we only want to switch compilers if installing to / or /tmp/stage1root
1941 [[ ${ROOT} == "/" || ${ROOT} == "/tmp/stage1root" ]] || return 1
1942
1943 # we always want to run gcc-config if we're bootstrapping, otherwise
1944 # we might get stuck with the c-only stage1 compiler
1945 use bootstrap && return 0
1946 use build && return 0
1947
1948 # if the current config is invalid, we definitely want a new one
1949 local curr_config
1950 if has_version 'app-admin/eselect-compiler' ; then
1951 curr_config=$(env -i eselect compiler show ${CTARGET} 2>&1) || return 0
1952 else
1953 curr_config=$(env -i gcc-config -c ${CTARGET} 2>&1) || return 0
1954 fi
1955
1956 # if the previously selected config has the same major.minor (branch) as
1957 # the version we are installing, then it will probably be uninstalled
1958 # for being in the same SLOT, make sure we run gcc-config.
1959 local curr_config_ver
1960 if has_version 'app-admin/eselect-compiler' ; then
1961 curr_config_ver=$(env -i eselect compiler show ${CTARGET} | cut -f1 -d/ | awk -F - '{ print $5 }')
1962 else
1963 curr_config_ver=$(env -i gcc-config -S ${curr_config} | awk '{print $2}')
1964 fi
1965
1966 local curr_branch_ver=$(get_version_component_range 1-2 ${curr_config_ver})
1967
1968 # If we're using multislot, just run gcc-config if we're installing
1969 # to the same profile as the current one.
1970 use multislot && return $([[ ${curr_config_ver} == ${GCC_CONFIG_VER} ]])
1971
1972 if [[ ${curr_branch_ver} == ${GCC_BRANCH_VER} ]] ; then
1973 return 0
1974 else
1975 # if we're installing a genuinely different compiler version,
1976 # we should probably tell the user -how- to switch to the new
1977 # gcc version, since we're not going to do it for him/her.
1978 # We don't want to switch from say gcc-3.3 to gcc-3.4 right in
1979 # the middle of an emerge operation (like an 'emerge -e world'
1980 # which could install multiple gcc versions).
1981 einfo "The current gcc config appears valid, so it will not be"
1982 einfo "automatically switched for you. If you would like to"
1983 einfo "switch to the newly installed gcc version, do the"
1984 einfo "following:"
1985 echo
1986 if has_version 'app-admin/eselect-compiler' ; then
1987 einfo "eselect compiler set <profile>"
1988 else
1989 einfo "gcc-config ${CTARGET}-${GCC_CONFIG_VER}"
1990 fi
1991 einfo "source /etc/profile"
1992 echo
1993 ebeep
1994 return 1
1995 fi
1996 }
1997
1998 do_gcc_config() {
1999 if ! should_we_gcc_config ; then
2000 # Just make sure all our LDPATH's are updated
2001 if has_version 'app-admin/eselect-compiler' ; then
2002 eselect compiler update
2003 else
2004 env -i gcc-config --use-old --force
2005 fi
2006 return 0
2007 fi
2008
2009 if has_version 'app-admin/eselect-compiler' ; then
2010 local current_gcc_config=$(env -i eselect compiler show ${CTARGET})
2011 local current_specs=$(echo ${current_gcc_config} | cut -f2 -d/)
2012 if eselect compiler set ${CTARGET}-${GCC_CONFIG_VER}/${current_specs} &> /dev/null; then
2013 einfo "The following compiler profile has been activated based on your previous profile:"
2014 einfo "${CTARGET}-${GCC_CONFIG_VER}/${current_specs}"
2015 else
2016 local prefix=${current_specs%-*}
2017 [[ -n ${prefix} ]] && prefix="${prefix}-"
2018
2019 local spec
2020 if use hardened ; then
2021 spec="hardened"
2022 else
2023 spec="vanilla"
2024 fi
2025
2026 if eselect compiler set ${CTARGET}-${GCC_CONFIG_VER}/${prefix}${spec} &> /dev/null ; then
2027 ewarn "We were not able to select the currently in use profile with"
2028 ewarn "your newly emerged gcc. Instead, we have enabled the following:"
2029 ewarn "${CTARGET}-${GCC_CONFIG_VER}/${prefix}${spec}"
2030 ewarn "If this is incorrect, please use 'eselect compiler set' to"
2031 ewarn "select another profile."
2032 else
2033 if [[ -n ${DEFAULT_ABI} ]] ; then
2034 prefix="${DEFAULT_ABI}-"
2035 fi
2036
2037 if eselect compiler set ${CTARGET}-${GCC_CONFIG_VER}/${prefix}${spec} &> /dev/null ; then
2038 ewarn "We were not able to select the currently in use profile with"
2039 ewarn "your newly emerged gcc. Instead, we have enabled the following:"
2040 ewarn "${CTARGET}-${GCC_CONFIG_VER}/${prefix}${spec}"
2041 ewarn "If this is incorrect, please use 'eselect compiler set' to"
2042 ewarn "select another profile."
2043 else
2044 eerror "We were not able to automatically set the current compiler"
2045 eerror "to your newly emerged gcc. Please use 'eselect compiler set'"
2046 eerror "to select your compiler."
2047 fi
2048 fi
2049 fi
2050 else
2051 local current_gcc_config="" current_specs="" use_specs=""
2052
2053 # We grep out any possible errors
2054 current_gcc_config=$(env -i gcc-config -c ${CTARGET} | grep -v '^ ')
2055 if [[ -n ${current_gcc_config} ]] ; then
2056 # figure out which specs-specific config is active
2057 current_specs=$(gcc-config -S ${current_gcc_config} | awk '{print $3}')
2058 [[ -n ${current_specs} ]] && use_specs=-${current_specs}
2059 fi
2060
2061 if [[ -n ${use_specs} ]] && \
2062 [[ ! -e ${ROOT}/etc/env.d/gcc/${CTARGET}-${GCC_CONFIG_VER}${use_specs} ]]
2063 then
2064 ewarn "The currently selected specs-specific gcc config,"
2065 ewarn "${current_specs}, doesn't exist anymore. This is usually"
2066 ewarn "due to enabling/disabling hardened or switching to a version"
2067 ewarn "of gcc that doesnt create multiple specs files. The default"
2068 ewarn "config will be used, and the previous preference forgotten."
2069 ebeep
2070 epause
2071 use_specs=""
2072 fi
2073
2074 gcc-config ${CTARGET}-${GCC_CONFIG_VER}${use_specs}
2075 fi
2076 }
2077
2078 # This function allows us to gentoo-ize gcc's version number and bugzilla
2079 # URL without needing to use patches.
2080 #
2081 # Travis Tilley <lv@gentoo.org> (02 Sep 2004)
2082 #
2083 gcc_version_patch() {
2084 [[ -z $1 ]] && die "no arguments to gcc_version_patch"
2085
2086 sed -i -e "s~\(const char version_string\[\] = \"\).*\(\".*\)~\1$1\2~" \
2087 -e 's~http:\/\/gcc\.gnu\.org\/bugs\.html~http:\/\/bugs\.gentoo\.org\/~' ${S}/gcc/version.c || die "failed to update version.c with Gentoo branding."
2088 }
2089
2090 # The purpose of this DISGUSTING gcc multilib hack is to allow 64bit libs
2091 # to live in lib instead of lib64 where they belong, with 32bit libraries
2092 # in lib32. This hack has been around since the beginning of the amd64 port,
2093 # and we're only now starting to fix everything that's broken. Eventually
2094 # this should go away.
2095 #
2096 # Travis Tilley <lv@gentoo.org> (03 Sep 2004)
2097 #
2098 disgusting_gcc_multilib_HACK() {
2099 local config
2100 local libdirs
2101 if has_multilib_profile ; then
2102 case $(tc-arch) in
2103 amd64)
2104 config="i386/t-linux64"
2105 libdirs="../$(get_abi_LIBDIR amd64) ../$(get_abi_LIBDIR x86)" \
2106 ;;
2107 ppc64)
2108 config="rs6000/t-linux64"
2109 libdirs="../$(get_abi_LIBDIR ppc64) ../$(get_abi_LIBDIR ppc)" \
2110 ;;
2111 esac
2112 else
2113 # Remove this hunk when amd64's 2004.3 is purged from portage.
2114 use amd64 || die "Your profile is no longer supported by portage."
2115 config="i386/t-linux64"
2116 libdirs="../$(get_libdir) ../$(get_multilibdir)"
2117 fi
2118
2119 einfo "updating multilib directories to be: ${libdirs}"
2120 sed -i -e "s:^MULTILIB_OSDIRNAMES.*:MULTILIB_OSDIRNAMES = ${libdirs}:" ${S}/gcc/config/${config}
2121 }
2122
2123 disable_multilib_libjava() {
2124 if is_gcj ; then
2125 # We dont want a multilib libjava, so lets use this hack taken from fedora
2126 pushd ${S} > /dev/null
2127 sed -i -e 's/^all: all-redirect/ifeq (\$(MULTISUBDIR),)\nall: all-redirect\nelse\nall:\n\techo Multilib libjava build disabled\nendif/' libjava/Makefile.in
2128 sed -i -e 's/^install: install-redirect/ifeq (\$(MULTISUBDIR),)\ninstall: install-redirect\nelse\ninstall:\n\techo Multilib libjava install disabled\nendif/' libjava/Makefile.in
2129 sed -i -e 's/^check: check-redirect/ifeq (\$(MULTISUBDIR),)\ncheck: check-redirect\nelse\ncheck:\n\techo Multilib libjava check disabled\nendif/' libjava/Makefile.in
2130 sed -i -e 's/^all: all-recursive/ifeq (\$(MULTISUBDIR),)\nall: all-recursive\nelse\nall:\n\techo Multilib libjava build disabled\nendif/' libjava/Makefile.in
2131 sed -i -e 's/^install: install-recursive/ifeq (\$(MULTISUBDIR),)\ninstall: install-recursive\nelse\ninstall:\n\techo Multilib libjava install disabled\nendif/' libjava/Makefile.in
2132 sed -i -e 's/^check: check-recursive/ifeq (\$(MULTISUBDIR),)\ncheck: check-recursive\nelse\ncheck:\n\techo Multilib libjava check disabled\nendif/' libjava/Makefile.in
2133 popd > /dev/null
2134 fi
2135 }
2136
2137 fix_libtool_libdir_paths() {
2138 local dirpath
2139 for archive in $* ; do
2140 dirpath=$(dirname ${archive} | sed -e "s:^${D}::")
2141 sed -i ${archive} -e "s:^libdir.*:libdir=\'${dirpath}\':"
2142 done
2143 }
2144
2145 is_multilib() {
2146 [[ ${GCCMAJOR} < 3 ]] && return 1
2147 case ${CTARGET} in
2148 mips64*|powerpc64*|s390x*|sparc64*|x86_64*)
2149 has_multilib_profile || use multilib ;;
2150 *) false ;;
2151 esac
2152 }
2153
2154 is_uclibc() {
2155 [[ ${GCCMAJOR} -lt 3 ]] && return 1
2156 [[ ${CTARGET} == *-uclibc ]]
2157 }
2158
2159 is_cxx() {
2160 gcc-lang-supported 'c++' || return 1
2161 use build && return 1
2162 ! use nocxx
2163 }
2164
2165 is_f77() {
2166 gcc-lang-supported f77 || return 1
2167 use build && return 1
2168 use fortran
2169 }
2170
2171 is_f95() {
2172 gcc-lang-supported f95 || return 1
2173 use build && return 1
2174 use fortran
2175 }
2176
2177 is_fortran() {
2178 gcc-lang-supported fortran || return 1
2179 use build && return 1
2180 use fortran
2181 }
2182
2183 is_gcj() {
2184 gcc-lang-supported java || return 1
2185 use build && return 1
2186 use gcj
2187 }
2188
2189 is_objc() {
2190 gcc-lang-supported objc || return 1
2191 use build && return 1
2192 use objc
2193 }
2194
2195 is_ada() {
2196 gcc-lang-supported ada || return 1
2197 use build && return 1
2198 use ada
2199 }

  ViewVC Help
Powered by ViewVC 1.1.20