[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gentoo-dev
Subject:    [gentoo-dev] Add Ada to toolchain.eclass v2
From:       "Luke A. Guest" <laguest () archeia ! com>
Date:       2016-08-23 14:43:28
Message-ID: 57BC6110.6010701 () archeia ! com
[Download RAW message or body]

Hi,

I've added more error handling and set the minimum for Ada builds to the
minimum in the eclass, GCC-3.4.0.

This adds Ada support to GCC, it builds for x86 and amd64 using a
bootstrap if there hasn't been a bootstrapped build already.

Thanks,
Luke.


["add-ada-to-toolchain-eclass_v2.patch" (text/x-patch)]

--- /usr/portage/eclass/toolchain.eclass	2016-06-21 18:20:38.000000000 +0100
+++ src/gentoo-overlays/ada/eclass/toolchain.eclass	2016-08-22 17:35:01.270437144 \
+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,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 || 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 \
GNAT bootstrap compiler" +				;;
+			x86)
+				unpack gnatboot-${GNAT_BOOTSTRAP_VERSION}-i686.tar.xz || die "Failed to unpack \
GNAT bootstrap compiler" +				;;
+		esac
+
+		popd >&/dev/null || die
+	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



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic