commit: 3355cb0ab6d92d84eeff44163da5309d114726b3 Author: Sam James <sam <AT> gentoo <DOT> org> AuthorDate: Sun Sep 29 01:04:44 2024 +0000 Commit: Sam James <sam <AT> gentoo <DOT> org> CommitDate: Sun Sep 29 01:04:44 2024 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=3355cb0a
toolchain.eclass: rework D handling The recent work for Ada makes things easier here because you don't have to try juggle both GNAT and GDC at the same time. Anyway, let's do something similar: iterate over installed GCCs and try to use the best GDC available for bootstrapping, so users don't have to manually select it with `gcc-config`. More mangling may be needed than setting GDC down the line. Bug: https://bugs.gentoo.org/868228 Signed-off-by: Sam James <sam <AT> gentoo.org> eclass/toolchain.eclass | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass index cfddba99a1a8..30d96f25aaa8 100644 --- a/eclass/toolchain.eclass +++ b/eclass/toolchain.eclass @@ -991,6 +991,32 @@ toolchain_src_configure() { export CC="$(tc-getCC) -specs=${T}/ada.spec" fi + if _tc_use_if_iuse d ; then + local latest_gcc=$(best_version -b "sys-devel/gcc") + latest_gcc="${latest_gcc#sys-devel/gcc-}" + latest_gcc=$(ver_cut 1 ${latest_gcc}) + + local d_bootstrap + local d_candidate + # We always prefer the version being built if possible + # as it has the greatest chance of success. Failing that, + # try the latest installed GCC and iterate downwards. + for d_candidate in ${SLOT} $(seq ${latest_gcc} -1 10) ; do + has_version -b "sys-devel/gcc:${d_candidate}" || continue + + ebegin "Testing sys-devel/gcc:${d_candidate} for D" + if has_version -b "sys-devel/gcc:${d_candidate}[d(-)]" ; then + d_bootstrap=${d_candidate} + + eend 0 + break + fi + eend 1 + done + + export GDC="${BROOT}/usr/${CTARGET}/gcc-bin/${d_bootstrap}/gdc" + fi + confgcc+=( --prefix="${PREFIX}" --bindir="${BINPATH}"
