/[gentoo-x86]/eclass/toolchain.eclass
Gentoo

Contents of /eclass/toolchain.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.559 - (hide annotations) (download)
Sat Nov 24 22:27:06 2012 UTC (19 months, 2 weeks ago) by vapier
Branch: MAIN
Changes since 1.558: +10 -2 lines
if uClibc is built w/out shared lib support (like nommu), then pass in --disable-shared #291870 by Petric Frank

1 dirtyepic 1.517 # Copyright 1999-2012 Gentoo Foundation
2 lv 1.1 # Distributed under the terms of the GNU General Public License v2
3 vapier 1.559 # $Header: /var/cvsroot/gentoo-x86/eclass/toolchain.eclass,v 1.558 2012/11/24 21:20:02 vapier Exp $
4 vapier 1.330 #
5     # Maintainer: Toolchain Ninjas <toolchain@gentoo.org>
6 lv 1.53
7 vapier 1.469 #---->> eclass stuff <<----
8 vapier 1.266 HOMEPAGE="http://gcc.gnu.org/"
9 lv 1.53 LICENSE="GPL-2 LGPL-2.1"
10 peper 1.337 RESTRICT="strip" # cross-compilers need controlled stripping
11 lv 1.53
12 zorry 1.516 inherit eutils versionator libtool toolchain-funcs flag-o-matic gnuconfig multilib fixheadtails pax-utils
13 vapier 1.78
14 dirtyepic 1.532 if [[ ${PV} == *_pre9999* ]] ; then
15 vapier 1.523 EGIT_REPO_URI="git://gcc.gnu.org/git/gcc.git"
16     # naming style:
17 dirtyepic 1.527 # gcc-4.7.1_pre9999 -> gcc-4_7-branch
18 dirtyepic 1.532 # Note that the micro version is required or lots of stuff will break.
19     # To checkout master set gcc_LIVE_BRANCH="master" in the ebuild before
20     # inheriting this eclass.
21     EGIT_BRANCH="${PN}-${PV%.?_pre9999}-branch"
22     EGIT_BRANCH=${EGIT_BRANCH//./_}
23 vapier 1.523 inherit git-2
24     fi
25    
26 vapier 1.548 EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_test src_install pkg_postinst pkg_postrm
27 vapier 1.522 DESCRIPTION="The GNU Compiler Collection"
28 vapier 1.51
29 eradicator 1.102 FEATURES=${FEATURES/multilib-strict/}
30 lv 1.53 #----<< eclass stuff >>----
31    
32 lv 1.1
33 lv 1.53 #---->> globals <<----
34 vapier 1.78 export CTARGET=${CTARGET:-${CHOST}}
35 vapier 1.64 if [[ ${CTARGET} = ${CHOST} ]] ; then
36     if [[ ${CATEGORY/cross-} != ${CATEGORY} ]] ; then
37 vapier 1.78 export CTARGET=${CATEGORY/cross-}
38 vapier 1.64 fi
39     fi
40 vapier 1.546 : ${TARGET_ABI:=${ABI}}
41     : ${TARGET_MULTILIB_ABIS:=${MULTILIB_ABIS}}
42     : ${TARGET_DEFAULT_ABI:=${DEFAULT_ABI}}
43    
44 eradicator 1.104 is_crosscompile() {
45     [[ ${CHOST} != ${CTARGET} ]]
46     }
47 lv 1.17
48 dirtyepic 1.448 tc_version_is_at_least() { version_is_at_least "$1" "${2:-${GCC_RELEASE_VER}}" ; }
49 vapier 1.248
50 vapier 1.238 GCC_PV=${TOOLCHAIN_GCC_PV:-${PV}}
51     GCC_PVR=${GCC_PV}
52     [[ ${PR} != "r0" ]] && GCC_PVR=${GCC_PVR}-${PR}
53     GCC_RELEASE_VER=$(get_version_component_range 1-3 ${GCC_PV})
54     GCC_BRANCH_VER=$(get_version_component_range 1-2 ${GCC_PV})
55     GCCMAJOR=$(get_version_component_range 1 ${GCC_PV})
56     GCCMINOR=$(get_version_component_range 2 ${GCC_PV})
57     GCCMICRO=$(get_version_component_range 3 ${GCC_PV})
58     [[ ${BRANCH_UPDATE-notset} == "notset" ]] && BRANCH_UPDATE=$(get_version_component_range 4 ${GCC_PV})
59 lv 1.53
60 eradicator 1.110 # According to gcc/c-cppbuiltin.c, GCC_CONFIG_VER MUST match this regex.
61     # ([^0-9]*-)?[0-9]+[.][0-9]+([.][0-9]+)?([- ].*)?
62 vapier 1.238 GCC_CONFIG_VER=${GCC_CONFIG_VER:-$(replace_version_separator 3 '-' ${GCC_PV})}
63 eradicator 1.110
64 lv 1.53 # Pre-release support
65 dirtyepic 1.528 if [[ ${GCC_PV} != ${GCC_PV/_pre/-} ]] ; then
66 vapier 1.238 PRERELEASE=${GCC_PV/_pre/-}
67 lv 1.53 fi
68     # make _alpha and _beta ebuilds automatically use a snapshot
69 vapier 1.408 if [[ ${GCC_PV} == *_alpha* ]] ; then
70 vapier 1.238 SNAPSHOT=${GCC_BRANCH_VER}-${GCC_PV##*_alpha}
71 vapier 1.408 elif [[ ${GCC_PV} == *_beta* ]] ; then
72 vapier 1.238 SNAPSHOT=${GCC_BRANCH_VER}-${GCC_PV##*_beta}
73 vapier 1.408 elif [[ ${GCC_PV} == *_rc* ]] ; then
74     SNAPSHOT=${GCC_PV%_rc*}-RC-${GCC_PV##*_rc}
75 lv 1.53 fi
76 vapier 1.211 export GCC_FILESDIR=${GCC_FILESDIR:-${FILESDIR}}
77 lv 1.53
78 vapier 1.469 PREFIX=${TOOLCHAIN_PREFIX:-/usr}
79    
80     if tc_version_is_at_least 3.4.0 ; then
81     LIBPATH=${TOOLCHAIN_LIBPATH:-${PREFIX}/lib/gcc/${CTARGET}/${GCC_CONFIG_VER}}
82 lv 1.53 else
83 vapier 1.469 LIBPATH=${TOOLCHAIN_LIBPATH:-${PREFIX}/lib/gcc-lib/${CTARGET}/${GCC_CONFIG_VER}}
84 lv 1.53 fi
85 vapier 1.469 INCLUDEPATH=${TOOLCHAIN_INCLUDEPATH:-${LIBPATH}/include}
86     if is_crosscompile ; then
87     BINPATH=${TOOLCHAIN_BINPATH:-${PREFIX}/${CHOST}/${CTARGET}/gcc-bin/${GCC_CONFIG_VER}}
88     else
89     BINPATH=${TOOLCHAIN_BINPATH:-${PREFIX}/${CTARGET}/gcc-bin/${GCC_CONFIG_VER}}
90 lv 1.53 fi
91 vapier 1.469 DATAPATH=${TOOLCHAIN_DATAPATH:-${PREFIX}/share/gcc-data/${CTARGET}/${GCC_CONFIG_VER}}
92     # Dont install in /usr/include/g++-v3/, but in gcc internal directory.
93     # We will handle /usr/include/g++-v3/ with gcc-config ...
94     STDCXX_INCDIR=${TOOLCHAIN_STDCXX_INCDIR:-${LIBPATH}/include/g++-v${GCC_BRANCH_VER/\.*/}}
95 eradicator 1.72
96 lv 1.53 #----<< globals >>----
97    
98    
99     #---->> SLOT+IUSE logic <<----
100 vapier 1.472 IUSE="build multislot nls nptl test vanilla"
101 vapier 1.469
102     if [[ ${PN} != "kgcc64" && ${PN} != gcc-* ]] ; then
103 vapier 1.556 IUSE+=" altivec cxx fortran"
104 vapier 1.469 [[ -n ${PIE_VER} ]] && IUSE+=" nopie"
105     [[ -n ${HTB_VER} ]] && IUSE+=" boundschecking"
106 vapier 1.476 [[ -n ${D_VER} ]] && IUSE+=" d"
107 vapier 1.494 [[ -n ${SPECS_VER} ]] && IUSE+=" nossp"
108 vapier 1.245
109 vapier 1.443 if tc_version_is_at_least 3 ; then
110 dirtyepic 1.520 IUSE+=" bootstrap doc gcj gtk hardened multilib objc"
111 vapier 1.443
112 vapier 1.469 tc_version_is_at_least "4.0" && IUSE+=" objc-gc mudflap"
113 vapier 1.495 tc_version_is_at_least "4.1" && IUSE+=" libssp objc++"
114 vapier 1.469 tc_version_is_at_least "4.2" && IUSE+=" openmp"
115     tc_version_is_at_least "4.3" && IUSE+=" fixed-point"
116 vapier 1.476 tc_version_is_at_least "4.4" && IUSE+=" graphite"
117 vapier 1.469 [[ ${GCC_BRANCH_VER} == 4.5 ]] && IUSE+=" lto"
118     tc_version_is_at_least "4.6" && IUSE+=" go"
119 halcy0n 1.239 fi
120 vapier 1.469 fi
121 halcy0n 1.239
122 vapier 1.469 # Support upgrade paths here or people get pissed
123     if use multislot ; then
124 vapier 1.533 SLOT="${GCC_CONFIG_VER}"
125 vapier 1.469 else
126     SLOT="${GCC_BRANCH_VER}"
127 lv 1.5 fi
128 lv 1.53 #----<< SLOT+IUSE logic >>----
129 lv 1.13
130 vapier 1.472 #---->> DEPEND <<----
131    
132     RDEPEND="sys-libs/zlib
133     !build? (
134     nls? ( sys-devel/gettext )
135     )"
136     if tc_version_is_at_least 3 ; then
137     RDEPEND+=" virtual/libiconv"
138     fi
139     if tc_version_is_at_least 4 ; then
140 vapier 1.478 GMP_MPFR_DEPS=">=dev-libs/gmp-4.3.2 >=dev-libs/mpfr-2.4.2"
141     if tc_version_is_at_least 4.3 ; then
142     RDEPEND+=" ${GMP_MPFR_DEPS}"
143     elif in_iuse fortran ; then
144     RDEPEND+=" fortran? ( ${GMP_MPFR_DEPS} )"
145     fi
146 vapier 1.472 if tc_version_is_at_least 4.5 ; then
147     RDEPEND+=" >=dev-libs/mpc-0.8.1"
148     fi
149 vapier 1.478 in_iuse lto && RDEPEND+=" lto? ( || ( >=dev-libs/elfutils-0.143 dev-libs/libelf ) )"
150 vapier 1.472 fi
151 vapier 1.478 if in_iuse graphite ; then
152 vapier 1.472 RDEPEND+="
153     graphite? (
154     >=dev-libs/cloog-ppl-0.15.10
155 dirtyepic 1.517 >=dev-libs/ppl-0.11
156 vapier 1.472 )"
157     fi
158    
159     DEPEND="${RDEPEND}
160     >=sys-apps/texinfo-4.8
161     >=sys-devel/bison-1.875
162     >=sys-devel/flex-2.5.4
163     test? (
164     >=dev-util/dejagnu-1.4.4
165     >=sys-devel/autogen-5.5.4
166     )"
167 vapier 1.478 if in_iuse gcj ; then
168     GCJ_GTK_DEPS="
169     x11-libs/libXt
170     x11-libs/libX11
171     x11-libs/libXtst
172     x11-proto/xproto
173     x11-proto/xextproto
174 vapier 1.552 =x11-libs/gtk+-2*
175     virtual/pkgconfig
176 vapier 1.558 amd64? ( multilib? (
177     app-emulation/emul-linux-x86-gtklibs
178     app-emulation/emul-linux-x86-xlibs
179     ) )
180 vapier 1.552 "
181 vapier 1.478 tc_version_is_at_least 3.4 && GCJ_GTK_DEPS+=" x11-libs/pango"
182     GCJ_DEPS=">=media-libs/libart_lgpl-2.1"
183     tc_version_is_at_least 4.2 && GCJ_DEPS+=" app-arch/zip app-arch/unzip"
184     DEPEND+=" gcj? ( gtk? ( ${GCJ_GTK_DEPS} ) ${GCJ_DEPS} )"
185 vapier 1.472 fi
186    
187 vapier 1.555 PDEPEND=">=sys-devel/gcc-config-1.7"
188 vapier 1.472
189     #----<< DEPEND >>----
190 lv 1.13
191 lv 1.53 #---->> S + SRC_URI essentials <<----
192 lv 1.13
193 vapier 1.501 # Set the source directory depending on whether we're using
194 vapier 1.469 # a prerelease, snapshot, or release tarball.
195 vapier 1.501 S=$(
196 vapier 1.78 if [[ -n ${PRERELEASE} ]] ; then
197 vapier 1.501 echo ${WORKDIR}/gcc-${PRERELEASE}
198 vapier 1.78 elif [[ -n ${SNAPSHOT} ]] ; then
199 vapier 1.501 echo ${WORKDIR}/gcc-${SNAPSHOT}
200 lv 1.53 else
201 vapier 1.501 echo ${WORKDIR}/gcc-${GCC_RELEASE_VER}
202 lv 1.13 fi
203 vapier 1.501 )
204 lv 1.13
205 lv 1.1 # This function handles the basics of setting the SRC_URI for a gcc ebuild.
206     # To use, set SRC_URI with:
207     #
208     # SRC_URI="$(get_gcc_src_uri)"
209     #
210     # Other than the variables normally set by portage, this function's behavior
211     # can be altered by setting the following:
212     #
213     # SNAPSHOT
214     # If set, this variable signals that we should be using a snapshot
215     # of gcc from ftp://sources.redhat.com/pub/gcc/snapshots/. It is
216     # expected to be in the format "YYYY-MM-DD". Note that if the ebuild
217     # has a _pre suffix, this variable is ignored and the prerelease
218     # tarball is used instead.
219     #
220     # BRANCH_UPDATE
221     # If set, this variable signals that we should be using the main
222     # release tarball (determined by ebuild version) and applying a
223     # CVS branch update patch against it. The location of this branch
224     # update patch is assumed to be in ${GENTOO_TOOLCHAIN_BASE_URI}.
225     # Just like with SNAPSHOT, this variable is ignored if the ebuild
226     # has a _pre suffix.
227     #
228     # PATCH_VER
229 lv 1.55 # PATCH_GCC_VER
230 lv 1.1 # This should be set to the version of the gentoo patch tarball.
231     # The resulting filename of this tarball will be:
232 vapier 1.210 # gcc-${PATCH_GCC_VER:-${GCC_RELEASE_VER}}-patches-${PATCH_VER}.tar.bz2
233 lv 1.1 #
234     # PIE_VER
235 vapier 1.147 # PIE_GCC_VER
236 lv 1.1 # These variables control patching in various updates for the logic
237     # controlling Position Independant Executables. PIE_VER is expected
238 vapier 1.494 # to be the version of this patch, and PIE_GCC_VER the gcc version of
239     # the patch:
240 vapier 1.147 # An example:
241 lv 1.1 # PIE_VER="8.7.6.5"
242 vapier 1.147 # PIE_GCC_VER="3.4.0"
243     # The resulting filename of this tarball will be:
244 vapier 1.210 # gcc-${PIE_GCC_VER:-${GCC_RELEASE_VER}}-piepatches-v${PIE_VER}.tar.bz2
245 lv 1.1 #
246 solar 1.369 # SPECS_VER
247     # SPECS_GCC_VER
248     # This is for the minispecs files included in the hardened gcc-4.x
249 zorry 1.428 # The specs files for hardenedno*, vanilla and for building the "specs" file.
250 vapier 1.433 # SPECS_VER is expected to be the version of this patch, SPECS_GCC_VER
251 zorry 1.428 # the gcc version of the patch.
252     # An example:
253     # SPECS_VER="8.7.6.5"
254     # SPECS_GCC_VER="3.4.0"
255     # The resulting filename of this tarball will be:
256     # gcc-${SPECS_GCC_VER:-${GCC_RELEASE_VER}}-specs-${SPECS_VER}.tar.bz2
257 solar 1.369 #
258 lv 1.53 # HTB_VER
259     # HTB_GCC_VER
260     # These variables control whether or not an ebuild supports Herman
261     # ten Brugge's bounds-checking patches. If you want to use a patch
262     # for an older gcc version with a new gcc, make sure you set
263     # HTB_GCC_VER to that version of gcc.
264     #
265 vapier 1.112 gentoo_urls() {
266 dirtyepic 1.506 local devspace="HTTP~vapier/dist/URI HTTP~dirtyepic/dist/URI
267     HTTP~halcy0n/patches/URI HTTP~zorry/patches/gcc/URI"
268 vapier 1.112 devspace=${devspace//HTTP/http:\/\/dev.gentoo.org\/}
269     echo mirror://gentoo/$1 ${devspace//URI/$1}
270     }
271 dirtyepic 1.506
272 lv 1.1 get_gcc_src_uri() {
273 vapier 1.112 export PATCH_GCC_VER=${PATCH_GCC_VER:-${GCC_RELEASE_VER}}
274 vapier 1.173 export UCLIBC_GCC_VER=${UCLIBC_GCC_VER:-${PATCH_GCC_VER}}
275 vapier 1.147 export PIE_GCC_VER=${PIE_GCC_VER:-${GCC_RELEASE_VER}}
276 vapier 1.113 export HTB_GCC_VER=${HTB_GCC_VER:-${GCC_RELEASE_VER}}
277 solar 1.369 export SPECS_GCC_VER=${SPECS_GCC_VER:-${GCC_RELEASE_VER}}
278 lv 1.1
279     # Set where to download gcc itself depending on whether we're using a
280     # prerelease, snapshot, or release tarball.
281 vapier 1.78 if [[ -n ${PRERELEASE} ]] ; then
282 lv 1.1 GCC_SRC_URI="ftp://gcc.gnu.org/pub/gcc/prerelease-${PRERELEASE}/gcc-${PRERELEASE}.tar.bz2"
283 vapier 1.78 elif [[ -n ${SNAPSHOT} ]] ; then
284 lv 1.40 GCC_SRC_URI="ftp://sources.redhat.com/pub/gcc/snapshots/${SNAPSHOT}/gcc-${SNAPSHOT}.tar.bz2"
285 vapier 1.522 elif [[ ${PV} != *9999* ]] ; then
286 vapier 1.238 GCC_SRC_URI="mirror://gnu/gcc/gcc-${GCC_PV}/gcc-${GCC_RELEASE_VER}.tar.bz2"
287 lv 1.1 # we want all branch updates to be against the main release
288 vapier 1.112 [[ -n ${BRANCH_UPDATE} ]] && \
289 vapier 1.501 GCC_SRC_URI+=" $(gentoo_urls gcc-${GCC_RELEASE_VER}-branch-update-${BRANCH_UPDATE}.patch.bz2)"
290 lv 1.1 fi
291    
292 vapier 1.501 [[ -n ${UCLIBC_VER} ]] && GCC_SRC_URI+=" $(gentoo_urls gcc-${UCLIBC_GCC_VER}-uclibc-patches-${UCLIBC_VER}.tar.bz2)"
293     [[ -n ${PATCH_VER} ]] && GCC_SRC_URI+=" $(gentoo_urls gcc-${PATCH_GCC_VER}-patches-${PATCH_VER}.tar.bz2)"
294 lv 1.53
295 vapier 1.78 # strawberry pie, Cappuccino and a Gauloises (it's a good thing)
296 vapier 1.147 [[ -n ${PIE_VER} ]] && \
297 zorry 1.428 PIE_CORE=${PIE_CORE:-gcc-${PIE_GCC_VER}-piepatches-v${PIE_VER}.tar.bz2} && \
298 vapier 1.501 GCC_SRC_URI+=" $(gentoo_urls ${PIE_CORE})"
299 vapier 1.433
300 solar 1.369 # gcc minispec for the hardened gcc 4 compiler
301 vapier 1.501 [[ -n ${SPECS_VER} ]] && GCC_SRC_URI+=" $(gentoo_urls gcc-${SPECS_GCC_VER}-specs-${SPECS_VER}.tar.bz2)"
302 solar 1.369
303 lv 1.53 # gcc bounds checking patch
304 vapier 1.78 if [[ -n ${HTB_VER} ]] ; then
305 vapier 1.150 local HTBFILE="bounds-checking-gcc-${HTB_GCC_VER}-${HTB_VER}.patch.bz2"
306 vapier 1.501 GCC_SRC_URI+="
307 vapier 1.112 boundschecking? (
308 eradicator 1.97 mirror://sourceforge/boundschecking/${HTBFILE}
309 vapier 1.112 $(gentoo_urls ${HTBFILE})
310 eradicator 1.97 )"
311 lv 1.53 fi
312    
313 vapier 1.501 [[ -n ${D_VER} ]] && GCC_SRC_URI+=" d? ( mirror://sourceforge/dgcc/gdc-${D_VER}-src.tar.bz2 )"
314 vapier 1.327
315 halcy0n 1.360 # >= gcc-4.3 uses ecj.jar and we only add gcj as a use flag under certain
316     # conditions
317     if [[ ${PN} != "kgcc64" && ${PN} != gcc-* ]] ; then
318 dirtyepic 1.439 if tc_version_is_at_least "4.5" ; then
319 vapier 1.501 GCC_SRC_URI+=" gcj? ( ftp://sourceware.org/pub/java/ecj-4.5.jar )"
320 dirtyepic 1.439 elif tc_version_is_at_least "4.3" ; then
321 vapier 1.501 GCC_SRC_URI+=" gcj? ( ftp://sourceware.org/pub/java/ecj-4.3.jar )"
322 dirtyepic 1.439 fi
323 halcy0n 1.360 fi
324 halcy0n 1.359
325 lv 1.53 echo "${GCC_SRC_URI}"
326     }
327 vapier 1.86 SRC_URI=$(get_gcc_src_uri)
328 lv 1.53 #---->> S + SRC_URI essentials >>----
329    
330    
331     #---->> support checks <<----
332    
333 vapier 1.256 # Grab a variable from the build system (taken from linux-info.eclass)
334     get_make_var() {
335     local var=$1 makefile=${2:-${WORKDIR}/build/Makefile}
336     echo -e "e:\\n\\t@echo \$(${var})\\ninclude ${makefile}" | \
337 vapier 1.282 r=${makefile%/*} emake --no-print-directory -s -f - 2>/dev/null
338 vapier 1.256 }
339     XGCC() { get_make_var GCC_FOR_TARGET ; }
340    
341 lv 1.53 # The gentoo piessp patches allow for 3 configurations:
342     # 1) PIE+SSP by default
343     # 2) PIE by default
344     # 3) SSP by default
345     hardened_gcc_works() {
346 flameeyes 1.278 if [[ $1 == "pie" ]] ; then
347     # $gcc_cv_ld_pie is unreliable as it simply take the output of
348     # `ld --help | grep -- -pie`, that reports the option in all cases, also if
349     # the loader doesn't actually load the resulting executables.
350     # To avoid breakage, blacklist FreeBSD here at least
351     [[ ${CTARGET} == *-freebsd* ]] && return 1
352 flameeyes 1.269
353 vapier 1.157 want_pie || return 1
354 vapier 1.496 use_if_iuse nopie && return 1
355     hardened_gcc_is_stable pie
356     return $?
357 vapier 1.78 elif [[ $1 == "ssp" ]] ; then
358 vapier 1.494 [[ -n ${SPECS_VER} ]] || return 1
359 vapier 1.497 use_if_iuse nossp && return 1
360 vapier 1.496 hardened_gcc_is_stable ssp
361     return $?
362 lv 1.54 else
363     # laziness ;)
364     hardened_gcc_works pie || return 1
365     hardened_gcc_works ssp || return 1
366     return 0
367     fi
368     }
369    
370     hardened_gcc_is_stable() {
371 vapier 1.497 local tocheck
372 vapier 1.116 if [[ $1 == "pie" ]] ; then
373 vapier 1.310 if [[ ${CTARGET} == *-uclibc* ]] ; then
374 vapier 1.497 tocheck=${PIE_UCLIBC_STABLE}
375 lv 1.54 else
376 vapier 1.497 tocheck=${PIE_GLIBC_STABLE}
377 lv 1.54 fi
378 vapier 1.116 elif [[ $1 == "ssp" ]] ; then
379 vapier 1.310 if [[ ${CTARGET} == *-uclibc* ]] ; then
380 vapier 1.497 tocheck=${SSP_UCLIBC_STABLE}
381 lv 1.54 else
382 vapier 1.497 tocheck=${SSP_STABLE}
383 lv 1.54 fi
384 lv 1.53 else
385 lv 1.54 die "hardened_gcc_stable needs to be called with pie or ssp"
386 lv 1.53 fi
387    
388 ssuominen 1.461 has $(tc-arch) ${tocheck} && return 0
389 lv 1.54 return 1
390     }
391    
392 zorry 1.428 want_pie() {
393     ! use hardened && [[ -n ${PIE_VER} ]] && use nopie && return 1
394     [[ -n ${PIE_VER} ]] && [[ -n ${SPECS_VER} ]] && return 0
395     tc_version_is_at_least 4.3.2 && return 1
396 vapier 1.512 [[ -z ${PIE_VER} ]] && return 1
397     use !nopie && return 0
398     return 1
399 zorry 1.428 }
400 lv 1.53
401 solar 1.369 want_minispecs() {
402     if tc_version_is_at_least 4.3.2 && use hardened ; then
403 zorry 1.428 if ! want_pie ; then
404     ewarn "PIE_VER or SPECS_VER is not defiend in the GCC ebuild."
405     elif use vanilla ; then
406     ewarn "You will not get hardened features if you have the vanilla USE-flag."
407     elif use nopie && use nossp ; then
408     ewarn "You will not get hardened features if you have the nopie and nossp USE-flag."
409 vapier 1.498 elif ! hardened_gcc_works ; then
410 zorry 1.428 ewarn "Your $(tc-arch) arch is not supported."
411     else
412 solar 1.369 return 0
413     fi
414 zorry 1.428 ewarn "Hope you know what you are doing. Hardened will not work."
415     return 0
416 solar 1.369 fi
417     return 1
418     }
419 lv 1.53
420     # This is to make sure we don't accidentally try to enable support for a
421     # language that doesnt exist. GCC 3.4 supports f77, while 4.0 supports f95, etc.
422     #
423 vapier 1.295 # Also add a hook so special ebuilds (kgcc64) can control which languages
424     # exactly get enabled
425 lv 1.53 gcc-lang-supported() {
426 vapier 1.295 grep ^language=\"${1}\" "${S}"/gcc/*/config-lang.in > /dev/null || return 1
427     [[ -z ${TOOLCHAIN_ALLOWED_LANGS} ]] && return 0
428     has $1 ${TOOLCHAIN_ALLOWED_LANGS}
429 lv 1.53 }
430    
431     #----<< support checks >>----
432    
433     #---->> specs + env.d logic <<----
434    
435     # configure to build with the hardened GCC specs as the default
436     make_gcc_hard() {
437 vapier 1.499 # defaults to enable for all hardened toolchains
438     local gcc_hard_flags="-DEFAULT_RELRO -DEFAULT_BIND_NOW"
439    
440 lv 1.53 if hardened_gcc_works ; then
441     einfo "Updating gcc to use automatic PIE + SSP building ..."
442 vapier 1.499 gcc_hard_flags+=" -DEFAULT_PIE_SSP"
443 lv 1.53 elif hardened_gcc_works pie ; then
444     einfo "Updating gcc to use automatic PIE building ..."
445     ewarn "SSP has not been enabled by default"
446 vapier 1.499 gcc_hard_flags+=" -DEFAULT_PIE"
447 lv 1.53 elif hardened_gcc_works ssp ; then
448     einfo "Updating gcc to use automatic SSP building ..."
449     ewarn "PIE has not been enabled by default"
450 vapier 1.499 gcc_hard_flags+=" -DEFAULT_SSP"
451 lv 1.53 else
452     # do nothing if hardened isnt supported, but dont die either
453     ewarn "hardened is not supported for this arch in this gcc version"
454     ebeep
455     return 0
456     fi
457    
458 vapier 1.499 sed -i \
459     -e "/^HARD_CFLAGS = /s|=|= ${gcc_hard_flags} |" \
460     "${S}"/gcc/Makefile.in || die
461    
462 lv 1.53 # rebrand to make bug reports easier
463 vapier 1.347 BRANDING_GCC_PKGVERSION=${BRANDING_GCC_PKGVERSION/Gentoo/Gentoo Hardened}
464 lv 1.53 }
465    
466     create_gcc_env_entry() {
467     dodir /etc/env.d/gcc
468 eradicator 1.73 local gcc_envd_base="/etc/env.d/gcc/${CTARGET}-${GCC_CONFIG_VER}"
469 lv 1.53
470 vapier 1.555 local gcc_specs_file
471     local gcc_envd_file="${D}${gcc_envd_base}"
472 vapier 1.119 if [[ -z $1 ]] ; then
473 lv 1.53 # I'm leaving the following commented out to remind me that it
474     # was an insanely -bad- idea. Stuff broke. GCC_SPECS isnt unset
475     # on chroot or in non-toolchain.eclass gcc ebuilds!
476     #gcc_specs_file="${LIBPATH}/specs"
477     gcc_specs_file=""
478     else
479 vapier 1.555 gcc_envd_file+="-$1"
480 lv 1.53 gcc_specs_file="${LIBPATH}/$1.specs"
481     fi
482    
483 vapier 1.503 # We want to list the default ABI's LIBPATH first so libtool
484     # searches that directory first. This is a temporary
485     # workaround for libtool being stupid and using .la's from
486     # conflicting ABIs by using the first one in the search path
487 vapier 1.555 local mdir mosdir mosdirs abi
488     local ldpath ldpaths
489 vapier 1.546 for abi in $(get_all_abis TARGET) ; do
490 vapier 1.555 mdir=$($(XGCC) $(get_abi_CFLAGS ${abi}) --print-multi-directory)
491     ldpath=${LIBPATH}
492     [[ ${mdir} != "." ]] && ldpath+="/${mdir}"
493     ldpaths="${ldpath}${ldpaths:+:${ldpaths}}"
494 eradicator 1.126
495 vapier 1.555 mosdir=$($(XGCC) $(get_abi_CFLAGS ${abi}) -print-multi-os-directory)
496     mosdirs="${mosdir}${mosdirs:+:${mosdirs}}"
497 vapier 1.503 done
498 lv 1.53
499 vapier 1.555 cat <<-EOF > ${gcc_envd_file}
500     PATH="${BINPATH}"
501     ROOTPATH="${BINPATH}"
502     GCC_PATH="${BINPATH}"
503 vapier 1.557 LDPATH="${ldpaths}"
504 vapier 1.555 MANPATH="${DATAPATH}/man"
505     INFOPATH="${DATAPATH}/info"
506     STDCXX_INCDIR="${STDCXX_INCDIR##*/}"
507     CTARGET="${CTARGET}"
508     GCC_SPECS="${gcc_specs_file}"
509     MULTIOSDIRS="${mosdirs}"
510     EOF
511 lv 1.53 }
512 solar 1.369 setup_minispecs_gcc_build_specs() {
513 zorry 1.428 # Setup the "build.specs" file for gcc 4.3 to use when building.
514     if hardened_gcc_works pie ; then
515     cat "${WORKDIR}"/specs/pie.specs >> "${WORKDIR}"/build.specs
516     fi
517     if hardened_gcc_works ssp ; then
518     for s in ssp sspall ; do
519 solar 1.369 cat "${WORKDIR}"/specs/${s}.specs >> "${WORKDIR}"/build.specs
520     done
521     fi
522 zorry 1.428 for s in nostrict znow ; do
523     cat "${WORKDIR}"/specs/${s}.specs >> "${WORKDIR}"/build.specs
524     done
525     export GCC_SPECS="${WORKDIR}"/build.specs
526 solar 1.369 }
527     copy_minispecs_gcc_specs() {
528 zorry 1.428 # setup the hardenedno* specs files and the vanilla specs file.
529     if hardened_gcc_works ; then
530     create_gcc_env_entry hardenednopiessp
531     fi
532 vapier 1.433 if hardened_gcc_works pie ; then
533 zorry 1.428 create_gcc_env_entry hardenednopie
534     fi
535 vapier 1.433 if hardened_gcc_works ssp ; then
536 zorry 1.428 create_gcc_env_entry hardenednossp
537     fi
538     create_gcc_env_entry vanilla
539     insinto ${LIBPATH}
540     doins "${WORKDIR}"/specs/*.specs || die "failed to install specs"
541 solar 1.369 # Build system specs file which, if it exists, must be a complete set of
542     # specs as it completely and unconditionally overrides the builtin specs.
543 zorry 1.428 # For gcc 4.3
544     if ! tc_version_is_at_least 4.4 ; then
545 solar 1.369 $(XGCC) -dumpspecs > "${WORKDIR}"/specs/specs
546     cat "${WORKDIR}"/build.specs >> "${WORKDIR}"/specs/specs
547 zorry 1.428 doins "${WORKDIR}"/specs/specs || die "failed to install the specs file"
548 vapier 1.433 fi
549 solar 1.369 }
550 eradicator 1.196
551 lv 1.53 #----<< specs + env.d logic >>----
552 lv 1.13
553 eradicator 1.72 #---->> pkg_* <<----
554 vapier 1.469 toolchain_pkg_setup() {
555 vapier 1.522 if [[ -n ${PRERELEASE}${SNAPSHOT} || ${PV} == *9999* ]] &&
556     [[ -z ${I_PROMISE_TO_SUPPLY_PATCHES_WITH_BUGS} ]]
557     then
558     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." \
559     "This is to try and cut down on people filing bugs for a compiler we do not currently support."
560     fi
561    
562 vapier 1.470 # we dont want to use the installed compiler's specs to build gcc!
563     unset GCC_SPECS
564 dirtyepic 1.449
565 vapier 1.482 if ! use_if_iuse cxx ; then
566 vapier 1.479 use_if_iuse go && ewarn 'Go requires a C++ compiler, disabled due to USE="-cxx"'
567     use_if_iuse objc++ && ewarn 'Obj-C++ requires a C++ compiler, disabled due to USE="-cxx"'
568     use_if_iuse gcj && ewarn 'GCJ requires a C++ compiler, disabled due to USE="-cxx"'
569 lv 1.1 fi
570    
571 zorry 1.428 want_minispecs
572 vapier 1.402
573     unset LANGUAGES #265283
574 lv 1.1 }
575    
576 vapier 1.469 toolchain_pkg_postinst() {
577 vapier 1.434 do_gcc_config
578 vapier 1.87
579 vapier 1.265 if ! is_crosscompile ; then
580     echo
581 vapier 1.301 ewarn "If you have issues with packages unable to locate libstdc++.la,"
582     ewarn "then try running 'fix_libtool_files.sh' on the old gcc versions."
583 vapier 1.265 echo
584 vapier 1.438 ewarn "You might want to review the GCC upgrade guide when moving between"
585     ewarn "major versions (like 4.2 to 4.3):"
586     ewarn "http://www.gentoo.org/doc/en/gcc-upgrading.xml"
587     echo
588 vapier 1.265 fi
589 eradicator 1.110
590 vapier 1.292 if ! is_crosscompile ; then
591 vapier 1.537 # hack to prevent collisions between SLOTs
592    
593     # Clean up old paths
594     rm -f "${ROOT}"/*/rcscripts/awk/fixlafiles.awk "${ROOT}"/sbin/fix_libtool_files.sh
595     rmdir "${ROOT}"/*/rcscripts{/awk,} 2>/dev/null
596    
597     mkdir -p "${ROOT}"/usr/{share/gcc-data,sbin,bin}
598     cp "${ROOT}/${DATAPATH}"/fixlafiles.awk "${ROOT}"/usr/share/gcc-data/ || die
599     cp "${ROOT}/${DATAPATH}"/fix_libtool_files.sh "${ROOT}"/usr/sbin/ || die
600 solar 1.299
601 vapier 1.307 # Since these aren't critical files and portage sucks with
602     # handling of binpkgs, don't require these to be found
603 vapier 1.537 cp "${ROOT}/${DATAPATH}"/c{89,99} "${ROOT}"/usr/bin/ 2>/dev/null
604 vapier 1.292 fi
605 vapier 1.87 }
606    
607 vapier 1.469 toolchain_pkg_postrm() {
608 swegener 1.174 # to make our lives easier (and saner), we do the fix_libtool stuff here.
609     # rather than checking SLOT's and trying in upgrade paths, we just see if
610     # the common libstdc++.la exists in the ${LIBPATH} of the gcc that we are
611 azarah 1.135 # unmerging. if it does, that means this was a simple re-emerge.
612    
613 vapier 1.168 # clean up the cruft left behind by cross-compilers
614     if is_crosscompile ; then
615     if [[ -z $(ls "${ROOT}"/etc/env.d/gcc/${CTARGET}* 2>/dev/null) ]] ; then
616     rm -f "${ROOT}"/etc/env.d/gcc/config-${CTARGET}
617     rm -f "${ROOT}"/etc/env.d/??gcc-${CTARGET}
618     rm -f "${ROOT}"/usr/bin/${CTARGET}-{gcc,{g,c}++}{,32,64}
619     fi
620     return 0
621     fi
622 eradicator 1.72
623 azarah 1.135 # ROOT isnt handled by the script
624     [[ ${ROOT} != "/" ]] && return 0
625 lv 1.1
626 vapier 1.281 if [[ ! -e ${LIBPATH}/libstdc++.so ]] ; then
627 vapier 1.415 # make sure the profile is sane during same-slot upgrade #289403
628     do_gcc_config
629    
630 vapier 1.281 einfo "Running 'fix_libtool_files.sh ${GCC_RELEASE_VER}'"
631 vapier 1.550 /usr/sbin/fix_libtool_files.sh ${GCC_RELEASE_VER}
632 vapier 1.281 if [[ -n ${BRANCH_UPDATE} ]] ; then
633     einfo "Running 'fix_libtool_files.sh ${GCC_RELEASE_VER}-${BRANCH_UPDATE}'"
634 vapier 1.550 /usr/sbin/fix_libtool_files.sh ${GCC_RELEASE_VER}-${BRANCH_UPDATE}
635 vapier 1.281 fi
636 azarah 1.135 fi
637 lv 1.1
638 azarah 1.135 return 0
639 eradicator 1.72 }
640 lv 1.1
641 eradicator 1.72 #---->> pkg_* <<----
642 pappy 1.27
643 eradicator 1.72 #---->> src_* <<----
644 lv 1.1
645 vapier 1.160 guess_patch_type_in_dir() {
646     [[ -n $(ls "$1"/*.bz2 2>/dev/null) ]] \
647     && EPATCH_SUFFIX="patch.bz2" \
648     || EPATCH_SUFFIX="patch"
649     }
650 kevquinn 1.297 do_gcc_rename_java_bins() {
651     # bug #139918 - conflict between gcc and java-config-2 for ownership of
652 flameeyes 1.322 # /usr/bin/rmi{c,registry}. Done with mv & sed rather than a patch
653 kevquinn 1.297 # because patches would be large (thanks to the rename of man files),
654     # and it's clear from the sed invocations that all that changes is the
655     # rmi{c,registry} names to grmi{c,registry} names.
656     # Kevin F. Quinn 2006-07-12
657     einfo "Renaming jdk executables rmic and rmiregistry to grmic and grmiregistry."
658     # 1) Move the man files if present (missing prior to gcc-3.4)
659     for manfile in rmic rmiregistry; do
660     [[ -f ${S}/gcc/doc/${manfile}.1 ]] || continue
661 maekke 1.390 mv "${S}"/gcc/doc/${manfile}.1 "${S}"/gcc/doc/g${manfile}.1
662 kevquinn 1.297 done
663     # 2) Fixup references in the docs if present (mission prior to gcc-3.4)
664     for jfile in gcc/doc/gcj.info gcc/doc/grmic.1 gcc/doc/grmiregistry.1 gcc/java/gcj.texi; do
665     [[ -f ${S}/${jfile} ]] || continue
666 maekke 1.390 sed -i -e 's:rmiregistry:grmiregistry:g' "${S}"/${jfile} ||
667 kevquinn 1.297 die "Failed to fixup file ${jfile} for rename to grmiregistry"
668 maekke 1.390 sed -i -e 's:rmic:grmic:g' "${S}"/${jfile} ||
669 kevquinn 1.297 die "Failed to fixup file ${jfile} for rename to grmic"
670     done
671     # 3) Fixup Makefiles to build the changed executable names
672 flameeyes 1.322 # These are present in all 3.x versions, and are the important bit
673     # to get gcc to build with the new names.
674 kevquinn 1.297 for jfile in libjava/Makefile.am libjava/Makefile.in gcc/java/Make-lang.in; do
675 maekke 1.390 sed -i -e 's:rmiregistry:grmiregistry:g' "${S}"/${jfile} ||
676 kevquinn 1.297 die "Failed to fixup file ${jfile} for rename to grmiregistry"
677     # Careful with rmic on these files; it's also the name of a directory
678     # which should be left unchanged. Replace occurrences of 'rmic$',
679     # 'rmic_' and 'rmic '.
680 maekke 1.390 sed -i -e 's:rmic\([$_ ]\):grmic\1:g' "${S}"/${jfile} ||
681 kevquinn 1.297 die "Failed to fixup file ${jfile} for rename to grmic"
682     done
683     }
684 vapier 1.469 toolchain_src_unpack() {
685 vapier 1.310 [[ -z ${UCLIBC_VER} ]] && [[ ${CTARGET} == *-uclibc* ]] && die "Sorry, this version does not support uClibc"
686 vapier 1.154
687 dirtyepic 1.528 if [[ ${PV} == *9999* ]]; then
688     git-2_src_unpack
689     else
690     gcc_quick_unpack
691     fi
692 lv 1.1
693 dirtyepic 1.526 export BRANDING_GCC_PKGVERSION="Gentoo ${GCC_PVR}"
694 vapier 1.327 cd "${S}"
695 eradicator 1.72
696 vapier 1.181 if ! use vanilla ; then
697     if [[ -n ${PATCH_VER} ]] ; then
698     guess_patch_type_in_dir "${WORKDIR}"/patch
699     EPATCH_MULTI_MSG="Applying Gentoo patches ..." \
700     epatch "${WORKDIR}"/patch
701 vapier 1.347 BRANDING_GCC_PKGVERSION="${BRANDING_GCC_PKGVERSION} p${PATCH_VER}"
702 vapier 1.181 fi
703     if [[ -n ${UCLIBC_VER} ]] ; then
704     guess_patch_type_in_dir "${WORKDIR}"/uclibc
705     EPATCH_MULTI_MSG="Applying uClibc patches ..." \
706     epatch "${WORKDIR}"/uclibc
707     fi
708     fi
709 vapier 1.234 do_gcc_HTB_patches
710     do_gcc_PIE_patches
711 vapier 1.406 epatch_user
712 lv 1.2
713 vapier 1.500 use hardened && make_gcc_hard
714 vapier 1.470
715 vapier 1.483 # install the libstdc++ python into the right location
716     # http://gcc.gnu.org/PR51368
717 vapier 1.553 if tc_version_is_at_least 4.5 && ! tc_version_is_at_least 4.7 ; then
718 vapier 1.483 sed -i \
719     '/^pythondir =/s:=.*:= $(datadir)/python:' \
720     "${S}"/libstdc++-v3/python/Makefile.in || die
721     fi
722    
723 vapier 1.555 # make sure the pkg config files install into multilib dirs.
724     # since we configure with just one --libdir, we can't use that
725     # (as gcc itself takes care of building multilibs). #435728
726     find "${S}" -name Makefile.in \
727     -exec sed -i '/^pkgconfigdir/s:=.*:=$(toolexeclibdir)/pkgconfig:' {} +
728    
729 vapier 1.455 # No idea when this first started being fixed, but let's go with 4.3.x for now
730     if ! tc_version_is_at_least 4.3 ; then
731     fix_files=""
732     for x in contrib/test_summary libstdc++-v3/scripts/check_survey.in ; do
733     [[ -e ${x} ]] && fix_files="${fix_files} ${x}"
734     done
735     ht_fix_file ${fix_files} */configure *.sh */Makefile.in
736     fi
737 vapier 1.162
738 vapier 1.456 setup_multilib_osdirnames
739 lv 1.1
740 vapier 1.347 gcc_version_patch
741 vapier 1.487 if tc_version_is_at_least 4.1 ; then
742 dirtyepic 1.526 if [[ -n ${SNAPSHOT} || -n ${PRERELEASE} ]] ; then
743 dirtyepic 1.529 # BASE-VER must be a three-digit version number
744     # followed by an optional -pre string
745     # eg. 4.5.1, 4.6.2-pre20120213, 4.7.0-pre9999
746 dirtyepic 1.532 # If BASE-VER differs from ${PV/_/-} then libraries get installed in
747     # the wrong directory.
748 halcy0n 1.264 echo ${PV/_/-} > "${S}"/gcc/BASE-VER
749     fi
750     fi
751    
752 halcy0n 1.360 # >= gcc-4.3 doesn't bundle ecj.jar, so copy it
753 vapier 1.487 if tc_version_is_at_least 4.3 && use gcj ; then
754 dirtyepic 1.439 if tc_version_is_at_least "4.5" ; then
755     einfo "Copying ecj-4.5.jar"
756     cp -pPR "${DISTDIR}/ecj-4.5.jar" "${S}/ecj.jar" || die
757     elif tc_version_is_at_least "4.3" ; then
758     einfo "Copying ecj-4.3.jar"
759     cp -pPR "${DISTDIR}/ecj-4.3.jar" "${S}/ecj.jar" || die
760     fi
761 halcy0n 1.359 fi
762    
763 eradicator 1.72 # disable --as-needed from being compiled into gcc specs
764 vapier 1.213 # natively when using a gcc version < 3.4.4
765     # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14992
766 vapier 1.393 if ! tc_version_is_at_least 3.4.4 ; then
767 vapier 1.213 sed -i -e s/HAVE_LD_AS_NEEDED/USE_LD_AS_NEEDED/g "${S}"/gcc/config.in
768 azarah 1.145 fi
769 eradicator 1.72
770 kevquinn 1.297 # In gcc 3.3.x and 3.4.x, rename the java bins to gcc-specific names
771     # in line with gcc-4.
772 vapier 1.487 if tc_version_is_at_least 3.3 && ! tc_version_is_at_least 4.0 ; then
773 kevquinn 1.297 do_gcc_rename_java_bins
774     fi
775    
776 dirtyepic 1.520 # Prevent libffi from being installed
777     sed -i -e 's/\(install.*:\) install-.*recursive/\1/' "${S}"/libffi/Makefile.in
778     sed -i -e 's/\(install-data-am:\).*/\1/' "${S}"/libffi/include/Makefile.in
779    
780 eradicator 1.72 # Fixup libtool to correctly generate .la files with portage
781 vapier 1.201 cd "${S}"
782 vapier 1.79 elibtoolize --portage --shallow --no-uclibc
783 eradicator 1.72
784     gnuconfig_update
785 lv 1.1
786 vapier 1.201 # update configure files
787 vapier 1.296 local f
788 vapier 1.201 einfo "Fixing misc issues in configure files"
789 vapier 1.393 tc_version_is_at_least 4.1 && epatch "${GCC_FILESDIR}"/gcc-configure-texinfo.patch
790 vapier 1.201 for f in $(grep -l 'autoconf version 2.13' $(find "${S}" -name configure)) ; do
791 vapier 1.340 ebegin " Updating ${f/${S}\/} [LANG]"
792 vapier 1.211 patch "${f}" "${GCC_FILESDIR}"/gcc-configure-LANG.patch >& "${T}"/configure-patch.log \
793 vapier 1.201 || eerror "Please file a bug about this"
794     eend $?
795     done
796 vapier 1.349 sed -i 's|A-Za-z0-9|[:alnum:]|g' "${S}"/gcc/*.awk #215828
797 vapier 1.201
798 vapier 1.320 if [[ -x contrib/gcc_update ]] ; then
799     einfo "Touching generated files"
800     ./contrib/gcc_update --touch | \
801     while read f ; do
802 vapier 1.334 einfo " ${f%%...}"
803 vapier 1.320 done
804     fi
805 lv 1.1 }
806    
807 vapier 1.508 gcc-abi-map() {
808     # Convert the ABI name we use in Gentoo to what gcc uses
809     local map=()
810     case ${CTARGET} in
811     mips*) map=("o32 32" "n32 n32" "n64 64") ;;
812     x86_64*) map=("amd64 m64" "x86 m32" "x32 mx32") ;;
813     esac
814    
815     local m
816     for m in "${map[@]}" ; do
817     l=( ${m} )
818     [[ $1 == ${l[0]} ]] && echo ${l[1]} && break
819     done
820     }
821    
822 vapier 1.468 gcc-multilib-configure() {
823     if ! is_multilib ; then
824     confgcc+=" --disable-multilib"
825 vapier 1.547 # Fun times: if we are building for a target that has multiple
826     # possible ABI formats, and the user has told us to pick one
827     # that isn't the default, then not specifying it via the list
828     # below will break that on us.
829 vapier 1.468 else
830 vapier 1.466 confgcc+=" --enable-multilib"
831 vapier 1.458 fi
832 vapier 1.468
833     # translate our notion of multilibs into gcc's
834 vapier 1.508 local abi list
835 vapier 1.546 for abi in $(get_all_abis TARGET) ; do
836 vapier 1.508 local l=$(gcc-abi-map ${abi})
837     [[ -n ${l} ]] && list+=",${l}"
838 vapier 1.468 done
839 vapier 1.508 if [[ -n ${list} ]] ; then
840     case ${CTARGET} in
841     x86_64*)
842 vapier 1.539 tc_version_is_at_least 4.7 && confgcc+=" --with-multilib-list=${list:1}"
843 vapier 1.508 ;;
844     esac
845     fi
846 vapier 1.468 }
847    
848 eradicator 1.72 gcc-compiler-configure() {
849 vapier 1.468 gcc-multilib-configure
850 lv 1.1
851 vapier 1.248 if tc_version_is_at_least "4.0" ; then
852 vapier 1.478 if in_iuse mudflap ; then
853 vapier 1.466 confgcc+=" $(use_enable mudflap libmudflap)"
854 vapier 1.336 else
855 vapier 1.466 confgcc+=" --disable-libmudflap"
856 vapier 1.336 fi
857 vapier 1.248
858 vapier 1.495 if use_if_iuse libssp ; then
859 vapier 1.466 confgcc+=" --enable-libssp"
860 vapier 1.248 else
861     export gcc_cv_libc_provides_ssp=yes
862 vapier 1.466 confgcc+=" --disable-libssp"
863 vapier 1.248 fi
864 vapier 1.356
865 zorry 1.428 # If we want hardened support with the newer piepatchset for >=gcc 4.4
866     if tc_version_is_at_least 4.4 && want_minispecs ; then
867 vapier 1.466 confgcc+=" $(use_enable hardened esp)"
868 zorry 1.428 fi
869    
870 dirtyepic 1.363 if tc_version_is_at_least "4.2" ; then
871 vapier 1.478 if in_iuse openmp ; then
872 vapier 1.442 # Make sure target has pthreads support. #326757 #335883
873     # There shouldn't be a chicken&egg problem here as openmp won't
874     # build without a C library, and you can't build that w/out
875     # already having a compiler ...
876     if ! is_crosscompile || \
877     $(tc-getCPP ${CTARGET}) -E - <<<"#include <pthread.h>" >& /dev/null
878     then
879 vapier 1.466 confgcc+=" $(use_enable openmp libgomp)"
880 vapier 1.454 else
881     # Force disable as the configure script can be dumb #359855
882 vapier 1.466 confgcc+=" --disable-libgomp"
883 vapier 1.442 fi
884     else
885 vapier 1.454 # For gcc variants where we don't want openmp (e.g. kgcc)
886 vapier 1.466 confgcc+=" --disable-libgomp"
887 vapier 1.440 fi
888 dirtyepic 1.363 fi
889    
890 halcy0n 1.404 # Stick the python scripts in their own slotted directory
891     # bug #279252
892 dirtyepic 1.426 #
893     # --with-python-dir=DIR
894 vapier 1.483 # Specifies where to install the Python modules used for aot-compile. DIR
895 vapier 1.433 # should not include the prefix used in installation. For example, if the
896     # Python modules are to be installed in /usr/lib/python2.5/site-packages,
897 vapier 1.483 # then --with-python-dir=/lib/python2.5/site-packages should be passed.
898 dirtyepic 1.426 #
899     # This should translate into "/share/gcc-data/${CTARGET}/${GCC_CONFIG_VER}/python"
900 halcy0n 1.404 if tc_version_is_at_least "4.4" ; then
901 vapier 1.466 confgcc+=" --with-python-dir=${DATAPATH/$PREFIX/}/python"
902 halcy0n 1.404 fi
903 dirtyepic 1.436 fi
904 lu_zero 1.435
905 vapier 1.551 # Enable build warnings by default with cross-compilers when system
906     # paths are included (e.g. via -I flags).
907     is_crosscompile && confgcc+=" --enable-poison-system-directories"
908    
909 dirtyepic 1.436 # For newer versions of gcc, use the default ("release"), because no
910     # one (even upstream apparently) tests with it disabled. #317217
911     if tc_version_is_at_least 4 || [[ -n ${GCC_CHECKS_LIST} ]] ; then
912 vapier 1.466 confgcc+=" --enable-checking=${GCC_CHECKS_LIST:-release}"
913 dirtyepic 1.436 else
914 vapier 1.466 confgcc+=" --disable-checking"
915 vapier 1.244 fi
916 vapier 1.219
917 eradicator 1.72 # GTK+ is preferred over xlib in 3.4.x (xlib is unmaintained
918     # right now). Much thanks to <csm@gnu.org> for the heads up.
919 flameeyes 1.322 # Travis Tilley <lv@gentoo.org> (11 Jul 2004)
920 eradicator 1.127 if ! is_gcj ; then
921 vapier 1.466 confgcc+=" --disable-libgcj"
922 eradicator 1.127 elif use gtk ; then
923 vapier 1.466 confgcc+=" --enable-java-awt=gtk"
924 eradicator 1.72 fi
925 lv 1.53
926 vapier 1.467 # newer gcc versions like to bootstrap themselves with C++,
927     # so we need to manually disable it ourselves
928     if tc_version_is_at_least 4.7 && ! is_cxx ; then
929     confgcc+=" --disable-build-with-cxx --disable-build-poststage1-with-cxx"
930     fi
931    
932     # newer gcc's come with libquadmath, but only fortran uses
933     # it, so auto punt it when we don't care
934     if tc_version_is_at_least 4.6 && ! is_fortran ; then
935     confgcc+=" --disable-libquadmath"
936     fi
937    
938 vapier 1.508 local with_abi_map=()
939 vapier 1.80 case $(tc-arch) in
940 vapier 1.534 arm) #264534 #414395
941     local a arm_arch=${CTARGET%%-*}
942     # Remove trailing endian variations first: eb el be bl b l
943     for a in e{b,l} {b,l}e b l ; do
944     if [[ ${arm_arch} == *${a} ]] ; then
945     arm_arch=${arm_arch%${a}}
946     break
947     fi
948     done
949     # Convert armv7{a,r,m} to armv7-{a,r,m}
950     [[ ${arm_arch} == armv7? ]] && arm_arch=${arm_arch/7/7-}
951     # See if this is a valid --with-arch flag
952     if (srcdir=${S}/gcc target=${CTARGET} with_arch=${arm_arch};
953     . "${srcdir}"/config.gcc) &>/dev/null
954     then
955 vapier 1.466 confgcc+=" --with-arch=${arm_arch}"
956 armin76 1.419 fi
957 armin76 1.423
958 armin76 1.422 # Enable hardvfp
959 vapier 1.549 if [[ $(tc-is-softfloat) == "no" ]] && \
960 vapier 1.538 [[ ${CTARGET} == armv[67]* ]] && \
961 vapier 1.534 tc_version_is_at_least "4.5"
962     then
963 vapier 1.538 # Follow the new arm hardfp distro standard by default
964 vapier 1.534 confgcc+=" --with-float=hard"
965 vapier 1.538 case ${CTARGET} in
966     armv6*) confgcc+=" --with-fpu=vfp" ;;
967     armv7*) confgcc+=" --with-fpu=vfpv3-d16" ;;
968     esac
969 armin76 1.422 fi
970 halcy0n 1.417 ;;
971 vapier 1.508 # Add --with-abi flags to set default ABI
972 vapier 1.509 mips)
973 vapier 1.546 confgcc+=" --with-abi=$(gcc-abi-map ${TARGET_DEFAULT_ABI})"
974 vapier 1.339 ;;
975 vapier 1.509 amd64)
976 vapier 1.514 # drop the older/ABI checks once this get's merged into some
977     # version of gcc upstream
978 vapier 1.546 if tc_version_is_at_least 4.7 && has x32 $(get_all_abis TARGET) ; then
979     confgcc+=" --with-abi=$(gcc-abi-map ${TARGET_DEFAULT_ABI})"
980 vapier 1.509 fi
981     ;;
982 vapier 1.339 # Default arch for x86 is normally i386, lets give it a bump
983     # since glibc will do so based on CTARGET anyways
984     x86)
985 vapier 1.466 confgcc+=" --with-arch=${CTARGET%%-*}"
986 vapier 1.339 ;;
987 gmsoft 1.143 # Enable sjlj exceptions for backward compatibility on hppa
988     hppa)
989 vapier 1.466 [[ ${GCCMAJOR} == "3" ]] && confgcc+=" --enable-sjlj-exceptions"
990 vapier 1.339 ;;
991 vapier 1.451 # Set up defaults based on current CFLAGS
992     ppc)
993     is-flagq -mfloat-gprs=double && confgcc+=" --enable-e500-double"
994     [[ ${CTARGET//_/-} == *-e500v2-* ]] && confgcc+=" --enable-e500-double"
995     ;;
996 eradicator 1.72 esac
997 lv 1.1
998 vapier 1.502 local GCC_LANG="c"
999     is_cxx && GCC_LANG+=",c++"
1000     is_d && GCC_LANG+=",d"
1001     is_gcj && GCC_LANG+=",java"
1002     is_go && GCC_LANG+=",go"
1003 vapier 1.247 if is_objc || is_objcxx ; then
1004 vapier 1.502 GCC_LANG+=",objc"
1005 halcy0n 1.358 if tc_version_is_at_least "4.0" ; then
1006 vapier 1.466 use objc-gc && confgcc+=" --enable-objc-gc"
1007 halcy0n 1.358 fi
1008 vapier 1.502 is_objcxx && GCC_LANG+=",obj-c++"
1009 vapier 1.217 fi
1010 vapier 1.502 is_treelang && GCC_LANG+=",treelang"
1011 eradicator 1.127
1012     # fortran support just got sillier! the lang value can be f77 for
1013     # fortran77, f95 for fortran95, or just plain old fortran for the
1014     # currently supported standard depending on gcc version.
1015 vapier 1.502 is_fortran && GCC_LANG+=",fortran"
1016     is_f77 && GCC_LANG+=",f77"
1017     is_f95 && GCC_LANG+=",f95"
1018 lv 1.49
1019 eradicator 1.127 # We do NOT want 'ADA support' in here!
1020 vapier 1.502 # is_ada && GCC_LANG+=",ada"
1021 lv 1.13
1022     einfo "configuring for GCC_LANG: ${GCC_LANG}"
1023 vapier 1.502 confgcc+=" --enable-languages=${GCC_LANG}"
1024 lv 1.13 }
1025    
1026 lv 1.1 gcc_do_configure() {
1027     local confgcc
1028    
1029     # Set configuration based on path variables
1030 vapier 1.466 confgcc+=" \
1031 lv 1.13 --prefix=${PREFIX} \
1032 lv 1.1 --bindir=${BINPATH} \
1033 lv 1.2 --includedir=${INCLUDEPATH} \
1034 lv 1.1 --datadir=${DATAPATH} \
1035     --mandir=${DATAPATH}/man \
1036     --infodir=${DATAPATH}/info \
1037 lv 1.13 --with-gxx-include-dir=${STDCXX_INCDIR}"
1038 grobian 1.396 # On Darwin we need libdir to be set in order to get correct install names
1039     # for things like libobjc-gnu, libgcj and libfortran. If we enable it on
1040     # non-Darwin we screw up the behaviour this eclass relies on. We in
1041     # particular need this over --libdir for bug #255315.
1042 grobian 1.452 [[ ${CTARGET} == *-darwin* ]] && \
1043 vapier 1.466 confgcc+=" --enable-version-specific-runtime-libs"
1044 lv 1.1
1045 vapier 1.78 # All our cross-compile logic goes here ! woo !
1046 vapier 1.466 confgcc+=" --host=${CHOST}"
1047 vapier 1.182 if is_crosscompile || tc-is-cross-compiler ; then
1048 lv 1.1 # Straight from the GCC install doc:
1049 swegener 1.174 # "GCC has code to correctly determine the correct value for target
1050 lv 1.1 # for nearly all native systems. Therefore, we highly recommend you
1051     # not provide a configure target when configuring a native compiler."
1052 vapier 1.466 confgcc+=" --target=${CTARGET}"
1053 lv 1.1 fi
1054 vapier 1.466 [[ -n ${CBUILD} ]] && confgcc+=" --build=${CBUILD}"
1055 lv 1.1
1056 vapier 1.33 # ppc altivec support
1057 vapier 1.466 confgcc+=" $(use_enable altivec)"
1058 lv 1.1
1059 kumba 1.364 # gcc has fixed-point arithmetic support in 4.3 for mips targets that can
1060     # significantly increase compile time by several hours. This will allow
1061     # users to control this feature in the event they need the support.
1062 vapier 1.466 tc_version_is_at_least "4.3" && confgcc+=" $(use_enable fixed-point)"
1063 kumba 1.364
1064 dirtyepic 1.445 # Graphite support was added in 4.4, which depends on external libraries
1065 dirtyepic 1.521 # for optimizations. Current versions use cloog-ppl (cloog fork with Parma
1066     # PPL backend). Sometime in the future we will use upstream cloog with the
1067     # ISL backend (note: PPL will still be a requirement). cloog-ppl's include
1068     # path was modified to prevent collisions between the two packages (library
1069     # names are different).
1070     #
1071     # We disable the PPL version check so we can use >=ppl-0.11.
1072 dirtyepic 1.445 if tc_version_is_at_least "4.4"; then
1073 vapier 1.466 confgcc+=" $(use_with graphite ppl)"
1074     confgcc+=" $(use_with graphite cloog)"
1075 dirtyepic 1.445 if use graphite; then
1076 vapier 1.466 confgcc+=" --disable-ppl-version-check"
1077 dirtyepic 1.517 confgcc+=" --with-cloog-include=/usr/include/cloog-ppl"
1078 dirtyepic 1.445 fi
1079     fi
1080 halcy0n 1.424
1081 dirtyepic 1.445 # LTO support was added in 4.5, which depends upon elfutils. This allows
1082     # users to enable that option, and pull in the additional library. In 4.6,
1083     # the dependency is no longer required.
1084 vapier 1.477 if tc_version_is_at_least "4.6" ; then
1085     confgcc+=" --enable-lto"
1086     elif tc_version_is_at_least "4.5" ; then
1087     confgcc+=" $(use_enable lto)"
1088     fi
1089 kumba 1.364
1090 vapier 1.549 case $(tc-is-softfloat) in
1091     yes) confgcc+=" --with-float=soft" ;;
1092     softfp) confgcc+=" --with-float=softfp" ;;
1093     *)
1094     # If they've explicitly opt-ed in, do hardfloat,
1095     # otherwise let the gcc default kick in.
1096     [[ ${CTARGET//_/-} == *-hardfloat-* ]] \
1097     && confgcc+=" --with-float=hard"
1098     ;;
1099     esac
1100 vapier 1.178
1101 lv 1.1 # Native Language Support
1102 vapier 1.355 if use nls ; then
1103 vapier 1.466 confgcc+=" --enable-nls --without-included-gettext"
1104 lv 1.1 else
1105 vapier 1.466 confgcc+=" --disable-nls"
1106 lv 1.1 fi
1107    
1108     # reasonably sane globals (hopefully)
1109 vapier 1.466 confgcc+=" \
1110 lv 1.1 --with-system-zlib \
1111 vapier 1.541 --enable-obsolete \
1112 lv 1.1 --disable-werror \
1113 vapier 1.353 --enable-secureplt"
1114 lv 1.1
1115 vapier 1.470 gcc-compiler-configure || die
1116 lv 1.13
1117 vapier 1.193 if is_crosscompile ; then
1118     # When building a stage1 cross-compiler (just C compiler), we have to
1119     # disable a bunch of features or gcc goes boom
1120     local needed_libc=""
1121     case ${CTARGET} in
1122 flameeyes 1.328 *-linux) needed_libc=no-fucking-clue;;
1123     *-dietlibc) needed_libc=dietlibc;;
1124 vapier 1.441 *-elf|*-eabi) needed_libc=newlib;;
1125 flameeyes 1.328 *-freebsd*) needed_libc=freebsd-lib;;
1126     *-gnu*) needed_libc=glibc;;
1127     *-klibc) needed_libc=klibc;;
1128 vapier 1.559 *-uclibc*)
1129     if ! echo '#include <features.h>' | \
1130     $(tc-getCPP ${CTARGET}) -E -dD - 2>/dev/null | \
1131     grep -q __HAVE_SHARED__
1132     then #291870
1133     confgcc+=" --disable-shared"
1134     fi
1135     needed_libc=uclibc
1136     ;;
1137 vapier 1.540 *-cygwin) needed_libc=cygwin;;
1138     x86_64-*-mingw*|\
1139     *-w64-mingw*) needed_libc=mingw64-runtime;;
1140 vapier 1.324 mingw*|*-mingw*) needed_libc=mingw-runtime;;
1141 vapier 1.466 avr) confgcc+=" --enable-shared --disable-threads";;
1142 vapier 1.193 esac
1143     if [[ -n ${needed_libc} ]] ; then
1144 vapier 1.219 if ! has_version ${CATEGORY}/${needed_libc} ; then
1145 vapier 1.466 confgcc+=" --disable-shared --disable-threads --without-headers"
1146 vapier 1.326 elif built_with_use --hidden --missing false ${CATEGORY}/${needed_libc} crosscompile_opts_headers-only ; then
1147 vapier 1.466 confgcc+=" --disable-shared --with-sysroot=${PREFIX}/${CTARGET}"
1148 eradicator 1.205 else
1149 vapier 1.466 confgcc+=" --with-sysroot=${PREFIX}/${CTARGET}"
1150 vapier 1.193 fi
1151     fi
1152 halcy0n 1.264
1153 vapier 1.487 tc_version_is_at_least 4.2 && confgcc+=" --disable-bootstrap"
1154 vapier 1.365 else
1155 vapier 1.427 if tc-is-static-only ; then
1156 vapier 1.466 confgcc+=" --disable-shared"
1157 vapier 1.427 else
1158 vapier 1.466 confgcc+=" --enable-shared"
1159 vapier 1.427 fi
1160     case ${CHOST} in
1161     mingw*|*-mingw*|*-cygwin)
1162 vapier 1.466 confgcc+=" --enable-threads=win32" ;;
1163 vapier 1.427 *)
1164 vapier 1.466 confgcc+=" --enable-threads=posix" ;;
1165 vapier 1.427 esac
1166 vapier 1.132 fi
1167     # __cxa_atexit is "essential for fully standards-compliant handling of
1168     # destructors", but apparently requires glibc.
1169 vapier 1.441 case ${CTARGET} in
1170     *-uclibc*)
1171 vapier 1.466 confgcc+=" --disable-__cxa_atexit --enable-target-optspace $(use_enable nptl tls)"
1172     [[ ${GCCMAJOR}.${GCCMINOR} == 3.3 ]] && confgcc+=" --enable-sjlj-exceptions"
1173 vapier 1.487 if tc_version_is_at_least 3.4 && ! tc_version_is_at_least 4.3 ; then
1174 vapier 1.466 confgcc+=" --enable-clocale=uclibc"
1175 vapier 1.395 fi
1176 vapier 1.441 ;;
1177     *-elf|*-eabi)
1178 vapier 1.466 confgcc+=" --with-newlib"
1179 vapier 1.441 ;;
1180     *-gnu*)
1181 vapier 1.466 confgcc+=" --enable-__cxa_atexit"
1182     confgcc+=" --enable-clocale=gnu"
1183 vapier 1.441 ;;
1184     *-freebsd*)
1185 vapier 1.466 confgcc+=" --enable-__cxa_atexit"
1186 vapier 1.441 ;;
1187     *-solaris*)
1188 vapier 1.466 confgcc+=" --enable-__cxa_atexit"
1189 vapier 1.441 ;;
1190     esac
1191 vapier 1.487 tc_version_is_at_least 3.4 || confgcc+=" --disable-libunwind-exceptions"
1192 eradicator 1.118
1193 vapier 1.510 # if the target can do biarch (-m32/-m64), enable it. overhead should
1194     # be small, and should simplify building of 64bit kernels in a 32bit
1195     # userland by not needing sys-devel/kgcc64. #349405
1196     case $(tc-arch) in
1197     ppc|ppc64) tc_version_is_at_least 3.4 && confgcc+=" --enable-targets=all" ;;
1198     sparc) tc_version_is_at_least 4.4 && confgcc+=" --enable-targets=all" ;;
1199     amd64|x86) tc_version_is_at_least 4.3 && confgcc+=" --enable-targets=all" ;;
1200     esac
1201 bluebird 1.357
1202 vapier 1.350 tc_version_is_at_least 4.3 && set -- "$@" \
1203 vapier 1.347 --with-bugurl=http://bugs.gentoo.org/ \
1204 vapier 1.350 --with-pkgversion="${BRANDING_GCC_PKGVERSION}"
1205     set -- ${confgcc} "$@" ${EXTRA_ECONF}
1206 vapier 1.347
1207 lv 1.1 # Nothing wrong with a good dose of verbosity
1208     echo
1209 flameeyes 1.322 einfo "PREFIX: ${PREFIX}"
1210     einfo "BINPATH: ${BINPATH}"
1211     einfo "LIBPATH: ${LIBPATH}"
1212     einfo "DATAPATH: ${DATAPATH}"
1213     einfo "STDCXX_INCDIR: ${STDCXX_INCDIR}"
1214 lv 1.1 echo
1215 vapier 1.347 einfo "Configuring GCC with: ${@//--/\n\t--}"
1216 lv 1.1 echo
1217    
1218     # Build in a separate build tree
1219 vapier 1.78 mkdir -p "${WORKDIR}"/build
1220     pushd "${WORKDIR}"/build > /dev/null
1221 lv 1.1
1222     # and now to do the actual configuration
1223 vapier 1.78 addwrite /dev/zero
1224 vapier 1.347 echo "${S}"/configure "$@"
1225     "${S}"/configure "$@" || die "failed to run configure"
1226 lv 1.1
1227     # return to whatever directory we were in before
1228 lv 1.13 popd > /dev/null
1229 lv 1.1 }
1230    
1231 vapier 1.511 has toolchain_death_notice ${EBUILD_DEATH_HOOKS} || EBUILD_DEATH_HOOKS+=" toolchain_death_notice"
1232     toolchain_death_notice() {
1233     pushd "${WORKDIR}"/build >/dev/null
1234     tar jcf gcc-build-logs.tar.bz2 $(find -name config.log)
1235     eerror
1236     eerror "Please include ${PWD}/gcc-build-logs.tar.bz2 in your bug report"
1237     eerror
1238     popd >/dev/null
1239     }
1240    
1241 lv 1.1 # This function accepts one optional argument, the make target to be used.
1242     # If ommitted, gcc_do_make will try to guess whether it should use all,
1243 vapier 1.33 # profiledbootstrap, or bootstrap-lean depending on CTARGET and arch. An
1244 lv 1.1 # example of how to use this function:
1245     #
1246     # gcc_do_make all-target-libstdc++-v3
1247     #
1248     # In addition to the target to be used, the following variables alter the
1249     # behavior of this function:
1250     #
1251     # LDFLAGS
1252     # Flags to pass to ld
1253     #
1254     # STAGE1_CFLAGS
1255     # CFLAGS to use during stage1 of a gcc bootstrap
1256     #
1257     # BOOT_CFLAGS
1258     # CFLAGS to use during stages 2+3 of a gcc bootstrap.
1259     #
1260 lv 1.2 # Travis Tilley <lv@gentoo.org> (04 Sep 2004)
1261 lv 1.1 #
1262     gcc_do_make() {
1263     # Fix for libtool-portage.patch
1264 vapier 1.78 local OLDS=${S}
1265     S=${WORKDIR}/build
1266 lv 1.1
1267     # Set make target to $1 if passed
1268 vapier 1.234 [[ -n $1 ]] && GCC_MAKE_TARGET=$1
1269 lv 1.1 # default target
1270 vapier 1.182 if is_crosscompile || tc-is-cross-compiler ; then
1271 lv 1.1 # 3 stage bootstrapping doesnt quite work when you cant run the
1272     # resulting binaries natively ^^;
1273 eradicator 1.118 GCC_MAKE_TARGET=${GCC_MAKE_TARGET-all}
1274 lv 1.1 else
1275 eradicator 1.118 GCC_MAKE_TARGET=${GCC_MAKE_TARGET-bootstrap-lean}
1276 lv 1.1 fi
1277    
1278     # the gcc docs state that parallel make isnt supported for the
1279     # profiledbootstrap target, as collisions in profile collecting may occur.
1280 vapier 1.512 # boundschecking also seems to introduce parallel build issues.
1281     if [[ ${GCC_MAKE_TARGET} == "profiledbootstrap" ]] ||
1282     use_if_iuse boundschecking
1283     then
1284     export MAKEOPTS="${MAKEOPTS} -j1"
1285     fi
1286 vapier 1.150
1287 eradicator 1.122 if [[ ${GCC_MAKE_TARGET} == "all" ]] ; then
1288     STAGE1_CFLAGS=${STAGE1_CFLAGS-"${CFLAGS}"}
1289 kevquinn 1.255 elif [[ $(gcc-version) == "3.4" && ${GCC_BRANCH_VER} == "3.4" ]] && gcc-specs-ssp ; then
1290 eradicator 1.195 # See bug #79852
1291     STAGE1_CFLAGS=${STAGE1_CFLAGS-"-O2"}
1292 eradicator 1.122 fi
1293    
1294     if is_crosscompile; then
1295     # In 3.4, BOOT_CFLAGS is never used on a crosscompile...
1296     # but I'll leave this in anyways as someone might have had
1297     # some reason for putting it in here... --eradicator
1298     BOOT_CFLAGS=${BOOT_CFLAGS-"-O2"}
1299     else
1300     # we only want to use the system's CFLAGS if not building a
1301     # cross-compiler.
1302 vapier 1.546 BOOT_CFLAGS=${BOOT_CFLAGS-"$(get_abi_CFLAGS ${TARGET_DEFAULT_ABI}) ${CFLAGS}"}
1303 eradicator 1.122 fi
1304    
1305 vapier 1.249 pushd "${WORKDIR}"/build
1306 lv 1.1
1307 vapier 1.139 emake \
1308 vapier 1.78 LDFLAGS="${LDFLAGS}" \
1309     STAGE1_CFLAGS="${STAGE1_CFLAGS}" \
1310     LIBPATH="${LIBPATH}" \
1311     BOOT_CFLAGS="${BOOT_CFLAGS}" \
1312     ${GCC_MAKE_TARGET} \
1313 vapier 1.139 || die "emake failed with ${GCC_MAKE_TARGET}"
1314 vapier 1.189
1315 vapier 1.479 if ! is_crosscompile && use cxx && use doc ; then
1316 vapier 1.214 if type -p doxygen > /dev/null ; then
1317 vapier 1.361 if tc_version_is_at_least 4.3 ; then
1318     cd "${CTARGET}"/libstdc++-v3/doc
1319     emake doc-man-doxygen || ewarn "failed to make docs"
1320     elif tc_version_is_at_least 3.0 ; then
1321     cd "${CTARGET}"/libstdc++-v3
1322     emake doxygen-man || ewarn "failed to make docs"
1323     fi
1324 vapier 1.214 else
1325     ewarn "Skipping libstdc++ manpage generation since you don't have doxygen installed"
1326 vapier 1.189 fi
1327     fi
1328    
1329 lv 1.1 popd
1330     }
1331    
1332 lv 1.13 # This is mostly a stub function to be overwritten in an ebuild
1333     gcc_do_filter_flags() {
1334     strip-flags
1335    
1336     # In general gcc does not like optimization, and add -O2 where
1337     # it is safe. This is especially true for gcc 3.3 + 3.4
1338     replace-flags -O? -O2
1339    
1340 vapier 1.158 # ... sure, why not?
1341 lv 1.13 strip-unsupported-flags
1342 eradicator 1.72
1343 vapier 1.79 # dont want to funk ourselves
1344 vapier 1.209 filter-flags '-mabi*' -m31 -m32 -m64
1345 vapier 1.78
1346 eradicator 1.104 case ${GCC_BRANCH_VER} in
1347 vapier 1.158 3.2|3.3)
1348 vapier 1.392 replace-cpu-flags k8 athlon64 opteron i686 x86-64
1349 vapier 1.391 replace-cpu-flags pentium-m pentium3m pentium3
1350 eradicator 1.122 case $(tc-arch) in
1351 vapier 1.392 amd64|x86) filter-flags '-mtune=*' ;;
1352     # in gcc 3.3 there is a bug on ppc64 where if -mcpu is used,
1353     # the compiler wrongly assumes a 32bit target
1354     ppc64) filter-flags "-mcpu=*";;
1355 eradicator 1.122 esac
1356 vapier 1.392 case $(tc-arch) in
1357     amd64) replace-cpu-flags core2 nocona;;
1358     x86) replace-cpu-flags core2 prescott;;
1359     esac
1360    
1361     replace-cpu-flags G3 750
1362     replace-cpu-flags G4 7400
1363     replace-cpu-flags G5 7400
1364    
1365     # XXX: should add a sed or something to query all supported flags
1366     # from the gcc source and trim everything else ...
1367     filter-flags -f{no-,}unit-at-a-time -f{no-,}web -mno-tls-direct-seg-refs
1368     filter-flags -f{no-,}stack-protector{,-all}
1369     filter-flags -fvisibility-inlines-hidden -fvisibility=hidden
1370 vapier 1.158 ;;
1371 eradicator 1.122 3.4|4.*)
1372     case $(tc-arch) in
1373     x86|amd64) filter-flags '-mcpu=*';;
1374 grobian 1.396 *-macos)
1375     # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25127
1376     [[ ${GCC_BRANCH_VER} == 4.0 || ${GCC_BRANCH_VER} == 4.1 ]] && \
1377     filter-flags '-mcpu=*' '-march=*' '-mtune=*'
1378     ;;
1379 eradicator 1.122 esac
1380 vapier 1.158 ;;
1381 eradicator 1.104 esac
1382 vapier 1.79
1383 eradicator 1.96 # Compile problems with these (bug #6641 among others)...
1384     #filter-flags "-fno-exceptions -fomit-frame-pointer -fforce-addr"
1385    
1386 eradicator 1.122 # CFLAGS logic (verified with 3.4.3):
1387     # CFLAGS:
1388 flameeyes 1.322 # 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 eradicator 1.122 #
1395     # CXXFLAGS:
1396 flameeyes 1.322 # used by xgcc when creating libstdc++
1397 eradicator 1.122 #
1398     # STAGE1_CFLAGS (not used in creating a crosscompile gcc):
1399 flameeyes 1.322 # used by ${CHOST}-gcc for building stage1 compiler
1400 eradicator 1.122 #
1401     # BOOT_CFLAGS (not used in creating a crosscompile gcc):
1402 flameeyes 1.322 # used by xgcc for building stage2/3 compiler
1403 eradicator 1.122
1404 vapier 1.158 if is_crosscompile ; then
1405 eradicator 1.123 # Set this to something sane for both native and target
1406 eradicator 1.122 CFLAGS="-O2 -pipe"
1407 vapier 1.554 FFLAGS=${CFLAGS}
1408     FCFLAGS=${CFLAGS}
1409 eradicator 1.122
1410     local VAR="CFLAGS_"${CTARGET//-/_}
1411     CXXFLAGS=${!VAR}
1412     fi
1413    
1414 eradicator 1.99 export GCJFLAGS=${GCJFLAGS:-${CFLAGS}}
1415 lv 1.13 }
1416    
1417 vapier 1.469 toolchain_src_compile() {
1418 lv 1.13 gcc_do_filter_flags
1419     einfo "CFLAGS=\"${CFLAGS}\""
1420     einfo "CXXFLAGS=\"${CXXFLAGS}\""
1421    
1422 vapier 1.471 # Force internal zip based jar script to avoid random
1423     # issues with 3rd party jar implementations. #384291
1424     export JAR=no
1425    
1426 vapier 1.433 # For hardened gcc 4.3 piepatchset to build the hardened specs
1427 zorry 1.428 # file (build.specs) to use when building gcc.
1428     if ! tc_version_is_at_least 4.4 && want_minispecs ; then
1429     setup_minispecs_gcc_build_specs
1430     fi
1431 lv 1.13 # Build in a separate build tree
1432 vapier 1.249 mkdir -p "${WORKDIR}"/build
1433     pushd "${WORKDIR}"/build > /dev/null
1434 lv 1.13
1435 vapier 1.31 einfo "Configuring ${PN} ..."
1436 lv 1.13 gcc_do_configure
1437    
1438 vapier 1.296 touch "${S}"/gcc/c-gperf.h
1439 lv 1.13
1440     # Do not make manpages if we do not have perl ...
1441 vapier 1.78 [[ ! -x /usr/bin/perl ]] \
1442     && find "${WORKDIR}"/build -name '*.[17]' | xargs touch
1443 lv 1.13
1444 vapier 1.31 einfo "Compiling ${PN} ..."
1445 lv 1.13 gcc_do_make ${GCC_MAKE_TARGET}
1446    
1447     popd > /dev/null
1448     }
1449    
1450 vapier 1.469 toolchain_src_test() {
1451 vapier 1.180 cd "${WORKDIR}"/build
1452 dirtyepic 1.459 emake -k check || ewarn "check failed and that sucks :("
1453 vapier 1.91 }
1454    
1455 vapier 1.469 toolchain_src_install() {
1456 eradicator 1.72 local x=
1457    
1458 vapier 1.388 cd "${WORKDIR}"/build
1459     # Do allow symlinks in private gcc include dir as this can break the build
1460 dirtyepic 1.421 find gcc/include*/ -type l -print0 | xargs -0 rm -f
1461 eradicator 1.72 # Remove generated headers, as they can cause things to break
1462     # (ncurses, openssl, etc).
1463 vapier 1.388 for x in $(find gcc/include*/ -name '*.h') ; do
1464 vapier 1.78 grep -q 'It has been auto-edited by fixincludes from' "${x}" \
1465     && rm -f "${x}"
1466 eradicator 1.72 done
1467     # Do the 'make install' from the build directory
1468 vapier 1.78 S=${WORKDIR}/build \
1469 vapier 1.389 emake -j1 DESTDIR="${D}" install || die
1470 vapier 1.183 # Punt some tools which are really only useful while building gcc
1471 vapier 1.383 find "${D}" -name install-tools -prune -type d -exec rm -rf "{}" \;
1472 vapier 1.226 # This one comes with binutils
1473 vapier 1.320 find "${D}" -name libiberty.a -exec rm -f "{}" \;
1474 vapier 1.226
1475     # Move the libraries to the proper location
1476     gcc_movelibs
1477    
1478 vapier 1.221 # Basic sanity check
1479 vapier 1.314 if ! is_crosscompile ; then
1480     local EXEEXT
1481     eval $(grep ^EXEEXT= "${WORKDIR}"/build/gcc/config.log)
1482     [[ -r ${D}${BINPATH}/gcc${EXEEXT} ]] || die "gcc not found in ${D}"
1483     fi
1484 eradicator 1.72
1485     dodir /etc/env.d/gcc
1486     create_gcc_env_entry
1487    
1488 solar 1.369 # Setup the gcc_env_entry for hardened gcc 4 with minispecs
1489     if want_minispecs ; then
1490 zorry 1.428 copy_minispecs_gcc_specs
1491 solar 1.369 fi
1492 eradicator 1.72 # Make sure we dont have stuff lying around that
1493     # can nuke multiple versions of gcc
1494    
1495 vapier 1.382 gcc_slot_java
1496 vapier 1.355
1497     # These should be symlinks
1498     dodir /usr/bin
1499     cd "${D}"${BINPATH}
1500 vapier 1.530 # Ugh: we really need to auto-detect this list.
1501     # It's constantly out of date.
1502     for x in cpp gcc g++ c++ gcov g77 gcj gcjh gfortran gccgo ; do
1503 vapier 1.355 # For some reason, g77 gets made instead of ${CTARGET}-g77...
1504     # this should take care of that
1505     [[ -f ${x} ]] && mv ${x} ${CTARGET}-${x}
1506    
1507 vapier 1.519 if [[ -f ${CTARGET}-${x} ]] ; then
1508 vapier 1.524 if ! is_crosscompile ; then
1509     ln -sf ${CTARGET}-${x} ${x}
1510     dosym ${BINPATH}/${CTARGET}-${x} \
1511     /usr/bin/${x}-${GCC_CONFIG_VER}
1512     fi
1513 vapier 1.355
1514     # Create version-ed symlinks
1515     dosym ${BINPATH}/${CTARGET}-${x} \
1516     /usr/bin/${CTARGET}-${x}-${GCC_CONFIG_VER}
1517     fi
1518    
1519     if [[ -f ${CTARGET}-${x}-${GCC_CONFIG_VER} ]] ; then
1520     rm -f ${CTARGET}-${x}-${GCC_CONFIG_VER}
1521     ln -sf ${CTARGET}-${x} ${CTARGET}-${x}-${GCC_CONFIG_VER}
1522     fi
1523     done
1524 eradicator 1.72
1525 vapier 1.277 # Now do the fun stripping stuff
1526 vapier 1.320 env RESTRICT="" CHOST=${CHOST} prepstrip "${D}${BINPATH}"
1527 vapier 1.277 env RESTRICT="" CHOST=${CTARGET} prepstrip "${D}${LIBPATH}"
1528 vapier 1.320 # gcc used to install helper binaries in lib/ but then moved to libexec/
1529     [[ -d ${D}${PREFIX}/libexec/gcc ]] && \
1530     env RESTRICT="" CHOST=${CHOST} prepstrip "${D}${PREFIX}/libexec/gcc/${CTARGET}/${GCC_CONFIG_VER}"
1531 vapier 1.277
1532 vapier 1.183 cd "${S}"
1533 vapier 1.355 if is_crosscompile; then
1534 vapier 1.115 rm -rf "${D}"/usr/share/{man,info}
1535     rm -rf "${D}"${DATAPATH}/{man,info}
1536 eradicator 1.104 else
1537 vapier 1.484 local cxx_mandir=$(find "${WORKDIR}/build/${CTARGET}/libstdc++-v3" -name man)
1538 vapier 1.222 if [[ -d ${cxx_mandir} ]] ; then
1539     # clean bogus manpages #113902
1540     find "${cxx_mandir}" -name '*_build_*' -exec rm {} \;
1541     cp -r "${cxx_mandir}"/man? "${D}/${DATAPATH}"/man/
1542 vapier 1.189 fi
1543 vapier 1.231 has noinfo ${FEATURES} \
1544 vapier 1.232 && rm -r "${D}/${DATAPATH}"/info \
1545 vapier 1.231 || prepinfo "${DATAPATH}"
1546     has noman ${FEATURES} \
1547 vapier 1.236 && rm -r "${D}/${DATAPATH}"/man \
1548 vapier 1.231 || prepman "${DATAPATH}"
1549 eradicator 1.72 fi
1550 vapier 1.305 # prune empty dirs left behind
1551 vapier 1.507 find "${D}" -depth -type d -delete 2>/dev/null
1552 eradicator 1.72
1553 dirtyepic 1.348 # install testsuite results
1554     if use test; then
1555     docinto testsuite
1556     find "${WORKDIR}"/build -type f -name "*.sum" -print0 | xargs -0 dodoc
1557     find "${WORKDIR}"/build -type f -path "*/testsuite/*.log" -print0 \
1558     | xargs -0 dodoc
1559     fi
1560    
1561 eradicator 1.72 # Rather install the script, else portage with changing $FILESDIR
1562     # between binary and source package borks things ....
1563 vapier 1.259 if ! is_crosscompile ; then
1564 vapier 1.289 insinto "${DATAPATH}"
1565 vapier 1.279 if tc_version_is_at_least 4.0 ; then
1566 vapier 1.280 newins "${GCC_FILESDIR}"/awk/fixlafiles.awk-no_gcc_la fixlafiles.awk || die
1567 vapier 1.279 find "${D}/${LIBPATH}" -name libstdc++.la -type f -exec rm "{}" \;
1568     else
1569     doins "${GCC_FILESDIR}"/awk/fixlafiles.awk || die
1570     fi
1571 vapier 1.289 exeinto "${DATAPATH}"
1572 vapier 1.259 doexe "${GCC_FILESDIR}"/fix_libtool_files.sh || die
1573 vapier 1.294 doexe "${GCC_FILESDIR}"/c{89,99} || die
1574 eradicator 1.72 fi
1575    
1576 vapier 1.505 # Use gid of 0 because some stupid ports don't have
1577     # the group 'root' set to gid 0. Send to /dev/null
1578     # for people who are testing as non-root.
1579     chown -R root:0 "${D}"${LIBPATH} 2>/dev/null
1580 eradicator 1.196
1581 halcy0n 1.424 # Move pretty-printers to gdb datadir to shut ldconfig up
1582 vapier 1.483 local py gdbdir=/usr/share/gdb/auto-load${LIBPATH/\/lib\//\/$(get_libdir)\/}
1583     pushd "${D}"${LIBPATH} >/dev/null
1584     for py in $(find . -name '*-gdb.py') ; do
1585     local multidir=${py%/*}
1586     insinto "${gdbdir}/${multidir}"
1587     sed -i "/^libdir =/s:=.*:= '${LIBPATH}/${multidir}':" "${py}" || die #348128
1588     doins "${py}" || die
1589     rm "${py}" || die
1590 halcy0n 1.424 done
1591 vapier 1.483 popd >/dev/null
1592 dirtyepic 1.449
1593     # Don't scan .gox files for executable stacks - false positives
1594     export QA_EXECSTACK="usr/lib*/go/*/*.gox"
1595     export QA_WX_LOAD="usr/lib*/go/*/*.gox"
1596 zorry 1.516
1597     # Disable RANDMMAP so PCH works. #301299
1598     if tc_version_is_at_least 4.3 ; then
1599     pax-mark -r "${D}${PREFIX}/libexec/gcc/${CTARGET}/${GCC_CONFIG_VER}/cc1"
1600     pax-mark -r "${D}${PREFIX}/libexec/gcc/${CTARGET}/${GCC_CONFIG_VER}/cc1plus"
1601     fi
1602 eradicator 1.72 }
1603    
1604 vapier 1.382 gcc_slot_java() {
1605     local x
1606    
1607     # Move Java headers to compiler-specific dir
1608     for x in "${D}"${PREFIX}/include/gc*.h "${D}"${PREFIX}/include/j*.h ; do
1609     [[ -f ${x} ]] && mv -f "${x}" "${D}"${LIBPATH}/include/
1610     done
1611     for x in gcj gnu java javax org ; do
1612     if [[ -d ${D}${PREFIX}/include/${x} ]] ; then
1613     dodir /${LIBPATH}/include/${x}
1614     mv -f "${D}"${PREFIX}/include/${x}/* "${D}"${LIBPATH}/include/${x}/
1615     rm -rf "${D}"${PREFIX}/include/${x}
1616     fi
1617     done
1618    
1619     if [[ -d ${D}${PREFIX}/lib/security ]] || [[ -d ${D}${PREFIX}/$(get_libdir)/security ]] ; then
1620     dodir /${LIBPATH}/security
1621     mv -f "${D}"${PREFIX}/lib*/security/* "${D}"${LIBPATH}/security
1622     rm -rf "${D}"${PREFIX}/lib*/security
1623     fi
1624    
1625 vapier 1.491 # Move random gcj files to compiler-specific directories
1626     for x in libgcj.spec logging.properties ; do
1627     x="${D}${PREFIX}/lib/${x}"
1628     [[ -f ${x} ]] && mv -f "${x}" "${D}"${LIBPATH}/
1629     done
1630    
1631 vapier 1.382 # Rename jar because it could clash with Kaffe's jar if this gcc is
1632     # primary compiler (aka don't have the -<version> extension)
1633     cd "${D}"${BINPATH}
1634     [[ -f jar ]] && mv -f jar gcj-jar
1635     }
1636    
1637 vapier 1.220 # Move around the libs to the right location. For some reason,
1638     # when installing gcc, it dumps internal libraries into /usr/lib
1639     # instead of the private gcc lib path
1640 eradicator 1.72 gcc_movelibs() {
1641 vapier 1.320 # older versions of gcc did not support --print-multi-os-directory
1642     tc_version_is_at_least 3.0 || return 0
1643    
1644 vapier 1.555 local x multiarg removedirs=""
1645 vapier 1.256 for multiarg in $($(XGCC) -print-multi-lib) ; do
1646 eradicator 1.104 multiarg=${multiarg#*;}
1647 vapier 1.228 multiarg=${multiarg//@/ -}
1648 eradicator 1.104
1649 vapier 1.256 local OS_MULTIDIR=$($(XGCC) ${multiarg} --print-multi-os-directory)
1650     local MULTIDIR=$($(XGCC) ${multiarg} --print-multi-directory)
1651 vapier 1.142 local TODIR=${D}${LIBPATH}/${MULTIDIR}
1652 eradicator 1.104 local FROMDIR=
1653    
1654 vapier 1.119 [[ -d ${TODIR} ]] || mkdir -p ${TODIR}
1655 eradicator 1.104
1656 vapier 1.226 for FROMDIR in \
1657     ${LIBPATH}/${OS_MULTIDIR} \
1658     ${LIBPATH}/../${MULTIDIR} \
1659     ${PREFIX}/lib/${OS_MULTIDIR} \
1660 mattst88 1.464 ${PREFIX}/${CTARGET}/lib/${OS_MULTIDIR}
1661 vapier 1.226 do
1662 vapier 1.260 removedirs="${removedirs} ${FROMDIR}"
1663 vapier 1.226 FROMDIR=${D}${FROMDIR}
1664     if [[ ${FROMDIR} != "${TODIR}" && -d ${FROMDIR} ]] ; then
1665     local files=$(find "${FROMDIR}" -maxdepth 1 ! -type d 2>/dev/null)
1666     if [[ -n ${files} ]] ; then
1667     mv ${files} "${TODIR}"
1668     fi
1669     fi
1670     done
1671 vapier 1.407 fix_libtool_libdir_paths "${LIBPATH}/${MULTIDIR}"
1672 vapier 1.555
1673     # SLOT up libgcj.pc if it's available (and let gcc-config worry about links)
1674     FROMDIR="${PREFIX}/lib/${OS_MULTIDIR}"
1675     for x in "${D}${FROMDIR}"/pkgconfig/libgcj*.pc ; do
1676     [[ -f ${x} ]] || continue
1677     sed -i "/^libdir=/s:=.*:=${LIBPATH}/${MULTIDIR}:" "${x}"
1678     mv "${x}" "${D}${FROMDIR}"/pkgconfig/libgcj-${GCC_PV}.pc || die
1679     done
1680 eradicator 1.104 done
1681 eradicator 1.72
1682 vapier 1.260 # We remove directories separately to avoid this case:
1683 flameeyes 1.322 # mv SRC/lib/../lib/*.o DEST
1684     # rmdir SRC/lib/../lib/
1685     # mv SRC/lib/../lib32/*.o DEST # Bork
1686 vapier 1.260 for FROMDIR in ${removedirs} ; do
1687     rmdir "${D}"${FROMDIR} >& /dev/null
1688     done
1689     find "${D}" -type d | xargs rmdir >& /dev/null
1690 eradicator 1.72 }
1691    
1692     #----<< src_* >>----
1693    
1694 lv 1.95 #---->> unorganized crap in need of refactoring follows
1695 eradicator 1.72
1696     # gcc_quick_unpack will unpack the gcc tarball and patches in a way that is
1697     # consistant with the behavior of get_gcc_src_uri. The only patch it applies
1698     # itself is the branch update if present.
1699     #
1700     # Travis Tilley <lv@gentoo.org> (03 Sep 2004)
1701     #
1702     gcc_quick_unpack() {
1703 vapier 1.249 pushd "${WORKDIR}" > /dev/null
1704 vapier 1.112 export PATCH_GCC_VER=${PATCH_GCC_VER:-${GCC_RELEASE_VER}}
1705 vapier 1.173 export UCLIBC_GCC_VER=${UCLIBC_GCC_VER:-${PATCH_GCC_VER}}
1706 vapier 1.150 export PIE_GCC_VER=${PIE_GCC_VER:-${GCC_RELEASE_VER}}
1707 vapier 1.113 export HTB_GCC_VER=${HTB_GCC_VER:-${GCC_RELEASE_VER}}
1708 solar 1.369 export SPECS_GCC_VER=${SPECS_GCC_VER:-${GCC_RELEASE_VER}}
1709 eradicator 1.72
1710 vapier 1.156 if [[ -n ${GCC_A_FAKEIT} ]] ; then
1711 vapier 1.237 unpack ${GCC_A_FAKEIT}
1712 vapier 1.156 elif [[ -n ${PRERELEASE} ]] ; then
1713 eradicator 1.72 unpack gcc-${PRERELEASE}.tar.bz2
1714 vapier 1.112 elif [[ -n ${SNAPSHOT} ]] ; then
1715 eradicator 1.72 unpack gcc-${SNAPSHOT}.tar.bz2
1716 vapier 1.523 elif [[ ${PV} != *9999* ]] ; then
1717 eradicator 1.73 unpack gcc-${GCC_RELEASE_VER}.tar.bz2
1718 eradicator 1.72 # We want branch updates to be against a release tarball
1719 vapier 1.112 if [[ -n ${BRANCH_UPDATE} ]] ; then
1720 vapier 1.327 pushd "${S}" > /dev/null
1721 maekke 1.390 epatch "${DISTDIR}"/gcc-${GCC_RELEASE_VER}-branch-update-${BRANCH_UPDATE}.patch.bz2
1722 eradicator 1.72 popd > /dev/null
1723     fi
1724     fi
1725    
1726 vapier 1.331 if [[ -n ${D_VER} ]] && use d ; then
1727 vapier 1.327 pushd "${S}"/gcc > /dev/null
1728     unpack gdc-${D_VER}-src.tar.bz2
1729     cd ..
1730 vapier 1.331 ebegin "Adding support for the D language"
1731     ./gcc/d/setup-gcc.sh >& "${T}"/dgcc.log
1732     if ! eend $? ; then
1733     eerror "The D gcc package failed to apply"
1734     eerror "Please include this log file when posting a bug report:"
1735     eerror " ${T}/dgcc.log"
1736     die "failed to include the D language"
1737 vapier 1.327 fi
1738     popd > /dev/null
1739     fi
1740    
1741 vapier 1.112 [[ -n ${PATCH_VER} ]] && \
1742 vapier 1.210 unpack gcc-${PATCH_GCC_VER}-patches-${PATCH_VER}.tar.bz2
1743 vapier 1.112
1744     [[ -n ${UCLIBC_VER} ]] && \
1745 vapier 1.210 unpack gcc-${UCLIBC_GCC_VER}-uclibc-patches-${UCLIBC_VER}.tar.bz2
1746 eradicator 1.72
1747 vapier 1.157 if want_pie ; then
1748 vapier 1.147 if [[ -n ${PIE_CORE} ]] ; then
1749     unpack ${PIE_CORE}
1750     else
1751 vapier 1.210 unpack gcc-${PIE_GCC_VER}-piepatches-v${PIE_VER}.tar.bz2
1752 vapier 1.147 fi
1753 solar 1.369 [[ -n ${SPECS_VER} ]] && \
1754 gengor 1.373 unpack gcc-${SPECS_GCC_VER}-specs-${SPECS_VER}.tar.bz2
1755 vapier 1.147 fi
1756 eradicator 1.72
1757 vapier 1.512 use_if_iuse boundschecking && unpack "bounds-checking-gcc-${HTB_GCC_VER}-${HTB_VER}.patch.bz2"
1758 eradicator 1.72
1759     popd > /dev/null
1760     }
1761    
1762 vapier 1.233 do_gcc_HTB_patches() {
1763 vapier 1.512 use_if_iuse boundschecking || return 0
1764 vapier 1.154
1765 eradicator 1.72 # modify the bounds checking patch with a regression patch
1766 vapier 1.210 epatch "${WORKDIR}/bounds-checking-gcc-${HTB_GCC_VER}-${HTB_VER}.patch"
1767 vapier 1.347 BRANDING_GCC_PKGVERSION="${BRANDING_GCC_PKGVERSION}, HTB-${HTB_GCC_VER}-${HTB_VER}"
1768 eradicator 1.72 }
1769    
1770     # do various updates to PIE logic
1771     do_gcc_PIE_patches() {
1772 vapier 1.488 want_pie || return 0
1773 vapier 1.153
1774 halcy0n 1.403 use vanilla && return 0
1775 vapier 1.242
1776 solar 1.368 if tc_version_is_at_least 4.3.2; then
1777     guess_patch_type_in_dir "${WORKDIR}"/piepatch/
1778     EPATCH_MULTI_MSG="Applying pie patches ..." \
1779     epatch "${WORKDIR}"/piepatch/
1780     else
1781     guess_patch_type_in_dir "${WORKDIR}"/piepatch/upstream
1782    
1783     # corrects startfile/endfile selection and shared/static/pie flag usage
1784     EPATCH_MULTI_MSG="Applying upstream pie patches ..." \
1785     epatch "${WORKDIR}"/piepatch/upstream
1786     # adds non-default pie support (rs6000)
1787     EPATCH_MULTI_MSG="Applying non-default pie patches ..." \
1788     epatch "${WORKDIR}"/piepatch/nondef
1789     # adds default pie support (rs6000 too) if DEFAULT_PIE[_SSP] is defined
1790     EPATCH_MULTI_MSG="Applying default pie patches ..." \
1791     epatch "${WORKDIR}"/piepatch/def
1792 zorry 1.428 fi
1793 zorry 1.515
1794     # we want to be able to control the pie patch logic via something other
1795     # than ALL_CFLAGS...
1796     sed -e '/^ALL_CFLAGS/iHARD_CFLAGS = ' \
1797     -e 's|^ALL_CFLAGS = |ALL_CFLAGS = $(HARD_CFLAGS) |' \
1798     -i "${S}"/gcc/Makefile.in
1799     # Need to add HARD_CFLAGS to ALL_CXXFLAGS on >= 4.7
1800     if tc_version_is_at_least 4.7.0 ; then
1801     sed -e '/^ALL_CXXFLAGS/iHARD_CFLAGS = ' \
1802     -e 's|^ALL_CXXFLAGS = |ALL_CXXFLAGS = $(HARD_CFLAGS) |' \
1803     -i "${S}"/gcc/Makefile.in
1804     fi
1805 eradicator 1.72
1806 vapier 1.347 BRANDING_GCC_PKGVERSION="${BRANDING_GCC_PKGVERSION}, pie-${PIE_VER}"
1807 eradicator 1.72 }
1808    
1809     should_we_gcc_config() {
1810     # we always want to run gcc-config if we're bootstrapping, otherwise
1811     # we might get stuck with the c-only stage1 compiler
1812 vapier 1.536 use_if_iuse bootstrap && return 0
1813 eradicator 1.72 use build && return 0
1814    
1815 vapier 1.86 # if the current config is invalid, we definitely want a new one
1816 vapier 1.253 # Note: due to bash quirkiness, the following must not be 1 line
1817     local curr_config
1818 vapier 1.333 curr_config=$(env -i ROOT="${ROOT}" gcc-config -c ${CTARGET} 2>&1) || return 0
1819 eradicator 1.72
1820 swegener 1.174 # if the previously selected config has the same major.minor (branch) as
1821 vapier 1.87 # the version we are installing, then it will probably be uninstalled
1822     # for being in the same SLOT, make sure we run gcc-config.
1823 vapier 1.333 local curr_config_ver=$(env -i ROOT="${ROOT}" gcc-config -S ${curr_config} | awk '{print $2}')
1824 eradicator 1.196
1825 vapier 1.87 local curr_branch_ver=$(get_version_component_range 1-2 ${curr_config_ver})
1826 eradicator 1.93
1827     # If we're using multislot, just run gcc-config if we're installing
1828     # to the same profile as the current one.
1829     use multislot && return $([[ ${curr_config_ver} == ${GCC_CONFIG_VER} ]])
1830    
1831 vapier 1.87 if [[ ${curr_branch_ver} == ${GCC_BRANCH_VER} ]] ; then
1832     return 0
1833 eradicator 1.72 else
1834 vapier 1.87 # if we're installing a genuinely different compiler version,
1835     # we should probably tell the user -how- to switch to the new
1836 swegener 1.174 # gcc version, since we're not going to do it for him/her.
1837     # We don't want to switch from say gcc-3.3 to gcc-3.4 right in
1838     # the middle of an emerge operation (like an 'emerge -e world'
1839 vapier 1.87 # which could install multiple gcc versions).
1840     einfo "The current gcc config appears valid, so it will not be"
1841 flameeyes 1.322 einfo "automatically switched for you. If you would like to"
1842 vapier 1.87 einfo "switch to the newly installed gcc version, do the"
1843     einfo "following:"
1844     echo
1845 eradicator 1.251 einfo "gcc-config ${CTARGET}-${GCC_CONFIG_VER}"
1846 vapier 1.87 einfo "source /etc/profile"
1847     echo
1848     ebeep
1849     return 1
1850 eradicator 1.72 fi
1851     }
1852    
1853     do_gcc_config() {
1854 azarah 1.179 if ! should_we_gcc_config ; then
1855 vapier 1.333 env -i ROOT="${ROOT}" gcc-config --use-old --force
1856 eradicator 1.251 return 0
1857     fi
1858    
1859     local current_gcc_config="" current_specs="" use_specs=""
1860    
1861 vapier 1.414 current_gcc_config=$(env -i ROOT="${ROOT}" gcc-config -c ${CTARGET} 2>/dev/null)
1862 eradicator 1.251 if [[ -n ${current_gcc_config} ]] ; then
1863     # figure out which specs-specific config is active
1864     current_specs=$(gcc-config -S ${current_gcc_config} | awk '{print $3}')
1865     [[ -n ${current_specs} ]] && use_specs=-${current_specs}
1866     fi
1867     if [[ -n ${use_specs} ]] && \
1868     [[ ! -e ${ROOT}/etc/env.d/gcc/${CTARGET}-${GCC_CONFIG_VER}${use_specs} ]]
1869     then
1870     ewarn "The currently selected specs-specific gcc config,"
1871     ewarn "${current_specs}, doesn't exist anymore. This is usually"
1872     ewarn "due to enabling/disabling hardened or switching to a version"
1873     ewarn "of gcc that doesnt create multiple specs files. The default"
1874     ewarn "config will be used, and the previous preference forgotten."
1875     ebeep
1876     epause
1877     use_specs=""
1878     fi
1879    
1880 vapier 1.283 gcc-config ${CTARGET}-${GCC_CONFIG_VER}${use_specs}
1881 eradicator 1.251 }
1882    
1883 eradicator 1.72 # This function allows us to gentoo-ize gcc's version number and bugzilla
1884     # URL without needing to use patches.
1885     gcc_version_patch() {
1886 vapier 1.347 # gcc-4.3+ has configure flags (whoo!)
1887     tc_version_is_at_least 4.3 && return 0
1888    
1889     local version_string=${GCC_CONFIG_VER}
1890 vapier 1.513 [[ -n ${BRANCH_UPDATE} ]] && version_string+=" ${BRANCH_UPDATE}"
1891 vapier 1.347
1892     einfo "patching gcc version: ${version_string} (${BRANDING_GCC_PKGVERSION})"
1893 eradicator 1.72
1894 vapier 1.513 local gcc_sed=( -e 's:gcc\.gnu\.org/bugs\.html:bugs\.gentoo\.org/:' )
1895 halcy0n 1.246 if grep -qs VERSUFFIX "${S}"/gcc/version.c ; then
1896 vapier 1.513 gcc_sed+=( -e "/VERSUFFIX \"\"/s:\"\":\" (${BRANDING_GCC_PKGVERSION})\":" )
1897 halcy0n 1.246 else
1898 vapier 1.347 version_string="${version_string} (${BRANDING_GCC_PKGVERSION})"
1899 vapier 1.513 gcc_sed+=( -e "/const char version_string\[\] = /s:= \".*\":= \"${version_string}\":" )
1900 halcy0n 1.246 fi
1901 vapier 1.513 sed -i "${gcc_sed[@]}" "${S}"/gcc/version.c || die
1902 eradicator 1.72 }
1903    
1904 vapier 1.456 # This is a historical wart. The original Gentoo/amd64 port used:
1905     # lib32 - 32bit binaries (x86)
1906     # lib64 - 64bit binaries (x86_64)
1907     # lib - "native" binaries (a symlink to lib64)
1908     # Most other distros use the logic (including mainline gcc):
1909     # lib - 32bit binaries (x86)
1910     # lib64 - 64bit binaries (x86_64)
1911     # Over time, Gentoo is migrating to the latter form.
1912     #
1913     # Unfortunately, due to distros picking the lib32 behavior, newer gcc
1914     # versions will dynamically detect whether to use lib or lib32 for its
1915     # 32bit multilib. So, to keep the automagic from getting things wrong
1916     # while people are transitioning from the old style to the new style,
1917     # we always set the MULTILIB_OSDIRNAMES var for relevant targets.
1918     setup_multilib_osdirnames() {
1919     is_multilib || return 0
1920    
1921 eradicator 1.172 local config
1922 vapier 1.465 local libdirs="../lib64 ../lib32"
1923 eradicator 1.172
1924 vapier 1.456 # this only makes sense for some Linux targets
1925     case ${CTARGET} in
1926     x86_64*-linux*) config="i386" ;;
1927     powerpc64*-linux*) config="rs6000" ;;
1928     sparc64*-linux*) config="sparc" ;;
1929     s390x*-linux*) config="s390" ;;
1930     *) return 0 ;;
1931     esac
1932     config+="/t-linux64"
1933    
1934 vapier 1.465 if [[ ${SYMLINK_LIB} == "yes" ]] ; then
1935     einfo "updating multilib directories to be: ${libdirs}"
1936 vapier 1.539 if tc_version_is_at_least 4.7 ; then
1937 vapier 1.465 set -- -e '/^MULTILIB_OSDIRNAMES.*lib32/s:[$][(]if.*):../lib32:'
1938     else
1939     set -- -e "/^MULTILIB_OSDIRNAMES/s:=.*:= ${libdirs}:"
1940     fi
1941     else
1942     einfo "using upstream multilib; disabling lib32 autodetection"
1943     set -- -r -e 's:[$][(]if.*,(.*)[)]:\1:'
1944     fi
1945     sed -i "$@" "${S}"/gcc/config/${config} || die
1946 eradicator 1.72 }
1947    
1948 vapier 1.384 # make sure the libtool archives have libdir set to where they actually
1949     # -are-, and not where they -used- to be. also, any dependencies we have
1950     # on our own .la files need to be updated.
1951 eradicator 1.72 fix_libtool_libdir_paths() {
1952 vapier 1.387 pushd "${D}" >/dev/null
1953    
1954 vapier 1.409 pushd "./${1}" >/dev/null
1955 dirtyepic 1.410 local dir="${PWD#${D%/}}"
1956 vapier 1.407 local allarchives=$(echo *.la)
1957 vapier 1.384 allarchives="\(${allarchives// /\\|}\)"
1958 vapier 1.407 popd >/dev/null
1959 vapier 1.387
1960     sed -i \
1961     -e "/^libdir=/s:=.*:='${dir}':" \
1962     ./${dir}/*.la
1963     sed -i \
1964     -e "/^dependency_libs=/s:/[^ ]*/${allarchives}:${LIBPATH}/\1:g" \
1965     $(find ./${PREFIX}/lib* -maxdepth 3 -name '*.la') \
1966     ./${dir}/*.la
1967    
1968     popd >/dev/null
1969 eradicator 1.72 }
1970 eradicator 1.88
1971 eradicator 1.127 is_multilib() {
1972 vapier 1.487 tc_version_is_at_least 3 || return 1
1973 vapier 1.458 use multilib
1974 eradicator 1.88 }
1975 eradicator 1.127
1976     is_cxx() {
1977 azarah 1.128 gcc-lang-supported 'c++' || return 1
1978 vapier 1.479 use cxx
1979 eradicator 1.127 }
1980    
1981 vapier 1.327 is_d() {
1982     gcc-lang-supported d || return 1
1983 vapier 1.475 use_if_iuse d
1984 vapier 1.327 }
1985    
1986 eradicator 1.127 is_f77() {
1987     gcc-lang-supported f77 || return 1
1988     use fortran
1989     }
1990    
1991     is_f95() {
1992     gcc-lang-supported f95 || return 1
1993     use fortran
1994     }
1995    
1996     is_fortran() {
1997     gcc-lang-supported fortran || return 1
1998     use fortran
1999     }
2000    
2001     is_gcj() {
2002     gcc-lang-supported java || return 1
2003 vapier 1.479 use cxx && use_if_iuse gcj
2004 dirtyepic 1.449 }
2005    
2006     is_go() {
2007     gcc-lang-supported go || return 1
2008 vapier 1.479 use cxx && use_if_iuse go
2009 eradicator 1.127 }
2010    
2011     is_objc() {
2012     gcc-lang-supported objc || return 1
2013 vapier 1.475 use_if_iuse objc
2014 eradicator 1.127 }
2015    
2016 vapier 1.247 is_objcxx() {
2017     gcc-lang-supported 'obj-c++' || return 1
2018 vapier 1.479 use cxx && use_if_iuse objc++
2019 vapier 1.247 }
2020    
2021 eradicator 1.127 is_ada() {
2022     gcc-lang-supported ada || return 1
2023     use ada
2024     }
2025 vapier 1.343
2026     is_treelang() {
2027 vapier 1.478 use_if_iuse boundschecking && return 1 #260532
2028 vapier 1.344 is_crosscompile && return 1 #199924
2029 vapier 1.343 gcc-lang-supported treelang || return 1
2030     #use treelang
2031     return 0
2032     }
2033 vapier 1.469
2034     # should kill these off once all the ebuilds are migrated
2035     gcc_pkg_setup() { toolchain_pkg_setup ; }
2036     gcc_src_unpack() { toolchain_src_unpack ; }
2037     gcc_src_compile() { toolchain_src_compile ; }
2038     gcc_src_test() { toolchain_src_test ; }

  ViewVC Help
Powered by ViewVC 1.1.20