--- /usr/portage/eclass/toolchain.eclass 2016-06-21 18:20:38.000000000 +0100 +++ src/gentoo-overlays/ada/eclass/toolchain.eclass 2016-08-24 23:35:05.159357853 +0100 @@ -141,7 +141,7 @@ [[ -n ${HTB_VER} ]] && IUSE+=" boundschecking" [[ -n ${D_VER} ]] && IUSE+=" d" [[ -n ${SPECS_VER} ]] && IUSE+=" nossp" - tc_version_is_at_least 3 && IUSE+=" doc gcj awt hardened multilib objc" + tc_version_is_at_least 3 && IUSE+=" ada doc gcj awt hardened multilib objc" tc_version_is_at_least 4.0 && IUSE+=" objc-gc" tc_version_is_between 4.0 4.9 && IUSE+=" mudflap" tc_version_is_at_least 4.1 && IUSE+=" libssp objc++" @@ -161,6 +161,14 @@ SLOT="${GCC_CONFIG_VER}" +# When using Ada, use this bootstrap compiler to build, only when there is no pre-existing Ada compiler. +if [[ ! -f `which gnatbind 2>&1|tee /dev/null` ]]; 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. + tc_version_is_at_least 3 && GNAT_BOOTSTRAP_VERSION="4.9" + GNAT_STRAP_DIR="${WORKDIR}/gnat_strap" +fi + #---->> DEPEND <<---- RDEPEND="sys-libs/zlib @@ -355,6 +363,12 @@ fi fi + if in_iuse ada && [[ -n ${GNAT_STRAP_DIR} ]] ; 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}" } @@ -401,6 +415,29 @@ else gcc_quick_unpack fi + + # Unpack the Ada bootstrap if we're using it. + if in_iuse ada && [[ -n ${GNAT_STRAP_DIR} ]] ; then + if [ ! -d ${GNAT_STRAP_DIR} ]; then + mkdir -p ${GNAT_STRAP_DIR} > /dev/null || die "Couldn't make GNAT bootstrap directory" + fi + + pushd ${GNAT_STRAP_DIR} >&/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() { @@ -805,6 +842,29 @@ 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 && [[ -n ${GNAT_STRAP_DIR} ]] ; then + # We need to tell the system about our cross compiler! + export GNATBOOT=${GNAT_STRAP_DIR}/usr + export PATH="${GNATBOOT}/bin:${PATH}" + + EXTRA_ECONF+=( + CC=${GNATBOOT}/bin/gnatgcc + CXX=${GNATBOOT}/bin/gnatg++ + AR=${GNATBOOT}/bin/ar + AS=${GNATBOOT}/bin/as + LD=${GNATBOOT}/bin/ld + NM=${GNATBOOT}/bin/nm + RANLIB=${GNATBOOT}/bin/ranlib + ) + + einfo "EXTRA_ECONF=\"${EXTRA_ECONF}\"" + fi + confgcc+=( --prefix="${PREFIX}" --bindir="${BINPATH}" @@ -851,8 +911,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} ) @@ -1669,7 +1729,12 @@ 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 + 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