1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
4 # Maintainer: Toolchain Ninjas <toolchain@gentoo.org>
5 # @SUPPORTED_EAPIS: 5 6 7
7 DESCRIPTION="The GNU Compiler Collection"
8 HOMEPAGE="https://gcc.gnu.org/"
10 inherit eutils fixheadtails flag-o-matic gnuconfig libtool multilib pax-utils toolchain-funcs prefix
17 EGIT_REPO_URI="git://gcc.gnu.org/git/gcc.git"
19 # gcc-10.1.0_pre9999 -> gcc-10-branch
20 # Note that the micro version is required or lots of stuff will break.
21 # To checkout master set gcc_LIVE_BRANCH="master" in the ebuild before
22 # inheriting this eclass.
23 EGIT_BRANCH="releases/${PN}-${PV%.?.?_pre9999}"
24 EGIT_BRANCH=${EGIT_BRANCH//./_}
28 FEATURES=${FEATURES/multilib-strict/}
31 0|1|2|3|4*) die "Need to upgrade to at least EAPI=5" ;;
32 5*|6) inherit eapi7-ver ;;
34 *) die "I don't speak EAPI ${EAPI}." ;;
37 EXPORT_FUNCTIONS pkg_pretend pkg_setup src_unpack src_prepare src_configure \
38 src_compile src_test src_install pkg_postinst pkg_postrm
40 #---->> globals <<----
42 export CTARGET=${CTARGET:-${CHOST}}
43 if [[ ${CTARGET} = ${CHOST} ]] ; then
44 if [[ ${CATEGORY} == cross-* ]] ; then
45 export CTARGET=${CATEGORY#cross-}
48 : ${TARGET_ABI:=${ABI}}
49 : ${TARGET_MULTILIB_ABIS:=${MULTILIB_ABIS}}
50 : ${TARGET_DEFAULT_ABI:=${DEFAULT_ABI}}
53 [[ ${CHOST} != ${CTARGET} ]]
56 # General purpose version check. Without a second arg matches up to minor version (x.x.x)
57 tc_version_is_at_least() {
58 ver_test "${2:-${GCC_RELEASE_VER}}" -ge "$1"
61 # General purpose version range check
62 # Note that it matches up to but NOT including the second version
63 tc_version_is_between() {
64 tc_version_is_at_least "${1}" && ! tc_version_is_at_least "${2}"
67 GCC_PV=${TOOLCHAIN_GCC_PV:-${PV}}
69 [[ ${PR} != "r0" ]] && GCC_PVR=${GCC_PVR}-${PR}
71 # GCC_RELEASE_VER must always match 'gcc/BASE-VER' value.
72 # It's an internal representation of gcc version used for:
73 # - versioned paths on disk
74 # - 'gcc -dumpversion' output. Must always match <digit>.<digit>.<digit>.
75 GCC_RELEASE_VER=$(ver_cut 1-3 ${GCC_PV})
77 GCC_BRANCH_VER=$(ver_cut 1-2 ${GCC_PV})
78 GCCMAJOR=$(ver_cut 1 ${GCC_PV})
79 GCCMINOR=$(ver_cut 2 ${GCC_PV})
80 GCCMICRO=$(ver_cut 3 ${GCC_PV})
82 # Ideally this variable should allow for custom gentoo versioning
83 # of binary and gcc-config names not directly tied to upstream
84 # versioning. In practive it's hard to untangle from gcc/BASE-VER
85 # (GCC_RELEASE_VER) value.
86 GCC_CONFIG_VER=${GCC_RELEASE_VER}
88 # Pre-release support. Versioning schema:
89 # 1.0.0_pre9999: live ebuild
90 # 1.2.3_alphaYYYYMMDD: weekly snapshots
91 # 1.2.3_rcYYYYMMDD: release candidates
92 if [[ ${GCC_PV} == *_alpha* ]] ; then
94 SNAPSHOT=${GCCMAJOR}-${GCC_PV##*_alpha}
95 elif [[ ${GCC_PV} == *_rc* ]] ; then
97 SNAPSHOT=${GCC_PV%_rc*}-RC-${GCC_PV##*_rc}
100 PREFIX=${TOOLCHAIN_PREFIX:-${EPREFIX}/usr}
102 if tc_version_is_at_least 3.4.0 ; then
103 LIBPATH=${TOOLCHAIN_LIBPATH:-${PREFIX}/lib/gcc/${CTARGET}/${GCC_CONFIG_VER}}
105 LIBPATH=${TOOLCHAIN_LIBPATH:-${PREFIX}/lib/gcc-lib/${CTARGET}/${GCC_CONFIG_VER}}
107 INCLUDEPATH=${TOOLCHAIN_INCLUDEPATH:-${LIBPATH}/include}
109 if is_crosscompile ; then
110 BINPATH=${TOOLCHAIN_BINPATH:-${PREFIX}/${CHOST}/${CTARGET}/gcc-bin/${GCC_CONFIG_VER}}
111 HOSTLIBPATH=${PREFIX}/${CHOST}/${CTARGET}/lib/${GCC_CONFIG_VER}
113 BINPATH=${TOOLCHAIN_BINPATH:-${PREFIX}/${CTARGET}/gcc-bin/${GCC_CONFIG_VER}}
116 DATAPATH=${TOOLCHAIN_DATAPATH:-${PREFIX}/share/gcc-data/${CTARGET}/${GCC_CONFIG_VER}}
118 # Dont install in /usr/include/g++-v3/, but in gcc internal directory.
119 # We will handle /usr/include/g++-v3/ with gcc-config ...
120 STDCXX_INCDIR=${TOOLCHAIN_STDCXX_INCDIR:-${LIBPATH}/include/g++-v${GCC_BRANCH_VER/\.*/}}
122 #---->> LICENSE+SLOT+IUSE logic <<----
124 if tc_version_is_at_least 4.6 ; then
125 LICENSE="GPL-3+ LGPL-3+ || ( GPL-3+ libgcc libstdc++ gcc-runtime-library-exception-3.1 ) FDL-1.3+"
126 elif tc_version_is_at_least 4.4 ; then
127 LICENSE="GPL-3+ LGPL-3+ || ( GPL-3+ libgcc libstdc++ gcc-runtime-library-exception-3.1 ) FDL-1.2+"
128 elif tc_version_is_at_least 4.3 ; then
129 LICENSE="GPL-3+ LGPL-3+ || ( GPL-3+ libgcc libstdc++ ) FDL-1.2+"
130 elif tc_version_is_at_least 4.2 ; then
131 LICENSE="GPL-3+ LGPL-2.1+ || ( GPL-3+ libgcc libstdc++ ) FDL-1.2+"
132 elif tc_version_is_at_least 3.3 ; then
133 LICENSE="GPL-2+ LGPL-2.1+ FDL-1.2+"
135 LICENSE="GPL-2+ LGPL-2.1+ FDL-1.1+"
138 IUSE="test vanilla +nls"
139 RESTRICT="!test? ( test )"
141 tc_supports_dostrip() {
145 *) die "Update apply_patches() for ${EAPI}." ;;
149 tc_supports_dostrip || RESTRICT+=" strip" # cross-compilers need controlled stripping
154 has "$1" "${TC_FEATURES[@]}"
157 if [[ ${PN} != "kgcc64" && ${PN} != gcc-* ]] ; then
158 IUSE+=" altivec debug +cxx +nptl" TC_FEATURES+=(nptl)
159 [[ -n ${PIE_VER} ]] && IUSE+=" nopie"
160 [[ -n ${HTB_VER} ]] && IUSE+=" boundschecking"
161 [[ -n ${D_VER} ]] && IUSE+=" d"
162 [[ -n ${SPECS_VER} ]] && IUSE+=" nossp"
163 # fortran support appeared in 4.1, but 4.1 needs outdated mpfr
164 tc_version_is_at_least 4.2 && IUSE+=" +fortran" TC_FEATURES+=(fortran)
165 tc_version_is_at_least 3 && IUSE+=" doc hardened multilib objc"
166 tc_version_is_between 3 7 && IUSE+=" awt gcj" TC_FEATURES+=(gcj)
167 tc_version_is_at_least 3.3 && IUSE+=" pgo"
168 tc_version_is_at_least 4.0 &&
169 IUSE+=" objc-gc" TC_FEATURES+=(objc-gc)
170 tc_version_is_between 4.0 4.9 && IUSE+=" mudflap"
171 tc_version_is_at_least 4.1 && IUSE+=" libssp objc++"
172 tc_version_is_at_least 4.2 && IUSE+=" +openmp"
173 tc_version_is_at_least 4.3 && IUSE+=" fixed-point"
174 tc_version_is_at_least 4.7 && IUSE+=" go"
175 # sanitizer support appeared in gcc-4.8, but <gcc-5 does not
176 # support modern glibc.
177 tc_version_is_at_least 5 && IUSE+=" +sanitize"
179 # <gcc-4.8 supported graphite, it required forked ppl
180 # versions which we dropped. Since graphite was also experimental in
181 # the older versions, we don't want to bother supporting it. #448024
182 # <gcc-5 supported graphite, it required cloog
183 # <gcc-6.5 supported graphite, it required old incompatible isl
184 tc_version_is_at_least 6.5 &&
185 IUSE+=" graphite" TC_FEATURES+=(graphite)
186 tc_version_is_between 4.9 8 && IUSE+=" cilk"
187 tc_version_is_at_least 4.9 && IUSE+=" +vtv"
188 tc_version_is_at_least 5.0 && IUSE+=" jit"
189 tc_version_is_between 5.0 9 && IUSE+=" mpx"
190 tc_version_is_at_least 6.0 && IUSE+=" +pie +ssp +pch"
191 # systemtap is a gentoo-specific switch: bug #654748
192 tc_version_is_at_least 8.0 &&
193 IUSE+=" systemtap" TC_FEATURES+=(systemtap)
194 tc_version_is_at_least 9.0 && IUSE+=" d"
195 tc_version_is_at_least 9.1 && IUSE+=" lto"
196 tc_version_is_at_least 10 && IUSE+=" zstd" TC_FEATURES+=(zstd)
199 if tc_version_is_at_least 10; then
200 # Note: currently we pull in releases, snapshots and
201 # git versions into the same SLOT.
204 SLOT="${GCC_CONFIG_VER}"
207 #---->> DEPEND <<----
209 RDEPEND="sys-libs/zlib
210 nls? ( virtual/libintl )"
212 tc_version_is_at_least 3 && RDEPEND+=" virtual/libiconv"
214 if tc_version_is_at_least 4 ; then
215 GMP_MPFR_DEPS=">=dev-libs/gmp-4.3.2:0= >=dev-libs/mpfr-2.4.2:0="
216 if tc_version_is_at_least 4.3 ; then
217 RDEPEND+=" ${GMP_MPFR_DEPS}"
218 elif tc_has_feature fortran ; then
219 RDEPEND+=" fortran? ( ${GMP_MPFR_DEPS} )"
223 tc_version_is_at_least 4.5 && RDEPEND+=" >=dev-libs/mpc-0.8.1:0="
225 if tc_has_feature objc-gc ; then
226 if tc_version_is_at_least 7 ; then
227 RDEPEND+=" objc-gc? ( >=dev-libs/boehm-gc-7.4.2 )"
231 if tc_has_feature graphite ; then
232 RDEPEND+=" graphite? ( >=dev-libs/isl-0.14:0= )"
236 >=sys-devel/bison-1.875
237 >=sys-devel/flex-2.5.4
238 nls? ( sys-devel/gettext )
240 >=dev-util/dejagnu-1.4.4
241 >=sys-devel/autogen-5.5.4
245 if tc_has_feature gcj ; then
246 GCJ_DEPS=">=media-libs/libart_lgpl-2.1"
255 tc_version_is_at_least 3.4 && GCJ_GTK_DEPS+=" x11-libs/pango"
256 tc_version_is_at_least 4.2 && GCJ_DEPS+=" app-arch/zip app-arch/unzip"
257 DEPEND+=" gcj? ( awt? ( ${GCJ_GTK_DEPS} ) ${GCJ_DEPS} )"
260 if tc_has_feature systemtap ; then
261 # gcc needs sys/sdt.h headers on target
262 DEPEND+=" systemtap? ( dev-util/systemtap )"
265 if tc_has_feature zstd ; then
266 DEPEND+=" zstd? ( app-arch/zstd )"
270 5*|6) DEPEND+=" ${BDEPEND}" ;;
273 PDEPEND=">=sys-devel/gcc-config-1.7"
275 #---->> S + SRC_URI essentials <<----
277 # Set the source directory depending on whether we're using
278 # a live git tree, snapshot, or release tarball.
281 echo ${EGIT_CHECKOUT_DIR}
282 elif [[ -n ${SNAPSHOT} ]] ; then
283 echo ${WORKDIR}/gcc-${SNAPSHOT}
285 echo ${WORKDIR}/gcc-${GCC_RELEASE_VER}
290 local devspace="HTTP~vapier/dist/URI HTTP~rhill/dist/URI
291 HTTP~zorry/patches/gcc/URI HTTP~blueness/dist/URI
292 HTTP~tamiko/distfiles/URI HTTP~slyfox/distfiles/URI"
293 devspace=${devspace//HTTP/https:\/\/dev.gentoo.org\/}
294 echo mirror://gentoo/$1 ${devspace//URI/$1}
297 # This function handles the basics of setting the SRC_URI for a gcc ebuild.
298 # To use, set SRC_URI with:
300 # SRC_URI="$(get_gcc_src_uri)"
302 # Other than the variables normally set by portage, this function's behavior
303 # can be altered by setting the following:
305 # GCC_TARBALL_SRC_URI
306 # Override link to main tarball into SRC_URI. Used by dev-lang/gnat-gpl
307 # to provide gcc tarball snapshots. Patches are usually reused as-is.
310 # If set, this variable signals that we should be using a snapshot of
311 # gcc. It is expected to be in the format "YYYY-MM-DD". Note that if
312 # the ebuild has a _pre suffix, this variable is ignored and the
313 # prerelease tarball is used instead.
317 # This should be set to the version of the gentoo patch tarball.
318 # The resulting filename of this tarball will be:
319 # gcc-${PATCH_GCC_VER:-${GCC_RELEASE_VER}}-patches-${PATCH_VER}.tar.bz2
323 # These variables control patching in various updates for the logic
324 # controlling Position Independant Executables. PIE_VER is expected
325 # to be the version of this patch, and PIE_GCC_VER the gcc version of
329 # PIE_GCC_VER="3.4.0"
330 # The resulting filename of this tarball will be:
331 # gcc-${PIE_GCC_VER:-${GCC_RELEASE_VER}}-piepatches-v${PIE_VER}.tar.bz2
335 # This is for the minispecs files included in the hardened gcc-4.x
336 # The specs files for hardenedno*, vanilla and for building the "specs" file.
337 # SPECS_VER is expected to be the version of this patch, SPECS_GCC_VER
338 # the gcc version of the patch.
340 # SPECS_VER="8.7.6.5"
341 # SPECS_GCC_VER="3.4.0"
342 # The resulting filename of this tarball will be:
343 # gcc-${SPECS_GCC_VER:-${GCC_RELEASE_VER}}-specs-${SPECS_VER}.tar.bz2
347 # These variables control whether or not an ebuild supports Herman
348 # ten Brugge's bounds-checking patches. If you want to use a patch
349 # for an older gcc version with a new gcc, make sure you set
350 # HTB_GCC_VER to that version of gcc.
353 # If set, this variable signals that we should apply additional patches
354 # maintained by upstream Cygwin developers at github/cygwinports/gcc,
355 # using the specified git commit id there. The list of patches to
356 # apply is extracted from gcc.cygport, maintained there as well.
357 # This is done for compilers running on Cygwin, not for cross compilers
358 # with a Cygwin target.
360 export PATCH_GCC_VER=${PATCH_GCC_VER:-${GCC_RELEASE_VER}}
361 export UCLIBC_GCC_VER=${UCLIBC_GCC_VER:-${PATCH_GCC_VER}}
362 export PIE_GCC_VER=${PIE_GCC_VER:-${GCC_RELEASE_VER}}
363 export HTB_GCC_VER=${HTB_GCC_VER:-${GCC_RELEASE_VER}}
364 export SPECS_GCC_VER=${SPECS_GCC_VER:-${GCC_RELEASE_VER}}
366 # Set where to download gcc itself depending on whether we're using a
367 # live git tree, snapshot, or release tarball.
369 : # Nothing to do w/git snapshots.
370 elif [[ -n ${GCC_TARBALL_SRC_URI} ]] ; then
371 # pull gcc tarball from another location. Frequently used by gnat-gpl.
372 GCC_SRC_URI="${GCC_TARBALL_SRC_URI}"
373 elif [[ -n ${SNAPSHOT} ]] ; then
374 GCC_SRC_URI="ftp://gcc.gnu.org/pub/gcc/snapshots/${SNAPSHOT}/gcc-${SNAPSHOT}.tar.xz"
376 if tc_version_is_between 5.5 6 || tc_version_is_between 6.4 7 || tc_version_is_at_least 7.2 ; then
377 GCC_SRC_URI="mirror://gnu/gcc/gcc-${GCC_PV}/gcc-${GCC_RELEASE_VER}.tar.xz"
379 GCC_SRC_URI="mirror://gnu/gcc/gcc-${GCC_PV}/gcc-${GCC_RELEASE_VER}.tar.bz2"
383 [[ -n ${UCLIBC_VER} ]] && \
384 GCC_SRC_URI+=" $(gentoo_urls gcc-${UCLIBC_GCC_VER}-uclibc-patches-${UCLIBC_VER}.tar.bz2)"
385 [[ -n ${PATCH_VER} ]] && \
386 GCC_SRC_URI+=" $(gentoo_urls gcc-${PATCH_GCC_VER}-patches-${PATCH_VER}.tar.bz2)"
388 [[ -n ${PIE_VER} ]] && \
389 PIE_CORE=${PIE_CORE:-gcc-${PIE_GCC_VER}-piepatches-v${PIE_VER}.tar.bz2} && \
390 GCC_SRC_URI+=" $(gentoo_urls ${PIE_CORE})"
392 # gcc minispec for the hardened gcc 4 compiler
393 [[ -n ${SPECS_VER} ]] && \
394 GCC_SRC_URI+=" $(gentoo_urls gcc-${SPECS_GCC_VER}-specs-${SPECS_VER}.tar.bz2)"
396 # gcc bounds checking patch
397 if [[ -n ${HTB_VER} ]] ; then
398 local HTBFILE="bounds-checking-gcc-${HTB_GCC_VER}-${HTB_VER}.patch.bz2"
401 mirror://sourceforge/boundschecking/${HTBFILE}
402 $(gentoo_urls ${HTBFILE})
406 [[ -n ${D_VER} ]] && \
407 GCC_SRC_URI+=" d? ( mirror://sourceforge/dgcc/gdc-${D_VER}-src.tar.bz2 )"
409 if tc_has_feature gcj ; then
410 if tc_version_is_at_least 4.5 ; then
411 GCC_SRC_URI+=" gcj? ( ftp://sourceware.org/pub/java/ecj-4.5.jar )"
412 elif tc_version_is_at_least 4.3 ; then
413 GCC_SRC_URI+=" gcj? ( ftp://sourceware.org/pub/java/ecj-4.3.jar )"
417 # Cygwin patches from https://github.com/cygwinports/gcc
418 [[ -n ${CYGWINPORTS_GITREV} ]] && \
419 GCC_SRC_URI+=" elibc_Cygwin? ( https://github.com/cygwinports/gcc/archive/${CYGWINPORTS_GITREV}.tar.gz
420 -> gcc-cygwinports-${CYGWINPORTS_GITREV}.tar.gz )"
422 echo "${GCC_SRC_URI}"
425 SRC_URI=$(get_gcc_src_uri)
427 #---->> pkg_pretend <<----
429 toolchain_pkg_pretend() {
430 if ! use_if_iuse cxx ; then
431 use_if_iuse go && ewarn 'Go requires a C++ compiler, disabled due to USE="-cxx"'
432 use_if_iuse objc++ && ewarn 'Obj-C++ requires a C++ compiler, disabled due to USE="-cxx"'
433 use_if_iuse gcj && ewarn 'GCJ requires a C++ compiler, disabled due to USE="-cxx"'
439 #---->> pkg_setup <<----
441 toolchain_pkg_setup() {
442 # we dont want to use the installed compiler's specs to build gcc
444 unset LANGUAGES #265283
447 #---->> src_unpack <<----
449 toolchain_src_unpack() {
457 #---->> src_prepare <<----
459 # 'epatch' is not available in EAPI=7. Abstract away patchset application
460 # until we eventually get all gcc ebuilds on EAPI=7 or later.
462 [[ ${#@} -lt 2 ]] && die "usage: tc_apply_patches <message> <patches...>"
467 # Note: even for EAPI=6 we used 'epatch' semantics. To avoid
468 # breaking existing ebuilds use 'eapply' only in EAPI=7 or later.
471 *) die "Update apply_patches() for ${EAPI}." ;;
475 toolchain_src_prepare() {
476 export BRANDING_GCC_PKGVERSION="Gentoo ${GCC_PVR}"
479 if [[ -n ${D_VER} ]] && use d ; then
480 mv "${WORKDIR}"/d gcc/d || die
481 ebegin "Adding support for the D language"
482 ./gcc/d/setup-gcc.sh >& "${T}"/dgcc.log
484 eerror "The D GCC package failed to apply"
485 eerror "Please include this log file when posting a bug report:"
486 eerror " ${T}/dgcc.log"
487 die "failed to include the D language"
491 do_gcc_gentoo_patches
494 do_gcc_CYGWINPORTS_patches
497 BRANDING_GCC_PKGVERSION="${BRANDING_GCC_PKGVERSION}, commit ${EGIT_VERSION}"
503 *) die "Update toolchain_src_prepare() for ${EAPI}." ;;
506 if ( tc_version_is_at_least 4.8.2 || use_if_iuse hardened ) && ! use vanilla ; then
510 # install the libstdc++ python into the right location
511 # http://gcc.gnu.org/PR51368
512 if tc_version_is_between 4.5 4.7 ; then
514 '/^pythondir =/s:=.*:= $(datadir)/python:' \
515 "${S}"/libstdc++-v3/python/Makefile.in || die
518 # make sure the pkg config files install into multilib dirs.
519 # since we configure with just one --libdir, we can't use that
520 # (as gcc itself takes care of building multilibs). #435728
521 find "${S}" -name Makefile.in \
522 -exec sed -i '/^pkgconfigdir/s:=.*:=$(toolexeclibdir)/pkgconfig:' {} +
524 # No idea when this first started being fixed, but let's go with 4.3.x for now
525 if ! tc_version_is_at_least 4.3 ; then
527 for x in contrib/test_summary libstdc++-v3/scripts/check_survey.in ; do
528 [[ -e ${x} ]] && fix_files="${fix_files} ${x}"
530 ht_fix_file ${fix_files} */configure *.sh */Makefile.in
533 setup_multilib_osdirnames
536 if tc_version_is_at_least 4.1 ; then
537 local actual_version=$(< "${S}"/gcc/BASE-VER)
538 if [[ "${GCC_RELEASE_VER}" != "${actual_version}" ]] ; then
539 eerror "'${S}/gcc/BASE-VER' contains '${actual_version}', expected '${GCC_RELEASE_VER}'"
540 die "Please set 'TOOLCHAIN_GCC_PV' to '${actual_version}'"
544 # >= gcc-4.3 doesn't bundle ecj.jar, so copy it
545 if tc_version_is_at_least 4.3 && use_if_iuse gcj ; then
546 if tc_version_is_at_least 4.5 ; then
547 einfo "Copying ecj-4.5.jar"
548 cp -pPR "${DISTDIR}/ecj-4.5.jar" "${S}/ecj.jar" || die
550 einfo "Copying ecj-4.3.jar"
551 cp -pPR "${DISTDIR}/ecj-4.3.jar" "${S}/ecj.jar" || die
555 # disable --as-needed from being compiled into gcc specs
556 # natively when using a gcc version < 3.4.4
557 # http://gcc.gnu.org/PR14992
558 if ! tc_version_is_at_least 3.4.4 ; then
559 sed -i -e s/HAVE_LD_AS_NEEDED/USE_LD_AS_NEEDED/g "${S}"/gcc/config.in
562 # In gcc 3.3.x and 3.4.x, rename the java bins to gcc-specific names
563 # in line with gcc-4.
564 if tc_version_is_between 3.3 4.0 ; then
565 do_gcc_rename_java_bins
568 # Prevent libffi from being installed
569 if tc_version_is_between 3.0 4.8 ; then
570 sed -i -e 's/\(install.*:\) install-.*recursive/\1/' "${S}"/libffi/Makefile.in || die
571 sed -i -e 's/\(install-data-am:\).*/\1/' "${S}"/libffi/include/Makefile.in || die
574 # Fixup libtool to correctly generate .la files with portage
575 elibtoolize --portage --shallow --no-uclibc
579 # update configure files
581 einfo "Fixing misc issues in configure files"
582 for f in $(grep -l 'autoconf version 2.13' $(find "${S}" -name configure)) ; do
583 ebegin " Updating ${f/${S}\/} [LANG]"
584 patch "${f}" "${FILESDIR}"/gcc-configure-LANG.patch >& "${T}"/configure-patch.log \
585 || eerror "Please file a bug about this"
588 sed -i 's|A-Za-z0-9|[:alnum:]|g' "${S}"/gcc/*.awk #215828
590 # Prevent new texinfo from breaking old versions (see #198182, #464008)
591 if tc_version_is_at_least 4.1; then
592 tc_apply_patches "Remove texinfo (bug #198182, bug #464008)" "${FILESDIR}"/gcc-configure-texinfo.patch
596 if [[ -x contrib/gcc_update ]] ; then
597 einfo "Touching generated files"
598 ./contrib/gcc_update --touch | \
605 do_gcc_gentoo_patches() {
606 if ! use vanilla ; then
607 if [[ -n ${PATCH_VER} ]] ; then
608 tc_apply_patches "Applying Gentoo patches ..." "${WORKDIR}"/patch/*.patch
609 BRANDING_GCC_PKGVERSION="${BRANDING_GCC_PKGVERSION} p${PATCH_VER}"
611 if [[ -n ${UCLIBC_VER} ]] ; then
612 tc_apply_patches "Applying uClibc patches ..." "${WORKDIR}"/uclibc/*.patch
617 do_gcc_HTB_patches() {
618 use_if_iuse boundschecking || return 0
620 # modify the bounds checking patch with a regression patch
621 tc_apply_patches "Bounds checking patch" "${WORKDIR}/bounds-checking-gcc-${HTB_GCC_VER}-${HTB_VER}.patch"
622 BRANDING_GCC_PKGVERSION="${BRANDING_GCC_PKGVERSION}, HTB-${HTB_GCC_VER}-${HTB_VER}"
625 do_gcc_PIE_patches() {
627 use vanilla && return 0
629 tc_apply_patches "Applying pie patches ..." "${WORKDIR}"/piepatch/*.patch
631 BRANDING_GCC_PKGVERSION="${BRANDING_GCC_PKGVERSION}, pie-${PIE_VER}"
634 do_gcc_CYGWINPORTS_patches() {
635 [[ -n ${CYGWINPORTS_GITREV} ]] || return 0
636 use elibc_Cygwin || return 0
638 local p d="${WORKDIR}/gcc-${CYGWINPORTS_GITREV}"
639 # readarray -t is available since bash-4.4 only, #690686
642 sed -e '1,/PATCH_URI="/d;/"/,$d' < "${d}"/gcc.cygport
647 tc_apply_patches "Applying cygwin port patches ..." ${patches[*]}
650 # configure to build with the hardened GCC specs as the default
652 local gcc_hard_flags=""
654 # If we use gcc-6 or newer with pie enable to compile older gcc we need to pass -no-pie
655 # to stage1; bug #618908
656 if ! tc_version_is_at_least 6.0 && [[ $(gcc-major-version) -ge 6 ]] ; then
657 einfo "Disabling PIE in stage1 (only) ..."
658 sed -i -e "/^STAGE1_LDFLAGS/ s/$/ -no-pie/" "${S}"/Makefile.in || die
661 # Gcc >= 6.X we can use configurations options to turn pie/ssp on as default
662 if tc_version_is_at_least 6.0 ; then
663 if use_if_iuse pie ; then
664 einfo "Updating gcc to use automatic PIE building ..."
666 if use_if_iuse ssp ; then
667 einfo "Updating gcc to use automatic SSP building ..."
669 if use_if_iuse hardened ; then
670 # Will add some hardened options as default, like:
671 # -fstack-clash-protection
673 # see *_all_extra-options.patch gcc patches.
674 gcc_hard_flags+=" -DEXTRA_OPTIONS"
675 # rebrand to make bug reports easier
676 BRANDING_GCC_PKGVERSION=${BRANDING_GCC_PKGVERSION/Gentoo/Gentoo Hardened}
679 if use_if_iuse hardened ; then
680 # rebrand to make bug reports easier
681 BRANDING_GCC_PKGVERSION=${BRANDING_GCC_PKGVERSION/Gentoo/Gentoo Hardened}
682 if hardened_gcc_works ; then
683 einfo "Updating gcc to use automatic PIE + SSP building ..."
684 gcc_hard_flags+=" -DEFAULT_PIE_SSP"
685 elif hardened_gcc_works pie ; then
686 einfo "Updating gcc to use automatic PIE building ..."
687 ewarn "SSP has not been enabled by default"
688 gcc_hard_flags+=" -DEFAULT_PIE"
689 elif hardened_gcc_works ssp ; then
690 einfo "Updating gcc to use automatic SSP building ..."
691 ewarn "PIE has not been enabled by default"
692 gcc_hard_flags+=" -DEFAULT_SSP"
694 # do nothing if hardened isn't supported, but don't die either
695 ewarn "hardened is not supported for this arch in this gcc version"
699 if hardened_gcc_works ssp ; then
700 einfo "Updating gcc to use automatic SSP building ..."
701 gcc_hard_flags+=" -DEFAULT_SSP"
706 # we want to be able to control the pie patch logic via something other
708 sed -e '/^ALL_CFLAGS/iHARD_CFLAGS = ' \
709 -e 's|^ALL_CFLAGS = |ALL_CFLAGS = $(HARD_CFLAGS) |' \
710 -i "${S}"/gcc/Makefile.in
711 # Need to add HARD_CFLAGS to ALL_CXXFLAGS on >= 4.7
712 if tc_version_is_at_least 4.7 ; then
713 sed -e '/^ALL_CXXFLAGS/iHARD_CFLAGS = ' \
714 -e 's|^ALL_CXXFLAGS = |ALL_CXXFLAGS = $(HARD_CFLAGS) |' \
715 -i "${S}"/gcc/Makefile.in
719 -e "/^HARD_CFLAGS = /s|=|= ${gcc_hard_flags} |" \
720 "${S}"/gcc/Makefile.in || die
724 # This is a historical wart. The original Gentoo/amd64 port used:
725 # lib32 - 32bit binaries (x86)
726 # lib64 - 64bit binaries (x86_64)
727 # lib - "native" binaries (a symlink to lib64)
728 # Most other distros use the logic (including mainline gcc):
729 # lib - 32bit binaries (x86)
730 # lib64 - 64bit binaries (x86_64)
731 # Over time, Gentoo is migrating to the latter form.
733 # Unfortunately, due to distros picking the lib32 behavior, newer gcc
734 # versions will dynamically detect whether to use lib or lib32 for its
735 # 32bit multilib. So, to keep the automagic from getting things wrong
736 # while people are transitioning from the old style to the new style,
737 # we always set the MULTILIB_OSDIRNAMES var for relevant targets.
738 setup_multilib_osdirnames() {
739 is_multilib || return 0
742 local libdirs="../lib64 ../lib32"
744 # this only makes sense for some Linux targets
746 x86_64*-linux*) config="i386" ;;
747 powerpc64*-linux*) config="rs6000" ;;
748 sparc64*-linux*) config="sparc" ;;
749 s390x*-linux*) config="s390" ;;
755 if tc_version_is_at_least 4.6 ; then
756 sed_args+=( -e 's:$[(]call if_multiarch[^)]*[)]::g' )
758 if [[ ${SYMLINK_LIB} == "yes" ]] ; then
759 einfo "updating multilib directories to be: ${libdirs}"
760 if tc_version_is_at_least 4.6.4 || tc_version_is_at_least 4.7 ; then
761 sed_args+=( -e '/^MULTILIB_OSDIRNAMES.*lib32/s:[$][(]if.*):../lib32:' )
763 sed_args+=( -e "/^MULTILIB_OSDIRNAMES/s:=.*:= ${libdirs}:" )
766 einfo "using upstream multilib; disabling lib32 autodetection"
767 sed_args+=( -r -e 's:[$][(]if.*,(.*)[)]:\1:' )
769 sed -i "${sed_args[@]}" "${S}"/gcc/config/${config} || die
772 gcc_version_patch() {
773 # gcc-4.3+ has configure flags (whoo!)
774 tc_version_is_at_least 4.3 && return 0
776 local version_string=${GCC_RELEASE_VER}
778 einfo "patching gcc version: ${version_string} (${BRANDING_GCC_PKGVERSION})"
780 local gcc_sed=( -e 's:gcc\.gnu\.org/bugs\.html:bugs\.gentoo\.org/:' )
781 if grep -qs VERSUFFIX "${S}"/gcc/version.c ; then
782 gcc_sed+=( -e "/VERSUFFIX \"\"/s:\"\":\" (${BRANDING_GCC_PKGVERSION})\":" )
784 version_string="${version_string} (${BRANDING_GCC_PKGVERSION})"
785 gcc_sed+=( -e "/const char version_string\[\] = /s:= \".*\":= \"${version_string}\":" )
787 sed -i "${gcc_sed[@]}" "${S}"/gcc/version.c || die
790 do_gcc_rename_java_bins() {
791 # bug #139918 - conflict between gcc and java-config-2 for ownership of
792 # /usr/bin/rmi{c,registry}. Done with mv & sed rather than a patch
793 # because patches would be large (thanks to the rename of man files),
794 # and it's clear from the sed invocations that all that changes is the
795 # rmi{c,registry} names to grmi{c,registry} names.
796 # Kevin F. Quinn 2006-07-12
797 einfo "Renaming jdk executables rmic and rmiregistry to grmic and grmiregistry."
798 # 1) Move the man files if present (missing prior to gcc-3.4)
799 for manfile in rmic rmiregistry ; do
800 [[ -f ${S}/gcc/doc/${manfile}.1 ]] || continue
801 mv "${S}"/gcc/doc/${manfile}.1 "${S}"/gcc/doc/g${manfile}.1
803 # 2) Fixup references in the docs if present (mission prior to gcc-3.4)
804 for jfile in gcc/doc/gcj.info gcc/doc/grmic.1 gcc/doc/grmiregistry.1 gcc/java/gcj.texi ; do
805 [[ -f ${S}/${jfile} ]] || continue
806 sed -i -e 's:rmiregistry:grmiregistry:g' "${S}"/${jfile} ||
807 die "Failed to fixup file ${jfile} for rename to grmiregistry"
808 sed -i -e 's:rmic:grmic:g' "${S}"/${jfile} ||
809 die "Failed to fixup file ${jfile} for rename to grmic"
811 # 3) Fixup Makefiles to build the changed executable names
812 # These are present in all 3.x versions, and are the important bit
813 # to get gcc to build with the new names.
814 for jfile in libjava/Makefile.am libjava/Makefile.in gcc/java/Make-lang.in ; do
815 sed -i -e 's:rmiregistry:grmiregistry:g' "${S}"/${jfile} ||
816 die "Failed to fixup file ${jfile} for rename to grmiregistry"
817 # Careful with rmic on these files; it's also the name of a directory
818 # which should be left unchanged. Replace occurrences of 'rmic$',
819 # 'rmic_' and 'rmic '.
820 sed -i -e 's:rmic\([$_ ]\):grmic\1:g' "${S}"/${jfile} ||
821 die "Failed to fixup file ${jfile} for rename to grmic"
825 #---->> src_configure <<----
827 toolchain_src_configure() {
831 einfo "CFLAGS=\"${CFLAGS}\""
832 einfo "CXXFLAGS=\"${CXXFLAGS}\""
833 einfo "LDFLAGS=\"${LDFLAGS}\""
835 # Force internal zip based jar script to avoid random
836 # issues with 3rd party jar implementations. #384291
839 # For hardened gcc 4.3 piepatchset to build the hardened specs
840 # file (build.specs) to use when building gcc.
841 if ! tc_version_is_at_least 4.4 && want_minispecs ; then
842 setup_minispecs_gcc_build_specs
845 local confgcc=( --host=${CHOST} )
847 if is_crosscompile || tc-is-cross-compiler ; then
848 # Straight from the GCC install doc:
849 # "GCC has code to correctly determine the correct value for target
850 # for nearly all native systems. Therefore, we highly recommend you
851 # not provide a configure target when configuring a native compiler."
852 confgcc+=( --target=${CTARGET} )
854 [[ -n ${CBUILD} ]] && confgcc+=( --build=${CBUILD} )
858 --bindir="${BINPATH}"
859 --includedir="${INCLUDEPATH}"
860 --datadir="${DATAPATH}"
861 --mandir="${DATAPATH}/man"
862 --infodir="${DATAPATH}/info"
863 --with-gxx-include-dir="${STDCXX_INCDIR}"
866 # Stick the python scripts in their own slotted directory (bug #279252)
868 # --with-python-dir=DIR
869 # Specifies where to install the Python modules used for aot-compile. DIR
870 # should not include the prefix used in installation. For example, if the
871 # Python modules are to be installed in /usr/lib/python2.5/site-packages,
872 # then --with-python-dir=/lib/python2.5/site-packages should be passed.
874 # This should translate into "/share/gcc-data/${CTARGET}/${GCC_CONFIG_VER}/python"
875 if tc_version_is_at_least 4.4 ; then
876 confgcc+=( --with-python-dir=${DATAPATH/$PREFIX/}/python )
882 is_cxx && GCC_LANG+=",c++"
883 is_d && GCC_LANG+=",d"
884 is_gcj && GCC_LANG+=",java"
885 is_go && GCC_LANG+=",go"
886 is_jit && GCC_LANG+=",jit"
887 if is_objc || is_objcxx ; then
889 if tc_version_is_at_least 4 ; then
890 use objc-gc && confgcc+=( --enable-objc-gc )
892 is_objcxx && GCC_LANG+=",obj-c++"
895 # fortran support just got sillier! the lang value can be f77 for
896 # fortran77, f95 for fortran95, or just plain old fortran for the
897 # currently supported standard depending on gcc version.
898 is_fortran && GCC_LANG+=",fortran"
899 is_f77 && GCC_LANG+=",f77"
900 is_f95 && GCC_LANG+=",f95"
902 # We do NOT want 'ADA support' in here!
903 # is_ada && GCC_LANG+=",ada"
905 confgcc+=( --enable-languages=${GCC_LANG} )
917 confgcc+=( --enable-nls --without-included-gettext )
919 confgcc+=( --disable-nls )
922 tc_version_is_at_least 3.4 || confgcc+=( --disable-libunwind-exceptions )
924 # Use the default ("release") checking because upstream usually neglects
925 # to test "disabled" so it has a history of breaking. bug #317217
926 if tc_version_is_at_least 3.4 && in_iuse debug ; then
927 # The "release" keyword is new to 4.0. bug #551636
928 local off=$(tc_version_is_at_least 4.0 && echo release || echo no)
929 confgcc+=( --enable-checking="${GCC_CHECKS_LIST:-$(usex debug yes ${off})}" )
933 tc_version_is_at_least 4.3 && confgcc+=(
934 --with-bugurl=https://bugs.gentoo.org/
935 --with-pkgversion="${BRANDING_GCC_PKGVERSION}"
938 # If we want hardened support with the newer piepatchset for >=gcc 4.4
939 if tc_version_is_at_least 4.4 && want_minispecs && in_iuse hardened ; then
940 confgcc+=( $(use_enable hardened esp) )
943 # allow gcc to search for clock funcs in the main C lib.
944 # if it can't find them, then tough cookies -- we aren't
945 # going to link in -lrt to all C++ apps. bug #411681
946 if tc_version_is_at_least 4.4 && is_cxx ; then
947 confgcc+=( --enable-libstdcxx-time )
950 # Build compiler itself using LTO
951 if tc_version_is_at_least 9.1 && use_if_iuse lto ; then
952 confgcc+=( --with-build-config=bootstrap-lto )
955 # Support to disable pch when building libstdcxx
956 if tc_version_is_at_least 6.0 && ! use_if_iuse pch ; then
957 confgcc+=( --disable-libstdcxx-pch )
960 # The jit language requires this.
961 is_jit && confgcc+=( --enable-host-shared )
963 # build-id was disabled for file collisions: bug #526144
965 # # Turn on the -Wl,--build-id flag by default for ELF targets. bug #525942
966 # # This helps with locating debug files.
968 # *-linux-*|*-elf|*-eabi)
969 # tc_version_is_at_least 4.5 && confgcc+=(
970 # --enable-linker-build-id
975 # newer gcc versions like to bootstrap themselves with C++,
976 # so we need to manually disable it ourselves
977 if tc_version_is_between 4.7 4.8 && ! is_cxx ; then
978 confgcc+=( --disable-build-with-cxx --disable-build-poststage1-with-cxx )
981 ### Cross-compiler options
982 if is_crosscompile ; then
983 # Enable build warnings by default with cross-compilers when system
984 # paths are included (e.g. via -I flags).
985 confgcc+=( --enable-poison-system-directories )
987 # When building a stage1 cross-compiler (just C compiler), we have to
988 # disable a bunch of features or gcc goes boom
991 *-linux) needed_libc=error-unknown-libc;;
992 *-dietlibc) needed_libc=dietlibc;;
995 # Bare-metal targets don't have access to clock_gettime()
996 # arm-none-eabi example: bug #589672
997 # But we explicitly do --enable-libstdcxx-time above.
999 confgcc+=( --disable-libstdcxx-time )
1001 *-freebsd*) needed_libc=freebsd-lib;;
1002 *-gnu*) needed_libc=glibc;;
1003 *-klibc) needed_libc=klibc;;
1004 *-musl*) needed_libc=musl;;
1006 # Enable shared library support only on targets
1007 # that support it: bug #291870
1008 if ! echo '#include <features.h>' | \
1009 $(tc-getCPP ${CTARGET}) -E -dD - 2>/dev/null | \
1010 grep -q __HAVE_SHARED__
1012 confgcc+=( --disable-shared )
1014 needed_libc=uclibc-ng
1016 *-cygwin) needed_libc=cygwin;;
1018 *-w64-mingw*) needed_libc=mingw64-runtime;;
1019 avr) confgcc+=( --enable-shared --disable-threads );;
1021 if [[ -n ${needed_libc} ]] ; then
1022 local confgcc_no_libc=( --disable-shared )
1023 tc_version_is_at_least 4.8 && confgcc_no_libc+=( --disable-libatomic )
1024 if ! has_version ${CATEGORY}/${needed_libc} ; then
1026 "${confgcc_no_libc[@]}"
1030 elif has_version "${CATEGORY}/${needed_libc}[headers-only(-)]" ; then
1032 "${confgcc_no_libc[@]}"
1033 --with-sysroot="${PREFIX}"/${CTARGET}
1036 confgcc+=( --with-sysroot="${PREFIX}"/${CTARGET} )
1040 tc_version_is_at_least 4.2 && confgcc+=( --disable-bootstrap )
1042 if tc-is-static-only ; then
1043 confgcc+=( --disable-shared )
1045 confgcc+=( --enable-shared )
1049 confgcc+=( --enable-threads=win32 ) ;;
1051 confgcc+=( --enable-threads=posix ) ;;
1055 # __cxa_atexit is "essential for fully standards-compliant handling of
1056 # destructors", but apparently requires glibc.
1059 if tc_has_feature nptl ; then
1061 --disable-__cxa_atexit
1062 $(use_enable nptl tls)
1065 tc_version_is_between 3.3 3.4 && confgcc+=( --enable-sjlj-exceptions )
1066 if tc_version_is_between 3.4 4.3 ; then
1067 confgcc+=( --enable-clocale=uclibc )
1071 confgcc+=( --with-newlib )
1074 confgcc+=( --enable-__cxa_atexit )
1078 --enable-__cxa_atexit
1079 --enable-clocale=gnu
1083 confgcc+=( --enable-__cxa_atexit )
1086 confgcc+=( --enable-__cxa_atexit )
1092 gcc-multilib-configure
1094 # ppc altivec support
1095 in_iuse altivec && confgcc+=( $(use_enable altivec) )
1097 # gcc has fixed-point arithmetic support in 4.3 for mips targets that can
1098 # significantly increase compile time by several hours. This will allow
1099 # users to control this feature in the event they need the support.
1100 tc_version_is_at_least 4.3 && in_iuse fixed-point && confgcc+=( $(use_enable fixed-point) )
1102 case $(tc-is-softfloat) in
1103 yes) confgcc+=( --with-float=soft ) ;;
1104 softfp) confgcc+=( --with-float=softfp ) ;;
1106 # If they've explicitly opt-ed in, do hardfloat,
1107 # otherwise let the gcc default kick in.
1108 case ${CTARGET//_/-} in
1109 *-hardfloat-*|*eabihf) confgcc+=( --with-float=hard ) ;;
1113 local with_abi_map=()
1115 arm) #264534 #414395
1116 local a arm_arch=${CTARGET%%-*}
1117 # Remove trailing endian variations first: eb el be bl b l
1118 for a in e{b,l} {b,l}e b l ; do
1119 if [[ ${arm_arch} == *${a} ]] ; then
1120 arm_arch=${arm_arch%${a}}
1124 # Convert armv7{a,r,m} to armv7-{a,r,m}
1125 [[ ${arm_arch} == armv7? ]] && arm_arch=${arm_arch/7/7-}
1126 # See if this is a valid --with-arch flag
1127 if (srcdir=${S}/gcc target=${CTARGET} with_arch=${arm_arch};
1128 . "${srcdir}"/config.gcc) &>/dev/null
1130 confgcc+=( --with-arch=${arm_arch} )
1133 # Make default mode thumb for microcontroller classes #418209
1134 [[ ${arm_arch} == *-m ]] && confgcc+=( --with-mode=thumb )
1137 if [[ $(tc-is-softfloat) == "no" ]] && \
1138 [[ ${CTARGET} == armv[67]* ]] && \
1139 tc_version_is_at_least 4.5
1141 # Follow the new arm hardfp distro standard by default
1142 confgcc+=( --with-float=hard )
1144 armv6*) confgcc+=( --with-fpu=vfp ) ;;
1145 armv7*) confgcc+=( --with-fpu=vfpv3-d16 ) ;;
1150 # Add --with-abi flags to set default ABI
1151 confgcc+=( --with-abi=$(gcc-abi-map ${TARGET_DEFAULT_ABI}) )
1154 # drop the older/ABI checks once this get's merged into some
1155 # version of gcc upstream
1156 if tc_version_is_at_least 4.8 && has x32 $(get_all_abis TARGET) ; then
1157 confgcc+=( --with-abi=$(gcc-abi-map ${TARGET_DEFAULT_ABI}) )
1161 # Default arch for x86 is normally i386, lets give it a bump
1162 # since glibc will do so based on CTARGET anyways
1163 confgcc+=( --with-arch=${CTARGET%%-*} )
1166 # Enable sjlj exceptions for backward compatibility on hppa
1167 [[ ${GCCMAJOR} == "3" ]] && confgcc+=( --enable-sjlj-exceptions )
1170 # Set up defaults based on current CFLAGS
1171 is-flagq -mfloat-gprs=double && confgcc+=( --enable-e500-double )
1172 [[ ${CTARGET//_/-} == *-e500v2-* ]] && confgcc+=( --enable-e500-double )
1175 # On ppc64 big endian target gcc assumes elfv1 by default,
1176 # and elfv2 on little endian
1177 # but musl does not support elfv1 at all on any endian ppc64
1178 # see https://git.musl-libc.org/cgit/musl/tree/INSTALL
1179 # https://bugs.gentoo.org/704784
1180 # https://gcc.gnu.org/PR93157
1181 [[ ${CTARGET} == powerpc64-*-musl ]] && confgcc+=( --with-abi=elfv2 )
1184 # Add --with-abi flags to set default ABI
1185 confgcc+=( --with-abi=$(gcc-abi-map ${TARGET_DEFAULT_ABI}) )
1189 # if the target can do biarch (-m32/-m64), enable it. overhead should
1190 # be small, and should simplify building of 64bit kernels in a 32bit
1191 # userland by not needing sys-devel/kgcc64. #349405
1193 ppc|ppc64) tc_version_is_at_least 3.4 && confgcc+=( --enable-targets=all ) ;;
1194 sparc) tc_version_is_at_least 4.4 && confgcc+=( --enable-targets=all ) ;;
1195 amd64|x86) tc_version_is_at_least 4.3 && confgcc+=( --enable-targets=all ) ;;
1198 # On Darwin we need libdir to be set in order to get correct install names
1199 # for things like libobjc-gnu, libgcj and libfortran. If we enable it on
1200 # non-Darwin we screw up the behaviour this eclass relies on. We in
1201 # particular need this over --libdir for bug #255315.
1202 [[ ${CTARGET} == *-darwin* ]] && \
1203 confgcc+=( --enable-version-specific-runtime-libs )
1207 if tc_version_is_between 3.0 7.0 ; then
1209 confgcc+=( --disable-gjdoc )
1210 use awt && confgcc+=( --enable-java-awt=gtk )
1212 confgcc+=( --disable-libgcj )
1216 if tc_version_is_at_least 4.2 ; then
1217 if in_iuse openmp ; then
1218 # Make sure target has pthreads support. #326757 #335883
1219 # There shouldn't be a chicken & egg problem here as openmp won't
1220 # build without a C library, and you can't build that w/out
1221 # already having a compiler ...
1222 if ! is_crosscompile || \
1223 $(tc-getCPP ${CTARGET}) -E - <<<"#include <pthread.h>" >& /dev/null
1225 confgcc+=( $(use_enable openmp libgomp) )
1227 # Force disable as the configure script can be dumb #359855
1228 confgcc+=( --disable-libgomp )
1231 # For gcc variants where we don't want openmp (e.g. kgcc)
1232 confgcc+=( --disable-libgomp )
1236 if tc_version_is_at_least 4.0 ; then
1237 if in_iuse mudflap ; then
1238 confgcc+=( $(use_enable mudflap libmudflap) )
1240 confgcc+=( --disable-libmudflap )
1243 if use_if_iuse libssp ; then
1244 confgcc+=( --enable-libssp )
1246 if hardened_gcc_is_stable ssp; then
1247 export gcc_cv_libc_provides_ssp=yes
1249 if use_if_iuse ssp; then
1250 # On some targets USE="ssp -libssp" is an invalid
1251 # configuration as target libc does not provide
1252 # stack_chk_* functions. Do not disable libssp there.
1254 mingw*|*-mingw*) ewarn "Not disabling libssp" ;;
1255 *) confgcc+=( --disable-libssp ) ;;
1258 confgcc+=( --disable-libssp )
1263 if in_iuse cilk ; then
1264 confgcc+=( $(use_enable cilk libcilkrts) )
1267 if in_iuse mpx ; then
1268 confgcc+=( $(use_enable mpx libmpx) )
1271 if in_iuse systemtap ; then
1272 confgcc+=( $(use_enable systemtap) )
1275 if in_iuse vtv ; then
1277 $(use_enable vtv vtable-verify)
1278 # See Note [implicitly enabled flags]
1279 $(usex vtv '' --disable-libvtv)
1283 if in_iuse zstd ; then
1284 confgcc+=( $(use_with zstd) )
1287 # newer gcc's come with libquadmath, but only fortran uses
1288 # it, so auto punt it when we don't care
1289 if tc_version_is_at_least 4.6 && ! is_fortran ; then
1290 confgcc+=( --disable-libquadmath )
1293 if tc_version_is_at_least 4.6 ; then
1294 confgcc+=( --enable-lto )
1295 elif tc_version_is_at_least 4.5 ; then
1296 confgcc+=( --disable-lto )
1299 # graphite was added in 4.4 but we only support it in 6.5+ due to external
1300 # library issues. #448024, #701270
1301 if tc_version_is_at_least 6.5 && in_iuse graphite ; then
1302 confgcc+=( $(use_with graphite isl) )
1303 use graphite && confgcc+=( --disable-isl-version-check )
1304 elif tc_version_is_at_least 5.0 ; then
1305 confgcc+=( --without-isl )
1306 elif tc_version_is_at_least 4.8 ; then
1307 confgcc+=( --without-cloog )
1308 elif tc_version_is_at_least 4.4 ; then
1309 confgcc+=( --without-{cloog,ppl} )
1312 if tc_version_is_at_least 4.8; then
1313 if in_iuse sanitize ; then
1314 # See Note [implicitly enabled flags]
1315 confgcc+=( $(usex sanitize '' --disable-libsanitizer) )
1317 confgcc+=( --disable-libsanitizer )
1321 if tc_version_is_at_least 6.0 && in_iuse pie ; then
1322 confgcc+=( $(use_enable pie default-pie) )
1325 if tc_version_is_at_least 6.0 && in_iuse ssp ; then
1327 # This defaults to -fstack-protector-strong.
1328 $(use_enable ssp default-ssp)
1332 # Disable gcc info regeneration -- it ships with generated info pages
1333 # already. Our custom version/urls/etc... trigger it. #464008
1334 export gcc_cv_prog_makeinfo_modern=no
1336 # Do not let the X detection get in our way. We know things can be found
1337 # via system paths, so no need to hardcode things that'll break multilib.
1338 # Older gcc versions will detect ac_x_libraries=/usr/lib64 which ends up
1339 # killing the 32bit builds which want /usr/lib.
1340 export ac_cv_have_x='have_x=yes ac_x_includes= ac_x_libraries='
1342 confgcc+=( "$@" ${EXTRA_ECONF} )
1344 # Nothing wrong with a good dose of verbosity
1346 einfo "PREFIX: ${PREFIX}"
1347 einfo "BINPATH: ${BINPATH}"
1348 einfo "LIBPATH: ${LIBPATH}"
1349 einfo "DATAPATH: ${DATAPATH}"
1350 einfo "STDCXX_INCDIR: ${STDCXX_INCDIR}"
1352 einfo "Languages: ${GCC_LANG}"
1354 einfo "Configuring GCC with: ${confgcc[@]//--/\n\t--}"
1357 # Build in a separate build tree
1358 mkdir -p "${WORKDIR}"/build
1359 pushd "${WORKDIR}"/build > /dev/null
1361 # and now to do the actual configuration
1363 echo "${S}"/configure "${confgcc[@]}"
1364 # Older gcc versions did not detect bash and re-exec itself, so force the
1365 # use of bash. Newer ones will auto-detect, but this is not harmful.
1366 CONFIG_SHELL="${EPREFIX}/bin/bash" \
1367 bash "${S}"/configure "${confgcc[@]}" || die "failed to run configure"
1369 # return to whatever directory we were in before
1373 # Replace -m flags unsupported by the version being built with the best
1374 # available equivalent
1375 downgrade_arch_flags() {
1376 local arch bver i isa myarch mytune rep ver
1378 bver=${1:-${GCC_BRANCH_VER}}
1379 # Don't perform downgrade if running gcc is older than ebuild's.
1380 tc_version_is_at_least ${bver} $(gcc-version) || return 0
1381 [[ $(tc-arch) != amd64 && $(tc-arch) != x86 ]] && return 0
1383 myarch=$(get-flag march)
1384 mytune=$(get-flag mtune)
1386 # If -march=native isn't supported we have to tease out the actual arch
1387 if [[ ${myarch} == native || ${mytune} == native ]] ; then
1388 if ! tc_version_is_at_least 4.2 ${bver}; then
1389 arch=$($(tc-getCC) -march=native -v -E -P - </dev/null 2>&1 \
1390 | sed -rn "/cc1.*-march/s:.*-march=([^ ']*).*:\1:p")
1391 replace-cpu-flags native ${arch}
1395 # Handle special -mtune flags
1396 [[ ${mytune} == intel ]] && ! tc_version_is_at_least 4.9 ${bver} && replace-cpu-flags intel generic
1397 [[ ${mytune} == generic ]] && ! tc_version_is_at_least 4.2 ${bver} && filter-flags '-mtune=*'
1398 [[ ${mytune} == x86-64 ]] && filter-flags '-mtune=*'
1399 tc_version_is_at_least 3.4 ${bver} || filter-flags '-mtune=*'
1401 # "added" "arch" "replacement"
1405 4.9 broadwell core-avx2
1406 4.9 haswell core-avx2
1407 4.9 ivybridge core-avx-i
1409 4.9 sandybridge corei7-avx
1410 4.9 silvermont corei7
1415 4.7 core-avx2 core-avx-i
1418 4.6 core-avx-i core2
1420 4.6 corei7-avx core2
1423 4.3 athlon64-sse3 k8
1426 4.3 geode k6-2 # gcc.gnu.org/PR41989#c22
1429 3.4 athlon-fx x86-64
1434 3.4 pentium-m pentium3
1435 3.4 pentium3m pentium3
1436 3.4 pentium4m pentium4
1439 for ((i = 0; i < ${#archlist[@]}; i += 3)) ; do
1440 myarch=$(get-flag march)
1441 mytune=$(get-flag mtune)
1444 arch=${archlist[i + 1]}
1445 rep=${archlist[i + 2]}
1447 [[ ${myarch} != ${arch} && ${mytune} != ${arch} ]] && continue
1449 if ! tc_version_is_at_least ${ver} ${bver}; then
1450 einfo "Downgrading '${myarch}' (added in gcc ${ver}) with '${rep}'..."
1451 [[ ${myarch} == ${arch} ]] && replace-cpu-flags ${myarch} ${rep}
1452 [[ ${mytune} == ${arch} ]] && replace-cpu-flags ${mytune} ${rep}
1459 # we only check -mno* here since -m* get removed by strip-flags later on
1495 for ((i = 0; i < ${#isalist[@]}; i += 2)) ; do
1497 isa=${isalist[i + 1]}
1498 tc_version_is_at_least ${ver} ${bver} || filter-flags ${isa} ${isa/-m/-mno-}
1502 gcc_do_filter_flags() {
1503 # Be conservative here:
1504 # - don't allow -O3 and like to over-optimize libgcc # 701786
1505 # - don't allow -O0 to generate potentially invalid startup code
1510 # dont want to funk ourselves
1511 filter-flags '-mabi*' -m31 -m32 -m64
1513 filter-flags -frecord-gcc-switches # 490738
1514 filter-flags -mno-rtm -mno-htm # 506202
1516 if tc_version_is_between 3.2 3.4 ; then
1517 # XXX: this is so outdated it's barely useful, but it don't hurt...
1518 replace-cpu-flags G3 750
1519 replace-cpu-flags G4 7400
1520 replace-cpu-flags G5 7400
1522 # XXX: should add a sed or something to query all supported flags
1523 # from the gcc source and trim everything else ...
1524 filter-flags -f{no-,}unit-at-a-time -f{no-,}web -mno-tls-direct-seg-refs
1525 filter-flags -f{no-,}stack-protector{,-all}
1526 filter-flags -fvisibility-inlines-hidden -fvisibility=hidden
1527 # and warning options
1528 filter-flags -Wextra -Wstack-protector
1530 if ! tc_version_is_at_least 4.1 ; then
1531 filter-flags -fdiagnostics-show-option
1532 filter-flags -Wstack-protector
1535 if tc_version_is_between 6 8 ; then
1536 # -mstackrealign triggers crashes in exception throwing
1537 # at least on ada: bug #688580
1538 # The reason is unknown. Drop the flag for now.
1539 filter-flags -mstackrealign
1542 if tc_version_is_at_least 3.4 ; then
1545 filter-flags '-mcpu=*'
1547 tc_version_is_between 4.4 4.5 && append-flags -mno-avx # 357287
1549 if tc_version_is_between 4.6 4.7 ; then
1550 # https://bugs.gentoo.org/411333
1551 # https://bugs.gentoo.org/466454
1552 replace-cpu-flags c3-2 pentium2 pentium3 pentium3m pentium-m i686
1556 # https://bugs.gentoo.org/454426
1557 append-ldflags -Wl,--no-relax
1560 # temporary workaround for random ICEs reproduced by multiple users
1561 # https://bugs.gentoo.org/457062
1562 tc_version_is_between 4.6 4.8 && MAKEOPTS+=" -j1"
1565 # http://gcc.gnu.org/PR25127
1566 tc_version_is_between 4.0 4.2 && \
1567 filter-flags '-mcpu=*' '-march=*' '-mtune=*'
1572 strip-unsupported-flags
1574 # these are set here so we have something sane at configure time
1575 if is_crosscompile ; then
1576 # Set this to something sane for both native and target
1581 # "hppa2.0-unknown-linux-gnu" -> hppa2_0_unknown_linux_gnu
1582 local VAR="CFLAGS_"${CTARGET//[-.]/_}
1583 CXXFLAGS=${!VAR-${CFLAGS}}
1586 export GCJFLAGS=${GCJFLAGS:-${CFLAGS}}
1589 setup_minispecs_gcc_build_specs() {
1590 # Setup the "build.specs" file for gcc 4.3 to use when building.
1591 if hardened_gcc_works pie ; then
1592 cat "${WORKDIR}"/specs/pie.specs >> "${WORKDIR}"/build.specs
1594 if hardened_gcc_works ssp ; then
1595 for s in ssp sspall ; do
1596 cat "${WORKDIR}"/specs/${s}.specs >> "${WORKDIR}"/build.specs
1599 for s in nostrict znow ; do
1600 cat "${WORKDIR}"/specs/${s}.specs >> "${WORKDIR}"/build.specs
1602 export GCC_SPECS="${WORKDIR}"/build.specs
1605 gcc-multilib-configure() {
1606 if ! is_multilib ; then
1607 confgcc+=( --disable-multilib )
1608 # Fun times: if we are building for a target that has multiple
1609 # possible ABI formats, and the user has told us to pick one
1610 # that isn't the default, then not specifying it via the list
1611 # below will break that on us.
1613 confgcc+=( --enable-multilib )
1616 # translate our notion of multilibs into gcc's
1618 for abi in $(get_all_abis TARGET) ; do
1619 local l=$(gcc-abi-map ${abi})
1620 [[ -n ${l} ]] && list+=",${l}"
1622 if [[ -n ${list} ]] ; then
1625 tc_version_is_at_least 4.8 && confgcc+=( --with-multilib-list=${list:1} )
1632 # Convert the ABI name we use in Gentoo to what gcc uses
1635 mips*) map=("o32 32" "n32 n32" "n64 64") ;;
1636 riscv*) map=("lp64d lp64d" "lp64 lp64") ;;
1637 x86_64*) map=("amd64 m64" "x86 m32" "x32 mx32") ;;
1641 for m in "${map[@]}" ; do
1643 [[ $1 == ${l[0]} ]] && echo ${l[1]} && break
1647 #----> src_compile <----
1649 toolchain_src_compile() {
1650 touch "${S}"/gcc/c-gperf.h
1652 # Do not make manpages if we do not have perl ...
1653 [[ ! -x /usr/bin/perl ]] \
1654 && find "${WORKDIR}"/build -name '*.[17]' -exec touch {} +
1656 # Older gcc versions did not detect bash and re-exec itself, so force the
1657 # use of bash. Newer ones will auto-detect, but this is not harmful.
1658 # This needs to be set for compile as well, as it's used in libtool
1659 # generation, which will break install otherwise (at least in 3.3.6): #664486
1660 CONFIG_SHELL="${EPREFIX}/bin/bash" \
1661 gcc_do_make ${GCC_MAKE_TARGET}
1665 # This function accepts one optional argument, the make target to be used.
1666 # If omitted, gcc_do_make will try to guess whether it should use all,
1667 # or bootstrap-lean depending on CTARGET and arch.
1668 # An example of how to use this function:
1670 # gcc_do_make all-target-libstdc++-v3
1672 [[ -n ${1} ]] && GCC_MAKE_TARGET=${1}
1675 if is_crosscompile || tc-is-cross-compiler ; then
1676 # 3 stage bootstrapping doesnt quite work when you cant run the
1677 # resulting binaries natively ^^;
1678 GCC_MAKE_TARGET=${GCC_MAKE_TARGET-all}
1680 if tc_version_is_at_least 3.3 && use_if_iuse pgo; then
1681 GCC_MAKE_TARGET=${GCC_MAKE_TARGET-profiledbootstrap}
1683 GCC_MAKE_TARGET=${GCC_MAKE_TARGET-bootstrap-lean}
1687 # Older versions of GCC could not do profiledbootstrap in parallel due to
1688 # collisions with profiling info.
1689 # boundschecking also seems to introduce parallel build issues.
1690 if [[ ${GCC_MAKE_TARGET} == "profiledbootstrap" ]] || use_if_iuse boundschecking ; then
1691 ! tc_version_is_at_least 4.6 && export MAKEOPTS="${MAKEOPTS} -j1"
1694 if [[ ${GCC_MAKE_TARGET} == "all" ]] ; then
1695 STAGE1_CFLAGS=${STAGE1_CFLAGS-"${CFLAGS}"}
1696 elif [[ $(gcc-version) == "3.4" && ${GCC_BRANCH_VER} == "3.4" ]] && gcc-specs-ssp ; then
1698 STAGE1_CFLAGS=${STAGE1_CFLAGS-"-O2"}
1701 if is_crosscompile; then
1702 # In 3.4, BOOT_CFLAGS is never used on a crosscompile...
1703 # but I'll leave this in anyways as someone might have had
1704 # some reason for putting it in here... --eradicator
1705 BOOT_CFLAGS=${BOOT_CFLAGS-"-O2"}
1707 # we only want to use the system's CFLAGS if not building a
1709 BOOT_CFLAGS=${BOOT_CFLAGS-"$(get_abi_CFLAGS ${TARGET_DEFAULT_ABI}) ${CFLAGS}"}
1712 einfo "Compiling ${PN} (${GCC_MAKE_TARGET})..."
1714 pushd "${WORKDIR}"/build >/dev/null
1717 LDFLAGS="${LDFLAGS}" \
1718 STAGE1_CFLAGS="${STAGE1_CFLAGS}" \
1719 LIBPATH="${LIBPATH}" \
1720 BOOT_CFLAGS="${BOOT_CFLAGS}" \
1721 ${GCC_MAKE_TARGET} \
1722 || die "emake failed with ${GCC_MAKE_TARGET}"
1724 if ! is_crosscompile && use_if_iuse cxx && use_if_iuse doc ; then
1725 if type -p doxygen > /dev/null ; then
1726 if tc_version_is_at_least 4.3 ; then
1727 cd "${CTARGET}"/libstdc++-v3/doc
1728 emake doc-man-doxygen || ewarn "failed to make docs"
1729 elif tc_version_is_at_least 3.0 ; then
1730 cd "${CTARGET}"/libstdc++-v3
1731 emake doxygen-man || ewarn "failed to make docs"
1733 # Clean bogus manpages. #113902
1734 find -name '*_build_*' -delete
1735 # Blow away generated directory references. Newer versions of gcc
1736 # have gotten better at this, but not perfect. This is easier than
1737 # backporting all of the various doxygen patches. #486754
1738 find -name '*_.3' -exec grep -l ' Directory Reference ' {} + | \
1741 ewarn "Skipping libstdc++ manpage generation since you don't have doxygen installed"
1748 #---->> src_test <<----
1750 toolchain_src_test() {
1751 cd "${WORKDIR}"/build
1752 # 'asan' wants to be preloaded first, so does 'sandbox'.
1753 # To make asan tests work disable sandbox for all of test suite.
1754 # 'backtrace' tests also does not like 'libsandbox.so' presence.
1755 SANDBOX_ON=0 LD_PRELOAD= emake -k check
1758 #---->> src_install <<----
1760 toolchain_src_install() {
1761 cd "${WORKDIR}"/build
1763 # Don't allow symlinks in private gcc include dir as this can break the build
1764 find gcc/include*/ -type l -delete
1766 # Copy over the info pages. We disabled their generation earlier, but the
1767 # build system only expects to install out of the build dir, not the source. #464008
1770 for x in "${S}"/gcc/doc/*.info* ; do
1771 if [[ -f ${x} ]] ; then
1772 cp "${x}" gcc/doc/ || die
1776 # We remove the generated fixincludes, as they can cause things to break
1777 # (ncurses, openssl, etc). We do not prevent them from being built, as
1778 # in the following commit which we revert:
1779 # https://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/eclass/toolchain.eclass?r1=1.647&r2=1.648
1780 # This is because bsd userland needs fixedincludes to build gcc, while
1781 # linux does not. Both can dispose of them afterwards.
1783 grep -q 'It has been auto-edited by fixincludes from' "${x}" \
1785 done < <(find gcc/include*/ -name '*.h')
1787 # Do the 'make install' from the build directory
1788 S="${WORKDIR}"/build emake -j1 DESTDIR="${D}" install || die
1790 # Punt some tools which are really only useful while building gcc
1791 find "${ED}" -name install-tools -prune -type d -exec rm -rf "{}" \;
1792 # This one comes with binutils
1793 find "${ED}" -name libiberty.a -delete
1795 # Move the libraries to the proper location
1798 # Basic sanity check
1799 if ! is_crosscompile ; then
1801 eval $(grep ^EXEEXT= "${WORKDIR}"/build/gcc/config.log)
1802 [[ -r ${D}${BINPATH}/gcc${EXEEXT} ]] || die "gcc not found in ${ED}"
1805 dodir /etc/env.d/gcc
1806 create_gcc_env_entry
1807 create_revdep_rebuild_entry
1809 # Setup the gcc_env_entry for hardened gcc 4 with minispecs
1810 want_minispecs && copy_minispecs_gcc_specs
1812 # Make sure we dont have stuff lying around that
1813 # can nuke multiple versions of gcc
1818 # Ugh: we really need to auto-detect this list.
1819 # It's constantly out of date.
1820 for x in cpp gcc g++ c++ gcov g77 gcj gcjh gfortran gccgo gnat* ; do
1821 # For some reason, g77 gets made instead of ${CTARGET}-g77...
1822 # this should take care of that
1823 if [[ -f ${x} ]] ; then
1824 # In case they're hardlinks, clear out the target first
1825 # otherwise the mv below will complain.
1826 rm -f ${CTARGET}-${x}
1827 mv ${x} ${CTARGET}-${x}
1830 if [[ -f ${CTARGET}-${x} ]] ; then
1831 if ! is_crosscompile ; then
1832 ln -sf ${CTARGET}-${x} ${x}
1833 dosym ${BINPATH}/${CTARGET}-${x} \
1834 /usr/bin/${x}-${GCC_CONFIG_VER}
1836 # Create versioned symlinks
1837 dosym ${BINPATH}/${CTARGET}-${x} \
1838 /usr/bin/${CTARGET}-${x}-${GCC_CONFIG_VER}
1841 if [[ -f ${CTARGET}-${x}-${GCC_CONFIG_VER} ]] ; then
1842 rm -f ${CTARGET}-${x}-${GCC_CONFIG_VER}
1843 ln -sf ${CTARGET}-${x} ${CTARGET}-${x}-${GCC_CONFIG_VER}
1847 # When gcc builds a crosscompiler it does not install unprefixed tools.
1848 # When cross-building gcc does install native tools.
1849 if ! is_crosscompile; then
1850 # Rename the main go binaries as we don't want to clobber dev-lang/go
1851 # when gcc-config runs. #567806
1852 if tc_version_is_at_least 5 && is_go ; then
1853 for x in go gofmt; do
1854 mv ${x} ${x}-${GCCMAJOR} || die
1859 # As gcc installs object files built against bost ${CHOST} and ${CTARGET}
1860 # ideally we will need to strip them using different tools:
1861 # Using ${CHOST} tools:
1862 # - "${D}${BINPATH}"
1863 # - (for is_crosscompile) "${D}${HOSTLIBPATH}"
1864 # - "${D}${PREFIX}/libexec/gcc/${CTARGET}/${GCC_CONFIG_VER}"
1865 # Using ${CTARGET} tools:
1866 # - "${D}${LIBPATH}"
1867 # As dostrip does not specify host to override ${CHOST} tools just skip
1868 # non-native binary stripping.
1869 is_crosscompile && tc_supports_dostrip && dostrip -x "${LIBPATH}"
1872 if is_crosscompile; then
1873 rm -rf "${ED}"/usr/share/{man,info}
1874 rm -rf "${D}"${DATAPATH}/{man,info}
1876 if tc_version_is_at_least 3.0 ; then
1877 local cxx_mandir=$(find "${WORKDIR}/build/${CTARGET}/libstdc++-v3" -name man)
1878 if [[ -d ${cxx_mandir} ]] ; then
1879 cp -r "${cxx_mandir}"/man? "${D}${DATAPATH}"/man/
1884 # portage regenerates 'dir' files on it's own: bug #672408
1885 # Drop 'dir' files to avoid collisions.
1886 if [[ -f "${D}${DATAPATH}"/info/dir ]]; then
1887 einfo "Deleting '${D}${DATAPATH}/info/dir'"
1888 rm "${D}${DATAPATH}"/info/dir || die
1891 # prune empty dirs left behind
1892 find "${ED}" -depth -type d -delete 2>/dev/null
1894 # Rather install the script, else portage with changing $FILESDIR
1895 # between binary and source package borks things ....
1896 if ! is_crosscompile && [[ ${PN} != "kgcc64" ]] ; then
1897 insinto "${DATAPATH#${EPREFIX}}"
1898 newins "$(prefixify_ro "${FILESDIR}"/awk/fixlafiles.awk-no_gcc_la)" fixlafiles.awk || die
1899 exeinto "${DATAPATH#${EPREFIX}}"
1900 doexe "$(prefixify_ro "${FILESDIR}"/fix_libtool_files.sh)" || die
1901 doexe "${FILESDIR}"/c{89,99} || die
1904 # libstdc++.la: Delete as it doesn't add anything useful: g++ itself
1905 # handles linkage correctly in the dynamic & static case. It also just
1906 # causes us pain: any C++ progs/libs linking with libtool will gain a
1907 # reference to the full libstdc++.la file which is gcc version specific.
1908 # libstdc++fs.la: It doesn't link against anything useful.
1909 # libsupc++.la: This has no dependencies.
1910 # libcc1.la: There is no static library, only dynamic.
1911 # libcc1plugin.la: Same as above, and it's loaded via dlopen.
1912 # libcp1plugin.la: Same as above, and it's loaded via dlopen.
1913 # libgomp.la: gcc itself handles linkage (libgomp.spec).
1914 # libgomp-plugin-*.la: Same as above, and it's an internal plugin only
1915 # loaded via dlopen.
1916 # libgfortran.la: gfortran itself handles linkage correctly in the
1917 # dynamic & static case (libgfortran.spec). #573302
1918 # libgfortranbegin.la: Same as above, and it's an internal lib.
1919 # libmpx.la: gcc itself handles linkage correctly (libmpx.spec).
1920 # libmpxwrappers.la: See above.
1921 # libitm.la: gcc itself handles linkage correctly (libitm.spec).
1922 # libvtv.la: gcc itself handles linkage correctly.
1923 # lib*san.la: Sanitizer linkage is handled internally by gcc, and they
1924 # do not support static linking. #487550 #546700
1925 find "${D}${LIBPATH}" \
1927 -name libstdc++.la -o \
1928 -name libstdc++fs.la -o \
1929 -name libsupc++.la -o \
1930 -name libcc1.la -o \
1931 -name libcc1plugin.la -o \
1932 -name libcp1plugin.la -o \
1933 -name 'libgomp.la' -o \
1934 -name 'libgomp-plugin-*.la' -o \
1935 -name libgfortran.la -o \
1936 -name libgfortranbegin.la -o \
1937 -name libmpx.la -o \
1938 -name libmpxwrappers.la -o \
1939 -name libitm.la -o \
1940 -name libvtv.la -o \
1941 -name 'lib*san.la' \
1944 # Use gid of 0 because some stupid ports don't have
1945 # the group 'root' set to gid 0. Send to /dev/null
1946 # for people who are testing as non-root.
1947 chown -R root:0 "${D}${LIBPATH}" 2>/dev/null
1949 # Installing gdb pretty-printers into gdb-specific location.
1950 local py gdbdir=/usr/share/gdb/auto-load${LIBPATH}
1951 pushd "${D}${LIBPATH}" >/dev/null
1952 for py in $(find . -name '*-gdb.py') ; do
1953 local multidir=${py%/*}
1954 insinto "${gdbdir}/${multidir}"
1955 sed -i "/^libdir =/s:=.*:= '${LIBPATH}/${multidir}':" "${py}" || die #348128
1956 doins "${py}" || die
1961 # Don't scan .gox files for executable stacks - false positives
1962 export QA_EXECSTACK="usr/lib*/go/*/*.gox"
1963 export QA_WX_LOAD="usr/lib*/go/*/*.gox"
1965 # Disable RANDMMAP so PCH works. #301299
1966 if tc_version_is_at_least 4.3 ; then
1967 pax-mark -r "${D}${PREFIX}/libexec/gcc/${CTARGET}/${GCC_CONFIG_VER}/cc1"
1968 pax-mark -r "${D}${PREFIX}/libexec/gcc/${CTARGET}/${GCC_CONFIG_VER}/cc1plus"
1971 # Disable MPROTECT so java works. #574808
1973 pax-mark -m "${D}${PREFIX}/libexec/gcc/${CTARGET}/${GCC_CONFIG_VER}/ecj1"
1974 pax-mark -m "${D}${PREFIX}/${CTARGET}/gcc-bin/${GCC_CONFIG_VER}/gij"
1978 # Move around the libs to the right location. For some reason,
1979 # when installing gcc, it dumps internal libraries into /usr/lib
1980 # instead of the private gcc lib path
1982 # older versions of gcc did not support --print-multi-os-directory
1983 tc_version_is_at_least 3.2 || return 0
1985 # For non-target libs which are for CHOST and not CTARGET, we want to
1986 # move them to the compiler-specific CHOST internal dir. This is stuff
1987 # that you want to link against when building tools rather than building
1988 # code to run on the target.
1989 if tc_version_is_at_least 5 && is_crosscompile ; then
1990 dodir "${HOSTLIBPATH#${EPREFIX}}"
1991 mv "${ED}"/usr/$(get_libdir)/libcc1* "${D}${HOSTLIBPATH}" || die
1994 # For all the libs that are built for CTARGET, move them into the
1995 # compiler-specific CTARGET internal dir.
1996 local x multiarg removedirs=""
1997 for multiarg in $($(XGCC) -print-multi-lib) ; do
1998 multiarg=${multiarg#*;}
1999 multiarg=${multiarg//@/ -}
2001 local OS_MULTIDIR=$($(XGCC) ${multiarg} --print-multi-os-directory)
2002 local MULTIDIR=$($(XGCC) ${multiarg} --print-multi-directory)
2003 local TODIR="${D}${LIBPATH}"/${MULTIDIR}
2006 [[ -d ${TODIR} ]] || mkdir -p ${TODIR}
2009 "${LIBPATH}"/${OS_MULTIDIR} \
2010 "${LIBPATH}"/../${MULTIDIR} \
2011 "${PREFIX}"/lib/${OS_MULTIDIR} \
2012 "${PREFIX}"/${CTARGET}/lib/${OS_MULTIDIR}
2014 removedirs="${removedirs} ${FROMDIR}"
2015 FROMDIR=${D}${FROMDIR}
2016 if [[ ${FROMDIR} != "${TODIR}" && -d ${FROMDIR} ]] ; then
2017 local files=$(find "${FROMDIR}" -maxdepth 1 ! -type d 2>/dev/null)
2018 if [[ -n ${files} ]] ; then
2019 mv ${files} "${TODIR}" || die
2023 fix_libtool_libdir_paths "${LIBPATH}/${MULTIDIR}"
2025 # SLOT up libgcj.pc if it's available (and let gcc-config worry about links)
2026 FROMDIR="${PREFIX}/lib/${OS_MULTIDIR}"
2027 for x in "${D}${FROMDIR}"/pkgconfig/libgcj*.pc ; do
2028 [[ -f ${x} ]] || continue
2029 sed -i "/^libdir=/s:=.*:=${LIBPATH}/${MULTIDIR}:" "${x}" || die
2030 mv "${x}" "${D}${FROMDIR}"/pkgconfig/libgcj-${GCC_PV}.pc || die
2034 # We remove directories separately to avoid this case:
2035 # mv SRC/lib/../lib/*.o DEST
2036 # rmdir SRC/lib/../lib/
2037 # mv SRC/lib/../lib32/*.o DEST # Bork
2038 for FROMDIR in ${removedirs} ; do
2039 rmdir "${D}"${FROMDIR} >& /dev/null
2041 find -depth "${ED}" -type d -exec rmdir {} + >& /dev/null
2044 # make sure the libtool archives have libdir set to where they actually
2045 # -are-, and not where they -used- to be. also, any dependencies we have
2046 # on our own .la files need to be updated.
2047 fix_libtool_libdir_paths() {
2050 pushd "${D}" >/dev/null
2052 pushd "./${libpath}" >/dev/null
2053 local dir="${PWD#${D%/}}"
2054 local allarchives=$(echo *.la)
2055 allarchives="\(${allarchives// /\\|}\)"
2058 # The libdir might not have any .la files. #548782
2059 find "./${dir}" -maxdepth 1 -name '*.la' \
2060 -exec sed -i -e "/^libdir=/s:=.*:='${dir}':" {} + || die
2061 # Would be nice to combine these, but -maxdepth can not be specified
2062 # on sub-expressions.
2063 find "./${PREFIX}"/lib* -maxdepth 3 -name '*.la' \
2064 -exec sed -i -e "/^dependency_libs=/s:/[^ ]*/${allarchives}:${libpath}/\1:g" {} + || die
2065 find "./${dir}/" -maxdepth 1 -name '*.la' \
2066 -exec sed -i -e "/^dependency_libs=/s:/[^ ]*/${allarchives}:${libpath}/\1:g" {} + || die
2071 create_gcc_env_entry() {
2072 dodir /etc/env.d/gcc
2073 local gcc_envd_base="/etc/env.d/gcc/${CTARGET}-${GCC_CONFIG_VER}"
2075 local gcc_specs_file
2076 local gcc_envd_file="${ED}${gcc_envd_base}"
2077 if [[ -z $1 ]] ; then
2078 # I'm leaving the following commented out to remind me that it
2079 # was an insanely -bad- idea. Stuff broke. GCC_SPECS isnt unset
2080 # on chroot or in non-toolchain.eclass gcc ebuilds!
2081 #gcc_specs_file="${LIBPATH}/specs"
2084 gcc_envd_file+="-$1"
2085 gcc_specs_file="${LIBPATH}/$1.specs"
2088 # We want to list the default ABI's LIBPATH first so libtool
2089 # searches that directory first. This is a temporary
2090 # workaround for libtool being stupid and using .la's from
2091 # conflicting ABIs by using the first one in the search path
2092 local ldpaths mosdirs
2093 if tc_version_is_at_least 3.2 ; then
2094 local mdir mosdir abi ldpath
2095 for abi in $(get_all_abis TARGET) ; do
2096 mdir=$($(XGCC) $(get_abi_CFLAGS ${abi}) --print-multi-directory)
2098 [[ ${mdir} != "." ]] && ldpath+="/${mdir}"
2099 ldpaths="${ldpath}${ldpaths:+:${ldpaths}}"
2101 mosdir=$($(XGCC) $(get_abi_CFLAGS ${abi}) -print-multi-os-directory)
2102 mosdirs="${mosdir}${mosdirs:+:${mosdirs}}"
2105 # Older gcc's didn't do multilib, so logic is simple.
2109 cat <<-EOF > ${gcc_envd_file}
2110 GCC_PATH="${BINPATH}"
2112 MANPATH="${DATAPATH}/man"
2113 INFOPATH="${DATAPATH}/info"
2114 STDCXX_INCDIR="${STDCXX_INCDIR##*/}"
2115 CTARGET="${CTARGET}"
2116 GCC_SPECS="${gcc_specs_file}"
2117 MULTIOSDIRS="${mosdirs}"
2121 create_revdep_rebuild_entry() {
2122 local revdep_rebuild_base="/etc/revdep-rebuild/05cross-${CTARGET}-${GCC_CONFIG_VER}"
2123 local revdep_rebuild_file="${ED}${revdep_rebuild_base}"
2125 is_crosscompile || return 0
2127 dodir /etc/revdep-rebuild
2128 cat <<-EOF > "${revdep_rebuild_file}"
2129 # Generated by ${CATEGORY}/${PF}
2130 # Ignore libraries built for ${CTARGET}, https://bugs.gentoo.org/692844.
2131 SEARCH_DIRS_MASK="${LIBPATH}"
2135 copy_minispecs_gcc_specs() {
2136 # on gcc 6 we don't need minispecs
2137 if tc_version_is_at_least 6.0 ; then
2141 # setup the hardenedno* specs files and the vanilla specs file.
2142 if hardened_gcc_works ; then
2143 create_gcc_env_entry hardenednopiessp
2145 if hardened_gcc_works pie ; then
2146 create_gcc_env_entry hardenednopie
2148 if hardened_gcc_works ssp ; then
2149 create_gcc_env_entry hardenednossp
2151 create_gcc_env_entry vanilla
2152 insinto ${LIBPATH#${EPREFIX}}
2153 doins "${WORKDIR}"/specs/*.specs || die "failed to install specs"
2154 # Build system specs file which, if it exists, must be a complete set of
2155 # specs as it completely and unconditionally overrides the builtin specs.
2156 if ! tc_version_is_at_least 4.4 ; then
2157 $(XGCC) -dumpspecs > "${WORKDIR}"/specs/specs
2158 cat "${WORKDIR}"/build.specs >> "${WORKDIR}"/specs/specs
2159 doins "${WORKDIR}"/specs/specs || die "failed to install the specs file"
2166 # Move Java headers to compiler-specific dir
2167 for x in "${D}${PREFIX}"/include/gc*.h "${D}${PREFIX}"/include/j*.h ; do
2168 [[ -f ${x} ]] && mv -f "${x}" "${D}${LIBPATH}"/include/
2170 for x in gcj gnu java javax org ; do
2171 if [[ -d ${D}${PREFIX}/include/${x} ]] ; then
2172 dodir /${LIBPATH#${EPREFIX}}/include/${x}
2173 mv -f "${D}${PREFIX}"/include/${x}/* "${D}${LIBPATH}"/include/${x}/
2174 rm -rf "${D}${PREFIX}"/include/${x}
2178 if [[ -d ${D}${PREFIX}/lib/security ]] || [[ -d ${D}${PREFIX}/$(get_libdir)/security ]] ; then
2179 dodir /${LIBPATH#${EPREFIX}}/security
2180 mv -f "${D}${PREFIX}"/lib*/security/* "${D}${LIBPATH}"/security
2181 rm -rf "${D}${PREFIX}"/lib*/security
2184 # Move random gcj files to compiler-specific directories
2185 for x in libgcj.spec logging.properties ; do
2186 x="${D}${PREFIX}/lib/${x}"
2187 [[ -f ${x} ]] && mv -f "${x}" "${D}${LIBPATH}"/
2190 # Rename jar because it could clash with Kaffe's jar if this gcc is
2191 # primary compiler (aka don't have the -<version> extension)
2193 [[ -f jar ]] && mv -f jar gcj-jar
2196 #---->> pkg_post* <<----
2198 toolchain_pkg_postinst() {
2200 if [[ ! ${ROOT%/} && -f ${EPREFIX}/usr/share/eselect/modules/compiler-shadow.eselect ]] ; then
2201 eselect compiler-shadow update all
2204 if ! is_crosscompile && [[ ${PN} != "kgcc64" ]] ; then
2206 ewarn "If you have issues with packages unable to locate libstdc++.la,"
2207 ewarn "then try running 'fix_libtool_files.sh' on the old gcc versions."
2209 ewarn "You might want to review the GCC upgrade guide when moving between"
2210 ewarn "major versions (like 4.2 to 4.3):"
2211 ewarn "https://wiki.gentoo.org/wiki/Upgrading_GCC"
2214 # Clean up old paths
2215 rm -f "${EROOT%/}"/*/rcscripts/awk/fixlafiles.awk "${EROOT%/}"/sbin/fix_libtool_files.sh
2216 rmdir "${EROOT%/}"/*/rcscripts{/awk,} 2>/dev/null
2218 mkdir -p "${EROOT%/}"/usr/{share/gcc-data,sbin,bin}
2219 # DATAPATH has EPREFIX already, use ROOT with it
2220 cp "${ROOT%/}${DATAPATH}"/fixlafiles.awk "${EROOT%/}"/usr/share/gcc-data/ || die
2221 cp "${ROOT%/}${DATAPATH}"/fix_libtool_files.sh "${EROOT%/}"/usr/sbin/ || die
2223 # Since these aren't critical files and portage sucks with
2224 # handling of binpkgs, don't require these to be found
2225 cp "${ROOT%/}${DATAPATH}"/c{89,99} "${EROOT%/}"/usr/bin/ 2>/dev/null
2229 toolchain_pkg_postrm() {
2231 if [[ ! ${ROOT%/} && -f ${EPREFIX}/usr/share/eselect/modules/compiler-shadow.eselect ]] ; then
2232 eselect compiler-shadow clean all
2235 # to make our lives easier (and saner), we do the fix_libtool stuff here.
2236 # rather than checking SLOT's and trying in upgrade paths, we just see if
2237 # the common libstdc++.la exists in the ${LIBPATH} of the gcc that we are
2238 # unmerging. if it does, that means this was a simple re-emerge.
2240 # clean up the cruft left behind by cross-compilers
2241 if is_crosscompile ; then
2242 if [[ -z $(ls "${EROOT%/}"/etc/env.d/gcc/${CTARGET}* 2>/dev/null) ]] ; then
2243 einfo "Removing last cross-compiler instance. Deleting dangling symlinks."
2244 rm -f "${EROOT%/}"/etc/env.d/gcc/config-${CTARGET}
2245 rm -f "${EROOT%/}"/etc/env.d/??gcc-${CTARGET}
2246 rm -f "${EROOT%/}"/usr/bin/${CTARGET}-{gcc,{g,c}++}{,32,64}
2251 # ROOT isnt handled by the script
2252 [[ ${ROOT%/} ]] && return 0
2254 if [[ ! -e ${LIBPATH}/libstdc++.so ]] ; then
2255 einfo "Running 'fix_libtool_files.sh ${GCC_RELEASE_VER}'"
2256 fix_libtool_files.sh ${GCC_RELEASE_VER}
2263 if ! should_we_gcc_config ; then
2264 gcc-config --use-old --force
2268 local current_gcc_config target
2270 current_gcc_config=$(gcc-config -c ${CTARGET} 2>/dev/null)
2271 if [[ -n ${current_gcc_config} ]] ; then
2272 local current_specs use_specs
2273 # figure out which specs-specific config is active
2274 current_specs=$(gcc-config -S ${current_gcc_config} | awk '{print $3}')
2275 [[ -n ${current_specs} ]] && use_specs=-${current_specs}
2277 if [[ -n ${use_specs} ]] && \
2278 [[ ! -e ${EROOT%/}/etc/env.d/gcc/${CTARGET}-${GCC_CONFIG_VER}${use_specs} ]]
2280 ewarn "The currently selected specs-specific gcc config,"
2281 ewarn "${current_specs}, doesn't exist anymore. This is usually"
2282 ewarn "due to enabling/disabling hardened or switching to a version"
2283 ewarn "of gcc that doesnt create multiple specs files. The default"
2284 ewarn "config will be used, and the previous preference forgotten."
2288 target="${CTARGET}-${GCC_CONFIG_VER}${use_specs}"
2290 # The curent target is invalid. Attempt to switch to a valid one.
2291 # Blindly pick the latest version. #529608
2292 # TODO: Should update gcc-config to accept `-l ${CTARGET}` rather than
2293 # doing a partial grep like this.
2294 target=$(gcc-config -l 2>/dev/null | grep " ${CTARGET}-[0-9]" | tail -1 | awk '{print $2}')
2297 gcc-config "${target}"
2300 should_we_gcc_config() {
2301 # if the current config is invalid, we definitely want a new one
2302 # Note: due to bash quirkiness, the following must not be 1 line
2304 curr_config=$(gcc-config -c ${CTARGET} 2>&1) || return 0
2306 # if the previously selected config has the same major.minor (branch) as
2307 # the version we are installing, then it will probably be uninstalled
2308 # for being in the same SLOT, make sure we run gcc-config.
2309 local curr_config_ver=$(gcc-config -S ${curr_config} | awk '{print $2}')
2311 local curr_branch_ver=$(ver_cut 1-2 ${curr_config_ver})
2313 if [[ ${curr_branch_ver} == ${GCC_BRANCH_VER} ]] ; then
2316 # if we're installing a genuinely different compiler version,
2317 # we should probably tell the user -how- to switch to the new
2318 # gcc version, since we're not going to do it for him/her.
2319 # We don't want to switch from say gcc-3.3 to gcc-3.4 right in
2320 # the middle of an emerge operation (like an 'emerge -e world'
2321 # which could install multiple gcc versions).
2322 # Only warn if we're installing a pkg as we might be called from
2323 # the pkg_{pre,post}rm steps. #446830
2324 if [[ ${EBUILD_PHASE} == *"inst" ]] ; then
2325 einfo "The current gcc config appears valid, so it will not be"
2326 einfo "automatically switched for you. If you would like to"
2327 einfo "switch to the newly installed gcc version, do the"
2330 einfo "gcc-config ${CTARGET}-${GCC_CONFIG_VER}"
2331 einfo "source /etc/profile"
2338 #---->> support and misc functions <<----
2340 # This is to make sure we don't accidentally try to enable support for a
2341 # language that doesnt exist. GCC 3.4 supports f77, while 4.0 supports f95, etc.
2343 # Also add a hook so special ebuilds (kgcc64) can control which languages
2344 # exactly get enabled
2345 gcc-lang-supported() {
2346 grep ^language=\"${1}\" "${S}"/gcc/*/config-lang.in > /dev/null || return 1
2347 [[ -z ${TOOLCHAIN_ALLOWED_LANGS} ]] && return 0
2348 has $1 ${TOOLCHAIN_ALLOWED_LANGS}
2352 gcc-lang-supported ada || return 1
2357 gcc-lang-supported 'c++' || return 1
2362 gcc-lang-supported d || return 1
2367 gcc-lang-supported f77 || return 1
2372 gcc-lang-supported f95 || return 1
2377 gcc-lang-supported fortran || return 1
2382 gcc-lang-supported java || return 1
2383 use_if_iuse cxx && use_if_iuse gcj
2387 gcc-lang-supported go || return 1
2388 use_if_iuse cxx && use_if_iuse go
2392 gcc-lang-supported jit || return 1
2393 # cross-compiler does not really support jit as it has
2394 # to generate code for a target. On target like avr
2395 # libgcclit.so can't link at all: bug #594572
2396 is_crosscompile && return 1
2401 tc_version_is_at_least 3 || return 1
2402 use_if_iuse multilib
2406 gcc-lang-supported objc || return 1
2411 gcc-lang-supported 'obj-c++' || return 1
2412 use_if_iuse cxx && use_if_iuse objc++
2415 # Grab a variable from the build system (taken from linux-info.eclass)
2417 local var=$1 makefile=${2:-${WORKDIR}/build/Makefile}
2418 echo -e "e:\\n\\t@echo \$(${var})\\ninclude ${makefile}" | \
2419 r=${makefile%/*} emake --no-print-directory -s -f - 2>/dev/null
2422 XGCC() { get_make_var GCC_FOR_TARGET ; }
2424 # The gentoo piessp patches allow for 3 configurations:
2425 # 1) PIE+SSP by default
2428 hardened_gcc_works() {
2429 if [[ $1 == "pie" ]] ; then
2430 # $gcc_cv_ld_pie is unreliable as it simply take the output of
2431 # `ld --help | grep -- -pie`, that reports the option in all cases, also if
2432 # the loader doesn't actually load the resulting executables.
2433 # To avoid breakage, blacklist FreeBSD here at least
2434 [[ ${CTARGET} == *-freebsd* ]] && return 1
2436 want_pie || return 1
2437 use_if_iuse nopie && return 1
2438 hardened_gcc_is_stable pie
2440 elif [[ $1 == "ssp" ]] ; then
2441 [[ -n ${SPECS_VER} ]] || return 1
2442 use_if_iuse nossp && return 1
2443 hardened_gcc_is_stable ssp
2447 hardened_gcc_works pie || return 1
2448 hardened_gcc_works ssp || return 1
2453 hardened_gcc_is_stable() {
2455 if [[ $1 == "pie" ]] ; then
2456 if [[ ${CTARGET} == *-uclibc* ]] ; then
2457 tocheck=${PIE_UCLIBC_STABLE}
2459 tocheck=${PIE_GLIBC_STABLE}
2461 elif [[ $1 == "ssp" ]] ; then
2462 if [[ ${CTARGET} == *-uclibc* ]] ; then
2463 tocheck=${SSP_UCLIBC_STABLE}
2464 elif [[ ${CTARGET} == *-gnu* ]] ; then
2465 tocheck=${SSP_STABLE}
2468 die "hardened_gcc_stable needs to be called with pie or ssp"
2471 has $(tc-arch) ${tocheck} && return 0
2476 # on gcc 6 we don't need minispecs
2477 if tc_version_is_at_least 6.0 ; then
2480 if tc_version_is_at_least 4.3.2 && use_if_iuse hardened ; then
2481 if ! want_pie ; then
2482 ewarn "PIE_VER or SPECS_VER is not defined in the GCC ebuild."
2483 elif use vanilla ; then
2484 ewarn "You will not get hardened features if you have the vanilla USE-flag."
2485 elif use_if_iuse nopie && use_if_iuse nossp ; then
2486 ewarn "You will not get hardened features if you have the nopie and nossp USE-flag."
2487 elif ! hardened_gcc_works ; then
2488 ewarn "Your $(tc-arch) arch is not supported."
2492 ewarn "Hope you know what you are doing. Hardened will not work."
2499 ! use_if_iuse hardened && [[ -n ${PIE_VER} ]] && use_if_iuse nopie && return 1
2500 [[ -n ${PIE_VER} ]] && [[ -n ${SPECS_VER} ]] && return 0
2501 tc_version_is_at_least 4.3.2 && return 1
2502 [[ -z ${PIE_VER} ]] && return 1
2503 use_if_iuse nopie || return 0
2507 has toolchain_death_notice ${EBUILD_DEATH_HOOKS} || EBUILD_DEATH_HOOKS+=" toolchain_death_notice"
2508 toolchain_death_notice() {
2509 if [[ -e "${WORKDIR}"/build ]] ; then
2510 pushd "${WORKDIR}"/build >/dev/null
2511 (echo '' | $(tc-getCC ${CTARGET}) ${CFLAGS} -v -E - 2>&1) > gccinfo.log
2512 [[ -e "${T}"/build.log ]] && cp "${T}"/build.log .
2513 tar jcf "${WORKDIR}"/gcc-build-logs.tar.bz2 \
2514 gccinfo.log build.log $(find -name config.log)
2515 rm gccinfo.log build.log
2517 eerror "Please include ${WORKDIR}/gcc-build-logs.tar.bz2 in your bug report."
2523 # Note [implicitly enabled flags]
2524 # -------------------------------
2525 # Usually configure-based packages handle explicit feature requests
2527 # ./configure --enable-foo
2528 # as explicit request to check for support of 'foo' and bail out at
2531 # GCC does not follow this pattern and instead overrides autodetection
2532 # of the feature and enables it unconditionally.
2534 # https://gcc.gnu.org/PR85663 (libsanitizer on mips)
2535 # https://bugs.gentoo.org/661252 (libvtv on powerpc64)
2537 # Thus safer way to enable/disable the feature is to rely on implicit
2538 # enabled-by-default state:
2539 # econf $(usex foo '' --disable-foo)