commit:     c9f79ed713758a95abea32d9c41f4f2a49f999b2
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Thu Oct  3 03:41:14 2024 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Thu Oct  3 03:43:15 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=c9f79ed7

toolchain.eclass: change iteration strategy for GNAT and GDC

This improves upon the strategy from 9bb87839a6ad66ee7c89837a546fbf2e7f69b577
and d1aa56b6e39f07490021e594920f4a965a968c07.

Earlier, I saw building GCC 15's gdc fail w/ bootstrap from 10, even
though we had 11/12/13/14 installed.

The new logic is as follows, with descending order of preference:
1) Match the version being built;
2) Iterate downwards from the version being built;
3) Iterate upwards from the version being built to the greatest version 
installed.

Signed-off-by: Sam James <sam <AT> gentoo.org>

 eclass/toolchain.eclass | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass
index 1c990f1f1114..3cacc2da31b7 100644
--- a/eclass/toolchain.eclass
+++ b/eclass/toolchain.eclass
@@ -844,10 +844,11 @@ toolchain_setup_ada() {
        # GNAT can usually be built using the last major version and
        # the current version, at least.
        #
-       # We always prefer the version being built if possible
-       # as it has the greatest chance of success. Failing that,
-       # try GCC 10 and iterate upwards.
-       for ada_candidate in ${SLOT} $(seq 10 ${latest_gcc}) ; do
+       # Order of preference (descending):
+       # 1) Match the version being built;
+       # 2) Iterate downwards from the version being built;
+       # 3) Iterate upwards from the version being built to the greatest 
version installed.
+       for ada_candidate in ${SLOT} $(seq -1 $((${SLOT} - 1)) 10) $(seq 
$((${SLOT} + 1)) ${latest_gcc}) ; do
                has_version -b "sys-devel/gcc:${ada_candidate}" || continue
 
                ebegin "Testing sys-devel/gcc:${ada_candidate} for Ada"
@@ -1005,10 +1006,11 @@ toolchain_setup_d() {
 
        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 GCC 10 and iterate upwards.
-       for d_candidate in ${SLOT} $(seq 10 ${latest_gcc}) ; do
+       # Order of preference (descending):
+       # 1) Match the version being built;
+       # 2) Iterate downwards from the version being built;
+       # 3) Iterate upwards from the version being built to the greatest 
version installed.
+       for d_candidate in ${SLOT} $(seq -1 $((${SLOT} - 1)) 10) $(seq 
$((${SLOT} + 1)) ${latest_gcc}) ; do
                has_version -b "sys-devel/gcc:${d_candidate}" || continue
 
                ebegin "Testing sys-devel/gcc:${d_candidate} for D"

Reply via email to