Gentoo Archives: gentoo-commits

From: Sam James <sam@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/
Date: Fri, 13 May 2022 00:04:24
Message-Id: 1652400070.f73459ce468082dfc59df6b32a13b507788eeec1.sam@gentoo
1 commit: f73459ce468082dfc59df6b32a13b507788eeec1
2 Author: Sam James <sam <AT> gentoo <DOT> org>
3 AuthorDate: Thu May 12 23:54:41 2022 +0000
4 Commit: Sam James <sam <AT> gentoo <DOT> org>
5 CommitDate: Fri May 13 00:01:10 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f73459ce
7
8 toolchain.eclass: style cleanups
9
10 Signed-off-by: Sam James <sam <AT> gentoo.org>
11
12 eclass/toolchain.eclass | 494 +++++++++++++++++++++++++++---------------------
13 1 file changed, 278 insertions(+), 216 deletions(-)
14
15 diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass
16 index 6561cea458e6..d6c20a9e1e97 100644
17 --- a/eclass/toolchain.eclass
18 +++ b/eclass/toolchain.eclass
19 @@ -431,9 +431,11 @@ toolchain_pkg_pretend() {
20 #---->> pkg_setup <<----
21
22 toolchain_pkg_setup() {
23 - # we dont want to use the installed compiler's specs to build gcc
24 + # We don't want to use the installed compiler's specs to build gcc
25 unset GCC_SPECS
26 - unset LANGUAGES #265283
27 +
28 + # bug #265283
29 + unset LANGUAGES
30 }
31
32 #---->> src_unpack <<----
33 @@ -467,9 +469,9 @@ toolchain_src_prepare() {
34 make_gcc_hard
35 fi
36
37 - # make sure the pkg config files install into multilib dirs.
38 - # since we configure with just one --libdir, we can't use that
39 - # (as gcc itself takes care of building multilibs). #435728
40 + # Make sure the pkg-config files install into multilib dirs.
41 + # Since we configure with just one --libdir, we can't use that
42 + # (as gcc itself takes care of building multilibs). bug #435728
43 find "${S}" -name Makefile.in \
44 -exec sed -i '/^pkgconfigdir/s:=.*:=$(toolexeclibdir)/pkgconfig:' {} + || die
45
46 @@ -504,7 +506,7 @@ toolchain_src_prepare() {
47
48 gnuconfig_update
49
50 - # update configure files
51 + # Update configure files
52 local f
53 einfo "Fixing misc issues in configure files"
54 for f in $(grep -l 'autoconf version 2.13' $(find "${S}" -name configure)) ; do
55 @@ -513,9 +515,10 @@ toolchain_src_prepare() {
56 || eerror "Please file a bug about this"
57 eend $?
58 done
59 - sed -i 's|A-Za-z0-9|[:alnum:]|g' "${S}"/gcc/*.awk || die #215828
60 + # bug #215828
61 + sed -i 's|A-Za-z0-9|[:alnum:]|g' "${S}"/gcc/*.awk || die
62
63 - # Prevent new texinfo from breaking old versions (see #198182, #464008)
64 + # Prevent new texinfo from breaking old versions (see #198182, bug #464008)
65 einfo "Remove texinfo (bug #198182, bug #464008)"
66 eapply "${FILESDIR}"/gcc-configure-texinfo.patch
67
68 @@ -572,7 +575,7 @@ do_gcc_CYGWINPORTS_patches() {
69 use elibc_Cygwin || return 0
70
71 local p d="${WORKDIR}/gcc-${CYGWINPORTS_GITREV}"
72 - # readarray -t is available since bash-4.4 only, #690686
73 + # readarray -t is available since bash-4.4 only, bug #690686
74 local patches=( $(
75 for p in $(
76 sed -e '1,/PATCH_URI="/d;/"/,$d' < "${d}"/gcc.cygport
77 @@ -588,14 +591,15 @@ do_gcc_CYGWINPORTS_patches() {
78 make_gcc_hard() {
79 local gcc_hard_flags=""
80
81 - # If we use gcc-6 or newer with pie enable to compile older gcc we need to pass -no-pie
82 - # to stage1; bug #618908
83 + # If we use gcc-6 or newer with PIE enabled to compile older gcc,
84 + # we need to pass -no-pie to stage1; bug #618908
85 if ! tc_version_is_at_least 6.0 && [[ $(gcc-major-version) -ge 6 ]] ; then
86 einfo "Disabling PIE in stage1 (only) ..."
87 sed -i -e "/^STAGE1_LDFLAGS/ s/$/ -no-pie/" "${S}"/Makefile.in || die
88 fi
89
90 - # Gcc >= 6.X we can use configurations options to turn pie/ssp on as default
91 + # For gcc >= 6.x, we can use configuration options to turn PIE/SSP
92 + # on as default
93 if tc_version_is_at_least 6.0 ; then
94 if _tc_use_if_iuse pie ; then
95 einfo "Updating gcc to use automatic PIE building ..."
96 @@ -605,21 +609,21 @@ make_gcc_hard() {
97 fi
98 if _tc_use_if_iuse hardened ; then
99 # Will add some hardened options as default, like:
100 - # -fstack-clash-protection
101 - # -z now
102 - # see *_all_extra-options.patch gcc patches.
103 + # * -fstack-clash-protection
104 + # * -z now
105 + # See gcc *_all_extra-options.patch patches.
106 gcc_hard_flags+=" -DEXTRA_OPTIONS"
107
108 if _tc_use_if_iuse cet && [[ ${CTARGET} == *x86_64*-linux* ]] ; then
109 gcc_hard_flags+=" -DEXTRA_OPTIONS_CF"
110 fi
111
112 - # rebrand to make bug reports easier
113 + # Rebrand to make bug reports easier
114 BRANDING_GCC_PKGVERSION=${BRANDING_GCC_PKGVERSION/Gentoo/Gentoo Hardened}
115 fi
116 else
117 if _tc_use_if_iuse hardened ; then
118 - # rebrand to make bug reports easier
119 + # Rebrand to make bug reports easier
120 BRANDING_GCC_PKGVERSION=${BRANDING_GCC_PKGVERSION/Gentoo/Gentoo Hardened}
121 if hardened_gcc_works ; then
122 einfo "Updating gcc to use automatic PIE + SSP building ..."
123 @@ -633,7 +637,7 @@ make_gcc_hard() {
124 ewarn "PIE has not been enabled by default"
125 gcc_hard_flags+=" -DEFAULT_SSP"
126 else
127 - # do nothing if hardened isn't supported, but don't die either
128 + # Do nothing if hardened isn't supported, but don't die either
129 ewarn "hardened is not supported for this arch in this gcc version"
130 return 0
131 fi
132 @@ -645,7 +649,7 @@ make_gcc_hard() {
133 fi
134 fi
135
136 - # we want to be able to control the pie patch logic via something other
137 + # We want to be able to control the PIEe patch logic via something other
138 # than ALL_CFLAGS...
139 sed -e '/^ALL_CFLAGS/iHARD_CFLAGS = ' \
140 -e 's|^ALL_CFLAGS = |ALL_CFLAGS = $(HARD_CFLAGS) |' \
141 @@ -683,13 +687,13 @@ setup_multilib_osdirnames() {
142 local config
143 local libdirs="../lib64 ../lib32"
144
145 - # this only makes sense for some Linux targets
146 + # This only makes sense for some Linux targets
147 case ${CTARGET} in
148 - x86_64*-linux*) config="i386" ;;
149 - powerpc64*-linux*) config="rs6000" ;;
150 - sparc64*-linux*) config="sparc" ;;
151 - s390x*-linux*) config="s390" ;;
152 - *) return 0 ;;
153 + x86_64*-linux*) config="i386" ;;
154 + powerpc64*-linux*) config="rs6000" ;;
155 + sparc64*-linux*) config="sparc" ;;
156 + s390x*-linux*) config="s390" ;;
157 + *) return 0 ;;
158 esac
159 config+="/t-linux64"
160
161 @@ -698,14 +702,14 @@ setup_multilib_osdirnames() {
162 sed_args+=( -e 's:$[(]call if_multiarch[^)]*[)]::g' )
163 fi
164 if [[ ${SYMLINK_LIB} == "yes" ]] ; then
165 - einfo "updating multilib directories to be: ${libdirs}"
166 + einfo "Updating multilib directories to be: ${libdirs}"
167 if tc_version_is_at_least 4.6.4 || tc_version_is_at_least 4.7 ; then
168 sed_args+=( -e '/^MULTILIB_OSDIRNAMES.*lib32/s:[$][(]if.*):../lib32:' )
169 else
170 sed_args+=( -e "/^MULTILIB_OSDIRNAMES/s:=.*:= ${libdirs}:" )
171 fi
172 else
173 - einfo "using upstream multilib; disabling lib32 autodetection"
174 + einfo "Using upstream multilib; disabling lib32 autodetection"
175 sed_args+=( -r -e 's:[$][(]if.*,(.*)[)]:\1:' )
176 fi
177 sed -i "${sed_args[@]}" "${S}"/gcc/config/${config} || die
178 @@ -717,7 +721,7 @@ gcc_version_patch() {
179
180 local version_string=${GCC_RELEASE_VER}
181
182 - einfo "patching gcc version: ${version_string} (${BRANDING_GCC_PKGVERSION})"
183 + einfo "Patching gcc version: ${version_string} (${BRANDING_GCC_PKGVERSION})"
184
185 local gcc_sed=( -e 's:gcc\.gnu\.org/bugs\.html:bugs\.gentoo\.org/:' )
186 if grep -qs VERSUFFIX "${S}"/gcc/version.c ; then
187 @@ -740,7 +744,7 @@ toolchain_src_configure() {
188 einfo "LDFLAGS=\"${LDFLAGS}\""
189
190 # Force internal zip based jar script to avoid random
191 - # issues with 3rd party jar implementations. #384291
192 + # issues with 3rd party jar implementations. bug #384291
193 export JAR=no
194
195 # For hardened gcc 4.3 piepatchset to build the hardened specs
196 @@ -797,7 +801,7 @@ toolchain_src_configure() {
197 is_objcxx && GCC_LANG+=",obj-c++"
198 fi
199
200 - # fortran support just got sillier! the lang value can be f77 for
201 + # Fortran support just got sillier! The lang value can be f77 for
202 # fortran77, f95 for fortran95, or just plain old fortran for the
203 # currently supported standard depending on gcc version.
204 is_fortran && GCC_LANG+=",fortran"
205 @@ -839,12 +843,12 @@ toolchain_src_configure() {
206 --with-pkgversion="${BRANDING_GCC_PKGVERSION}"
207 )
208
209 - # If we want hardened support with the newer piepatchset for >=gcc 4.4
210 + # If we want hardened support with the newer PIE patchset for >=gcc 4.4
211 if tc_version_is_at_least 4.4 && want_minispecs && in_iuse hardened ; then
212 confgcc+=( $(use_enable hardened esp) )
213 fi
214
215 - # allow gcc to search for clock funcs in the main C lib.
216 + # Allow gcc to search for clock funcs in the main C lib.
217 # if it can't find them, then tough cookies -- we aren't
218 # going to link in -lrt to all C++ apps. bug #411681
219 if tc_version_is_at_least 4.4 && is_cxx ; then
220 @@ -856,12 +860,13 @@ toolchain_src_configure() {
221 confgcc+=( --with-build-config=bootstrap-lto )
222 fi
223
224 - # Support to disable pch when building libstdcxx
225 + # Support to disable PCH when building libstdcxx
226 if tc_version_is_at_least 6.0 && ! _tc_use_if_iuse pch ; then
227 confgcc+=( --disable-libstdcxx-pch )
228 fi
229
230 - # The jit language requires this.
231 + # The JIT support requires this.
232 + # But see bug #843341.
233 is_jit && confgcc+=( --enable-host-shared )
234
235 # build-id was disabled for file collisions: bug #526144
236 @@ -876,7 +881,7 @@ toolchain_src_configure() {
237 # ;;
238 # esac
239
240 - # newer gcc versions like to bootstrap themselves with C++,
241 + # Newer gcc versions like to bootstrap themselves with C++,
242 # so we need to manually disable it ourselves
243 if tc_version_is_between 4.7 4.8 && ! is_cxx ; then
244 confgcc+=( --disable-build-with-cxx --disable-build-poststage1-with-cxx )
245 @@ -892,37 +897,55 @@ toolchain_src_configure() {
246 # disable a bunch of features or gcc goes boom
247 local needed_libc=""
248 case ${CTARGET} in
249 - *-linux) needed_libc=error-unknown-libc;;
250 - *-dietlibc) needed_libc=dietlibc;;
251 - *-elf|*-eabi)
252 - needed_libc=newlib
253 - # Bare-metal targets don't have access to clock_gettime()
254 - # arm-none-eabi example: bug #589672
255 - # But we explicitly do --enable-libstdcxx-time above.
256 - # Undoing it here.
257 - confgcc+=( --disable-libstdcxx-time )
258 - ;;
259 - *-gnu*) needed_libc=glibc;;
260 - *-klibc) needed_libc=klibc;;
261 - *-musl*) needed_libc=musl;;
262 - *-cygwin) needed_libc=cygwin;;
263 - x86_64-*-mingw*|\
264 - *-w64-mingw*) needed_libc=mingw64-runtime;;
265 - avr) confgcc+=( --enable-shared --disable-threads );;
266 + *-linux)
267 + needed_libc=error-unknown-libc
268 + ;;
269 + *-dietlibc)
270 + needed_libc=dietlibc
271 + ;;
272 + *-elf|*-eabi)
273 + needed_libc=newlib
274 + # Bare-metal targets don't have access to clock_gettime()
275 + # arm-none-eabi example: bug #589672
276 + # But we explicitly do --enable-libstdcxx-time above.
277 + # Undoing it here.
278 + confgcc+=( --disable-libstdcxx-time )
279 + ;;
280 + *-gnu*)
281 + needed_libc=glibc
282 + ;;
283 + *-klibc)
284 + needed_libc=klibc
285 + ;;
286 + *-musl*)
287 + needed_libc=musl
288 + ;;
289 + *-cygwin)
290 + needed_libc=cygwin
291 + ;;
292 + x86_64-*-mingw*|*-w64-mingw*)
293 + needed_libc=mingw64-runtime
294 + ;;
295 + avr)
296 + confgcc+=( --enable-shared --disable-threads )
297 + ;;
298 esac
299 +
300 if [[ -n ${needed_libc} ]] ; then
301 local confgcc_no_libc=( --disable-shared )
302 # requires libc: bug #734820
303 tc_version_is_at_least 4.6 && confgcc_no_libc+=( --disable-libquadmath )
304 # requires libc
305 tc_version_is_at_least 4.8 && confgcc_no_libc+=( --disable-libatomic )
306 +
307 if ! has_version ${CATEGORY}/${needed_libc} ; then
308 confgcc+=(
309 "${confgcc_no_libc[@]}"
310 --disable-threads
311 --without-headers
312 )
313 - if [[ $needed_libc == glibc ]]; then
314 +
315 + if [[ ${needed_libc} == glibc ]] ; then
316 # By default gcc looks at glibc's headers
317 # to detect long double support. This does
318 # not work for --disable-headers mode.
319 @@ -948,31 +971,33 @@ toolchain_src_configure() {
320 confgcc+=( --enable-shared )
321 fi
322 case ${CHOST} in
323 - mingw*|*-mingw*)
324 - confgcc+=( --enable-threads=win32 ) ;;
325 - *)
326 - confgcc+=( --enable-threads=posix ) ;;
327 + mingw*|*-mingw*)
328 + confgcc+=( --enable-threads=win32 )
329 + ;;
330 + *)
331 + confgcc+=( --enable-threads=posix )
332 + ;;
333 esac
334 fi
335
336 # __cxa_atexit is "essential for fully standards-compliant handling of
337 # destructors", but apparently requires glibc.
338 case ${CTARGET} in
339 - *-elf|*-eabi)
340 - confgcc+=( --with-newlib )
341 - ;;
342 - *-musl*)
343 - confgcc+=( --enable-__cxa_atexit )
344 - ;;
345 - *-gnu*)
346 - confgcc+=(
347 - --enable-__cxa_atexit
348 - --enable-clocale=gnu
349 - )
350 - ;;
351 - *-solaris*)
352 - confgcc+=( --enable-__cxa_atexit )
353 - ;;
354 + *-elf|*-eabi)
355 + confgcc+=( --with-newlib )
356 + ;;
357 + *-musl*)
358 + confgcc+=( --enable-__cxa_atexit )
359 + ;;
360 + *-gnu*)
361 + confgcc+=(
362 + --enable-__cxa_atexit
363 + --enable-clocale=gnu
364 + )
365 + ;;
366 + *-solaris*)
367 + confgcc+=( --enable-__cxa_atexit )
368 + ;;
369 esac
370
371 ### arch options
372 @@ -985,99 +1010,114 @@ toolchain_src_configure() {
373 tc_version_is_at_least 4.3 && in_iuse fixed-point && confgcc+=( $(use_enable fixed-point) )
374
375 case $(tc-is-softfloat) in
376 - yes) confgcc+=( --with-float=soft ) ;;
377 - softfp) confgcc+=( --with-float=softfp ) ;;
378 - *)
379 - # If they've explicitly opt-ed in, do hardfloat,
380 - # otherwise let the gcc default kick in.
381 - case ${CTARGET//_/-} in
382 - *-hardfloat-*|*eabihf) confgcc+=( --with-float=hard ) ;;
383 - esac
384 + yes)
385 + confgcc+=( --with-float=soft )
386 + ;;
387 + softfp)
388 + confgcc+=( --with-float=softfp )
389 + ;;
390 + *)
391 + # If they've explicitly opt-ed in, do hardfloat,
392 + # otherwise let the gcc default kick in.
393 + case ${CTARGET//_/-} in
394 + *-hardfloat-*|*eabihf)
395 + confgcc+=( --with-float=hard )
396 + ;;
397 + esac
398 esac
399
400 local with_abi_map=()
401 case $(tc-arch) in
402 - arm) #264534 #414395
403 - local a arm_arch=${CTARGET%%-*}
404 - # Remove trailing endian variations first: eb el be bl b l
405 - for a in e{b,l} {b,l}e b l ; do
406 - if [[ ${arm_arch} == *${a} ]] ; then
407 - arm_arch=${arm_arch%${a}}
408 - break
409 + arm)
410 + # bug 264534, bug #414395
411 + local a arm_arch=${CTARGET%%-*}
412 + # Remove trailing endian variations first: eb el be bl b l
413 + for a in e{b,l} {b,l}e b l ; do
414 + if [[ ${arm_arch} == *${a} ]] ; then
415 + arm_arch=${arm_arch%${a}}
416 + break
417 + fi
418 + done
419 +
420 + # Convert armv7{a,r,m} to armv7-{a,r,m}
421 + [[ ${arm_arch} == armv7? ]] && arm_arch=${arm_arch/7/7-}
422 + # See if this is a valid --with-arch flag
423 + if (srcdir=${S}/gcc target=${CTARGET} with_arch=${arm_arch};
424 + . "${srcdir}"/config.gcc) &>/dev/null
425 + then
426 + confgcc+=( --with-arch=${arm_arch} )
427 fi
428 - done
429 - # Convert armv7{a,r,m} to armv7-{a,r,m}
430 - [[ ${arm_arch} == armv7? ]] && arm_arch=${arm_arch/7/7-}
431 - # See if this is a valid --with-arch flag
432 - if (srcdir=${S}/gcc target=${CTARGET} with_arch=${arm_arch};
433 - . "${srcdir}"/config.gcc) &>/dev/null
434 - then
435 - confgcc+=( --with-arch=${arm_arch} )
436 - fi
437
438 - # Make default mode thumb for microcontroller classes #418209
439 - [[ ${arm_arch} == *-m ]] && confgcc+=( --with-mode=thumb )
440 + # Make default mode thumb for microcontroller classes #418209
441 + [[ ${arm_arch} == *-m ]] && confgcc+=( --with-mode=thumb )
442 +
443 + # Enable hardvfp
444 + if [[ $(tc-is-softfloat) == "no" ]] && \
445 + [[ ${CTARGET} == armv[67]* ]] && \
446 + tc_version_is_at_least 4.5
447 + then
448 + # Follow the new arm hardfp distro standard by default
449 + confgcc+=( --with-float=hard )
450 + case ${CTARGET} in
451 + armv6*) confgcc+=( --with-fpu=vfp ) ;;
452 + armv7*) confgcc+=( --with-fpu=vfpv3-d16 ) ;;
453 + esac
454 + fi
455 + ;;
456 + mips)
457 + # Add --with-abi flags to set default ABI
458 + confgcc+=( --with-abi=$(gcc-abi-map ${TARGET_DEFAULT_ABI}) )
459 + ;;
460
461 - # Enable hardvfp
462 - if [[ $(tc-is-softfloat) == "no" ]] && \
463 - [[ ${CTARGET} == armv[67]* ]] && \
464 - tc_version_is_at_least 4.5
465 - then
466 - # Follow the new arm hardfp distro standard by default
467 - confgcc+=( --with-float=hard )
468 - case ${CTARGET} in
469 - armv6*) confgcc+=( --with-fpu=vfp ) ;;
470 - armv7*) confgcc+=( --with-fpu=vfpv3-d16 ) ;;
471 - esac
472 - fi
473 - ;;
474 - mips)
475 - # Add --with-abi flags to set default ABI
476 - confgcc+=( --with-abi=$(gcc-abi-map ${TARGET_DEFAULT_ABI}) )
477 - ;;
478 - amd64)
479 - # drop the older/ABI checks once this get's merged into some
480 - # version of gcc upstream
481 - if tc_version_is_at_least 4.8 && has x32 $(get_all_abis TARGET) ; then
482 + amd64)
483 + # drop the older/ABI checks once this get's merged into some
484 + # version of gcc upstream
485 + if tc_version_is_at_least 4.8 && has x32 $(get_all_abis TARGET) ; then
486 + confgcc+=( --with-abi=$(gcc-abi-map ${TARGET_DEFAULT_ABI}) )
487 + fi
488 + ;;
489 + x86)
490 + # Default arch for x86 is normally i386, lets give it a bump
491 + # since glibc will do so based on CTARGET anyways
492 + confgcc+=( --with-arch=${CTARGET%%-*} )
493 + ;;
494 + hppa)
495 + # Enable sjlj exceptions for backward compatibility on hppa
496 + [[ ${GCCMAJOR} == "3" ]] && confgcc+=( --enable-sjlj-exceptions )
497 + ;;
498 + ppc)
499 + # Set up defaults based on current CFLAGS
500 + is-flagq -mfloat-gprs=double && confgcc+=( --enable-e500-double )
501 + [[ ${CTARGET//_/-} == *-e500v2-* ]] && confgcc+=( --enable-e500-double )
502 + ;;
503 + ppc64)
504 + # On ppc64 big endian target gcc assumes elfv1 by default,
505 + # and elfv2 on little endian
506 + # but musl does not support elfv1 at all on any endian ppc64
507 + # see https://git.musl-libc.org/cgit/musl/tree/INSTALL
508 + # bug #704784
509 + # https://gcc.gnu.org/PR93157
510 + [[ ${CTARGET} == powerpc64-*-musl ]] && confgcc+=( --with-abi=elfv2 )
511 + ;;
512 + riscv)
513 + # Add --with-abi flags to set default ABI
514 confgcc+=( --with-abi=$(gcc-abi-map ${TARGET_DEFAULT_ABI}) )
515 - fi
516 - ;;
517 - x86)
518 - # Default arch for x86 is normally i386, lets give it a bump
519 - # since glibc will do so based on CTARGET anyways
520 - confgcc+=( --with-arch=${CTARGET%%-*} )
521 - ;;
522 - hppa)
523 - # Enable sjlj exceptions for backward compatibility on hppa
524 - [[ ${GCCMAJOR} == "3" ]] && confgcc+=( --enable-sjlj-exceptions )
525 - ;;
526 - ppc)
527 - # Set up defaults based on current CFLAGS
528 - is-flagq -mfloat-gprs=double && confgcc+=( --enable-e500-double )
529 - [[ ${CTARGET//_/-} == *-e500v2-* ]] && confgcc+=( --enable-e500-double )
530 - ;;
531 - ppc64)
532 - # On ppc64 big endian target gcc assumes elfv1 by default,
533 - # and elfv2 on little endian
534 - # but musl does not support elfv1 at all on any endian ppc64
535 - # see https://git.musl-libc.org/cgit/musl/tree/INSTALL
536 - # https://bugs.gentoo.org/704784
537 - # https://gcc.gnu.org/PR93157
538 - [[ ${CTARGET} == powerpc64-*-musl ]] && confgcc+=( --with-abi=elfv2 )
539 - ;;
540 - riscv)
541 - # Add --with-abi flags to set default ABI
542 - confgcc+=( --with-abi=$(gcc-abi-map ${TARGET_DEFAULT_ABI}) )
543 - ;;
544 + ;;
545 esac
546
547 # if the target can do biarch (-m32/-m64), enable it. overhead should
548 # be small, and should simplify building of 64bit kernels in a 32bit
549 - # userland by not needing sys-devel/kgcc64. #349405
550 + # userland by not needing sys-devel/kgcc64. bug #349405
551 case $(tc-arch) in
552 - ppc|ppc64) confgcc+=( --enable-targets=all ) ;;
553 - sparc) tc_version_is_at_least 4.4 && confgcc+=( --enable-targets=all ) ;;
554 - amd64|x86) tc_version_is_at_least 4.3 && confgcc+=( --enable-targets=all ) ;;
555 + ppc|ppc64)
556 + confgcc+=( --enable-targets=all )
557 + ;;
558 + sparc)
559 + tc_version_is_at_least 4.4 && confgcc+=( --enable-targets=all )
560 + ;;
561 + amd64|x86)
562 + tc_version_is_at_least 4.3 && confgcc+=( --enable-targets=all )
563 + ;;
564 esac
565
566 # On Darwin we need libdir to be set in order to get correct install names
567 @@ -1099,7 +1139,7 @@ toolchain_src_configure() {
568 fi
569
570 if in_iuse openmp ; then
571 - # Make sure target has pthreads support. #326757 #335883
572 + # Make sure target has pthreads support: bug #326757, bug #335883
573 # There shouldn't be a chicken & egg problem here as openmp won't
574 # build without a C library, and you can't build that w/out
575 # already having a compiler ...
576 @@ -1127,8 +1167,12 @@ toolchain_src_configure() {
577 # configuration as target libc does not provide
578 # stack_chk_* functions. Do not disable libssp there.
579 case ${CTARGET} in
580 - mingw*|*-mingw*) ewarn "Not disabling libssp" ;;
581 - *) confgcc+=( --disable-libssp ) ;;
582 + mingw*|*-mingw*)
583 + ewarn "Not disabling libssp"
584 + ;;
585 + *)
586 + confgcc+=( --disable-libssp )
587 + ;;
588 esac
589 else
590 confgcc+=( --disable-libssp )
591 @@ -1178,7 +1222,7 @@ toolchain_src_configure() {
592 fi
593
594 # graphite was added in 4.4 but we only support it in 6.5+ due to external
595 - # library issues. #448024, #701270
596 + # library issues. bug #448024, bug #701270
597 if tc_version_is_at_least 6.5 && in_iuse graphite ; then
598 confgcc+=( $(use_with graphite isl) )
599 use graphite && confgcc+=( --disable-isl-version-check )
600 @@ -1211,7 +1255,7 @@ toolchain_src_configure() {
601 fi
602
603 # Disable gcc info regeneration -- it ships with generated info pages
604 - # already. Our custom version/urls/etc... trigger it. #464008
605 + # already. Our custom version/urls/etc... trigger it. bug #464008
606 export gcc_cv_prog_makeinfo_modern=no
607
608 # Do not let the X detection get in our way. We know things can be found
609 @@ -1239,15 +1283,16 @@ toolchain_src_configure() {
610 mkdir -p "${WORKDIR}"/build
611 pushd "${WORKDIR}"/build > /dev/null
612
613 - # and now to do the actual configuration
614 + # ...and now to do the actual configuration
615 addwrite /dev/zero
616 +
617 echo "${S}"/configure "${confgcc[@]}"
618 # Older gcc versions did not detect bash and re-exec itself, so force the
619 - # use of bash. Newer ones will auto-detect, but this is not harmful.
620 - CONFIG_SHELL="${EPREFIX}/bin/bash" \
621 - bash "${S}"/configure "${confgcc[@]}" || die "failed to run configure"
622 + # use of bash. Newer ones will auto-detect, but this is not harmful.
623 + CONFIG_SHELL="${BROOT}/bin/bash" \
624 + "${BROOT}"/bin/bash "${S}"/configure "${confgcc[@]}" || die "failed to run configure"
625
626 - # return to whatever directory we were in before
627 + # Return to whatever directory we were in before
628 popd > /dev/null
629 }
630
631 @@ -1320,7 +1365,7 @@ downgrade_arch_flags() {
632 fi
633 done
634
635 - # we only check -mno* here since -m* get removed by strip-flags later on
636 + # We only check -mno* here since -m* get removed by strip-flags later on
637 local isalist=(
638 4.9 -mno-sha
639 4.9 -mno-avx512pf
640 @@ -1372,16 +1417,19 @@ gcc_do_filter_flags() {
641 # relating to failed builds, we strip most CFLAGS out to ensure as few
642 # problems as possible.
643 strip-flags
644 +
645 # Lock gcc at -O2; we want to be conservative here.
646 filter-flags '-O?'
647 append-flags -O2
648 fi
649
650 - # dont want to funk ourselves
651 + # Don't want to funk ourselves
652 filter-flags '-mabi*' -m31 -m32 -m64
653
654 - filter-flags -frecord-gcc-switches # 490738
655 - filter-flags -mno-rtm -mno-htm # 506202
656 + # bug #490738
657 + filter-flags -frecord-gcc-switches
658 + # bug #506202
659 + filter-flags -mno-rtm -mno-htm
660
661 filter-flags '-fsanitize=*'
662
663 @@ -1396,25 +1444,25 @@ gcc_do_filter_flags() {
664 amd64|x86)
665 filter-flags '-mcpu=*'
666
667 - tc_version_is_between 4.4 4.5 && append-flags -mno-avx # 357287
668 + # bug #357287
669 + tc_version_is_between 4.4 4.5 && append-flags -mno-avx
670
671 if tc_version_is_between 4.6 4.7 ; then
672 - # https://bugs.gentoo.org/411333
673 - # https://bugs.gentoo.org/466454
674 + # bug #411333, bug #466454
675 replace-cpu-flags c3-2 pentium2 pentium3 pentium3m pentium-m i686
676 fi
677 ;;
678 alpha)
679 - # https://bugs.gentoo.org/454426
680 + # bug #454426
681 append-ldflags -Wl,--no-relax
682 ;;
683 sparc)
684 - # temporary workaround for random ICEs reproduced by multiple users
685 - # https://bugs.gentoo.org/457062
686 + # Temporary workaround for random ICEs reproduced by multiple users
687 + # bug #457062
688 tc_version_is_between 4.6 4.8 && MAKEOPTS+=" -j1"
689 ;;
690 *-macos)
691 - # http://gcc.gnu.org/PR25127
692 + # https://gcc.gnu.org/PR25127
693 tc_version_is_between 4.0 4.2 && \
694 filter-flags '-mcpu=*' '-march=*' '-mtune=*'
695 ;;
696 @@ -1422,7 +1470,7 @@ gcc_do_filter_flags() {
697
698 strip-unsupported-flags
699
700 - # these are set here so we have something sane at configure time
701 + # These are set here so we have something sane at configure time
702 if is_crosscompile ; then
703 # Set this to something sane for both native and target
704 CFLAGS="-O2 -pipe"
705 @@ -1464,7 +1512,7 @@ gcc-multilib-configure() {
706 confgcc+=( --enable-multilib )
707 fi
708
709 - # translate our notion of multilibs into gcc's
710 + # Translate our notion of multilibs into gcc's
711 local abi list
712 for abi in $(get_all_abis TARGET) ; do
713 local l=$(gcc-abi-map ${abi})
714 @@ -1483,9 +1531,15 @@ gcc-abi-map() {
715 # Convert the ABI name we use in Gentoo to what gcc uses
716 local map=()
717 case ${CTARGET} in
718 - mips*) map=("o32 32" "n32 n32" "n64 64") ;;
719 - riscv*) map=("lp64d lp64d" "lp64 lp64" "ilp32d ilp32d" "ilp32 ilp32") ;;
720 - x86_64*) map=("amd64 m64" "x86 m32" "x32 mx32") ;;
721 + mips*)
722 + map=("o32 32" "n32 n32" "n64 64")
723 + ;;
724 + riscv*)
725 + map=("lp64d lp64d" "lp64 lp64" "ilp32d ilp32d" "ilp32 ilp32")
726 + ;;
727 + x86_64*)
728 + map=("amd64 m64" "x86 m32" "x32 mx32")
729 + ;;
730 esac
731
732 local m
733 @@ -1512,9 +1566,9 @@ toolchain_src_compile() {
734 # Older gcc versions did not detect bash and re-exec itself, so force the
735 # use of bash. Newer ones will auto-detect, but this is not harmful.
736 # This needs to be set for compile as well, as it's used in libtool
737 - # generation, which will break install otherwise (at least in 3.3.6): #664486
738 + # generation, which will break install otherwise (at least in 3.3.6): bug #664486
739 CONFIG_SHELL="${EPREFIX}/bin/bash" \
740 - gcc_do_make ${GCC_MAKE_TARGET}
741 + gcc_do_make ${GCC_MAKE_TARGET}
742 }
743
744 gcc_do_make() {
745 @@ -1573,8 +1627,7 @@ gcc_do_make() {
746 STAGE1_CFLAGS="${STAGE1_CFLAGS}" \
747 LIBPATH="${LIBPATH}" \
748 BOOT_CFLAGS="${BOOT_CFLAGS}" \
749 - ${GCC_MAKE_TARGET} \
750 - || die "emake failed with ${GCC_MAKE_TARGET}"
751 + ${GCC_MAKE_TARGET}
752
753 if is_ada; then
754 # Without these links it is not getting the good compiler
755 @@ -1591,16 +1644,17 @@ gcc_do_make() {
756 if type -p doxygen > /dev/null ; then
757 if tc_version_is_at_least 4.3 ; then
758 cd "${CTARGET}"/libstdc++-v3/doc
759 - emake doc-man-doxygen || ewarn "failed to make docs"
760 + emake doc-man-doxygen
761 else
762 cd "${CTARGET}"/libstdc++-v3
763 - emake doxygen-man || ewarn "failed to make docs"
764 + emake doxygen-man
765 fi
766 - # Clean bogus manpages. #113902
767 + # Clean bogus manpages. bug #113902
768 find -name '*_build_*' -delete
769 - # Blow away generated directory references. Newer versions of gcc
770 - # have gotten better at this, but not perfect. This is easier than
771 - # backporting all of the various doxygen patches. #486754
772 +
773 + # Blow away generated directory references. Newer versions of gcc
774 + # have gotten better at this, but not perfect. This is easier than
775 + # backporting all of the various doxygen patches. bug #486754
776 find -name '*_.3' -exec grep -l ' Directory Reference ' {} + | \
777 xargs rm -f
778 else
779 @@ -1615,6 +1669,7 @@ gcc_do_make() {
780
781 toolchain_src_test() {
782 cd "${WORKDIR}"/build
783 +
784 # 'asan' wants to be preloaded first, so does 'sandbox'.
785 # To make asan tests work disable sandbox for all of test suite.
786 # 'backtrace' tests also does not like 'libsandbox.so' presence.
787 @@ -1630,7 +1685,7 @@ toolchain_src_install() {
788 find gcc/include*/ -type l -delete
789
790 # Copy over the info pages. We disabled their generation earlier, but the
791 - # build system only expects to install out of the build dir, not the source. #464008
792 + # build system only expects to install out of the build dir, not the source. bug #464008
793 mkdir -p gcc/doc
794 local x=
795 for x in "${S}"/gcc/doc/*.info* ; do
796 @@ -1675,7 +1730,7 @@ toolchain_src_install() {
797 # Setup the gcc_env_entry for hardened gcc 4 with minispecs
798 want_minispecs && copy_minispecs_gcc_specs
799
800 - # Make sure we dont have stuff lying around that
801 + # Make sure we don't have stuff lying around that
802 # can nuke multiple versions of gcc
803 gcc_slot_java
804
805 @@ -1714,7 +1769,7 @@ toolchain_src_install() {
806 # When cross-building gcc does install native tools.
807 if ! is_crosscompile; then
808 # Rename the main go binaries as we don't want to clobber dev-lang/go
809 - # when gcc-config runs. #567806
810 + # when gcc-config runs. bug #567806
811 if tc_version_is_at_least 5 && is_go ; then
812 for x in go gofmt; do
813 mv ${x} ${x}-${GCCMAJOR} || die
814 @@ -1722,7 +1777,7 @@ toolchain_src_install() {
815 fi
816 fi
817
818 - # As gcc installs object files built against bost ${CHOST} and ${CTARGET}
819 + # As gcc installs object files built against both ${CHOST} and ${CTARGET}
820 # ideally we will need to strip them using different tools:
821 # Using ${CHOST} tools:
822 # - "${D}${BINPATH}"
823 @@ -1745,14 +1800,14 @@ toolchain_src_install() {
824 fi
825 fi
826
827 - # portage regenerates 'dir' files on it's own: bug #672408
828 + # Portage regenerates 'dir' files on its own: bug #672408
829 # Drop 'dir' files to avoid collisions.
830 if [[ -f "${D}${DATAPATH}"/info/dir ]]; then
831 einfo "Deleting '${D}${DATAPATH}/info/dir'"
832 rm "${D}${DATAPATH}"/info/dir || die
833 fi
834
835 - # prune empty dirs left behind
836 + # Prune empty dirs left behind
837 find "${ED}" -depth -type d -delete 2>/dev/null
838
839 # libstdc++.la: Delete as it doesn't add anything useful: g++ itself
840 @@ -1768,14 +1823,14 @@ toolchain_src_install() {
841 # libgomp-plugin-*.la: Same as above, and it's an internal plugin only
842 # loaded via dlopen.
843 # libgfortran.la: gfortran itself handles linkage correctly in the
844 - # dynamic & static case (libgfortran.spec). #573302
845 + # dynamic & static case (libgfortran.spec). bug #573302
846 # libgfortranbegin.la: Same as above, and it's an internal lib.
847 # libmpx.la: gcc itself handles linkage correctly (libmpx.spec).
848 # libmpxwrappers.la: See above.
849 # libitm.la: gcc itself handles linkage correctly (libitm.spec).
850 # libvtv.la: gcc itself handles linkage correctly.
851 # lib*san.la: Sanitizer linkage is handled internally by gcc, and they
852 - # do not support static linking. #487550 #546700
853 + # do not support static linking. bug #487550, bug #546700
854 find "${D}${LIBPATH}" \
855 '(' \
856 -name libstdc++.la -o \
857 @@ -1805,9 +1860,12 @@ toolchain_src_install() {
858 pushd "${D}${LIBPATH}" >/dev/null
859 for py in $(find . -name '*-gdb.py') ; do
860 local multidir=${py%/*}
861 +
862 insinto "${gdbdir}/${multidir}"
863 - sed -i "/^libdir =/s:=.*:= '${LIBPATH}/${multidir}':" "${py}" || die #348128
864 - doins "${py}" || die
865 + # bug #348128
866 + sed -i "/^libdir =/s:=.*:= '${LIBPATH}/${multidir}':" "${py}" || die
867 + doins "${py}"
868 +
869 rm "${py}" || die
870 done
871 popd >/dev/null
872 @@ -1816,13 +1874,13 @@ toolchain_src_install() {
873 export QA_EXECSTACK="usr/lib*/go/*/*.gox"
874 export QA_WX_LOAD="usr/lib*/go/*/*.gox"
875
876 - # Disable RANDMMAP so PCH works. #301299
877 + # Disable RANDMMAP so PCH works, bug #301299
878 if tc_version_is_at_least 4.3 ; then
879 pax-mark -r "${D}${PREFIX}/libexec/gcc/${CTARGET}/${GCC_CONFIG_VER}/cc1"
880 pax-mark -r "${D}${PREFIX}/libexec/gcc/${CTARGET}/${GCC_CONFIG_VER}/cc1plus"
881 fi
882
883 - # Disable MPROTECT so java works. #574808
884 + # Disable MPROTECT so java works, bug #574808
885 if is_gcj ; then
886 pax-mark -m "${D}${PREFIX}/libexec/gcc/${CTARGET}/${GCC_CONFIG_VER}/ecj1"
887 pax-mark -m "${D}${PREFIX}/${CTARGET}/gcc-bin/${GCC_CONFIG_VER}/gij"
888 @@ -1898,8 +1956,8 @@ gcc_movelibs() {
889 find -depth "${ED}" -type d -exec rmdir {} + >& /dev/null
890 }
891
892 -# make sure the libtool archives have libdir set to where they actually
893 -# -are-, and not where they -used- to be. also, any dependencies we have
894 +# Make sure the libtool archives have libdir set to where they actually
895 +# -are-, and not where they -used- to be. Also, any dependencies we have
896 # on our own .la files need to be updated.
897 fix_libtool_libdir_paths() {
898 local libpath="$1"
899 @@ -1912,7 +1970,7 @@ fix_libtool_libdir_paths() {
900 allarchives="\(${allarchives// /\\|}\)"
901 popd >/dev/null
902
903 - # The libdir might not have any .la files. #548782
904 + # The libdir might not have any .la files. bug #548782
905 find "./${dir}" -maxdepth 1 -name '*.la' \
906 -exec sed -i -e "/^libdir=/s:=.*:='${dir}':" {} + || die
907 # Would be nice to combine these, but -maxdepth can not be specified
908 @@ -1985,12 +2043,12 @@ create_revdep_rebuild_entry() {
909 }
910
911 copy_minispecs_gcc_specs() {
912 - # on gcc 6 we don't need minispecs
913 + # On gcc 6, we don't need minispecs
914 if tc_version_is_at_least 6.0 ; then
915 return 0
916 fi
917
918 - # setup the hardenedno* specs files and the vanilla specs file.
919 + # Setup the hardenedno* specs files and the vanilla specs file.
920 if hardened_gcc_works ; then
921 create_gcc_env_entry hardenednopiessp
922 fi
923 @@ -2040,7 +2098,7 @@ gcc_slot_java() {
924 done
925
926 # Rename jar because it could clash with Kaffe's jar if this gcc is
927 - # primary compiler (aka don't have the -<version> extension)
928 + # primary compiler (aka doesn't have the -<version> extension)
929 cd "${D}${BINPATH}"
930 [[ -f jar ]] && mv -f jar gcj-jar
931 }
932 @@ -2068,7 +2126,7 @@ toolchain_pkg_postrm() {
933 eselect compiler-shadow clean all
934 fi
935
936 - # clean up the cruft left behind by cross-compilers
937 + # Clean up the cruft left behind by cross-compilers
938 if is_crosscompile ; then
939 if [[ -z $(ls "${EROOT}"/etc/env.d/gcc/${CTARGET}* 2>/dev/null) ]] ; then
940 einfo "Removing last cross-compiler instance. Deleting dangling symlinks."
941 @@ -2096,7 +2154,7 @@ do_gcc_config() {
942 current_gcc_config=$(gcc-config -c ${CTARGET} 2>/dev/null)
943 if [[ -n ${current_gcc_config} ]] ; then
944 local current_specs use_specs
945 - # figure out which specs-specific config is active
946 + # Figure out which specs-specific config is active
947 current_specs=$(gcc-config -S ${current_gcc_config} | awk '{print $3}')
948 [[ -n ${current_specs} ]] && use_specs=-${current_specs}
949
950 @@ -2114,7 +2172,7 @@ do_gcc_config() {
951 target="${CTARGET}-${GCC_CONFIG_VER}${use_specs}"
952 else
953 # The curent target is invalid. Attempt to switch to a valid one.
954 - # Blindly pick the latest version. #529608
955 + # Blindly pick the latest version. bug #529608
956 # TODO: Should update gcc-config to accept `-l ${CTARGET}` rather than
957 # doing a partial grep like this.
958 target=$(gcc-config -l 2>/dev/null | grep " ${CTARGET}-[0-9]" | tail -1 | awk '{print $2}')
959 @@ -2129,9 +2187,9 @@ should_we_gcc_config() {
960 local curr_config
961 curr_config=$(gcc-config -c ${CTARGET} 2>&1) || return 0
962
963 - # if the previously selected config has the same major.minor (branch) as
964 + # If the previously selected config has the same major.minor (branch) as
965 # the version we are installing, then it will probably be uninstalled
966 - # for being in the same SLOT, make sure we run gcc-config.
967 + # for being in the same SLOT, so make sure we run gcc-config.
968 local curr_config_ver=$(gcc-config -S ${curr_config} | awk '{print $2}')
969
970 local curr_branch_ver=$(ver_cut 1-2 ${curr_config_ver})
971 @@ -2139,12 +2197,14 @@ should_we_gcc_config() {
972 if [[ ${curr_branch_ver} == ${GCC_BRANCH_VER} ]] ; then
973 return 0
974 else
975 - # if we're installing a genuinely different compiler version,
976 + # If we're installing a genuinely different compiler version,
977 # we should probably tell the user -how- to switch to the new
978 - # gcc version, since we're not going to do it for him/her.
979 + # gcc version, since we're not going to do it for them.
980 + #
981 # We don't want to switch from say gcc-3.3 to gcc-3.4 right in
982 # the middle of an emerge operation (like an 'emerge -e world'
983 # which could install multiple gcc versions).
984 + #
985 # Only warn if we're installing a pkg as we might be called from
986 # the pkg_{pre,post}rm steps. #446830
987 if [[ ${EBUILD_PHASE} == *"inst" ]] ; then
988 @@ -2220,10 +2280,12 @@ is_go() {
989
990 is_jit() {
991 gcc-lang-supported jit || return 1
992 +
993 # cross-compiler does not really support jit as it has
994 - # to generate code for a target. On target like avr
995 + # to generate code for a target. On targets like avr,
996 # libgcclit.so can't link at all: bug #594572
997 is_crosscompile && return 1
998 +
999 _tc_use_if_iuse jit
1000 }
1001
1002 @@ -2250,7 +2312,7 @@ get_make_var() {
1003
1004 XGCC() { get_make_var GCC_FOR_TARGET ; }
1005
1006 -# The gentoo piessp patches allow for 3 configurations:
1007 +# The gentoo pie-ssp patches allow for 3 configurations:
1008 # 1) PIE+SSP by default
1009 # 2) PIE by default
1010 # 3) SSP by default
1011 @@ -2292,7 +2354,7 @@ hardened_gcc_is_stable() {
1012 }
1013
1014 want_minispecs() {
1015 - # on gcc 6 we don't need minispecs
1016 + # On gcc 6, we don't need minispecs
1017 if tc_version_is_at_least 6.0 ; then
1018 return 0
1019 fi