From ba248f432b46473734c506fdc8cadd1bea24b656 Mon Sep 17 00:00:00 2001 From: "Luke A. Guest" Date: Sat, 9 Dec 2023 17:32:31 +0000 Subject: [PATCH 1/2] Add building Ada support into the base toolchain (GCC) mechanics. To: gentoo-dev@lists.gentoo.org --- eclass/toolchain.eclass | 53 ++++++++++++++++++++++++++++++++++------- 1 file changed, 44 insertions(+), 9 deletions(-) diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass index 60769c938..7368894ab 100644 --- a/eclass/toolchain.eclass +++ b/eclass/toolchain.eclass @@ -250,7 +250,6 @@ if [[ ${PN} != kgcc64 && ${PN} != gcc-* ]] ; then IUSE+=" go" IUSE+=" +sanitize" TC_FEATURES+=( sanitize ) IUSE+=" graphite" TC_FEATURES+=( graphite ) - IUSE+=" ada" IUSE+=" vtv" IUSE+=" jit" tc_version_is_between 5.0 9 && IUSE+=" mpx" @@ -259,6 +258,7 @@ if [[ ${PN} != kgcc64 && ${PN} != gcc-* ]] ; then IUSE+=" systemtap" TC_FEATURES+=( systemtap ) tc_version_is_at_least 9.0 && IUSE+=" d" TC_FEATURES+=( d ) + tc_version_is_at_least 9.0 && IUSE+=" ada" TC_FEATURES+=( ada ) tc_version_is_at_least 9.1 && IUSE+=" lto" tc_version_is_at_least 10 && IUSE+=" cet" tc_version_is_at_least 10 && IUSE+=" zstd" TC_FEATURES+=( zstd ) @@ -284,8 +284,7 @@ fi #---->> DEPEND <<---- -RDEPEND=" - sys-libs/zlib +RDEPEND="sys-libs/zlib virtual/libiconv nls? ( virtual/libintl ) " @@ -311,6 +310,20 @@ BDEPEND=" >=sys-devel/autogen-5.5.4 ) " + +# Ada in 9.0+ is self-hosting and needs Ada to bootstrap. +# Taken from the D version below. I'm fairly sure if this is now correct, +# We should build using either ada-bootstrap: if the installed gcc has +# Ada disabled or the installed slot which matches the slot being built. +if tc_has_feature ada ; then + if tc_version_is_at_least 9.0 ; then + BDEPEND+=" ada? ( || ( + > Ada Bootstrap slot is ${GCCMAJOR}/${PREVSLOT}" + + # Make sure we set a path to the Ada bootstrap if gcc[ada] is not already + # installed. GNAT can usually be built using the last major version and + # the current version, at least. + if has_version -b "sys-devel/gcc:${SLOT}[ada]" ; then + einfo "Using GNAT compiler installed in slot ${SLOT}..." + + PATH="${BINPATH}:${PATH}" + elif has_version -b "sys-devel/gcc:${PREVSLOT}[ada]" ; then + einfo "Using GNAT compiler installed in previous slot ${PREVSLOT}..." + + PATH="${PREFIX}/${CTARGET}/gcc-bin/${PREVSLOT}:${PATH}" + else + einfo "Using bootstrap GNAT compiler..." + + PATH="/opt/ada-bootstrap-${GCCMAJOR}/bin:${PATH}" + + export PATH + fi + fi + confgcc+=( --prefix="${PREFIX}" --bindir="${BINPATH}" @@ -1335,6 +1368,8 @@ toolchain_src_configure() { einfo "DATAPATH: ${DATAPATH}" einfo "STDCXX_INCDIR: ${STDCXX_INCDIR}" einfo "Languages: ${GCC_LANG}" + einfo "GCC version: $(gcc -v 2>&1|grep " version " | awk '{ print $3 }')" + is_ada && einfo "GNAT version: $(gnat 2>&1|grep GNAT | awk '{ print $2 }')" echo # Build in a separate build tree -- 2.43.0