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