Hi,

I've managed to add Ada to the toolchain.eclass, I've built in a chroot
for x86 and amd64, building 4.9.3 using the bootstrap that Steve Arnold
put together. I also then built a 5.1.0 build using the installed 4.9.3
toolchain. I then installed mingw crossdev toolchain with ada support.

It's based on my overlay to add this to gentoo,
https://github.com/Lucretia/ada-overlay.

I've included a patch to the latest eclass.

Thanks,
Luke.

--- /usr/portage/eclass/toolchain.eclass	2016-06-21 18:20:38.000000000 +0100
+++ eclass/toolchain.eclass	2016-07-10 18:18:14.849734912 +0100
@@ -152,7 +152,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+=" cilk +vtv ada"
 	tc_version_is_at_least 5.0 && IUSE+=" jit mpx"
 	tc_version_is_at_least 6.0 && IUSE+=" pie +ssp"
 fi
@@ -161,6 +161,14 @@
 
 SLOT="${GCC_CONFIG_VER}"
 
+# If using Ada, use this bootstrap compiler to build, only when there is not existing compiler.
+# Support nothing before 4.9.x series.
+if [[ ! -f `which gnatbind 2>&1|tee /dev/null` ]]; then
+	# First time build, so need to bootstrap this.
+	tc_version_is_at_least 4.9 && GNAT_BOOTSTRAP_VERSION="4.9"
+	GNAT_STRAP_DIR="${WORKDIR}/gnat_strap"
+fi
+
 #---->> DEPEND <<----
 
 RDEPEND="sys-libs/zlib
@@ -355,6 +363,11 @@
 		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 )"
+	fi
+
 	echo "${GCC_SRC_URI}"
 }
 
@@ -401,6 +414,26 @@
 	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
+		fi
+
+		pushd ${GNAT_STRAP_DIR} > /dev/null
+
+		case $(tc-arch) in
+			amd64)
+				unpack gnatboot-${GNAT_BOOTSTRAP_VERSION}-amd64.tar.xz
+				;;
+			x86)
+				unpack gnatboot-${GNAT_BOOTSTRAP_VERSION}-i686.tar.xz
+				;;
+		esac
+
+		popd > /dev/null
+	fi
 }
 
 gcc_quick_unpack() {
@@ -805,6 +838,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 +907,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 +1725,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

Reply via email to