Index: toolchain.eclass =================================================================== RCS file: /var/cvsroot/gentoo-x86/eclass/toolchain.eclass,v retrieving revision 1.675 diff -u -r1.675 toolchain.eclass --- toolchain.eclass 1 Jun 2015 16:05:43 -0000 1.675 +++ toolchain.eclass 22 Jun 2015 14:08:51 -0000 @@ -146,6 +146,7 @@ tc_version_is_at_least 4.1 && IUSE+=" libssp objc++" tc_version_is_at_least 4.2 && IUSE_DEF+=( openmp ) tc_version_is_at_least 4.3 && IUSE+=" fixed-point" + tc_version_is_at_least 4.4 && IUSE+=${BOOTGCC_SRC_URI:+" ada"} tc_version_is_at_least 4.7 && IUSE+=" go" # Note: while <=gcc-4.7 also supported graphite, it required forked ppl # versions which we dropped. Since graphite was also experimental in @@ -304,6 +305,18 @@ # ten Brugge's bounds-checking patches. If you want to use a patch # for an older gcc version with a new gcc, make sure you set # HTB_GCC_VER to that version of gcc. +# +# BOOTGCC_SRC_URI +# This variable specifies the SRC_URI value for the gcc binary image +# for bootstrap, where the filename needs to start with "bootgcc-". +# See comments in prepare_bootgcc() for how to create such images. +# An example: +# BOOTGCC_SRC_URI=" +# amd64? ( mirror://gentoo/bootgcc-4.4.7-amd64.tar.xz ) +# x86? ( mirror://gentoo/bootgcc-4.4.7-x86.tar.xz ) +# " +# That is, in a native build, the bootgcc-* filename in $A, if any, +# is used as the bootstrap compiler for your native ARCH. get_gcc_src_uri() { export PATCH_GCC_VER=${PATCH_GCC_VER:-${GCC_RELEASE_VER}} export UCLIBC_GCC_VER=${UCLIBC_GCC_VER:-${PATCH_GCC_VER}} @@ -362,6 +375,8 @@ fi fi + is_crosscompile || GCC_SRC_URI+="${BOOTGCC_SRC_URI:+ ${BOOTGCC_SRC_URI}}" + echo "${GCC_SRC_URI}" } @@ -408,6 +423,8 @@ else gcc_quick_unpack fi + + unpack_bootgcc } gcc_quick_unpack() { @@ -470,6 +487,19 @@ popd > /dev/null } +unpack_bootgcc() { + is_crosscompile && return 0 + tc-is-cross-compiler && return 0 + + local a + for a in ${A} ; do + [[ ${a} == bootgcc-* ]] && unpack ${a} + tc_version_is_at_least 4.8 && continue + # support gnatboot images (c,ada) used by old gnatbuild.eclass + [[ ${a} == gnatboot-* ]] && unpack ${a} + done +} + #---->> src_prepare <<---- toolchain_src_prepare() { @@ -590,6 +620,8 @@ einfo " ${f%%...}" done fi + + prepare_bootgcc } guess_patch_type_in_dir() { @@ -781,6 +813,111 @@ done } +prepare_bootgcc() { + local bootbin= + local bootlib= + if [[ -d ${WORKDIR}/etc/env.d/gcc ]] ; then + # + # How to create the bootstrap gcc binary image to be used here: + # + # $ USE=" + # ada # gnat needs Ada compiler for bootstrap (#547358) + # cxx # >=gcc-4.8 needs C++ compiler for bootstrap + # -multilib # needless for bootstrap (switch profile!) + # -nptl # needless for bootstrap + # -openmp # needless for bootstrap + # -anything # needless for bootstrap + # " emerge --buildpkg =sys-devel/gcc-X.Y.Z-R + # + # $ bzip2 -dc /usr/portage/packages/sys-devel/gcc-X.Y.Z-R.tbz2 | + # xz -c -9 --extreme > bootgcc-X.Y.Z-R-ARCH.tar.xz + # + # For a new ARCH, you have to find out yourself where to get your + # initial C,C++,Ada compiler from. Eventually there is an existing + # one somewhere, or you have to cross-compile. + # + eval $( + PATH= + LDPATH= + source "${WORKDIR}"/etc/env.d/gcc/* + echo "bootbin='${WORKDIR}/${PATH##/}'" + echo "bootlib='${WORKDIR}/${LDPATH##/}'" + ) + elif [[ -d ${WORKDIR}/usr/lib/gnatgcc ]] ; then + # <=gnatboot-4.1 image used by old gnatbuild.eclass + bootbin=${WORKDIR}/usr/bin + bootlib=$(echo "${WORKDIR}"/usr/lib/gnatgcc/*/*) + if [[ -x ${bootbin}/gnatgcc_2wrap ]] ; then + # gnatgcc wrapper script fails to properly quote args, + # and we create wrappers anyway + mv -f ${bootbin}/gnatgcc{_2wrap,} || die + fi + elif [[ -d ${WORKDIR}/usr/bin ]] ; then + # >gnatboot-4.1 image used by old gnatbuild.eclass + bootbin=${WORKDIR}/usr/bin + bootlib=${WORKDIR}/usr/lib + else + # + # nothing unpacked: + # either we do cross compile, or there is no binary image for ARCH yet + # + return 0 + fi + + # Must not set tool variables into environment, + # as they break the just-built stage compilers. + _setup_bootgcc_tool() { + local wrapdir=$1 envvar=$2 tool=$3 bootbin=$4 bootlib=$5 + mkdir -p "${wrapdir}" || die + { + echo "#! ${BASH}" + echo "export CPATH='${bootlib}/include'" + echo "export LIB_DIR='${bootlib}'" + echo "export LDFLAGS='-L${bootlib}'" + echo "export LIBRARY_PATH='${bootlib}'" + echo "export ADA_OBJECTS_PATH='${bootlib}/adalib'" + echo "export ADA_INCLUDE_PATH='${bootlib}/adainclude'" + # need to find cc1, cc1plus, gnat1, ... + echo "export PATH='${bootbin}:${PATH}'" + echo "exec '${bootbin}/${tool}' \"\${@}\"" + } > "${wrapdir}/${tool}" || die + chmod +x "${wrapdir}/${tool}" || die + export ${envvar}=${wrapdir}/${tool} + } + local wrapdir=${WORKDIR}/bootgcc + local wraplist=( + CPP cpp + CC gcc + CXX g++ + # do we really need all of them? more? + GNATBIND gnatbind + GNATCHOP gnatchop + GNATCLEAN gnatclean + GNATFIND gnatfind + GNATKR gnatkr + GNATLINK gnatlink + GNATLS gnatls + GNATMAKE gnatmake + GNATMEM gnatmem + GNATPREP gnatprep + GNATSYM gnatsym + GNATXREF gnatxref + ) + local i var tool + for ((i = 0; i < ${#wraplist[@]}; i += 2)) ; do + var=${wraplist[i]} + tool=${wraplist[i + 1]} + if [[ -x ${bootbin}/${tool} ]] ; then + _setup_bootgcc_tool "${wrapdir}" ${var} "${tool}" "${bootbin}" "${bootlib}" + elif [[ ${tool} != gnat* && -x ${bootbin}/gnat${tool} ]] ; then + # gnatcpp,gnatgcc,gnatg++ in image used by old gnatbuild.eclass + _setup_bootgcc_tool "${wrapdir}" ${var} "gnat${tool}" "${bootbin}" "${bootlib}" + fi + done + # some (older) gcc do not use (enough) GNAT-tool environment vars + export PATH=${wrapdir}:${PATH} +} + #---->> src_configure <<---- toolchain_src_configure() { @@ -849,6 +986,10 @@ fi is_objcxx && GCC_LANG+=",obj-c++" fi + if is_ada ; then + GCC_LANG+=",ada" + confgcc+=( --enable-libada ) + fi # fortran support just got sillier! the lang value can be f77 for # fortran77, f95 for fortran95, or just plain old fortran for the @@ -857,9 +998,6 @@ is_f77 && GCC_LANG+=",f77" is_f95 && GCC_LANG+=",f95" - # We do NOT want 'ADA support' in here! - # is_ada && GCC_LANG+=",ada" - confgcc+=( --enable-languages=${GCC_LANG} ) ### general options @@ -1655,7 +1793,9 @@ cd "${D}"${BINPATH} # Ugh: we really need to auto-detect this list. # It's constantly out of date. - for x in cpp gcc g++ c++ gcov g77 gcj gcjh gfortran gccgo ; do + for x in cpp gcc g++ c++ gcov g77 gcj gcjh gfortran gccgo \ + gnat{bind,chop,clean,find,kr,link,ls,make,mem,name,prep,sym,xref} \ + ; do # For some reason, g77 gets made instead of ${CTARGET}-g77... # this should take care of that [[ -f ${x} ]] && mv ${x} ${CTARGET}-${x} @@ -2102,7 +2242,7 @@ is_ada() { gcc-lang-supported ada || return 1 - use ada + use_if_iuse ada } is_cxx() {