--- /usr/portage/eclass/toolchain.eclass 2017-05-10 17:13:07.000000000 +0100 +++ toolchain.eclass 2017-06-21 17:32:41.389222791 +0100 @@ -151,7 +151,7 @@ # versions which we dropped. Since graphite was also experimental in # the older versions, we don't want to bother supporting it. #448024 tc_version_is_at_least 4.8 && IUSE+=" graphite" IUSE_DEF+=( sanitize ) - tc_version_is_at_least 4.9 && IUSE+=" cilk +vtv" + tc_version_is_at_least 4.9 && IUSE+=" ada cilk +vtv" tc_version_is_at_least 5.0 && IUSE+=" jit mpx" tc_version_is_at_least 6.0 && IUSE+=" +pie +ssp +pch" fi @@ -160,6 +160,15 @@ SLOT="${GCC_CONFIG_VER}" +# When using Ada, use this bootstrap compiler to build, only when there is no pre-existing Ada compiler. +if in_iuse ada; then + # First time build, so need to bootstrap this. + # A newer version of GNAT should build an older version, just not vice-versa. 4.9 can definitely build 5.1.0. + # + # TODO: Add support for bootstraps for 5.4.0 and 6.3.0 + GNAT_BOOTSTRAP_VERSION="4.9" +fi + #---->> DEPEND <<---- RDEPEND="sys-libs/zlib @@ -361,6 +370,13 @@ fi fi + # TODO: Add support for bootstraps for 5.4.0 and 6.3.0 + if in_iuse ada; then + GCC_SRC_URI+=" amd64? ( https://dev.gentoo.org/~nerdboy/files/gnatboot-${GNAT_BOOTSTRAP_VERSION}-amd64.tar.xz ) + x86? ( https://dev.gentoo.org/~nerdboy/files/gnatboot-${GNAT_BOOTSTRAP_VERSION}-i686.tar.xz ) + arm? ( https://dev.gentoo.org/~nerdboy/files/gnatboot-${GNAT_BOOTSTRAP_VERSION}-arm.tar.xz )" + fi + echo "${GCC_SRC_URI}" } @@ -407,6 +423,26 @@ else gcc_quick_unpack fi + + # Unpack the Ada bootstrap if we're using it. + if in_iuse ada && ! type -P gnatbind > /dev/null; then + mkdir -p "${WORKDIR}/gnat_bootstrap" || die "Couldn't make GNAT bootstrap directory" + pushd "${WORKDIR}/gnat_bootstrap" > /dev/null || die + + case $(tc-arch) in + amd64) + unpack gnatboot-${GNAT_BOOTSTRAP_VERSION}-amd64.tar.xz || die "Failed to unpack AMD64 GNAT bootstrap compiler" + ;; + x86) + unpack gnatboot-${GNAT_BOOTSTRAP_VERSION}-i686.tar.xz || die "Failed to unpack x86 GNAT bootstrap compiler" + ;; + arm) + unpack gnatboot-${GNAT_BOOTSTRAP_VERSION}-arm.tar.xz || die "Failed to unpack ARM GNAT bootstrap compiler" + ;; + esac + + popd > /dev/null || die + fi } gcc_quick_unpack() { @@ -827,6 +863,27 @@ fi [[ -n ${CBUILD} ]] && confgcc+=( --build=${CBUILD} ) + # Add variables we need to make the build find the bootstrap compiler. + # We only want to use the bootstrap compiler for stage 1 of bootstrap, this will build the necessary compilers, + # then stage 2 uses these compilers. + # + # We only want to use the bootstrap when we don't have an already installed GNAT compiler. + if in_iuse ada && [[ -d ${WORKDIR}/gnat_bootstrap ]] ; then + # We need to tell the system about our cross compiler! + export GNATBOOT="${WORKDIR}/gnat_bootstrap/usr" + export PATH="${GNATBOOT}/bin:${PATH}" + + confgcc+=( + CC=${GNATBOOT}/bin/gnatgcc + CXX=${GNATBOOT}/bin/gnatg++ + AR=${GNATBOOT}/bin/gcc-ar + AS=as + LD=ld + NM=${GNATBOOT}/bin/gcc-nm + RANLIB=${GNATBOOT}/bin/gcc-ranlib + ) + fi + confgcc+=( --prefix="${PREFIX}" --bindir="${BINPATH}" @@ -873,8 +930,8 @@ is_f77 && GCC_LANG+=",f77" is_f95 && GCC_LANG+=",f95" - # We do NOT want 'ADA support' in here! - # is_ada && GCC_LANG+=",ada" + # We DO want 'Ada support' in here! + is_ada && GCC_LANG+=",ada" confgcc+=( --enable-languages=${GCC_LANG} ) @@ -1696,7 +1753,11 @@ 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 + if in_iuse ada ; then + local gnat_extra_bins="gnat gnatbind gnatchop gnatclean gnatfind gnatkr gnatlink gnatls gnatmake gnatname gnatprep gnatxref" + fi + + for x in cpp gcc g++ c++ gcov g77 gcj gcjh gfortran gccgo ${gnat_extra_bins} ; do # For some reason, g77 gets made instead of ${CTARGET}-g77... # this should take care of that if [[ -f ${x} ]] ; then