1 |
commit: 2ce0208d19c5417cc5ac001c265da5880147d4b2 |
2 |
Author: Benda Xu <heroxbd <AT> gentoo <DOT> org> |
3 |
AuthorDate: Mon Aug 7 06:12:17 2017 +0000 |
4 |
Commit: Benda XU <heroxbd <AT> gentoo <DOT> org> |
5 |
CommitDate: Mon Aug 7 06:12:17 2017 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/android.git/commit/?id=2ce0208d |
7 |
|
8 |
toolchain.eclass: merged to gentoo main. |
9 |
|
10 |
eclass/toolchain.eclass | 2382 ----------------------------------------------- |
11 |
1 file changed, 2382 deletions(-) |
12 |
|
13 |
diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass |
14 |
deleted file mode 100644 |
15 |
index ca64091..0000000 |
16 |
--- a/eclass/toolchain.eclass |
17 |
+++ /dev/null |
18 |
@@ -1,2382 +0,0 @@ |
19 |
-# Copyright 1999-2016 Gentoo Foundation |
20 |
-# Distributed under the terms of the GNU General Public License v2 |
21 |
-# $Id$ |
22 |
- |
23 |
-# Maintainer: Toolchain Ninjas <toolchain@g.o> |
24 |
- |
25 |
-DESCRIPTION="The GNU Compiler Collection" |
26 |
-HOMEPAGE="https://gcc.gnu.org/" |
27 |
-RESTRICT="strip" # cross-compilers need controlled stripping |
28 |
- |
29 |
-inherit eutils fixheadtails flag-o-matic gnuconfig libtool multilib pax-utils toolchain-funcs versionator prefix |
30 |
- |
31 |
-if [[ ${PV} == *_pre9999* ]] ; then |
32 |
- EGIT_REPO_URI="git://gcc.gnu.org/git/gcc.git" |
33 |
- # naming style: |
34 |
- # gcc-4.7.1_pre9999 -> gcc-4_7-branch |
35 |
- # Note that the micro version is required or lots of stuff will break. |
36 |
- # To checkout master set gcc_LIVE_BRANCH="master" in the ebuild before |
37 |
- # inheriting this eclass. |
38 |
- EGIT_BRANCH="${PN}-${PV%.?_pre9999}-branch" |
39 |
- EGIT_BRANCH=${EGIT_BRANCH//./_} |
40 |
- inherit git-2 |
41 |
-fi |
42 |
- |
43 |
-FEATURES=${FEATURES/multilib-strict/} |
44 |
- |
45 |
-EXPORTED_FUNCTIONS="pkg_setup src_unpack src_compile src_test src_install pkg_postinst pkg_postrm" |
46 |
-case ${EAPI:-0} in |
47 |
- 0|1) die "Need to upgrade to at least EAPI=2";; |
48 |
- 2|3) EXPORTED_FUNCTIONS+=" src_prepare src_configure" ;; |
49 |
- 4*|5*) EXPORTED_FUNCTIONS+=" pkg_pretend src_prepare src_configure" ;; |
50 |
- *) die "I don't speak EAPI ${EAPI}." |
51 |
-esac |
52 |
-EXPORT_FUNCTIONS ${EXPORTED_FUNCTIONS} |
53 |
- |
54 |
-#---->> globals <<---- |
55 |
- |
56 |
-export CTARGET=${CTARGET:-${CHOST}} |
57 |
-if [[ ${CTARGET} = ${CHOST} ]] ; then |
58 |
- if [[ ${CATEGORY} == cross-* ]] ; then |
59 |
- export CTARGET=${CATEGORY#cross-} |
60 |
- fi |
61 |
-fi |
62 |
-: ${TARGET_ABI:=${ABI}} |
63 |
-: ${TARGET_MULTILIB_ABIS:=${MULTILIB_ABIS}} |
64 |
-: ${TARGET_DEFAULT_ABI:=${DEFAULT_ABI}} |
65 |
- |
66 |
-is_crosscompile() { |
67 |
- [[ ${CHOST} != ${CTARGET} ]] |
68 |
-} |
69 |
- |
70 |
-if [[ ${EAPI:-0} == [012] ]] ; then |
71 |
- : ${ED:=${D}} |
72 |
- : ${EROOT:=${ROOT}} |
73 |
-fi |
74 |
- |
75 |
-# General purpose version check. Without a second arg matches up to minor version (x.x.x) |
76 |
-tc_version_is_at_least() { |
77 |
- version_is_at_least "$1" "${2:-${GCC_RELEASE_VER}}" |
78 |
-} |
79 |
- |
80 |
-# General purpose version range check |
81 |
-# Note that it matches up to but NOT including the second version |
82 |
-tc_version_is_between() { |
83 |
- tc_version_is_at_least "${1}" && ! tc_version_is_at_least "${2}" |
84 |
-} |
85 |
- |
86 |
-GCC_PV=${TOOLCHAIN_GCC_PV:-${PV}} |
87 |
-GCC_PVR=${GCC_PV} |
88 |
-[[ ${PR} != "r0" ]] && GCC_PVR=${GCC_PVR}-${PR} |
89 |
-GCC_RELEASE_VER=$(get_version_component_range 1-3 ${GCC_PV}) |
90 |
-GCC_BRANCH_VER=$(get_version_component_range 1-2 ${GCC_PV}) |
91 |
-GCCMAJOR=$(get_version_component_range 1 ${GCC_PV}) |
92 |
-GCCMINOR=$(get_version_component_range 2 ${GCC_PV}) |
93 |
-GCCMICRO=$(get_version_component_range 3 ${GCC_PV}) |
94 |
-[[ ${BRANCH_UPDATE-notset} == "notset" ]] && \ |
95 |
- BRANCH_UPDATE=$(get_version_component_range 4 ${GCC_PV}) |
96 |
- |
97 |
-# According to gcc/c-cppbuiltin.c, GCC_CONFIG_VER MUST match this regex. |
98 |
-# ([^0-9]*-)?[0-9]+[.][0-9]+([.][0-9]+)?([- ].*)? |
99 |
-GCC_CONFIG_VER=${GCC_CONFIG_VER:-$(replace_version_separator 3 '-' ${GCC_PV})} |
100 |
- |
101 |
-# Pre-release support |
102 |
-if [[ ${GCC_PV} == *_pre* ]] ; then |
103 |
- PRERELEASE=${GCC_PV/_pre/-} |
104 |
-elif [[ ${GCC_PV} == *_alpha* ]] ; then |
105 |
- SNAPSHOT=${GCC_BRANCH_VER}-${GCC_PV##*_alpha} |
106 |
-elif [[ ${GCC_PV} == *_beta* ]] ; then |
107 |
- SNAPSHOT=${GCC_BRANCH_VER}-${GCC_PV##*_beta} |
108 |
-elif [[ ${GCC_PV} == *_rc* ]] ; then |
109 |
- SNAPSHOT=${GCC_PV%_rc*}-RC-${GCC_PV##*_rc} |
110 |
-fi |
111 |
- |
112 |
-if [[ ${SNAPSHOT} == [56789].0-* ]] ; then |
113 |
- # The gcc-5+ releases have dropped the .0 for some reason. |
114 |
- SNAPSHOT=${SNAPSHOT/.0} |
115 |
-fi |
116 |
- |
117 |
-export GCC_FILESDIR=${GCC_FILESDIR:-${FILESDIR}} |
118 |
- |
119 |
-PREFIX=${TOOLCHAIN_PREFIX:-${EPREFIX}/usr} |
120 |
- |
121 |
-if tc_version_is_at_least 3.4.0 ; then |
122 |
- LIBPATH=${TOOLCHAIN_LIBPATH:-${PREFIX}/lib/gcc/${CTARGET}/${GCC_CONFIG_VER}} |
123 |
-else |
124 |
- LIBPATH=${TOOLCHAIN_LIBPATH:-${PREFIX}/lib/gcc-lib/${CTARGET}/${GCC_CONFIG_VER}} |
125 |
-fi |
126 |
-INCLUDEPATH=${TOOLCHAIN_INCLUDEPATH:-${LIBPATH}/include} |
127 |
- |
128 |
-if is_crosscompile ; then |
129 |
- BINPATH=${TOOLCHAIN_BINPATH:-${PREFIX}/${CHOST}/${CTARGET}/gcc-bin/${GCC_CONFIG_VER}} |
130 |
- HOSTLIBPATH=${PREFIX}/${CHOST}/${CTARGET}/lib/${GCC_CONFIG_VER} |
131 |
-else |
132 |
- BINPATH=${TOOLCHAIN_BINPATH:-${PREFIX}/${CTARGET}/gcc-bin/${GCC_CONFIG_VER}} |
133 |
-fi |
134 |
- |
135 |
-DATAPATH=${TOOLCHAIN_DATAPATH:-${PREFIX}/share/gcc-data/${CTARGET}/${GCC_CONFIG_VER}} |
136 |
- |
137 |
-# Dont install in /usr/include/g++-v3/, but in gcc internal directory. |
138 |
-# We will handle /usr/include/g++-v3/ with gcc-config ... |
139 |
-STDCXX_INCDIR=${TOOLCHAIN_STDCXX_INCDIR:-${LIBPATH}/include/g++-v${GCC_BRANCH_VER/\.*/}} |
140 |
- |
141 |
-#---->> LICENSE+SLOT+IUSE logic <<---- |
142 |
- |
143 |
-if tc_version_is_at_least 4.6 ; then |
144 |
- LICENSE="GPL-3+ LGPL-3+ || ( GPL-3+ libgcc libstdc++ gcc-runtime-library-exception-3.1 ) FDL-1.3+" |
145 |
-elif tc_version_is_at_least 4.4 ; then |
146 |
- LICENSE="GPL-3+ LGPL-3+ || ( GPL-3+ libgcc libstdc++ gcc-runtime-library-exception-3.1 ) FDL-1.2+" |
147 |
-elif tc_version_is_at_least 4.3 ; then |
148 |
- LICENSE="GPL-3+ LGPL-3+ || ( GPL-3+ libgcc libstdc++ ) FDL-1.2+" |
149 |
-elif tc_version_is_at_least 4.2 ; then |
150 |
- LICENSE="GPL-3+ LGPL-2.1+ || ( GPL-3+ libgcc libstdc++ ) FDL-1.2+" |
151 |
-elif tc_version_is_at_least 3.3 ; then |
152 |
- LICENSE="GPL-2+ LGPL-2.1+ FDL-1.2+" |
153 |
-else |
154 |
- LICENSE="GPL-2+ LGPL-2.1+ FDL-1.1+" |
155 |
-fi |
156 |
- |
157 |
-IUSE="regression-test vanilla" |
158 |
-IUSE_DEF=( nls nptl ) |
159 |
- |
160 |
-if [[ ${PN} != "kgcc64" && ${PN} != gcc-* ]] ; then |
161 |
- IUSE+=" altivec debug" |
162 |
- IUSE_DEF+=( cxx fortran ) |
163 |
- [[ -n ${PIE_VER} ]] && IUSE+=" nopie" |
164 |
- [[ -n ${HTB_VER} ]] && IUSE+=" boundschecking" |
165 |
- [[ -n ${D_VER} ]] && IUSE+=" d" |
166 |
- [[ -n ${SPECS_VER} ]] && IUSE+=" nossp" |
167 |
- tc_version_is_at_least 3 && IUSE+=" doc gcj awt hardened multilib objc" |
168 |
- tc_version_is_at_least 4.0 && IUSE+=" objc-gc" |
169 |
- tc_version_is_between 4.0 4.9 && IUSE+=" mudflap" |
170 |
- tc_version_is_at_least 4.1 && IUSE+=" libssp objc++" |
171 |
- tc_version_is_at_least 4.2 && IUSE_DEF+=( openmp ) |
172 |
- tc_version_is_at_least 4.3 && IUSE+=" fixed-point" |
173 |
- tc_version_is_at_least 4.7 && IUSE+=" go" |
174 |
- # Note: while <=gcc-4.7 also supported graphite, it required forked ppl |
175 |
- # versions which we dropped. Since graphite was also experimental in |
176 |
- # the older versions, we don't want to bother supporting it. #448024 |
177 |
- tc_version_is_at_least 4.8 && IUSE+=" graphite" IUSE_DEF+=( sanitize ) |
178 |
- tc_version_is_at_least 4.9 && IUSE+=" cilk +vtv" |
179 |
- tc_version_is_at_least 5.0 && IUSE+=" jit mpx" |
180 |
- tc_version_is_at_least 6.0 && IUSE+=" pie ssp +pch" |
181 |
-fi |
182 |
- |
183 |
-IUSE+=" ${IUSE_DEF[*]/#/+}" |
184 |
- |
185 |
-SLOT="${GCC_CONFIG_VER}" |
186 |
- |
187 |
-#---->> DEPEND <<---- |
188 |
- |
189 |
-RDEPEND="sys-libs/zlib |
190 |
- nls? ( virtual/libintl )" |
191 |
- |
192 |
-tc_version_is_at_least 3 && RDEPEND+=" virtual/libiconv" |
193 |
- |
194 |
-if tc_version_is_at_least 4 ; then |
195 |
- GMP_MPFR_DEPS=">=dev-libs/gmp-4.3.2:0 >=dev-libs/mpfr-2.4.2:0" |
196 |
- if tc_version_is_at_least 4.3 ; then |
197 |
- RDEPEND+=" ${GMP_MPFR_DEPS}" |
198 |
- elif in_iuse fortran ; then |
199 |
- RDEPEND+=" fortran? ( ${GMP_MPFR_DEPS} )" |
200 |
- fi |
201 |
-fi |
202 |
- |
203 |
-tc_version_is_at_least 4.5 && RDEPEND+=" >=dev-libs/mpc-0.8.1:0" |
204 |
- |
205 |
-if in_iuse graphite ; then |
206 |
- if tc_version_is_at_least 5.0 ; then |
207 |
- RDEPEND+=" graphite? ( >=dev-libs/isl-0.14 )" |
208 |
- elif tc_version_is_at_least 4.8 ; then |
209 |
- RDEPEND+=" |
210 |
- graphite? ( |
211 |
- >=dev-libs/cloog-0.18.0 |
212 |
- >=dev-libs/isl-0.11.1 |
213 |
- )" |
214 |
- fi |
215 |
-fi |
216 |
- |
217 |
-DEPEND="${RDEPEND} |
218 |
- >=sys-devel/bison-1.875 |
219 |
- >=sys-devel/flex-2.5.4 |
220 |
- nls? ( sys-devel/gettext ) |
221 |
- regression-test? ( |
222 |
- >=dev-util/dejagnu-1.4.4 |
223 |
- >=sys-devel/autogen-5.5.4 |
224 |
- )" |
225 |
- |
226 |
-if in_iuse gcj ; then |
227 |
- GCJ_DEPS=">=media-libs/libart_lgpl-2.1" |
228 |
- GCJ_GTK_DEPS=" |
229 |
- x11-libs/libXt |
230 |
- x11-libs/libX11 |
231 |
- x11-libs/libXtst |
232 |
- x11-proto/xproto |
233 |
- x11-proto/xextproto |
234 |
- =x11-libs/gtk+-2* |
235 |
- virtual/pkgconfig |
236 |
- " |
237 |
- tc_version_is_at_least 3.4 && GCJ_GTK_DEPS+=" x11-libs/pango" |
238 |
- tc_version_is_at_least 4.2 && GCJ_DEPS+=" app-arch/zip app-arch/unzip" |
239 |
- DEPEND+=" gcj? ( awt? ( ${GCJ_GTK_DEPS} ) ${GCJ_DEPS} )" |
240 |
-fi |
241 |
- |
242 |
-PDEPEND=">=sys-devel/gcc-config-1.7" |
243 |
- |
244 |
-#---->> S + SRC_URI essentials <<---- |
245 |
- |
246 |
-# Set the source directory depending on whether we're using |
247 |
-# a prerelease, snapshot, or release tarball. |
248 |
-S=$( |
249 |
- if [[ -n ${PRERELEASE} ]] ; then |
250 |
- echo ${WORKDIR}/gcc-${PRERELEASE} |
251 |
- elif [[ -n ${SNAPSHOT} ]] ; then |
252 |
- echo ${WORKDIR}/gcc-${SNAPSHOT} |
253 |
- else |
254 |
- echo ${WORKDIR}/gcc-${GCC_RELEASE_VER} |
255 |
- fi |
256 |
-) |
257 |
- |
258 |
-gentoo_urls() { |
259 |
- local devspace="HTTP~vapier/dist/URI HTTP~rhill/dist/URI |
260 |
- HTTP~zorry/patches/gcc/URI HTTP~blueness/dist/URI" |
261 |
- devspace=${devspace//HTTP/https:\/\/dev.gentoo.org\/} |
262 |
- echo mirror://gentoo/$1 ${devspace//URI/$1} |
263 |
-} |
264 |
- |
265 |
-# This function handles the basics of setting the SRC_URI for a gcc ebuild. |
266 |
-# To use, set SRC_URI with: |
267 |
-# |
268 |
-# SRC_URI="$(get_gcc_src_uri)" |
269 |
-# |
270 |
-# Other than the variables normally set by portage, this function's behavior |
271 |
-# can be altered by setting the following: |
272 |
-# |
273 |
-# SNAPSHOT |
274 |
-# If set, this variable signals that we should be using a snapshot of |
275 |
-# gcc. It is expected to be in the format "YYYY-MM-DD". Note that if |
276 |
-# the ebuild has a _pre suffix, this variable is ignored and the |
277 |
-# prerelease tarball is used instead. |
278 |
-# |
279 |
-# BRANCH_UPDATE |
280 |
-# If set, this variable signals that we should be using the main |
281 |
-# release tarball (determined by ebuild version) and applying a |
282 |
-# CVS branch update patch against it. The location of this branch |
283 |
-# update patch is assumed to be in ${GENTOO_TOOLCHAIN_BASE_URI}. |
284 |
-# Just like with SNAPSHOT, this variable is ignored if the ebuild |
285 |
-# has a _pre suffix. |
286 |
-# |
287 |
-# PATCH_VER |
288 |
-# PATCH_GCC_VER |
289 |
-# This should be set to the version of the gentoo patch tarball. |
290 |
-# The resulting filename of this tarball will be: |
291 |
-# gcc-${PATCH_GCC_VER:-${GCC_RELEASE_VER}}-patches-${PATCH_VER}.tar.bz2 |
292 |
-# |
293 |
-# PIE_VER |
294 |
-# PIE_GCC_VER |
295 |
-# These variables control patching in various updates for the logic |
296 |
-# controlling Position Independant Executables. PIE_VER is expected |
297 |
-# to be the version of this patch, and PIE_GCC_VER the gcc version of |
298 |
-# the patch: |
299 |
-# An example: |
300 |
-# PIE_VER="8.7.6.5" |
301 |
-# PIE_GCC_VER="3.4.0" |
302 |
-# The resulting filename of this tarball will be: |
303 |
-# gcc-${PIE_GCC_VER:-${GCC_RELEASE_VER}}-piepatches-v${PIE_VER}.tar.bz2 |
304 |
-# |
305 |
-# SPECS_VER |
306 |
-# SPECS_GCC_VER |
307 |
-# This is for the minispecs files included in the hardened gcc-4.x |
308 |
-# The specs files for hardenedno*, vanilla and for building the "specs" file. |
309 |
-# SPECS_VER is expected to be the version of this patch, SPECS_GCC_VER |
310 |
-# the gcc version of the patch. |
311 |
-# An example: |
312 |
-# SPECS_VER="8.7.6.5" |
313 |
-# SPECS_GCC_VER="3.4.0" |
314 |
-# The resulting filename of this tarball will be: |
315 |
-# gcc-${SPECS_GCC_VER:-${GCC_RELEASE_VER}}-specs-${SPECS_VER}.tar.bz2 |
316 |
-# |
317 |
-# HTB_VER |
318 |
-# HTB_GCC_VER |
319 |
-# These variables control whether or not an ebuild supports Herman |
320 |
-# ten Brugge's bounds-checking patches. If you want to use a patch |
321 |
-# for an older gcc version with a new gcc, make sure you set |
322 |
-# HTB_GCC_VER to that version of gcc. |
323 |
-get_gcc_src_uri() { |
324 |
- export PATCH_GCC_VER=${PATCH_GCC_VER:-${GCC_RELEASE_VER}} |
325 |
- export UCLIBC_GCC_VER=${UCLIBC_GCC_VER:-${PATCH_GCC_VER}} |
326 |
- export PIE_GCC_VER=${PIE_GCC_VER:-${GCC_RELEASE_VER}} |
327 |
- export HTB_GCC_VER=${HTB_GCC_VER:-${GCC_RELEASE_VER}} |
328 |
- export SPECS_GCC_VER=${SPECS_GCC_VER:-${GCC_RELEASE_VER}} |
329 |
- |
330 |
- # Set where to download gcc itself depending on whether we're using a |
331 |
- # prerelease, snapshot, or release tarball. |
332 |
- if [[ ${PV} == *9999* ]] ; then |
333 |
- # Nothing to do w/git snapshots. |
334 |
- : |
335 |
- elif [[ -n ${PRERELEASE} ]] ; then |
336 |
- GCC_SRC_URI="ftp://gcc.gnu.org/pub/gcc/prerelease-${PRERELEASE}/gcc-${PRERELEASE}.tar.bz2" |
337 |
- elif [[ -n ${SNAPSHOT} ]] ; then |
338 |
- GCC_SRC_URI="ftp://gcc.gnu.org/pub/gcc/snapshots/${SNAPSHOT}/gcc-${SNAPSHOT}.tar.bz2" |
339 |
- else |
340 |
- GCC_SRC_URI="mirror://gnu/gcc/gcc-${GCC_PV}/gcc-${GCC_RELEASE_VER}.tar.bz2" |
341 |
- # we want all branch updates to be against the main release |
342 |
- [[ -n ${BRANCH_UPDATE} ]] && \ |
343 |
- GCC_SRC_URI+=" $(gentoo_urls gcc-${GCC_RELEASE_VER}-branch-update-${BRANCH_UPDATE}.patch.bz2)" |
344 |
- fi |
345 |
- |
346 |
- [[ -n ${UCLIBC_VER} ]] && \ |
347 |
- GCC_SRC_URI+=" $(gentoo_urls gcc-${UCLIBC_GCC_VER}-uclibc-patches-${UCLIBC_VER}.tar.bz2)" |
348 |
- [[ -n ${PATCH_VER} ]] && \ |
349 |
- GCC_SRC_URI+=" $(gentoo_urls gcc-${PATCH_GCC_VER}-patches-${PATCH_VER}.tar.bz2)" |
350 |
- |
351 |
- # strawberry pie, Cappuccino and a Gauloises (it's a good thing) |
352 |
- [[ -n ${PIE_VER} ]] && \ |
353 |
- PIE_CORE=${PIE_CORE:-gcc-${PIE_GCC_VER}-piepatches-v${PIE_VER}.tar.bz2} && \ |
354 |
- GCC_SRC_URI+=" $(gentoo_urls ${PIE_CORE})" |
355 |
- |
356 |
- # gcc minispec for the hardened gcc 4 compiler |
357 |
- [[ -n ${SPECS_VER} ]] && \ |
358 |
- GCC_SRC_URI+=" $(gentoo_urls gcc-${SPECS_GCC_VER}-specs-${SPECS_VER}.tar.bz2)" |
359 |
- |
360 |
- # gcc bounds checking patch |
361 |
- if [[ -n ${HTB_VER} ]] ; then |
362 |
- local HTBFILE="bounds-checking-gcc-${HTB_GCC_VER}-${HTB_VER}.patch.bz2" |
363 |
- GCC_SRC_URI+=" |
364 |
- boundschecking? ( |
365 |
- mirror://sourceforge/boundschecking/${HTBFILE} |
366 |
- $(gentoo_urls ${HTBFILE}) |
367 |
- )" |
368 |
- fi |
369 |
- |
370 |
- [[ -n ${D_VER} ]] && \ |
371 |
- GCC_SRC_URI+=" d? ( mirror://sourceforge/dgcc/gdc-${D_VER}-src.tar.bz2 )" |
372 |
- |
373 |
- if in_iuse gcj ; then |
374 |
- if tc_version_is_at_least 4.5 ; then |
375 |
- GCC_SRC_URI+=" gcj? ( ftp://sourceware.org/pub/java/ecj-4.5.jar )" |
376 |
- elif tc_version_is_at_least 4.3 ; then |
377 |
- GCC_SRC_URI+=" gcj? ( ftp://sourceware.org/pub/java/ecj-4.3.jar )" |
378 |
- fi |
379 |
- fi |
380 |
- |
381 |
- echo "${GCC_SRC_URI}" |
382 |
-} |
383 |
- |
384 |
-SRC_URI=$(get_gcc_src_uri) |
385 |
- |
386 |
-#---->> pkg_pretend <<---- |
387 |
- |
388 |
-toolchain_pkg_pretend() { |
389 |
- if [[ -n ${PRERELEASE}${SNAPSHOT} || ${PV} == *9999* ]] && |
390 |
- [[ -z ${I_PROMISE_TO_SUPPLY_PATCHES_WITH_BUGS} ]] ; then |
391 |
- die "Please \`export I_PROMISE_TO_SUPPLY_PATCHES_WITH_BUGS=1\` or define it" \ |
392 |
- "in your make.conf if you want to use this version." |
393 |
- fi |
394 |
- |
395 |
- [[ -z ${UCLIBC_VER} ]] && [[ ${CTARGET} == *-uclibc* ]] && \ |
396 |
- die "Sorry, this version does not support uClibc" |
397 |
- |
398 |
- if ! use_if_iuse cxx ; then |
399 |
- use_if_iuse go && ewarn 'Go requires a C++ compiler, disabled due to USE="-cxx"' |
400 |
- use_if_iuse objc++ && ewarn 'Obj-C++ requires a C++ compiler, disabled due to USE="-cxx"' |
401 |
- use_if_iuse gcj && ewarn 'GCJ requires a C++ compiler, disabled due to USE="-cxx"' |
402 |
- fi |
403 |
- |
404 |
- want_minispecs |
405 |
-} |
406 |
- |
407 |
-#---->> pkg_setup <<---- |
408 |
- |
409 |
-toolchain_pkg_setup() { |
410 |
- case ${EAPI} in |
411 |
- 2|3) toolchain_pkg_pretend ;; |
412 |
- esac |
413 |
- |
414 |
- # we dont want to use the installed compiler's specs to build gcc |
415 |
- unset GCC_SPECS |
416 |
- unset LANGUAGES #265283 |
417 |
-} |
418 |
- |
419 |
-#---->> src_unpack <<---- |
420 |
- |
421 |
-toolchain_src_unpack() { |
422 |
- if [[ ${PV} == *9999* ]]; then |
423 |
- git-2_src_unpack |
424 |
- else |
425 |
- gcc_quick_unpack |
426 |
- fi |
427 |
-} |
428 |
- |
429 |
-gcc_quick_unpack() { |
430 |
- pushd "${WORKDIR}" > /dev/null |
431 |
- export PATCH_GCC_VER=${PATCH_GCC_VER:-${GCC_RELEASE_VER}} |
432 |
- export UCLIBC_GCC_VER=${UCLIBC_GCC_VER:-${PATCH_GCC_VER}} |
433 |
- export PIE_GCC_VER=${PIE_GCC_VER:-${GCC_RELEASE_VER}} |
434 |
- export HTB_GCC_VER=${HTB_GCC_VER:-${GCC_RELEASE_VER}} |
435 |
- export SPECS_GCC_VER=${SPECS_GCC_VER:-${GCC_RELEASE_VER}} |
436 |
- |
437 |
- if [[ -n ${GCC_A_FAKEIT} ]] ; then |
438 |
- unpack ${GCC_A_FAKEIT} |
439 |
- elif [[ -n ${PRERELEASE} ]] ; then |
440 |
- unpack gcc-${PRERELEASE}.tar.bz2 |
441 |
- elif [[ -n ${SNAPSHOT} ]] ; then |
442 |
- unpack gcc-${SNAPSHOT}.tar.bz2 |
443 |
- elif [[ ${PV} != *9999* ]] ; then |
444 |
- unpack gcc-${GCC_RELEASE_VER}.tar.bz2 |
445 |
- # We want branch updates to be against a release tarball |
446 |
- if [[ -n ${BRANCH_UPDATE} ]] ; then |
447 |
- pushd "${S}" > /dev/null |
448 |
- epatch "${DISTDIR}"/gcc-${GCC_RELEASE_VER}-branch-update-${BRANCH_UPDATE}.patch.bz2 |
449 |
- popd > /dev/null |
450 |
- fi |
451 |
- fi |
452 |
- |
453 |
- if [[ -n ${D_VER} ]] && use d ; then |
454 |
- pushd "${S}"/gcc > /dev/null |
455 |
- unpack gdc-${D_VER}-src.tar.bz2 |
456 |
- cd .. |
457 |
- ebegin "Adding support for the D language" |
458 |
- ./gcc/d/setup-gcc.sh >& "${T}"/dgcc.log |
459 |
- if ! eend $? ; then |
460 |
- eerror "The D GCC package failed to apply" |
461 |
- eerror "Please include this log file when posting a bug report:" |
462 |
- eerror " ${T}/dgcc.log" |
463 |
- die "failed to include the D language" |
464 |
- fi |
465 |
- popd > /dev/null |
466 |
- fi |
467 |
- |
468 |
- [[ -n ${PATCH_VER} ]] && \ |
469 |
- unpack gcc-${PATCH_GCC_VER}-patches-${PATCH_VER}.tar.bz2 |
470 |
- |
471 |
- [[ -n ${UCLIBC_VER} ]] && \ |
472 |
- unpack gcc-${UCLIBC_GCC_VER}-uclibc-patches-${UCLIBC_VER}.tar.bz2 |
473 |
- |
474 |
- if want_pie ; then |
475 |
- if [[ -n ${PIE_CORE} ]] ; then |
476 |
- unpack ${PIE_CORE} |
477 |
- else |
478 |
- unpack gcc-${PIE_GCC_VER}-piepatches-v${PIE_VER}.tar.bz2 |
479 |
- fi |
480 |
- [[ -n ${SPECS_VER} ]] && \ |
481 |
- unpack gcc-${SPECS_GCC_VER}-specs-${SPECS_VER}.tar.bz2 |
482 |
- fi |
483 |
- |
484 |
- use_if_iuse boundschecking && unpack "bounds-checking-gcc-${HTB_GCC_VER}-${HTB_VER}.patch.bz2" |
485 |
- |
486 |
- popd > /dev/null |
487 |
-} |
488 |
- |
489 |
-#---->> src_prepare <<---- |
490 |
- |
491 |
-toolchain_src_prepare() { |
492 |
- export BRANDING_GCC_PKGVERSION="Gentoo ${GCC_PVR}" |
493 |
- cd "${S}" |
494 |
- |
495 |
- if ! use vanilla ; then |
496 |
- if [[ -n ${PATCH_VER} ]] ; then |
497 |
- guess_patch_type_in_dir "${WORKDIR}"/patch |
498 |
- EPATCH_MULTI_MSG="Applying Gentoo patches ..." \ |
499 |
- epatch "${WORKDIR}"/patch |
500 |
- BRANDING_GCC_PKGVERSION="${BRANDING_GCC_PKGVERSION} p${PATCH_VER}" |
501 |
- fi |
502 |
- if [[ -n ${UCLIBC_VER} ]] ; then |
503 |
- guess_patch_type_in_dir "${WORKDIR}"/uclibc |
504 |
- EPATCH_MULTI_MSG="Applying uClibc patches ..." \ |
505 |
- epatch "${WORKDIR}"/uclibc |
506 |
- fi |
507 |
- fi |
508 |
- do_gcc_HTB_patches |
509 |
- do_gcc_PIE_patches |
510 |
- epatch_user |
511 |
- |
512 |
- if ( tc_version_is_at_least 4.8.2 || use hardened ) && ! use vanilla ; then |
513 |
- make_gcc_hard |
514 |
- fi |
515 |
- |
516 |
- # install the libstdc++ python into the right location |
517 |
- # http://gcc.gnu.org/PR51368 |
518 |
- if tc_version_is_between 4.5 4.7 ; then |
519 |
- sed -i \ |
520 |
- '/^pythondir =/s:=.*:= $(datadir)/python:' \ |
521 |
- "${S}"/libstdc++-v3/python/Makefile.in || die |
522 |
- fi |
523 |
- |
524 |
- # make sure the pkg config files install into multilib dirs. |
525 |
- # since we configure with just one --libdir, we can't use that |
526 |
- # (as gcc itself takes care of building multilibs). #435728 |
527 |
- find "${S}" -name Makefile.in \ |
528 |
- -exec sed -i '/^pkgconfigdir/s:=.*:=$(toolexeclibdir)/pkgconfig:' {} + |
529 |
- |
530 |
- # No idea when this first started being fixed, but let's go with 4.3.x for now |
531 |
- if ! tc_version_is_at_least 4.3 ; then |
532 |
- fix_files="" |
533 |
- for x in contrib/test_summary libstdc++-v3/scripts/check_survey.in ; do |
534 |
- [[ -e ${x} ]] && fix_files="${fix_files} ${x}" |
535 |
- done |
536 |
- ht_fix_file ${fix_files} */configure *.sh */Makefile.in |
537 |
- fi |
538 |
- |
539 |
- setup_multilib_osdirnames |
540 |
- gcc_version_patch |
541 |
- |
542 |
- if tc_version_is_at_least 4.1 ; then |
543 |
- if [[ -n ${SNAPSHOT} || -n ${PRERELEASE} ]] ; then |
544 |
- # BASE-VER must be a three-digit version number |
545 |
- # followed by an optional -pre string |
546 |
- # eg. 4.5.1, 4.6.2-pre20120213, 4.7.0-pre9999 |
547 |
- # If BASE-VER differs from ${PV/_/-} then libraries get installed in |
548 |
- # the wrong directory. |
549 |
- echo ${PV/_/-} > "${S}"/gcc/BASE-VER |
550 |
- fi |
551 |
- fi |
552 |
- |
553 |
- # >= gcc-4.3 doesn't bundle ecj.jar, so copy it |
554 |
- if tc_version_is_at_least 4.3 && use gcj ; then |
555 |
- if tc_version_is_at_least 4.5 ; then |
556 |
- einfo "Copying ecj-4.5.jar" |
557 |
- cp -pPR "${DISTDIR}/ecj-4.5.jar" "${S}/ecj.jar" || die |
558 |
- else |
559 |
- einfo "Copying ecj-4.3.jar" |
560 |
- cp -pPR "${DISTDIR}/ecj-4.3.jar" "${S}/ecj.jar" || die |
561 |
- fi |
562 |
- fi |
563 |
- |
564 |
- # disable --as-needed from being compiled into gcc specs |
565 |
- # natively when using a gcc version < 3.4.4 |
566 |
- # http://gcc.gnu.org/PR14992 |
567 |
- if ! tc_version_is_at_least 3.4.4 ; then |
568 |
- sed -i -e s/HAVE_LD_AS_NEEDED/USE_LD_AS_NEEDED/g "${S}"/gcc/config.in |
569 |
- fi |
570 |
- |
571 |
- # In gcc 3.3.x and 3.4.x, rename the java bins to gcc-specific names |
572 |
- # in line with gcc-4. |
573 |
- if tc_version_is_between 3.3 4.0 ; then |
574 |
- do_gcc_rename_java_bins |
575 |
- fi |
576 |
- |
577 |
- # Prevent libffi from being installed |
578 |
- if tc_version_is_between 3.0 4.8 ; then |
579 |
- sed -i -e 's/\(install.*:\) install-.*recursive/\1/' "${S}"/libffi/Makefile.in || die |
580 |
- sed -i -e 's/\(install-data-am:\).*/\1/' "${S}"/libffi/include/Makefile.in || die |
581 |
- fi |
582 |
- |
583 |
- # Fixup libtool to correctly generate .la files with portage |
584 |
- elibtoolize --portage --shallow --no-uclibc |
585 |
- |
586 |
- gnuconfig_update |
587 |
- |
588 |
- # update configure files |
589 |
- local f |
590 |
- einfo "Fixing misc issues in configure files" |
591 |
- for f in $(grep -l 'autoconf version 2.13' $(find "${S}" -name configure)) ; do |
592 |
- ebegin " Updating ${f/${S}\/} [LANG]" |
593 |
- patch "${f}" "${GCC_FILESDIR}"/gcc-configure-LANG.patch >& "${T}"/configure-patch.log \ |
594 |
- || eerror "Please file a bug about this" |
595 |
- eend $? |
596 |
- done |
597 |
- sed -i 's|A-Za-z0-9|[:alnum:]|g' "${S}"/gcc/*.awk #215828 |
598 |
- |
599 |
- # Prevent new texinfo from breaking old versions (see #198182, #464008) |
600 |
- tc_version_is_at_least 4.1 && epatch "${GCC_FILESDIR}"/gcc-configure-texinfo.patch |
601 |
- |
602 |
- if [[ -x contrib/gcc_update ]] ; then |
603 |
- einfo "Touching generated files" |
604 |
- ./contrib/gcc_update --touch | \ |
605 |
- while read f ; do |
606 |
- einfo " ${f%%...}" |
607 |
- done |
608 |
- fi |
609 |
-} |
610 |
- |
611 |
-guess_patch_type_in_dir() { |
612 |
- [[ -n $(ls "$1"/*.bz2 2>/dev/null) ]] \ |
613 |
- && EPATCH_SUFFIX="patch.bz2" \ |
614 |
- || EPATCH_SUFFIX="patch" |
615 |
-} |
616 |
- |
617 |
-do_gcc_HTB_patches() { |
618 |
- use_if_iuse boundschecking || return 0 |
619 |
- |
620 |
- # modify the bounds checking patch with a regression patch |
621 |
- epatch "${WORKDIR}/bounds-checking-gcc-${HTB_GCC_VER}-${HTB_VER}.patch" |
622 |
- BRANDING_GCC_PKGVERSION="${BRANDING_GCC_PKGVERSION}, HTB-${HTB_GCC_VER}-${HTB_VER}" |
623 |
-} |
624 |
- |
625 |
-do_gcc_PIE_patches() { |
626 |
- want_pie || return 0 |
627 |
- use vanilla && return 0 |
628 |
- |
629 |
- if tc_version_is_at_least 4.3.2 ; then |
630 |
- guess_patch_type_in_dir "${WORKDIR}"/piepatch/ |
631 |
- EPATCH_MULTI_MSG="Applying pie patches ..." \ |
632 |
- epatch "${WORKDIR}"/piepatch/ |
633 |
- else |
634 |
- guess_patch_type_in_dir "${WORKDIR}"/piepatch/upstream |
635 |
- |
636 |
- # corrects startfile/endfile selection and shared/static/pie flag usage |
637 |
- EPATCH_MULTI_MSG="Applying upstream pie patches ..." \ |
638 |
- epatch "${WORKDIR}"/piepatch/upstream |
639 |
- # adds non-default pie support (rs6000) |
640 |
- EPATCH_MULTI_MSG="Applying non-default pie patches ..." \ |
641 |
- epatch "${WORKDIR}"/piepatch/nondef |
642 |
- # adds default pie support (rs6000 too) if DEFAULT_PIE[_SSP] is defined |
643 |
- EPATCH_MULTI_MSG="Applying default pie patches ..." \ |
644 |
- epatch "${WORKDIR}"/piepatch/def |
645 |
- fi |
646 |
- |
647 |
- BRANDING_GCC_PKGVERSION="${BRANDING_GCC_PKGVERSION}, pie-${PIE_VER}" |
648 |
-} |
649 |
- |
650 |
-# configure to build with the hardened GCC specs as the default |
651 |
-make_gcc_hard() { |
652 |
- |
653 |
- local gcc_hard_flags="" |
654 |
- # Gcc >= 6.X we can use configurations options to turn pie/ssp on as default |
655 |
- if tc_version_is_at_least 6.0 ; then |
656 |
- if use pie ; then |
657 |
- einfo "Updating gcc to use automatic PIE building ..." |
658 |
- fi |
659 |
- if use ssp ; then |
660 |
- einfo "Updating gcc to use automatic SSP building ..." |
661 |
- fi |
662 |
- if use hardened ; then |
663 |
- # Will add some optimatizion as default. |
664 |
- gcc_hard_flags+=" -DEXTRA_OPTIONS" |
665 |
- # rebrand to make bug reports easier |
666 |
- BRANDING_GCC_PKGVERSION=${BRANDING_GCC_PKGVERSION/Gentoo/Gentoo Hardened} |
667 |
- fi |
668 |
- else |
669 |
- if use hardened ; then |
670 |
- # rebrand to make bug reports easier |
671 |
- BRANDING_GCC_PKGVERSION=${BRANDING_GCC_PKGVERSION/Gentoo/Gentoo Hardened} |
672 |
- if hardened_gcc_works ; then |
673 |
- einfo "Updating gcc to use automatic PIE + SSP building ..." |
674 |
- gcc_hard_flags+=" -DEFAULT_PIE_SSP" |
675 |
- elif hardened_gcc_works pie ; then |
676 |
- einfo "Updating gcc to use automatic PIE building ..." |
677 |
- ewarn "SSP has not been enabled by default" |
678 |
- gcc_hard_flags+=" -DEFAULT_PIE" |
679 |
- elif hardened_gcc_works ssp ; then |
680 |
- einfo "Updating gcc to use automatic SSP building ..." |
681 |
- ewarn "PIE has not been enabled by default" |
682 |
- gcc_hard_flags+=" -DEFAULT_SSP" |
683 |
- else |
684 |
- # do nothing if hardened isn't supported, but don't die either |
685 |
- ewarn "hardened is not supported for this arch in this gcc version" |
686 |
- return 0 |
687 |
- fi |
688 |
- else |
689 |
- if hardened_gcc_works ssp ; then |
690 |
- einfo "Updating gcc to use automatic SSP building ..." |
691 |
- gcc_hard_flags+=" -DEFAULT_SSP" |
692 |
- fi |
693 |
- fi |
694 |
- fi |
695 |
- |
696 |
- # we want to be able to control the pie patch logic via something other |
697 |
- # than ALL_CFLAGS... |
698 |
- sed -e '/^ALL_CFLAGS/iHARD_CFLAGS = ' \ |
699 |
- -e 's|^ALL_CFLAGS = |ALL_CFLAGS = $(HARD_CFLAGS) |' \ |
700 |
- -i "${S}"/gcc/Makefile.in |
701 |
- # Need to add HARD_CFLAGS to ALL_CXXFLAGS on >= 4.7 |
702 |
- if tc_version_is_at_least 4.7 ; then |
703 |
- sed -e '/^ALL_CXXFLAGS/iHARD_CFLAGS = ' \ |
704 |
- -e 's|^ALL_CXXFLAGS = |ALL_CXXFLAGS = $(HARD_CFLAGS) |' \ |
705 |
- -i "${S}"/gcc/Makefile.in |
706 |
- fi |
707 |
- |
708 |
- sed -i \ |
709 |
- -e "/^HARD_CFLAGS = /s|=|= ${gcc_hard_flags} |" \ |
710 |
- "${S}"/gcc/Makefile.in || die |
711 |
- |
712 |
-} |
713 |
- |
714 |
-# This is a historical wart. The original Gentoo/amd64 port used: |
715 |
-# lib32 - 32bit binaries (x86) |
716 |
-# lib64 - 64bit binaries (x86_64) |
717 |
-# lib - "native" binaries (a symlink to lib64) |
718 |
-# Most other distros use the logic (including mainline gcc): |
719 |
-# lib - 32bit binaries (x86) |
720 |
-# lib64 - 64bit binaries (x86_64) |
721 |
-# Over time, Gentoo is migrating to the latter form. |
722 |
-# |
723 |
-# Unfortunately, due to distros picking the lib32 behavior, newer gcc |
724 |
-# versions will dynamically detect whether to use lib or lib32 for its |
725 |
-# 32bit multilib. So, to keep the automagic from getting things wrong |
726 |
-# while people are transitioning from the old style to the new style, |
727 |
-# we always set the MULTILIB_OSDIRNAMES var for relevant targets. |
728 |
-setup_multilib_osdirnames() { |
729 |
- is_multilib || return 0 |
730 |
- |
731 |
- local config |
732 |
- local libdirs="../lib64 ../lib32" |
733 |
- |
734 |
- # this only makes sense for some Linux targets |
735 |
- case ${CTARGET} in |
736 |
- x86_64*-linux*) config="i386" ;; |
737 |
- powerpc64*-linux*) config="rs6000" ;; |
738 |
- sparc64*-linux*) config="sparc" ;; |
739 |
- s390x*-linux*) config="s390" ;; |
740 |
- *) return 0 ;; |
741 |
- esac |
742 |
- config+="/t-linux64" |
743 |
- |
744 |
- local sed_args=() |
745 |
- if tc_version_is_at_least 4.6 ; then |
746 |
- sed_args+=( -e 's:$[(]call if_multiarch[^)]*[)]::g' ) |
747 |
- fi |
748 |
- if [[ ${SYMLINK_LIB} == "yes" ]] ; then |
749 |
- einfo "updating multilib directories to be: ${libdirs}" |
750 |
- if tc_version_is_at_least 4.6.4 || tc_version_is_at_least 4.7 ; then |
751 |
- sed_args+=( -e '/^MULTILIB_OSDIRNAMES.*lib32/s:[$][(]if.*):../lib32:' ) |
752 |
- else |
753 |
- sed_args+=( -e "/^MULTILIB_OSDIRNAMES/s:=.*:= ${libdirs}:" ) |
754 |
- fi |
755 |
- else |
756 |
- einfo "using upstream multilib; disabling lib32 autodetection" |
757 |
- sed_args+=( -r -e 's:[$][(]if.*,(.*)[)]:\1:' ) |
758 |
- fi |
759 |
- sed -i "${sed_args[@]}" "${S}"/gcc/config/${config} || die |
760 |
-} |
761 |
- |
762 |
-gcc_version_patch() { |
763 |
- # gcc-4.3+ has configure flags (whoo!) |
764 |
- tc_version_is_at_least 4.3 && return 0 |
765 |
- |
766 |
- local version_string=${GCC_CONFIG_VER} |
767 |
- [[ -n ${BRANCH_UPDATE} ]] && version_string+=" ${BRANCH_UPDATE}" |
768 |
- |
769 |
- einfo "patching gcc version: ${version_string} (${BRANDING_GCC_PKGVERSION})" |
770 |
- |
771 |
- local gcc_sed=( -e 's:gcc\.gnu\.org/bugs\.html:bugs\.gentoo\.org/:' ) |
772 |
- if grep -qs VERSUFFIX "${S}"/gcc/version.c ; then |
773 |
- gcc_sed+=( -e "/VERSUFFIX \"\"/s:\"\":\" (${BRANDING_GCC_PKGVERSION})\":" ) |
774 |
- else |
775 |
- version_string="${version_string} (${BRANDING_GCC_PKGVERSION})" |
776 |
- gcc_sed+=( -e "/const char version_string\[\] = /s:= \".*\":= \"${version_string}\":" ) |
777 |
- fi |
778 |
- sed -i "${gcc_sed[@]}" "${S}"/gcc/version.c || die |
779 |
-} |
780 |
- |
781 |
-do_gcc_rename_java_bins() { |
782 |
- # bug #139918 - conflict between gcc and java-config-2 for ownership of |
783 |
- # /usr/bin/rmi{c,registry}. Done with mv & sed rather than a patch |
784 |
- # because patches would be large (thanks to the rename of man files), |
785 |
- # and it's clear from the sed invocations that all that changes is the |
786 |
- # rmi{c,registry} names to grmi{c,registry} names. |
787 |
- # Kevin F. Quinn 2006-07-12 |
788 |
- einfo "Renaming jdk executables rmic and rmiregistry to grmic and grmiregistry." |
789 |
- # 1) Move the man files if present (missing prior to gcc-3.4) |
790 |
- for manfile in rmic rmiregistry ; do |
791 |
- [[ -f ${S}/gcc/doc/${manfile}.1 ]] || continue |
792 |
- mv "${S}"/gcc/doc/${manfile}.1 "${S}"/gcc/doc/g${manfile}.1 |
793 |
- done |
794 |
- # 2) Fixup references in the docs if present (mission prior to gcc-3.4) |
795 |
- for jfile in gcc/doc/gcj.info gcc/doc/grmic.1 gcc/doc/grmiregistry.1 gcc/java/gcj.texi ; do |
796 |
- [[ -f ${S}/${jfile} ]] || continue |
797 |
- sed -i -e 's:rmiregistry:grmiregistry:g' "${S}"/${jfile} || |
798 |
- die "Failed to fixup file ${jfile} for rename to grmiregistry" |
799 |
- sed -i -e 's:rmic:grmic:g' "${S}"/${jfile} || |
800 |
- die "Failed to fixup file ${jfile} for rename to grmic" |
801 |
- done |
802 |
- # 3) Fixup Makefiles to build the changed executable names |
803 |
- # These are present in all 3.x versions, and are the important bit |
804 |
- # to get gcc to build with the new names. |
805 |
- for jfile in libjava/Makefile.am libjava/Makefile.in gcc/java/Make-lang.in ; do |
806 |
- sed -i -e 's:rmiregistry:grmiregistry:g' "${S}"/${jfile} || |
807 |
- die "Failed to fixup file ${jfile} for rename to grmiregistry" |
808 |
- # Careful with rmic on these files; it's also the name of a directory |
809 |
- # which should be left unchanged. Replace occurrences of 'rmic$', |
810 |
- # 'rmic_' and 'rmic '. |
811 |
- sed -i -e 's:rmic\([$_ ]\):grmic\1:g' "${S}"/${jfile} || |
812 |
- die "Failed to fixup file ${jfile} for rename to grmic" |
813 |
- done |
814 |
-} |
815 |
- |
816 |
-#---->> src_configure <<---- |
817 |
- |
818 |
-toolchain_src_configure() { |
819 |
- downgrade_arch_flags |
820 |
- gcc_do_filter_flags |
821 |
- |
822 |
- einfo "CFLAGS=\"${CFLAGS}\"" |
823 |
- einfo "CXXFLAGS=\"${CXXFLAGS}\"" |
824 |
- einfo "LDFLAGS=\"${LDFLAGS}\"" |
825 |
- |
826 |
- # Force internal zip based jar script to avoid random |
827 |
- # issues with 3rd party jar implementations. #384291 |
828 |
- export JAR=no |
829 |
- |
830 |
- # For hardened gcc 4.3 piepatchset to build the hardened specs |
831 |
- # file (build.specs) to use when building gcc. |
832 |
- if ! tc_version_is_at_least 4.4 && want_minispecs ; then |
833 |
- setup_minispecs_gcc_build_specs |
834 |
- fi |
835 |
- |
836 |
- local confgcc=( --host=${CHOST} ) |
837 |
- |
838 |
- if is_crosscompile || tc-is-cross-compiler ; then |
839 |
- # Straight from the GCC install doc: |
840 |
- # "GCC has code to correctly determine the correct value for target |
841 |
- # for nearly all native systems. Therefore, we highly recommend you |
842 |
- # not provide a configure target when configuring a native compiler." |
843 |
- confgcc+=( --target=${CTARGET} ) |
844 |
- fi |
845 |
- [[ -n ${CBUILD} ]] && confgcc+=( --build=${CBUILD} ) |
846 |
- |
847 |
- confgcc+=( |
848 |
- --prefix="${PREFIX}" |
849 |
- --bindir="${BINPATH}" |
850 |
- --includedir="${INCLUDEPATH}" |
851 |
- --datadir="${DATAPATH}" |
852 |
- --mandir="${DATAPATH}/man" |
853 |
- --infodir="${DATAPATH}/info" |
854 |
- --with-gxx-include-dir="${STDCXX_INCDIR}" |
855 |
- ) |
856 |
- |
857 |
- # Stick the python scripts in their own slotted directory (bug #279252) |
858 |
- # |
859 |
- # --with-python-dir=DIR |
860 |
- # Specifies where to install the Python modules used for aot-compile. DIR |
861 |
- # should not include the prefix used in installation. For example, if the |
862 |
- # Python modules are to be installed in /usr/lib/python2.5/site-packages, |
863 |
- # then --with-python-dir=/lib/python2.5/site-packages should be passed. |
864 |
- # |
865 |
- # This should translate into "/share/gcc-data/${CTARGET}/${GCC_CONFIG_VER}/python" |
866 |
- if tc_version_is_at_least 4.4 ; then |
867 |
- confgcc+=( --with-python-dir=${DATAPATH/$PREFIX/}/python ) |
868 |
- fi |
869 |
- |
870 |
- ### language options |
871 |
- |
872 |
- local GCC_LANG="c" |
873 |
- is_cxx && GCC_LANG+=",c++" |
874 |
- is_d && GCC_LANG+=",d" |
875 |
- is_gcj && GCC_LANG+=",java" |
876 |
- is_go && GCC_LANG+=",go" |
877 |
- is_jit && GCC_LANG+=",jit" |
878 |
- if is_objc || is_objcxx ; then |
879 |
- GCC_LANG+=",objc" |
880 |
- if tc_version_is_at_least 4 ; then |
881 |
- use objc-gc && confgcc+=( --enable-objc-gc ) |
882 |
- fi |
883 |
- is_objcxx && GCC_LANG+=",obj-c++" |
884 |
- fi |
885 |
- |
886 |
- # fortran support just got sillier! the lang value can be f77 for |
887 |
- # fortran77, f95 for fortran95, or just plain old fortran for the |
888 |
- # currently supported standard depending on gcc version. |
889 |
- is_fortran && GCC_LANG+=",fortran" |
890 |
- is_f77 && GCC_LANG+=",f77" |
891 |
- is_f95 && GCC_LANG+=",f95" |
892 |
- |
893 |
- # We do NOT want 'ADA support' in here! |
894 |
- # is_ada && GCC_LANG+=",ada" |
895 |
- |
896 |
- confgcc+=( --enable-languages=${GCC_LANG} ) |
897 |
- |
898 |
- ### general options |
899 |
- |
900 |
- confgcc+=( |
901 |
- --enable-obsolete |
902 |
- --enable-secureplt |
903 |
- --disable-werror |
904 |
- --with-system-zlib |
905 |
- ) |
906 |
- |
907 |
- if use nls ; then |
908 |
- confgcc+=( --enable-nls --without-included-gettext ) |
909 |
- else |
910 |
- confgcc+=( --disable-nls ) |
911 |
- fi |
912 |
- |
913 |
- tc_version_is_at_least 3.4 || confgcc+=( --disable-libunwind-exceptions ) |
914 |
- |
915 |
- # Use the default ("release") checking because upstream usually neglects |
916 |
- # to test "disabled" so it has a history of breaking. #317217 |
917 |
- if tc_version_is_at_least 3.4 ; then |
918 |
- # The "release" keyword is new to 4.0. #551636 |
919 |
- local off=$(tc_version_is_at_least 4.0 && echo release || echo no) |
920 |
- confgcc+=( --enable-checking="${GCC_CHECKS_LIST:-$(usex debug yes ${off})}" ) |
921 |
- fi |
922 |
- |
923 |
- # Branding |
924 |
- tc_version_is_at_least 4.3 && confgcc+=( |
925 |
- --with-bugurl=https://bugs.gentoo.org/ |
926 |
- --with-pkgversion="${BRANDING_GCC_PKGVERSION}" |
927 |
- ) |
928 |
- |
929 |
- # If we want hardened support with the newer piepatchset for >=gcc 4.4 |
930 |
- if tc_version_is_at_least 4.4 && want_minispecs ; then |
931 |
- confgcc+=( $(use_enable hardened esp) ) |
932 |
- fi |
933 |
- |
934 |
- # allow gcc to search for clock funcs in the main C lib. |
935 |
- # if it can't find them, then tough cookies -- we aren't |
936 |
- # going to link in -lrt to all C++ apps. #411681 |
937 |
- if tc_version_is_at_least 4.4 && is_cxx ; then |
938 |
- confgcc+=( --enable-libstdcxx-time ) |
939 |
- fi |
940 |
- |
941 |
- # Support to disable pch when building libstdcxx |
942 |
- if tc_version_is_at_least 6.0 && ! use pch ; then |
943 |
- confgcc+=( --disable-libstdcxx-pch ) |
944 |
- fi |
945 |
- |
946 |
- # The jit language requires this. |
947 |
- is_jit && confgcc+=( --enable-host-shared ) |
948 |
- |
949 |
- # # Turn on the -Wl,--build-id flag by default for ELF targets. #525942 |
950 |
- # # This helps with locating debug files. |
951 |
- # case ${CTARGET} in |
952 |
- # *-linux-*|*-elf|*-eabi) |
953 |
- # tc_version_is_at_least 4.5 && confgcc+=( |
954 |
- # --enable-linker-build-id |
955 |
- # ) |
956 |
- # ;; |
957 |
- # esac |
958 |
- |
959 |
- # newer gcc versions like to bootstrap themselves with C++, |
960 |
- # so we need to manually disable it ourselves |
961 |
- if tc_version_is_between 4.7 4.8 && ! is_cxx ; then |
962 |
- confgcc+=( --disable-build-with-cxx --disable-build-poststage1-with-cxx ) |
963 |
- fi |
964 |
- |
965 |
- ### Cross-compiler options |
966 |
- if is_crosscompile ; then |
967 |
- # Enable build warnings by default with cross-compilers when system |
968 |
- # paths are included (e.g. via -I flags). |
969 |
- confgcc+=( --enable-poison-system-directories ) |
970 |
- |
971 |
- # When building a stage1 cross-compiler (just C compiler), we have to |
972 |
- # disable a bunch of features or gcc goes boom |
973 |
- local needed_libc="" |
974 |
- case ${CTARGET} in |
975 |
- *-linux) needed_libc=no-fucking-clue;; |
976 |
- *-dietlibc) needed_libc=dietlibc;; |
977 |
- *-elf|*-eabi) needed_libc=newlib;; |
978 |
- *-freebsd*) needed_libc=freebsd-lib;; |
979 |
- *-gnu*) needed_libc=glibc;; |
980 |
- *-klibc) needed_libc=klibc;; |
981 |
- *-musl*) needed_libc=musl;; |
982 |
- *-uclibc*) |
983 |
- if ! echo '#include <features.h>' | \ |
984 |
- $(tc-getCPP ${CTARGET}) -E -dD - 2>/dev/null | \ |
985 |
- grep -q __HAVE_SHARED__ |
986 |
- then #291870 |
987 |
- confgcc+=( --disable-shared ) |
988 |
- fi |
989 |
- needed_libc=uclibc |
990 |
- ;; |
991 |
- *-cygwin) needed_libc=cygwin;; |
992 |
- x86_64-*-mingw*|\ |
993 |
- *-w64-mingw*) needed_libc=mingw64-runtime;; |
994 |
- mingw*|*-mingw*) needed_libc=mingw-runtime;; |
995 |
- avr) confgcc+=( --enable-shared --disable-threads );; |
996 |
- esac |
997 |
- if [[ -n ${needed_libc} ]] ; then |
998 |
- local confgcc_no_libc=( --disable-shared ) |
999 |
- tc_version_is_at_least 4.8 && confgcc_no_libc+=( --disable-libatomic ) |
1000 |
- if ! has_version ${CATEGORY}/${needed_libc} ; then |
1001 |
- confgcc+=( |
1002 |
- "${confgcc_no_libc[@]}" |
1003 |
- --disable-threads |
1004 |
- --without-headers |
1005 |
- ) |
1006 |
- elif built_with_use --hidden --missing false ${CATEGORY}/${needed_libc} crosscompile_opts_headers-only ; then |
1007 |
- confgcc+=( |
1008 |
- "${confgcc_no_libc[@]}" |
1009 |
- --with-sysroot="${PREFIX}"/${CTARGET} |
1010 |
- ) |
1011 |
- else |
1012 |
- confgcc+=( --with-sysroot="${PREFIX}"/${CTARGET} ) |
1013 |
- fi |
1014 |
- fi |
1015 |
- |
1016 |
- tc_version_is_at_least 4.2 && confgcc+=( --disable-bootstrap ) |
1017 |
- else |
1018 |
- if tc-is-static-only ; then |
1019 |
- confgcc+=( --disable-shared ) |
1020 |
- else |
1021 |
- confgcc+=( --enable-shared ) |
1022 |
- fi |
1023 |
- case ${CHOST} in |
1024 |
- mingw*|*-mingw*|*-cygwin) |
1025 |
- confgcc+=( --enable-threads=win32 ) ;; |
1026 |
- *) |
1027 |
- confgcc+=( --enable-threads=posix ) ;; |
1028 |
- esac |
1029 |
- fi |
1030 |
- |
1031 |
- # __cxa_atexit is "essential for fully standards-compliant handling of |
1032 |
- # destructors", but apparently requires glibc. |
1033 |
- case ${CTARGET} in |
1034 |
- *-uclibc*) |
1035 |
- confgcc+=( |
1036 |
- --disable-__cxa_atexit |
1037 |
- $(use_enable nptl tls) |
1038 |
- ) |
1039 |
- tc_version_is_between 3.3 3.4 && confgcc+=( --enable-sjlj-exceptions ) |
1040 |
- if tc_version_is_between 3.4 4.3 ; then |
1041 |
- confgcc+=( --enable-clocale=uclibc ) |
1042 |
- fi |
1043 |
- ;; |
1044 |
- *-elf|*-eabi) |
1045 |
- confgcc+=( --with-newlib ) |
1046 |
- ;; |
1047 |
- *-gnu*) |
1048 |
- confgcc+=( |
1049 |
- --enable-__cxa_atexit |
1050 |
- --enable-clocale=gnu |
1051 |
- ) |
1052 |
- ;; |
1053 |
- *-freebsd*) |
1054 |
- confgcc+=( --enable-__cxa_atexit ) |
1055 |
- ;; |
1056 |
- *-solaris*) |
1057 |
- confgcc+=( --enable-__cxa_atexit ) |
1058 |
- ;; |
1059 |
- esac |
1060 |
- |
1061 |
- ### arch options |
1062 |
- |
1063 |
- gcc-multilib-configure |
1064 |
- |
1065 |
- # ppc altivec support |
1066 |
- confgcc+=( $(use_enable altivec) ) |
1067 |
- |
1068 |
- # gcc has fixed-point arithmetic support in 4.3 for mips targets that can |
1069 |
- # significantly increase compile time by several hours. This will allow |
1070 |
- # users to control this feature in the event they need the support. |
1071 |
- tc_version_is_at_least 4.3 && confgcc+=( $(use_enable fixed-point) ) |
1072 |
- |
1073 |
- case $(tc-is-softfloat) in |
1074 |
- yes) confgcc+=( --with-float=soft ) ;; |
1075 |
- softfp) confgcc+=( --with-float=softfp ) ;; |
1076 |
- *) |
1077 |
- # If they've explicitly opt-ed in, do hardfloat, |
1078 |
- # otherwise let the gcc default kick in. |
1079 |
- case ${CTARGET//_/-} in |
1080 |
- *-hardfloat-*|*eabihf) confgcc+=( --with-float=hard ) ;; |
1081 |
- esac |
1082 |
- esac |
1083 |
- |
1084 |
- local with_abi_map=() |
1085 |
- case $(tc-arch) in |
1086 |
- arm) #264534 #414395 |
1087 |
- local a arm_arch=${CTARGET%%-*} |
1088 |
- # Remove trailing endian variations first: eb el be bl b l |
1089 |
- for a in e{b,l} {b,l}e b l ; do |
1090 |
- if [[ ${arm_arch} == *${a} ]] ; then |
1091 |
- arm_arch=${arm_arch%${a}} |
1092 |
- break |
1093 |
- fi |
1094 |
- done |
1095 |
- # Convert armv7{a,r,m} to armv7-{a,r,m} |
1096 |
- [[ ${arm_arch} == armv7? ]] && arm_arch=${arm_arch/7/7-} |
1097 |
- # See if this is a valid --with-arch flag |
1098 |
- if (srcdir=${S}/gcc target=${CTARGET} with_arch=${arm_arch}; |
1099 |
- . "${srcdir}"/config.gcc) &>/dev/null |
1100 |
- then |
1101 |
- confgcc+=( --with-arch=${arm_arch} ) |
1102 |
- fi |
1103 |
- |
1104 |
- # Make default mode thumb for microcontroller classes #418209 |
1105 |
- [[ ${arm_arch} == *-m ]] && confgcc+=( --with-mode=thumb ) |
1106 |
- |
1107 |
- # Enable hardvfp |
1108 |
- if [[ $(tc-is-softfloat) == "no" ]] && \ |
1109 |
- [[ ${CTARGET} == armv[67]* ]] && \ |
1110 |
- tc_version_is_at_least 4.5 |
1111 |
- then |
1112 |
- # Follow the new arm hardfp distro standard by default |
1113 |
- confgcc+=( --with-float=hard ) |
1114 |
- case ${CTARGET} in |
1115 |
- armv6*) confgcc+=( --with-fpu=vfp ) ;; |
1116 |
- armv7*) confgcc+=( --with-fpu=vfpv3-d16 ) ;; |
1117 |
- esac |
1118 |
- fi |
1119 |
- ;; |
1120 |
- mips) |
1121 |
- # Add --with-abi flags to set default ABI |
1122 |
- confgcc+=( --with-abi=$(gcc-abi-map ${TARGET_DEFAULT_ABI}) ) |
1123 |
- ;; |
1124 |
- amd64) |
1125 |
- # drop the older/ABI checks once this get's merged into some |
1126 |
- # version of gcc upstream |
1127 |
- if tc_version_is_at_least 4.8 && has x32 $(get_all_abis TARGET) ; then |
1128 |
- confgcc+=( --with-abi=$(gcc-abi-map ${TARGET_DEFAULT_ABI}) ) |
1129 |
- fi |
1130 |
- ;; |
1131 |
- x86) |
1132 |
- # Default arch for x86 is normally i386, lets give it a bump |
1133 |
- # since glibc will do so based on CTARGET anyways |
1134 |
- confgcc+=( --with-arch=${CTARGET%%-*} ) |
1135 |
- ;; |
1136 |
- hppa) |
1137 |
- # Enable sjlj exceptions for backward compatibility on hppa |
1138 |
- [[ ${GCCMAJOR} == "3" ]] && confgcc+=( --enable-sjlj-exceptions ) |
1139 |
- ;; |
1140 |
- ppc) |
1141 |
- # Set up defaults based on current CFLAGS |
1142 |
- is-flagq -mfloat-gprs=double && confgcc+=( --enable-e500-double ) |
1143 |
- [[ ${CTARGET//_/-} == *-e500v2-* ]] && confgcc+=( --enable-e500-double ) |
1144 |
- ;; |
1145 |
- esac |
1146 |
- |
1147 |
- # if the target can do biarch (-m32/-m64), enable it. overhead should |
1148 |
- # be small, and should simplify building of 64bit kernels in a 32bit |
1149 |
- # userland by not needing sys-devel/kgcc64. #349405 |
1150 |
- case $(tc-arch) in |
1151 |
- ppc|ppc64) tc_version_is_at_least 3.4 && confgcc+=( --enable-targets=all ) ;; |
1152 |
- sparc) tc_version_is_at_least 4.4 && confgcc+=( --enable-targets=all ) ;; |
1153 |
- amd64|x86) tc_version_is_at_least 4.3 && confgcc+=( --enable-targets=all ) ;; |
1154 |
- esac |
1155 |
- |
1156 |
- # On Darwin we need libdir to be set in order to get correct install names |
1157 |
- # for things like libobjc-gnu, libgcj and libfortran. If we enable it on |
1158 |
- # non-Darwin we screw up the behaviour this eclass relies on. We in |
1159 |
- # particular need this over --libdir for bug #255315. |
1160 |
- [[ ${CTARGET} == *-darwin* ]] && \ |
1161 |
- confgcc+=( --enable-version-specific-runtime-libs ) |
1162 |
- |
1163 |
- ### library options |
1164 |
- |
1165 |
- if ! is_gcj ; then |
1166 |
- confgcc+=( --disable-libgcj ) |
1167 |
- elif use awt ; then |
1168 |
- confgcc+=( --enable-java-awt=gtk ) |
1169 |
- fi |
1170 |
- |
1171 |
- if tc_version_is_at_least 4.2 ; then |
1172 |
- if in_iuse openmp ; then |
1173 |
- # Make sure target has pthreads support. #326757 #335883 |
1174 |
- # There shouldn't be a chicken & egg problem here as openmp won't |
1175 |
- # build without a C library, and you can't build that w/out |
1176 |
- # already having a compiler ... |
1177 |
- if ! is_crosscompile || \ |
1178 |
- $(tc-getCPP ${CTARGET}) -E - <<<"#include <pthread.h>" >& /dev/null |
1179 |
- then |
1180 |
- confgcc+=( $(use_enable openmp libgomp) ) |
1181 |
- else |
1182 |
- # Force disable as the configure script can be dumb #359855 |
1183 |
- confgcc+=( --disable-libgomp ) |
1184 |
- fi |
1185 |
- else |
1186 |
- # For gcc variants where we don't want openmp (e.g. kgcc) |
1187 |
- confgcc+=( --disable-libgomp ) |
1188 |
- fi |
1189 |
- fi |
1190 |
- |
1191 |
- if tc_version_is_at_least 4.0 ; then |
1192 |
- if in_iuse mudflap ; then |
1193 |
- confgcc+=( $(use_enable mudflap libmudflap) ) |
1194 |
- else |
1195 |
- confgcc+=( --disable-libmudflap ) |
1196 |
- fi |
1197 |
- |
1198 |
- if use_if_iuse libssp ; then |
1199 |
- confgcc+=( --enable-libssp ) |
1200 |
- else |
1201 |
- if hardened_gcc_is_stable ssp; then |
1202 |
- export gcc_cv_libc_provides_ssp=yes |
1203 |
- fi |
1204 |
- confgcc+=( --disable-libssp ) |
1205 |
- fi |
1206 |
- fi |
1207 |
- |
1208 |
- if in_iuse cilk ; then |
1209 |
- confgcc+=( $(use_enable cilk libcilkrts) ) |
1210 |
- fi |
1211 |
- |
1212 |
- if in_iuse mpx ; then |
1213 |
- confgcc+=( $(use_enable mpx libmpx) ) |
1214 |
- fi |
1215 |
- |
1216 |
- if in_iuse vtv ; then |
1217 |
- confgcc+=( |
1218 |
- $(use_enable vtv vtable-verify) |
1219 |
- $(use_enable vtv libvtv) |
1220 |
- ) |
1221 |
- fi |
1222 |
- |
1223 |
- # newer gcc's come with libquadmath, but only fortran uses |
1224 |
- # it, so auto punt it when we don't care |
1225 |
- if tc_version_is_at_least 4.6 && ! is_fortran ; then |
1226 |
- confgcc+=( --disable-libquadmath ) |
1227 |
- fi |
1228 |
- |
1229 |
- if tc_version_is_at_least 4.6 ; then |
1230 |
- confgcc+=( --enable-lto ) |
1231 |
- elif tc_version_is_at_least 4.5 ; then |
1232 |
- confgcc+=( --disable-lto ) |
1233 |
- fi |
1234 |
- |
1235 |
- # graphite was added in 4.4 but we only support it in 4.8+ due to external |
1236 |
- # library issues. #448024 |
1237 |
- if tc_version_is_at_least 5.0 ; then |
1238 |
- confgcc+=( $(use_with graphite isl) ) |
1239 |
- use graphite && confgcc+=( --disable-isl-version-check ) |
1240 |
- elif tc_version_is_at_least 4.8 ; then |
1241 |
- confgcc+=( $(use_with graphite cloog) ) |
1242 |
- use graphite && confgcc+=( --disable-isl-version-check ) |
1243 |
- elif tc_version_is_at_least 4.4 ; then |
1244 |
- confgcc+=( --without-{cloog,ppl} ) |
1245 |
- fi |
1246 |
- |
1247 |
- if tc_version_is_at_least 4.8 ; then |
1248 |
- confgcc+=( $(use_enable sanitize libsanitizer) ) |
1249 |
- fi |
1250 |
- |
1251 |
- if tc_version_is_at_least 6.0 ; then |
1252 |
- confgcc+=( |
1253 |
- $(use_enable pie default-pie) |
1254 |
- # This defaults to -fstack-protector-strong. |
1255 |
- $(use_enable ssp default-ssp) |
1256 |
- ) |
1257 |
- fi |
1258 |
- |
1259 |
- # Disable gcc info regeneration -- it ships with generated info pages |
1260 |
- # already. Our custom version/urls/etc... trigger it. #464008 |
1261 |
- export gcc_cv_prog_makeinfo_modern=no |
1262 |
- |
1263 |
- # Do not let the X detection get in our way. We know things can be found |
1264 |
- # via system paths, so no need to hardcode things that'll break multilib. |
1265 |
- # Older gcc versions will detect ac_x_libraries=/usr/lib64 which ends up |
1266 |
- # killing the 32bit builds which want /usr/lib. |
1267 |
- export ac_cv_have_x='have_x=yes ac_x_includes= ac_x_libraries=' |
1268 |
- |
1269 |
- confgcc+=( "$@" ${EXTRA_ECONF} ) |
1270 |
- |
1271 |
- # Nothing wrong with a good dose of verbosity |
1272 |
- echo |
1273 |
- einfo "PREFIX: ${PREFIX}" |
1274 |
- einfo "BINPATH: ${BINPATH}" |
1275 |
- einfo "LIBPATH: ${LIBPATH}" |
1276 |
- einfo "DATAPATH: ${DATAPATH}" |
1277 |
- einfo "STDCXX_INCDIR: ${STDCXX_INCDIR}" |
1278 |
- echo |
1279 |
- einfo "Languages: ${GCC_LANG}" |
1280 |
- echo |
1281 |
- einfo "Configuring GCC with: ${confgcc[@]//--/\n\t--}" |
1282 |
- echo |
1283 |
- |
1284 |
- # Build in a separate build tree |
1285 |
- mkdir -p "${WORKDIR}"/build |
1286 |
- pushd "${WORKDIR}"/build > /dev/null |
1287 |
- |
1288 |
- # and now to do the actual configuration |
1289 |
- addwrite /dev/zero |
1290 |
- echo "${S}"/configure "${confgcc[@]}" |
1291 |
- # Older gcc versions did not detect bash and re-exec itself, so force the |
1292 |
- # use of bash. Newer ones will auto-detect, but this is not harmeful. |
1293 |
- CONFIG_SHELL="${EPREFIX}/bin/bash" \ |
1294 |
- bash "${S}"/configure "${confgcc[@]}" || die "failed to run configure" |
1295 |
- |
1296 |
- # return to whatever directory we were in before |
1297 |
- popd > /dev/null |
1298 |
-} |
1299 |
- |
1300 |
-# Replace -m flags unsupported by the version being built with the best |
1301 |
-# available equivalent |
1302 |
-downgrade_arch_flags() { |
1303 |
- local arch bver i isa myarch mytune rep ver |
1304 |
- |
1305 |
- bver=${1:-${GCC_BRANCH_VER}} |
1306 |
- [[ $(gcc-version) < ${bver} ]] && return 0 |
1307 |
- [[ $(tc-arch) != amd64 && $(tc-arch) != x86 ]] && return 0 |
1308 |
- |
1309 |
- myarch=$(get-flag march) |
1310 |
- mytune=$(get-flag mtune) |
1311 |
- |
1312 |
- # If -march=native isn't supported we have to tease out the actual arch |
1313 |
- if [[ ${myarch} == native || ${mytune} == native ]] ; then |
1314 |
- if [[ ${bver} < 4.2 ]] ; then |
1315 |
- arch=$($(tc-getCC) -march=native -v -E -P - </dev/null 2>&1 \ |
1316 |
- | sed -rn "/cc1.*-march/s:.*-march=([^ ']*).*:\1:p") |
1317 |
- replace-cpu-flags native ${arch} |
1318 |
- fi |
1319 |
- fi |
1320 |
- |
1321 |
- # Handle special -mtune flags |
1322 |
- [[ ${mytune} == intel && ${bver} < 4.9 ]] && replace-cpu-flags intel generic |
1323 |
- [[ ${mytune} == generic && ${bver} < 4.2 ]] && filter-flags '-mtune=*' |
1324 |
- [[ ${mytune} == x86-64 ]] && filter-flags '-mtune=*' |
1325 |
- [[ ${bver} < 3.4 ]] && filter-flags '-mtune=*' |
1326 |
- |
1327 |
- # "added" "arch" "replacement" |
1328 |
- local archlist=( |
1329 |
- 4.9 bdver4 bdver3 |
1330 |
- 4.9 bonnell atom |
1331 |
- 4.9 broadwell core-avx2 |
1332 |
- 4.9 haswell core-avx2 |
1333 |
- 4.9 ivybridge core-avx-i |
1334 |
- 4.9 nehalem corei7 |
1335 |
- 4.9 sandybridge corei7-avx |
1336 |
- 4.9 silvermont corei7 |
1337 |
- 4.9 westmere corei7 |
1338 |
- 4.8 bdver3 bdver2 |
1339 |
- 4.8 btver2 btver1 |
1340 |
- 4.7 bdver2 bdver1 |
1341 |
- 4.7 core-avx2 core-avx-i |
1342 |
- 4.6 bdver1 amdfam10 |
1343 |
- 4.6 btver1 amdfam10 |
1344 |
- 4.6 core-avx-i core2 |
1345 |
- 4.6 corei7 core2 |
1346 |
- 4.6 corei7-avx core2 |
1347 |
- 4.5 atom core2 |
1348 |
- 4.3 amdfam10 k8 |
1349 |
- 4.3 athlon64-sse3 k8 |
1350 |
- 4.3 barcelona k8 |
1351 |
- 4.3 core2 nocona |
1352 |
- 4.3 geode k6-2 # gcc.gnu.org/PR41989#c22 |
1353 |
- 4.3 k8-sse3 k8 |
1354 |
- 4.3 opteron-sse3 k8 |
1355 |
- 3.4 athlon-fx x86-64 |
1356 |
- 3.4 athlon64 x86-64 |
1357 |
- 3.4 c3-2 c3 |
1358 |
- 3.4 k8 x86-64 |
1359 |
- 3.4 opteron x86-64 |
1360 |
- 3.4 pentium-m pentium3 |
1361 |
- 3.4 pentium3m pentium3 |
1362 |
- 3.4 pentium4m pentium4 |
1363 |
- ) |
1364 |
- |
1365 |
- for ((i = 0; i < ${#archlist[@]}; i += 3)) ; do |
1366 |
- myarch=$(get-flag march) |
1367 |
- mytune=$(get-flag mtune) |
1368 |
- |
1369 |
- ver=${archlist[i]} |
1370 |
- arch=${archlist[i + 1]} |
1371 |
- rep=${archlist[i + 2]} |
1372 |
- |
1373 |
- [[ ${myarch} != ${arch} && ${mytune} != ${arch} ]] && continue |
1374 |
- |
1375 |
- if [[ ${ver} > ${bver} ]] ; then |
1376 |
- einfo "Replacing ${myarch} (added in gcc ${ver}) with ${rep}..." |
1377 |
- [[ ${myarch} == ${arch} ]] && replace-cpu-flags ${myarch} ${rep} |
1378 |
- [[ ${mytune} == ${arch} ]] && replace-cpu-flags ${mytune} ${rep} |
1379 |
- continue |
1380 |
- else |
1381 |
- break |
1382 |
- fi |
1383 |
- done |
1384 |
- |
1385 |
- # we only check -mno* here since -m* get removed by strip-flags later on |
1386 |
- local isalist=( |
1387 |
- 4.9 -mno-sha |
1388 |
- 4.9 -mno-avx512pf |
1389 |
- 4.9 -mno-avx512f |
1390 |
- 4.9 -mno-avx512er |
1391 |
- 4.9 -mno-avx512cd |
1392 |
- 4.8 -mno-xsaveopt |
1393 |
- 4.8 -mno-xsave |
1394 |
- 4.8 -mno-rtm |
1395 |
- 4.8 -mno-fxsr |
1396 |
- 4.7 -mno-lzcnt |
1397 |
- 4.7 -mno-bmi2 |
1398 |
- 4.7 -mno-avx2 |
1399 |
- 4.6 -mno-tbm |
1400 |
- 4.6 -mno-rdrnd |
1401 |
- 4.6 -mno-fsgsbase |
1402 |
- 4.6 -mno-f16c |
1403 |
- 4.6 -mno-bmi |
1404 |
- 4.5 -mno-xop |
1405 |
- 4.5 -mno-movbe |
1406 |
- 4.5 -mno-lwp |
1407 |
- 4.5 -mno-fma4 |
1408 |
- 4.4 -mno-pclmul |
1409 |
- 4.4 -mno-fma |
1410 |
- 4.4 -mno-avx |
1411 |
- 4.4 -mno-aes |
1412 |
- 4.3 -mno-ssse3 |
1413 |
- 4.3 -mno-sse4a |
1414 |
- 4.3 -mno-sse4 |
1415 |
- 4.3 -mno-sse4.2 |
1416 |
- 4.3 -mno-sse4.1 |
1417 |
- 4.3 -mno-popcnt |
1418 |
- 4.3 -mno-abm |
1419 |
- ) |
1420 |
- |
1421 |
- for ((i = 0; i < ${#isalist[@]}; i += 2)) ; do |
1422 |
- ver=${isalist[i]} |
1423 |
- isa=${isalist[i + 1]} |
1424 |
- [[ ${ver} > ${bver} ]] && filter-flags ${isa} ${isa/-m/-mno-} |
1425 |
- done |
1426 |
-} |
1427 |
- |
1428 |
-gcc_do_filter_flags() { |
1429 |
- strip-flags |
1430 |
- replace-flags -O? -O2 |
1431 |
- |
1432 |
- # dont want to funk ourselves |
1433 |
- filter-flags '-mabi*' -m31 -m32 -m64 |
1434 |
- |
1435 |
- filter-flags -frecord-gcc-switches # 490738 |
1436 |
- filter-flags -mno-rtm -mno-htm # 506202 |
1437 |
- |
1438 |
- if tc_version_is_between 3.2 3.4 ; then |
1439 |
- # XXX: this is so outdated it's barely useful, but it don't hurt... |
1440 |
- replace-cpu-flags G3 750 |
1441 |
- replace-cpu-flags G4 7400 |
1442 |
- replace-cpu-flags G5 7400 |
1443 |
- |
1444 |
- # XXX: should add a sed or something to query all supported flags |
1445 |
- # from the gcc source and trim everything else ... |
1446 |
- filter-flags -f{no-,}unit-at-a-time -f{no-,}web -mno-tls-direct-seg-refs |
1447 |
- filter-flags -f{no-,}stack-protector{,-all} |
1448 |
- filter-flags -fvisibility-inlines-hidden -fvisibility=hidden |
1449 |
- fi |
1450 |
- |
1451 |
- if tc_version_is_at_least 3.4 ; then |
1452 |
- case $(tc-arch) in |
1453 |
- amd64|x86) |
1454 |
- filter-flags '-mcpu=*' |
1455 |
- |
1456 |
- tc_version_is_between 4.4 4.5 && append-flags -mno-avx # 357287 |
1457 |
- |
1458 |
- if tc_version_is_between 4.6 4.7 ; then |
1459 |
- # https://bugs.gentoo.org/411333 |
1460 |
- # https://bugs.gentoo.org/466454 |
1461 |
- replace-cpu-flags c3-2 pentium2 pentium3 pentium3m pentium-m i686 |
1462 |
- fi |
1463 |
- ;; |
1464 |
- alpha) |
1465 |
- # https://bugs.gentoo.org/454426 |
1466 |
- append-ldflags -Wl,--no-relax |
1467 |
- ;; |
1468 |
- sparc) |
1469 |
- # temporary workaround for random ICEs reproduced by multiple users |
1470 |
- # https://bugs.gentoo.org/457062 |
1471 |
- tc_version_is_between 4.6 4.8 && MAKEOPTS+=" -j1" |
1472 |
- ;; |
1473 |
- *-macos) |
1474 |
- # http://gcc.gnu.org/PR25127 |
1475 |
- tc_version_is_between 4.0 4.2 && \ |
1476 |
- filter-flags '-mcpu=*' '-march=*' '-mtune=*' |
1477 |
- ;; |
1478 |
- esac |
1479 |
- fi |
1480 |
- |
1481 |
- strip-unsupported-flags |
1482 |
- |
1483 |
- # these are set here so we have something sane at configure time |
1484 |
- if is_crosscompile ; then |
1485 |
- # Set this to something sane for both native and target |
1486 |
- CFLAGS="-O2 -pipe" |
1487 |
- FFLAGS=${CFLAGS} |
1488 |
- FCFLAGS=${CFLAGS} |
1489 |
- |
1490 |
- local VAR="CFLAGS_"${CTARGET//-/_} |
1491 |
- CXXFLAGS=${!VAR} |
1492 |
- fi |
1493 |
- |
1494 |
- export GCJFLAGS=${GCJFLAGS:-${CFLAGS}} |
1495 |
-} |
1496 |
- |
1497 |
-setup_minispecs_gcc_build_specs() { |
1498 |
- # Setup the "build.specs" file for gcc 4.3 to use when building. |
1499 |
- if hardened_gcc_works pie ; then |
1500 |
- cat "${WORKDIR}"/specs/pie.specs >> "${WORKDIR}"/build.specs |
1501 |
- fi |
1502 |
- if hardened_gcc_works ssp ; then |
1503 |
- for s in ssp sspall ; do |
1504 |
- cat "${WORKDIR}"/specs/${s}.specs >> "${WORKDIR}"/build.specs |
1505 |
- done |
1506 |
- fi |
1507 |
- for s in nostrict znow ; do |
1508 |
- cat "${WORKDIR}"/specs/${s}.specs >> "${WORKDIR}"/build.specs |
1509 |
- done |
1510 |
- export GCC_SPECS="${WORKDIR}"/build.specs |
1511 |
-} |
1512 |
- |
1513 |
-gcc-multilib-configure() { |
1514 |
- if ! is_multilib ; then |
1515 |
- confgcc+=( --disable-multilib ) |
1516 |
- # Fun times: if we are building for a target that has multiple |
1517 |
- # possible ABI formats, and the user has told us to pick one |
1518 |
- # that isn't the default, then not specifying it via the list |
1519 |
- # below will break that on us. |
1520 |
- else |
1521 |
- confgcc+=( --enable-multilib ) |
1522 |
- fi |
1523 |
- |
1524 |
- # translate our notion of multilibs into gcc's |
1525 |
- local abi list |
1526 |
- for abi in $(get_all_abis TARGET) ; do |
1527 |
- local l=$(gcc-abi-map ${abi}) |
1528 |
- [[ -n ${l} ]] && list+=",${l}" |
1529 |
- done |
1530 |
- if [[ -n ${list} ]] ; then |
1531 |
- case ${CTARGET} in |
1532 |
- x86_64*) |
1533 |
- tc_version_is_at_least 4.8 && confgcc+=( --with-multilib-list=${list:1} ) |
1534 |
- ;; |
1535 |
- esac |
1536 |
- fi |
1537 |
-} |
1538 |
- |
1539 |
-gcc-abi-map() { |
1540 |
- # Convert the ABI name we use in Gentoo to what gcc uses |
1541 |
- local map=() |
1542 |
- case ${CTARGET} in |
1543 |
- mips*) map=("o32 32" "n32 n32" "n64 64") ;; |
1544 |
- x86_64*) map=("amd64 m64" "x86 m32" "x32 mx32") ;; |
1545 |
- esac |
1546 |
- |
1547 |
- local m |
1548 |
- for m in "${map[@]}" ; do |
1549 |
- l=( ${m} ) |
1550 |
- [[ $1 == ${l[0]} ]] && echo ${l[1]} && break |
1551 |
- done |
1552 |
-} |
1553 |
- |
1554 |
-#----> src_compile <---- |
1555 |
- |
1556 |
-toolchain_src_compile() { |
1557 |
- touch "${S}"/gcc/c-gperf.h |
1558 |
- |
1559 |
- # Do not make manpages if we do not have perl ... |
1560 |
- [[ ! -x /usr/bin/perl ]] \ |
1561 |
- && find "${WORKDIR}"/build -name '*.[17]' -exec touch {} + |
1562 |
- |
1563 |
- gcc_do_make ${GCC_MAKE_TARGET} |
1564 |
-} |
1565 |
- |
1566 |
-gcc_do_make() { |
1567 |
- # This function accepts one optional argument, the make target to be used. |
1568 |
- # If omitted, gcc_do_make will try to guess whether it should use all, |
1569 |
- # or bootstrap-lean depending on CTARGET and arch. |
1570 |
- # An example of how to use this function: |
1571 |
- # |
1572 |
- # gcc_do_make all-target-libstdc++-v3 |
1573 |
- |
1574 |
- [[ -n ${1} ]] && GCC_MAKE_TARGET=${1} |
1575 |
- |
1576 |
- # default target |
1577 |
- if is_crosscompile || tc-is-cross-compiler ; then |
1578 |
- # 3 stage bootstrapping doesnt quite work when you cant run the |
1579 |
- # resulting binaries natively ^^; |
1580 |
- GCC_MAKE_TARGET=${GCC_MAKE_TARGET-all} |
1581 |
- else |
1582 |
- GCC_MAKE_TARGET=${GCC_MAKE_TARGET-bootstrap-lean} |
1583 |
- fi |
1584 |
- |
1585 |
- # Older versions of GCC could not do profiledbootstrap in parallel due to |
1586 |
- # collisions with profiling info. |
1587 |
- # boundschecking also seems to introduce parallel build issues. |
1588 |
- if [[ ${GCC_MAKE_TARGET} == "profiledbootstrap" ]] || use_if_iuse boundschecking ; then |
1589 |
- ! tc_version_is_at_least 4.6 && export MAKEOPTS="${MAKEOPTS} -j1" |
1590 |
- fi |
1591 |
- |
1592 |
- if [[ ${GCC_MAKE_TARGET} == "all" ]] ; then |
1593 |
- STAGE1_CFLAGS=${STAGE1_CFLAGS-"${CFLAGS}"} |
1594 |
- elif [[ $(gcc-version) == "3.4" && ${GCC_BRANCH_VER} == "3.4" ]] && gcc-specs-ssp ; then |
1595 |
- # See bug #79852 |
1596 |
- STAGE1_CFLAGS=${STAGE1_CFLAGS-"-O2"} |
1597 |
- fi |
1598 |
- |
1599 |
- if is_crosscompile; then |
1600 |
- # In 3.4, BOOT_CFLAGS is never used on a crosscompile... |
1601 |
- # but I'll leave this in anyways as someone might have had |
1602 |
- # some reason for putting it in here... --eradicator |
1603 |
- BOOT_CFLAGS=${BOOT_CFLAGS-"-O2"} |
1604 |
- else |
1605 |
- # we only want to use the system's CFLAGS if not building a |
1606 |
- # cross-compiler. |
1607 |
- BOOT_CFLAGS=${BOOT_CFLAGS-"$(get_abi_CFLAGS ${TARGET_DEFAULT_ABI}) ${CFLAGS}"} |
1608 |
- fi |
1609 |
- |
1610 |
- einfo "Compiling ${PN} (${GCC_MAKE_TARGET})..." |
1611 |
- |
1612 |
- pushd "${WORKDIR}"/build >/dev/null |
1613 |
- |
1614 |
- emake \ |
1615 |
- LDFLAGS="${LDFLAGS}" \ |
1616 |
- STAGE1_CFLAGS="${STAGE1_CFLAGS}" \ |
1617 |
- LIBPATH="${LIBPATH}" \ |
1618 |
- BOOT_CFLAGS="${BOOT_CFLAGS}" \ |
1619 |
- ${GCC_MAKE_TARGET} \ |
1620 |
- || die "emake failed with ${GCC_MAKE_TARGET}" |
1621 |
- |
1622 |
- if ! is_crosscompile && use cxx && use_if_iuse doc ; then |
1623 |
- if type -p doxygen > /dev/null ; then |
1624 |
- if tc_version_is_at_least 4.3 ; then |
1625 |
- cd "${CTARGET}"/libstdc++-v3/doc |
1626 |
- emake doc-man-doxygen || ewarn "failed to make docs" |
1627 |
- elif tc_version_is_at_least 3.0 ; then |
1628 |
- cd "${CTARGET}"/libstdc++-v3 |
1629 |
- emake doxygen-man || ewarn "failed to make docs" |
1630 |
- fi |
1631 |
- # Clean bogus manpages. #113902 |
1632 |
- find -name '*_build_*' -delete |
1633 |
- # Blow away generated directory references. Newer versions of gcc |
1634 |
- # have gotten better at this, but not perfect. This is easier than |
1635 |
- # backporting all of the various doxygen patches. #486754 |
1636 |
- find -name '*_.3' -exec grep -l ' Directory Reference ' {} + | \ |
1637 |
- xargs rm -f |
1638 |
- else |
1639 |
- ewarn "Skipping libstdc++ manpage generation since you don't have doxygen installed" |
1640 |
- fi |
1641 |
- fi |
1642 |
- |
1643 |
- popd >/dev/null |
1644 |
-} |
1645 |
- |
1646 |
-#---->> src_test <<---- |
1647 |
- |
1648 |
-toolchain_src_test() { |
1649 |
- if use regression-test ; then |
1650 |
- cd "${WORKDIR}"/build |
1651 |
- emake -k check |
1652 |
- fi |
1653 |
-} |
1654 |
- |
1655 |
-#---->> src_install <<---- |
1656 |
- |
1657 |
-toolchain_src_install() { |
1658 |
- cd "${WORKDIR}"/build |
1659 |
- |
1660 |
- # Do allow symlinks in private gcc include dir as this can break the build |
1661 |
- find gcc/include*/ -type l -delete |
1662 |
- |
1663 |
- # Copy over the info pages. We disabled their generation earlier, but the |
1664 |
- # build system only expects to install out of the build dir, not the source. #464008 |
1665 |
- mkdir -p gcc/doc |
1666 |
- local x= |
1667 |
- for x in "${S}"/gcc/doc/*.info* ; do |
1668 |
- if [[ -f ${x} ]] ; then |
1669 |
- cp "${x}" gcc/doc/ || die |
1670 |
- fi |
1671 |
- done |
1672 |
- |
1673 |
- # We remove the generated fixincludes, as they can cause things to break |
1674 |
- # (ncurses, openssl, etc). We do not prevent them from being built, as |
1675 |
- # in the following commit which we revert: |
1676 |
- # https://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/eclass/toolchain.eclass?r1=1.647&r2=1.648 |
1677 |
- # This is because bsd userland needs fixedincludes to build gcc, while |
1678 |
- # linux does not. Both can dispose of them afterwards. |
1679 |
- while read x ; do |
1680 |
- grep -q 'It has been auto-edited by fixincludes from' "${x}" \ |
1681 |
- && rm -f "${x}" |
1682 |
- done < <(find gcc/include*/ -name '*.h') |
1683 |
- |
1684 |
- # Do the 'make install' from the build directory |
1685 |
- S="${WORKDIR}"/build emake -j1 DESTDIR="${D}" install || die |
1686 |
- |
1687 |
- # Punt some tools which are really only useful while building gcc |
1688 |
- find "${D}" -name install-tools -prune -type d -exec rm -rf "{}" \; |
1689 |
- # This one comes with binutils |
1690 |
- find "${D}" -name libiberty.a -delete |
1691 |
- |
1692 |
- # Move the libraries to the proper location |
1693 |
- gcc_movelibs |
1694 |
- |
1695 |
- # Basic sanity check |
1696 |
- if ! is_crosscompile ; then |
1697 |
- local EXEEXT |
1698 |
- eval $(grep ^EXEEXT= "${WORKDIR}"/build/gcc/config.log) |
1699 |
- [[ -r ${D}${BINPATH}/gcc${EXEEXT} ]] || die "gcc not found in ${D}" |
1700 |
- fi |
1701 |
- |
1702 |
- dodir /etc/env.d/gcc |
1703 |
- create_gcc_env_entry |
1704 |
- |
1705 |
- # Setup the gcc_env_entry for hardened gcc 4 with minispecs |
1706 |
- want_minispecs && copy_minispecs_gcc_specs |
1707 |
- |
1708 |
- # Make sure we dont have stuff lying around that |
1709 |
- # can nuke multiple versions of gcc |
1710 |
- gcc_slot_java |
1711 |
- |
1712 |
- dodir /usr/bin |
1713 |
- cd "${D}"${BINPATH} |
1714 |
- # Ugh: we really need to auto-detect this list. |
1715 |
- # It's constantly out of date. |
1716 |
- for x in cpp gcc g++ c++ gcov g77 gcj gcjh gfortran gccgo ; do |
1717 |
- # For some reason, g77 gets made instead of ${CTARGET}-g77... |
1718 |
- # this should take care of that |
1719 |
- if [[ -f ${x} ]] ; then |
1720 |
- # In case they're hardlinks, clear out the target first |
1721 |
- # otherwise the mv below will complain. |
1722 |
- rm -f ${CTARGET}-${x} |
1723 |
- mv ${x} ${CTARGET}-${x} |
1724 |
- fi |
1725 |
- |
1726 |
- if [[ -f ${CTARGET}-${x} ]] ; then |
1727 |
- if ! is_crosscompile ; then |
1728 |
- ln -sf ${CTARGET}-${x} ${x} |
1729 |
- dosym ${BINPATH#${EPREFIX}}/${CTARGET}-${x} \ |
1730 |
- /usr/bin/${x}-${GCC_CONFIG_VER} |
1731 |
- fi |
1732 |
- # Create versioned symlinks |
1733 |
- dosym ${BINPATH#${EPREFIX}}/${CTARGET}-${x} \ |
1734 |
- /usr/bin/${CTARGET}-${x}-${GCC_CONFIG_VER} |
1735 |
- fi |
1736 |
- |
1737 |
- if [[ -f ${CTARGET}-${x}-${GCC_CONFIG_VER} ]] ; then |
1738 |
- rm -f ${CTARGET}-${x}-${GCC_CONFIG_VER} |
1739 |
- ln -sf ${CTARGET}-${x} ${CTARGET}-${x}-${GCC_CONFIG_VER} |
1740 |
- fi |
1741 |
- done |
1742 |
- # Rename the main go binaries as we don't want to clobber dev-lang/go |
1743 |
- # when gcc-config runs. #567806 |
1744 |
- if tc_version_is_at_least 5 && is_go ; then |
1745 |
- for x in go gofmt; do |
1746 |
- mv ${x} ${x}-${GCCMAJOR} || die |
1747 |
- done |
1748 |
- fi |
1749 |
- |
1750 |
- # Now do the fun stripping stuff |
1751 |
- env RESTRICT="" CHOST=${CHOST} prepstrip "${D}${BINPATH}" |
1752 |
- is_crosscompile && \ |
1753 |
- env RESTRICT="" CHOST=${CHOST} prepstrip "${D}${HOSTLIBPATH}" |
1754 |
- env RESTRICT="" CHOST=${CTARGET} prepstrip "${D}${LIBPATH}" |
1755 |
- # gcc used to install helper binaries in lib/ but then moved to libexec/ |
1756 |
- [[ -d ${D}${PREFIX}/libexec/gcc ]] && \ |
1757 |
- env RESTRICT="" CHOST=${CHOST} prepstrip "${D}${PREFIX}/libexec/gcc/${CTARGET}/${GCC_CONFIG_VER}" |
1758 |
- |
1759 |
- cd "${S}" |
1760 |
- if is_crosscompile; then |
1761 |
- rm -rf "${ED}"usr/share/{man,info} |
1762 |
- rm -rf "${D}"${DATAPATH}/{man,info} |
1763 |
- else |
1764 |
- if tc_version_is_at_least 3.0 ; then |
1765 |
- local cxx_mandir=$(find "${WORKDIR}/build/${CTARGET}/libstdc++-v3" -name man) |
1766 |
- if [[ -d ${cxx_mandir} ]] ; then |
1767 |
- cp -r "${cxx_mandir}"/man? "${D}/${DATAPATH}"/man/ |
1768 |
- fi |
1769 |
- fi |
1770 |
- has noinfo ${FEATURES} \ |
1771 |
- && rm -r "${D}${DATAPATH}"/info \ |
1772 |
- || prepinfo "${DATAPATH#${EPREFIX}}" |
1773 |
- has noman ${FEATURES} \ |
1774 |
- && rm -r "${D}${DATAPATH}"/man \ |
1775 |
- || prepman "${DATAPATH#${EPREFIX}}" |
1776 |
- fi |
1777 |
- # prune empty dirs left behind |
1778 |
- find "${D}" -depth -type d -delete 2>/dev/null |
1779 |
- |
1780 |
- # install testsuite results |
1781 |
- if use regression-test; then |
1782 |
- docinto testsuite |
1783 |
- find "${WORKDIR}"/build -type f -name "*.sum" -exec dodoc {} + |
1784 |
- find "${WORKDIR}"/build -type f -path "*/testsuite/*.log" -exec dodoc {} + |
1785 |
- fi |
1786 |
- |
1787 |
- # Rather install the script, else portage with changing $FILESDIR |
1788 |
- # between binary and source package borks things .... |
1789 |
- if ! is_crosscompile ; then |
1790 |
- insinto "${DATAPATH#${EPREFIX}}" |
1791 |
- newins "$(prefixify_ro "${GCC_FILESDIR}"/awk/fixlafiles.awk-no_gcc_la)" fixlafiles.awk || die |
1792 |
- exeinto "${DATAPATH#${EPREFIX}}" |
1793 |
- doexe "$(prefixify_ro "${GCC_FILESDIR}"/fix_libtool_files.sh)" || die |
1794 |
- doexe "${GCC_FILESDIR}"/c{89,99} || die |
1795 |
- fi |
1796 |
- |
1797 |
- # libstdc++.la: Delete as it doesn't add anything useful: g++ itself |
1798 |
- # handles linkage correctly in the dynamic & static case. It also just |
1799 |
- # causes us pain: any C++ progs/libs linking with libtool will gain a |
1800 |
- # reference to the full libstdc++.la file which is gcc version specific. |
1801 |
- # libstdc++fs.la: It doesn't link against anything useful. |
1802 |
- # libsupc++.la: This has no dependencies. |
1803 |
- # libcc1.la: There is no static library, only dynamic. |
1804 |
- # libcc1plugin.la: Same as above, and it's loaded via dlopen. |
1805 |
- # libgomp.la: gcc itself handles linkage (libgomp.spec). |
1806 |
- # libgomp-plugin-*.la: Same as above, and it's an internal plugin only |
1807 |
- # loaded via dlopen. |
1808 |
- # libgfortran.la: gfortran itself handles linkage correctly in the |
1809 |
- # dynamic & static case (libgfortran.spec). #573302 |
1810 |
- # libgfortranbegin.la: Same as above, and it's an internal lib. |
1811 |
- # libmpx.la: gcc itself handles linkage correctly (libmpx.spec). |
1812 |
- # libmpxwrappers.la: See above. |
1813 |
- # libitm.la: gcc itself handles linkage correctly (libitm.spec). |
1814 |
- # libvtv.la: gcc itself handles linkage correctly. |
1815 |
- # lib*san.la: Sanitizer linkage is handled internally by gcc, and they |
1816 |
- # do not support static linking. #487550 #546700 |
1817 |
- find "${D}/${LIBPATH}" \ |
1818 |
- '(' \ |
1819 |
- -name libstdc++.la -o \ |
1820 |
- -name libstdc++fs.la -o \ |
1821 |
- -name libsupc++.la -o \ |
1822 |
- -name libcc1.la -o \ |
1823 |
- -name libcc1plugin.la -o \ |
1824 |
- -name 'libgomp.la' -o \ |
1825 |
- -name 'libgomp-plugin-*.la' -o \ |
1826 |
- -name libgfortran.la -o \ |
1827 |
- -name libgfortranbegin.la -o \ |
1828 |
- -name libmpx.la -o \ |
1829 |
- -name libmpxwrappers.la -o \ |
1830 |
- -name libitm.la -o \ |
1831 |
- -name libvtv.la -o \ |
1832 |
- -name 'lib*san.la' \ |
1833 |
- ')' -type f -delete |
1834 |
- |
1835 |
- # Use gid of 0 because some stupid ports don't have |
1836 |
- # the group 'root' set to gid 0. Send to /dev/null |
1837 |
- # for people who are testing as non-root. |
1838 |
- chown -R root:0 "${D}${LIBPATH}" 2>/dev/null |
1839 |
- |
1840 |
- # Move pretty-printers to gdb datadir to shut ldconfig up |
1841 |
- local py gdbdir=/usr/share/gdb/auto-load${LIBPATH/\/lib\//\/$(get_libdir)\/} |
1842 |
- pushd "${D}${LIBPATH}" >/dev/null |
1843 |
- for py in $(find . -name '*-gdb.py') ; do |
1844 |
- local multidir=${py%/*} |
1845 |
- insinto "${gdbdir}/${multidir}" |
1846 |
- sed -i "/^libdir =/s:=.*:= '${LIBPATH}/${multidir}':" "${py}" || die #348128 |
1847 |
- doins "${py}" || die |
1848 |
- rm "${py}" || die |
1849 |
- done |
1850 |
- popd >/dev/null |
1851 |
- |
1852 |
- # Don't scan .gox files for executable stacks - false positives |
1853 |
- export QA_EXECSTACK="usr/lib*/go/*/*.gox" |
1854 |
- export QA_WX_LOAD="usr/lib*/go/*/*.gox" |
1855 |
- |
1856 |
- # Disable RANDMMAP so PCH works. #301299 |
1857 |
- if tc_version_is_at_least 4.3 ; then |
1858 |
- pax-mark -r "${D}${PREFIX}/libexec/gcc/${CTARGET}/${GCC_CONFIG_VER}/cc1" |
1859 |
- pax-mark -r "${D}${PREFIX}/libexec/gcc/${CTARGET}/${GCC_CONFIG_VER}/cc1plus" |
1860 |
- fi |
1861 |
-} |
1862 |
- |
1863 |
-# Move around the libs to the right location. For some reason, |
1864 |
-# when installing gcc, it dumps internal libraries into /usr/lib |
1865 |
-# instead of the private gcc lib path |
1866 |
-gcc_movelibs() { |
1867 |
- # older versions of gcc did not support --print-multi-os-directory |
1868 |
- tc_version_is_at_least 3.2 || return 0 |
1869 |
- |
1870 |
- # For non-target libs which are for CHOST and not CTARGET, we want to |
1871 |
- # move them to the compiler-specific CHOST internal dir. This is stuff |
1872 |
- # that you want to link against when building tools rather than building |
1873 |
- # code to run on the target. |
1874 |
- if tc_version_is_at_least 5 && is_crosscompile ; then |
1875 |
- dodir "${HOSTLIBPATH#${EPREFIX}}" |
1876 |
- mv "${ED}"usr/$(get_libdir)/libcc1* "${D}${HOSTLIBPATH}" || die |
1877 |
- fi |
1878 |
- |
1879 |
- # For all the libs that are built for CTARGET, move them into the |
1880 |
- # compiler-specific CTARGET internal dir. |
1881 |
- local x multiarg removedirs="" |
1882 |
- for multiarg in $($(XGCC) -print-multi-lib) ; do |
1883 |
- multiarg=${multiarg#*;} |
1884 |
- multiarg=${multiarg//@/ -} |
1885 |
- |
1886 |
- local OS_MULTIDIR=$($(XGCC) ${multiarg} --print-multi-os-directory) |
1887 |
- local MULTIDIR=$($(XGCC) ${multiarg} --print-multi-directory) |
1888 |
- local TODIR="${D}${LIBPATH}"/${MULTIDIR} |
1889 |
- local FROMDIR= |
1890 |
- |
1891 |
- [[ -d ${TODIR} ]] || mkdir -p ${TODIR} |
1892 |
- |
1893 |
- for FROMDIR in \ |
1894 |
- "${LIBPATH}"/${OS_MULTIDIR} \ |
1895 |
- "${LIBPATH}"/../${MULTIDIR} \ |
1896 |
- "${PREFIX}"/lib/${OS_MULTIDIR} \ |
1897 |
- "${PREFIX}"/${CTARGET}/lib/${OS_MULTIDIR} |
1898 |
- do |
1899 |
- removedirs="${removedirs} ${FROMDIR}" |
1900 |
- FROMDIR=${D}${FROMDIR} |
1901 |
- if [[ ${FROMDIR} != "${TODIR}" && -d ${FROMDIR} ]] ; then |
1902 |
- local files=$(find "${FROMDIR}" -maxdepth 1 ! -type d 2>/dev/null) |
1903 |
- if [[ -n ${files} ]] ; then |
1904 |
- mv ${files} "${TODIR}" || die |
1905 |
- fi |
1906 |
- fi |
1907 |
- done |
1908 |
- fix_libtool_libdir_paths "${LIBPATH}/${MULTIDIR}" |
1909 |
- |
1910 |
- # SLOT up libgcj.pc if it's available (and let gcc-config worry about links) |
1911 |
- FROMDIR="${PREFIX}/lib/${OS_MULTIDIR}" |
1912 |
- for x in "${D}${FROMDIR}"/pkgconfig/libgcj*.pc ; do |
1913 |
- [[ -f ${x} ]] || continue |
1914 |
- sed -i "/^libdir=/s:=.*:=${LIBPATH}/${MULTIDIR}:" "${x}" || die |
1915 |
- mv "${x}" "${D}${FROMDIR}"/pkgconfig/libgcj-${GCC_PV}.pc || die |
1916 |
- done |
1917 |
- done |
1918 |
- |
1919 |
- # We remove directories separately to avoid this case: |
1920 |
- # mv SRC/lib/../lib/*.o DEST |
1921 |
- # rmdir SRC/lib/../lib/ |
1922 |
- # mv SRC/lib/../lib32/*.o DEST # Bork |
1923 |
- for FROMDIR in ${removedirs} ; do |
1924 |
- rmdir "${D}"${FROMDIR} >& /dev/null |
1925 |
- done |
1926 |
- find -depth "${D}" -type d -exec rmdir {} + >& /dev/null |
1927 |
-} |
1928 |
- |
1929 |
-# make sure the libtool archives have libdir set to where they actually |
1930 |
-# -are-, and not where they -used- to be. also, any dependencies we have |
1931 |
-# on our own .la files need to be updated. |
1932 |
-fix_libtool_libdir_paths() { |
1933 |
- local libpath="$1" |
1934 |
- |
1935 |
- pushd "${D}" >/dev/null |
1936 |
- |
1937 |
- pushd "./${libpath}" >/dev/null |
1938 |
- local dir="${PWD#${D%/}}" |
1939 |
- local allarchives=$(echo *.la) |
1940 |
- allarchives="\(${allarchives// /\\|}\)" |
1941 |
- popd >/dev/null |
1942 |
- |
1943 |
- # The libdir might not have any .la files. #548782 |
1944 |
- find "./${dir}" -maxdepth 1 -name '*.la' \ |
1945 |
- -exec sed -i -e "/^libdir=/s:=.*:='${dir}':" {} + || die |
1946 |
- # Would be nice to combine these, but -maxdepth can not be specified |
1947 |
- # on sub-expressions. |
1948 |
- find "./${PREFIX}"/lib* -maxdepth 3 -name '*.la' \ |
1949 |
- -exec sed -i -e "/^dependency_libs=/s:/[^ ]*/${allarchives}:${libpath}/\1:g" {} + || die |
1950 |
- find "./${dir}/" -maxdepth 1 -name '*.la' \ |
1951 |
- -exec sed -i -e "/^dependency_libs=/s:/[^ ]*/${allarchives}:${libpath}/\1:g" {} + || die |
1952 |
- |
1953 |
- popd >/dev/null |
1954 |
-} |
1955 |
- |
1956 |
-create_gcc_env_entry() { |
1957 |
- dodir /etc/env.d/gcc |
1958 |
- local gcc_envd_base="/etc/env.d/gcc/${CTARGET}-${GCC_CONFIG_VER}" |
1959 |
- |
1960 |
- local gcc_specs_file |
1961 |
- local gcc_envd_file="${ED}${gcc_envd_base}" |
1962 |
- if [[ -z $1 ]] ; then |
1963 |
- # I'm leaving the following commented out to remind me that it |
1964 |
- # was an insanely -bad- idea. Stuff broke. GCC_SPECS isnt unset |
1965 |
- # on chroot or in non-toolchain.eclass gcc ebuilds! |
1966 |
- #gcc_specs_file="${LIBPATH}/specs" |
1967 |
- gcc_specs_file="" |
1968 |
- else |
1969 |
- gcc_envd_file+="-$1" |
1970 |
- gcc_specs_file="${LIBPATH}/$1.specs" |
1971 |
- fi |
1972 |
- |
1973 |
- # We want to list the default ABI's LIBPATH first so libtool |
1974 |
- # searches that directory first. This is a temporary |
1975 |
- # workaround for libtool being stupid and using .la's from |
1976 |
- # conflicting ABIs by using the first one in the search path |
1977 |
- local ldpaths mosdirs |
1978 |
- if tc_version_is_at_least 3.2 ; then |
1979 |
- local mdir mosdir abi ldpath |
1980 |
- for abi in $(get_all_abis TARGET) ; do |
1981 |
- mdir=$($(XGCC) $(get_abi_CFLAGS ${abi}) --print-multi-directory) |
1982 |
- ldpath=${LIBPATH} |
1983 |
- [[ ${mdir} != "." ]] && ldpath+="/${mdir}" |
1984 |
- ldpaths="${ldpath}${ldpaths:+:${ldpaths}}" |
1985 |
- |
1986 |
- mosdir=$($(XGCC) $(get_abi_CFLAGS ${abi}) -print-multi-os-directory) |
1987 |
- mosdirs="${mosdir}${mosdirs:+:${mosdirs}}" |
1988 |
- done |
1989 |
- else |
1990 |
- # Older gcc's didn't do multilib, so logic is simple. |
1991 |
- ldpaths=${LIBPATH} |
1992 |
- fi |
1993 |
- |
1994 |
- cat <<-EOF > ${gcc_envd_file} |
1995 |
- PATH="${BINPATH}" |
1996 |
- ROOTPATH="${BINPATH}" |
1997 |
- GCC_PATH="${BINPATH}" |
1998 |
- LDPATH="${ldpaths}" |
1999 |
- MANPATH="${DATAPATH}/man" |
2000 |
- INFOPATH="${DATAPATH}/info" |
2001 |
- STDCXX_INCDIR="${STDCXX_INCDIR##*/}" |
2002 |
- CTARGET="${CTARGET}" |
2003 |
- GCC_SPECS="${gcc_specs_file}" |
2004 |
- MULTIOSDIRS="${mosdirs}" |
2005 |
- EOF |
2006 |
-} |
2007 |
- |
2008 |
-copy_minispecs_gcc_specs() { |
2009 |
- # on gcc 6 we don't need minispecs |
2010 |
- if tc_version_is_at_least 6.0 ; then |
2011 |
- return 0 |
2012 |
- fi |
2013 |
- |
2014 |
- # setup the hardenedno* specs files and the vanilla specs file. |
2015 |
- if hardened_gcc_works ; then |
2016 |
- create_gcc_env_entry hardenednopiessp |
2017 |
- fi |
2018 |
- if hardened_gcc_works pie ; then |
2019 |
- create_gcc_env_entry hardenednopie |
2020 |
- fi |
2021 |
- if hardened_gcc_works ssp ; then |
2022 |
- create_gcc_env_entry hardenednossp |
2023 |
- fi |
2024 |
- create_gcc_env_entry vanilla |
2025 |
- insinto ${LIBPATH#${EPREFIX}} |
2026 |
- doins "${WORKDIR}"/specs/*.specs || die "failed to install specs" |
2027 |
- # Build system specs file which, if it exists, must be a complete set of |
2028 |
- # specs as it completely and unconditionally overrides the builtin specs. |
2029 |
- if ! tc_version_is_at_least 4.4 ; then |
2030 |
- $(XGCC) -dumpspecs > "${WORKDIR}"/specs/specs |
2031 |
- cat "${WORKDIR}"/build.specs >> "${WORKDIR}"/specs/specs |
2032 |
- doins "${WORKDIR}"/specs/specs || die "failed to install the specs file" |
2033 |
- fi |
2034 |
-} |
2035 |
- |
2036 |
-gcc_slot_java() { |
2037 |
- local x |
2038 |
- |
2039 |
- # Move Java headers to compiler-specific dir |
2040 |
- for x in "${D}${PREFIX}"/include/gc*.h "${D}${PREFIX}"/include/j*.h ; do |
2041 |
- [[ -f ${x} ]] && mv -f "${x}" "${D}${LIBPATH}"/include/ |
2042 |
- done |
2043 |
- for x in gcj gnu java javax org ; do |
2044 |
- if [[ -d ${D}${PREFIX}/include/${x} ]] ; then |
2045 |
- dodir /${LIBPATH#${EPREFIX}}/include/${x} |
2046 |
- mv -f "${D}${PREFIX}"/include/${x}/* "${D}${LIBPATH}"/include/${x}/ |
2047 |
- rm -rf "${D}${PREFIX}"/include/${x} |
2048 |
- fi |
2049 |
- done |
2050 |
- |
2051 |
- if [[ -d ${D}${PREFIX}/lib/security ]] || [[ -d ${D}${PREFIX}/$(get_libdir)/security ]] ; then |
2052 |
- dodir /${LIBPATH#${EPREFIX}}/security |
2053 |
- mv -f "${D}${PREFIX}"/lib*/security/* "${D}${LIBPATH}"/security |
2054 |
- rm -rf "${D}${PREFIX}"/lib*/security |
2055 |
- fi |
2056 |
- |
2057 |
- # Move random gcj files to compiler-specific directories |
2058 |
- for x in libgcj.spec logging.properties ; do |
2059 |
- x="${D}${PREFIX}/lib/${x}" |
2060 |
- [[ -f ${x} ]] && mv -f "${x}" "${D}${LIBPATH}"/ |
2061 |
- done |
2062 |
- |
2063 |
- # Rename jar because it could clash with Kaffe's jar if this gcc is |
2064 |
- # primary compiler (aka don't have the -<version> extension) |
2065 |
- cd "${D}${BINPATH}" |
2066 |
- [[ -f jar ]] && mv -f jar gcj-jar |
2067 |
-} |
2068 |
- |
2069 |
-#---->> pkg_post* <<---- |
2070 |
- |
2071 |
-toolchain_pkg_postinst() { |
2072 |
- do_gcc_config |
2073 |
- |
2074 |
- if ! is_crosscompile ; then |
2075 |
- echo |
2076 |
- ewarn "If you have issues with packages unable to locate libstdc++.la," |
2077 |
- ewarn "then try running 'fix_libtool_files.sh' on the old gcc versions." |
2078 |
- echo |
2079 |
- ewarn "You might want to review the GCC upgrade guide when moving between" |
2080 |
- ewarn "major versions (like 4.2 to 4.3):" |
2081 |
- ewarn "https://wiki.gentoo.org/wiki/Upgrading_GCC" |
2082 |
- echo |
2083 |
- |
2084 |
- # Clean up old paths |
2085 |
- rm -f "${EROOT}"*/rcscripts/awk/fixlafiles.awk "${EROOT}"sbin/fix_libtool_files.sh |
2086 |
- rmdir "${EROOT}"*/rcscripts{/awk,} 2>/dev/null |
2087 |
- |
2088 |
- mkdir -p "${EROOT}"usr/{share/gcc-data,sbin,bin} |
2089 |
- # DATAPATH has EPREFIX already, use ROOT with it |
2090 |
- cp "${ROOT}${DATAPATH}"/fixlafiles.awk "${EROOT}"usr/share/gcc-data/ || die |
2091 |
- cp "${ROOT}${DATAPATH}"/fix_libtool_files.sh "${EROOT}"usr/sbin/ || die |
2092 |
- |
2093 |
- # Since these aren't critical files and portage sucks with |
2094 |
- # handling of binpkgs, don't require these to be found |
2095 |
- cp "${ROOT}${DATAPATH}"/c{89,99} "${EROOT}"usr/bin/ 2>/dev/null |
2096 |
- fi |
2097 |
- |
2098 |
- if use regression-test ; then |
2099 |
- elog "Testsuite results have been installed into /usr/share/doc/${PF}/testsuite" |
2100 |
- echo |
2101 |
- fi |
2102 |
- |
2103 |
- if [[ -n ${PRERELEASE}${SNAPSHOT} ]] ; then |
2104 |
- einfo "This GCC ebuild is provided for your convenience, and the use" |
2105 |
- einfo "of this compiler is not supported by the Gentoo Developers." |
2106 |
- einfo "Please report bugs to upstream at http://gcc.gnu.org/bugzilla/" |
2107 |
- fi |
2108 |
-} |
2109 |
- |
2110 |
-toolchain_pkg_postrm() { |
2111 |
- # to make our lives easier (and saner), we do the fix_libtool stuff here. |
2112 |
- # rather than checking SLOT's and trying in upgrade paths, we just see if |
2113 |
- # the common libstdc++.la exists in the ${LIBPATH} of the gcc that we are |
2114 |
- # unmerging. if it does, that means this was a simple re-emerge. |
2115 |
- |
2116 |
- # clean up the cruft left behind by cross-compilers |
2117 |
- if is_crosscompile ; then |
2118 |
- if [[ -z $(ls "${EROOT}"etc/env.d/gcc/${CTARGET}* 2>/dev/null) ]] ; then |
2119 |
- rm -f "${EROOT}"etc/env.d/gcc/config-${CTARGET} |
2120 |
- rm -f "${EROOT}"etc/env.d/??gcc-${CTARGET} |
2121 |
- rm -f "${EROOT}"usr/bin/${CTARGET}-{gcc,{g,c}++}{,32,64} |
2122 |
- fi |
2123 |
- return 0 |
2124 |
- fi |
2125 |
- |
2126 |
- # ROOT isnt handled by the script |
2127 |
- [[ ${ROOT} != "/" ]] && return 0 |
2128 |
- |
2129 |
- if [[ ! -e ${LIBPATH}/libstdc++.so ]] ; then |
2130 |
- # make sure the profile is sane during same-slot upgrade #289403 |
2131 |
- do_gcc_config |
2132 |
- |
2133 |
- einfo "Running 'fix_libtool_files.sh ${GCC_RELEASE_VER}'" |
2134 |
- fix_libtool_files.sh ${GCC_RELEASE_VER} |
2135 |
- if [[ -n ${BRANCH_UPDATE} ]] ; then |
2136 |
- einfo "Running 'fix_libtool_files.sh ${GCC_RELEASE_VER}-${BRANCH_UPDATE}'" |
2137 |
- fix_libtool_files.sh ${GCC_RELEASE_VER}-${BRANCH_UPDATE} |
2138 |
- fi |
2139 |
- fi |
2140 |
- |
2141 |
- return 0 |
2142 |
-} |
2143 |
- |
2144 |
-do_gcc_config() { |
2145 |
- if ! should_we_gcc_config ; then |
2146 |
- env -i PATH="${PATH}" ROOT="${ROOT}" gcc-config --use-old --force |
2147 |
- return 0 |
2148 |
- fi |
2149 |
- |
2150 |
- local current_gcc_config target |
2151 |
- |
2152 |
- current_gcc_config=$(env -i PATH="${PATH}" ROOT="${ROOT}" gcc-config -c ${CTARGET} 2>/dev/null) |
2153 |
- if [[ -n ${current_gcc_config} ]] ; then |
2154 |
- local current_specs use_specs |
2155 |
- # figure out which specs-specific config is active |
2156 |
- current_specs=$(gcc-config -S ${current_gcc_config} | awk '{print $3}') |
2157 |
- [[ -n ${current_specs} ]] && use_specs=-${current_specs} |
2158 |
- |
2159 |
- if [[ -n ${use_specs} ]] && \ |
2160 |
- [[ ! -e ${ROOT}/etc/env.d/gcc/${CTARGET}-${GCC_CONFIG_VER}${use_specs} ]] |
2161 |
- then |
2162 |
- ewarn "The currently selected specs-specific gcc config," |
2163 |
- ewarn "${current_specs}, doesn't exist anymore. This is usually" |
2164 |
- ewarn "due to enabling/disabling hardened or switching to a version" |
2165 |
- ewarn "of gcc that doesnt create multiple specs files. The default" |
2166 |
- ewarn "config will be used, and the previous preference forgotten." |
2167 |
- use_specs="" |
2168 |
- fi |
2169 |
- |
2170 |
- target="${CTARGET}-${GCC_CONFIG_VER}${use_specs}" |
2171 |
- else |
2172 |
- # The curent target is invalid. Attempt to switch to a valid one. |
2173 |
- # Blindly pick the latest version. #529608 |
2174 |
- # TODO: Should update gcc-config to accept `-l ${CTARGET}` rather than |
2175 |
- # doing a partial grep like this. |
2176 |
- target=$(gcc-config -l 2>/dev/null | grep " ${CTARGET}-[0-9]" | tail -1 | awk '{print $2}') |
2177 |
- fi |
2178 |
- |
2179 |
- gcc-config "${target}" |
2180 |
-} |
2181 |
- |
2182 |
-should_we_gcc_config() { |
2183 |
- # if the current config is invalid, we definitely want a new one |
2184 |
- # Note: due to bash quirkiness, the following must not be 1 line |
2185 |
- local curr_config |
2186 |
- curr_config=$(env -i PATH="${PATH}" ROOT="${ROOT}" gcc-config -c ${CTARGET} 2>&1) || return 0 |
2187 |
- |
2188 |
- # if the previously selected config has the same major.minor (branch) as |
2189 |
- # the version we are installing, then it will probably be uninstalled |
2190 |
- # for being in the same SLOT, make sure we run gcc-config. |
2191 |
- local curr_config_ver=$(env -i PATH="${PATH}" ROOT="${ROOT}" gcc-config -S ${curr_config} | awk '{print $2}') |
2192 |
- |
2193 |
- local curr_branch_ver=$(get_version_component_range 1-2 ${curr_config_ver}) |
2194 |
- |
2195 |
- if [[ ${curr_branch_ver} == ${GCC_BRANCH_VER} ]] ; then |
2196 |
- return 0 |
2197 |
- else |
2198 |
- # if we're installing a genuinely different compiler version, |
2199 |
- # we should probably tell the user -how- to switch to the new |
2200 |
- # gcc version, since we're not going to do it for him/her. |
2201 |
- # We don't want to switch from say gcc-3.3 to gcc-3.4 right in |
2202 |
- # the middle of an emerge operation (like an 'emerge -e world' |
2203 |
- # which could install multiple gcc versions). |
2204 |
- # Only warn if we're installing a pkg as we might be called from |
2205 |
- # the pkg_{pre,post}rm steps. #446830 |
2206 |
- if [[ ${EBUILD_PHASE} == *"inst" ]] ; then |
2207 |
- einfo "The current gcc config appears valid, so it will not be" |
2208 |
- einfo "automatically switched for you. If you would like to" |
2209 |
- einfo "switch to the newly installed gcc version, do the" |
2210 |
- einfo "following:" |
2211 |
- echo |
2212 |
- einfo "gcc-config ${CTARGET}-${GCC_CONFIG_VER}" |
2213 |
- einfo "source /etc/profile" |
2214 |
- echo |
2215 |
- fi |
2216 |
- return 1 |
2217 |
- fi |
2218 |
-} |
2219 |
- |
2220 |
-#---->> support and misc functions <<---- |
2221 |
- |
2222 |
-# This is to make sure we don't accidentally try to enable support for a |
2223 |
-# language that doesnt exist. GCC 3.4 supports f77, while 4.0 supports f95, etc. |
2224 |
-# |
2225 |
-# Also add a hook so special ebuilds (kgcc64) can control which languages |
2226 |
-# exactly get enabled |
2227 |
-gcc-lang-supported() { |
2228 |
- grep ^language=\"${1}\" "${S}"/gcc/*/config-lang.in > /dev/null || return 1 |
2229 |
- [[ -z ${TOOLCHAIN_ALLOWED_LANGS} ]] && return 0 |
2230 |
- has $1 ${TOOLCHAIN_ALLOWED_LANGS} |
2231 |
-} |
2232 |
- |
2233 |
-is_ada() { |
2234 |
- gcc-lang-supported ada || return 1 |
2235 |
- use ada |
2236 |
-} |
2237 |
- |
2238 |
-is_cxx() { |
2239 |
- gcc-lang-supported 'c++' || return 1 |
2240 |
- ! is_crosscompile && tc_version_is_at_least 4.8 && return 0 |
2241 |
- use cxx |
2242 |
-} |
2243 |
- |
2244 |
-is_d() { |
2245 |
- gcc-lang-supported d || return 1 |
2246 |
- use_if_iuse d |
2247 |
-} |
2248 |
- |
2249 |
-is_f77() { |
2250 |
- gcc-lang-supported f77 || return 1 |
2251 |
- use fortran |
2252 |
-} |
2253 |
- |
2254 |
-is_f95() { |
2255 |
- gcc-lang-supported f95 || return 1 |
2256 |
- use fortran |
2257 |
-} |
2258 |
- |
2259 |
-is_fortran() { |
2260 |
- gcc-lang-supported fortran || return 1 |
2261 |
- use fortran |
2262 |
-} |
2263 |
- |
2264 |
-is_gcj() { |
2265 |
- gcc-lang-supported java || return 1 |
2266 |
- use cxx && use_if_iuse gcj |
2267 |
-} |
2268 |
- |
2269 |
-is_go() { |
2270 |
- gcc-lang-supported go || return 1 |
2271 |
- use cxx && use_if_iuse go |
2272 |
-} |
2273 |
- |
2274 |
-is_jit() { |
2275 |
- gcc-lang-supported jit || return 1 |
2276 |
- use_if_iuse jit |
2277 |
-} |
2278 |
- |
2279 |
-is_multilib() { |
2280 |
- tc_version_is_at_least 3 || return 1 |
2281 |
- use multilib |
2282 |
-} |
2283 |
- |
2284 |
-is_objc() { |
2285 |
- gcc-lang-supported objc || return 1 |
2286 |
- use_if_iuse objc |
2287 |
-} |
2288 |
- |
2289 |
-is_objcxx() { |
2290 |
- gcc-lang-supported 'obj-c++' || return 1 |
2291 |
- use cxx && use_if_iuse objc++ |
2292 |
-} |
2293 |
- |
2294 |
-# Grab a variable from the build system (taken from linux-info.eclass) |
2295 |
-get_make_var() { |
2296 |
- local var=$1 makefile=${2:-${WORKDIR}/build/Makefile} |
2297 |
- echo -e "e:\\n\\t@echo \$(${var})\\ninclude ${makefile}" | \ |
2298 |
- r=${makefile%/*} emake --no-print-directory -s -f - 2>/dev/null |
2299 |
-} |
2300 |
- |
2301 |
-XGCC() { get_make_var GCC_FOR_TARGET ; } |
2302 |
- |
2303 |
-# The gentoo piessp patches allow for 3 configurations: |
2304 |
-# 1) PIE+SSP by default |
2305 |
-# 2) PIE by default |
2306 |
-# 3) SSP by default |
2307 |
-hardened_gcc_works() { |
2308 |
- if [[ $1 == "pie" ]] ; then |
2309 |
- # $gcc_cv_ld_pie is unreliable as it simply take the output of |
2310 |
- # `ld --help | grep -- -pie`, that reports the option in all cases, also if |
2311 |
- # the loader doesn't actually load the resulting executables. |
2312 |
- # To avoid breakage, blacklist FreeBSD here at least |
2313 |
- [[ ${CTARGET} == *-freebsd* ]] && return 1 |
2314 |
- |
2315 |
- want_pie || return 1 |
2316 |
- use_if_iuse nopie && return 1 |
2317 |
- hardened_gcc_is_stable pie |
2318 |
- return $? |
2319 |
- elif [[ $1 == "ssp" ]] ; then |
2320 |
- [[ -n ${SPECS_VER} ]] || return 1 |
2321 |
- use_if_iuse nossp && return 1 |
2322 |
- hardened_gcc_is_stable ssp |
2323 |
- return $? |
2324 |
- else |
2325 |
- # laziness ;) |
2326 |
- hardened_gcc_works pie || return 1 |
2327 |
- hardened_gcc_works ssp || return 1 |
2328 |
- return 0 |
2329 |
- fi |
2330 |
-} |
2331 |
- |
2332 |
-hardened_gcc_is_stable() { |
2333 |
- local tocheck |
2334 |
- if [[ $1 == "pie" ]] ; then |
2335 |
- if [[ ${CTARGET} == *-uclibc* ]] ; then |
2336 |
- tocheck=${PIE_UCLIBC_STABLE} |
2337 |
- else |
2338 |
- tocheck=${PIE_GLIBC_STABLE} |
2339 |
- fi |
2340 |
- elif [[ $1 == "ssp" ]] ; then |
2341 |
- if [[ ${CTARGET} == *-uclibc* ]] ; then |
2342 |
- tocheck=${SSP_UCLIBC_STABLE} |
2343 |
- elif [[ ${CTARGET} == *-gnu* ]] ; then |
2344 |
- tocheck=${SSP_STABLE} |
2345 |
- fi |
2346 |
- else |
2347 |
- die "hardened_gcc_stable needs to be called with pie or ssp" |
2348 |
- fi |
2349 |
- |
2350 |
- has $(tc-arch) ${tocheck} && return 0 |
2351 |
- return 1 |
2352 |
-} |
2353 |
- |
2354 |
-want_minispecs() { |
2355 |
- # on gcc 6 we don't need minispecs |
2356 |
- if tc_version_is_at_least 6.0 ; then |
2357 |
- return 0 |
2358 |
- fi |
2359 |
- if tc_version_is_at_least 4.3.2 && use hardened ; then |
2360 |
- if ! want_pie ; then |
2361 |
- ewarn "PIE_VER or SPECS_VER is not defined in the GCC ebuild." |
2362 |
- elif use vanilla ; then |
2363 |
- ewarn "You will not get hardened features if you have the vanilla USE-flag." |
2364 |
- elif use nopie && use nossp ; then |
2365 |
- ewarn "You will not get hardened features if you have the nopie and nossp USE-flag." |
2366 |
- elif ! hardened_gcc_works ; then |
2367 |
- ewarn "Your $(tc-arch) arch is not supported." |
2368 |
- else |
2369 |
- return 0 |
2370 |
- fi |
2371 |
- ewarn "Hope you know what you are doing. Hardened will not work." |
2372 |
- return 0 |
2373 |
- fi |
2374 |
- return 1 |
2375 |
-} |
2376 |
- |
2377 |
-want_pie() { |
2378 |
- ! use hardened && [[ -n ${PIE_VER} ]] && use nopie && return 1 |
2379 |
- [[ -n ${PIE_VER} ]] && [[ -n ${SPECS_VER} ]] && return 0 |
2380 |
- tc_version_is_at_least 4.3.2 && return 1 |
2381 |
- [[ -z ${PIE_VER} ]] && return 1 |
2382 |
- use !nopie && return 0 |
2383 |
- return 1 |
2384 |
-} |
2385 |
- |
2386 |
-has toolchain_death_notice ${EBUILD_DEATH_HOOKS} || EBUILD_DEATH_HOOKS+=" toolchain_death_notice" |
2387 |
-toolchain_death_notice() { |
2388 |
- if [[ -e "${WORKDIR}"/build ]] ; then |
2389 |
- pushd "${WORKDIR}"/build >/dev/null |
2390 |
- (echo '' | $(tc-getCC ${CTARGET}) ${CFLAGS} -v -E - 2>&1) > gccinfo.log |
2391 |
- [[ -e "${T}"/build.log ]] && cp "${T}"/build.log . |
2392 |
- tar jcf "${WORKDIR}"/gcc-build-logs.tar.bz2 \ |
2393 |
- gccinfo.log build.log $(find -name config.log) |
2394 |
- rm gccinfo.log build.log |
2395 |
- eerror |
2396 |
- eerror "Please include ${WORKDIR}/gcc-build-logs.tar.bz2 in your bug report." |
2397 |
- eerror |
2398 |
- popd >/dev/null |
2399 |
- fi |
2400 |
-} |