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

Contents of /eclass/toolchain.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.568 - (hide annotations) (download)
Thu Jan 24 01:27:27 2013 UTC (18 months ago) by vapier
Branch: MAIN
Changes since 1.567: +5 -12 lines
drop USE="bootstrap build" as it does very little and the existing logic should handle things correctly #440224

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

  ViewVC Help
Powered by ViewVC 1.1.20