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