Maybe a more detailed check can be done, as some version can be built with 
newer compiler
Could be envisaged to switch the compiler automatically "gcc-config x" instead 
of die

Signed-off-by: Alfredo Tupone <tup...@gentoo.org>
---
 eclass/toolchain.eclass | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass
index f8e06fa39884..ce665b3c594b 100644
--- a/eclass/toolchain.eclass
+++ b/eclass/toolchain.eclass
@@ -540,30 +540,42 @@ get_gcc_src_uri() {
 
        echo "${GCC_SRC_URI}"
 }
 
 SRC_URI=$(get_gcc_src_uri)
 
 #---->> pkg_pretend <<----
 
 toolchain_pkg_pretend() {
        if ! _tc_use_if_iuse cxx ; then
                _tc_use_if_iuse go && \
                        ewarn 'Go requires a C++ compiler, disabled due to 
USE="-cxx"'
                _tc_use_if_iuse objc++ && \
                        ewarn 'Obj-C++ requires a C++ compiler, disabled due to 
USE="-cxx"'
        fi
+       if _tc_use_if_iuse ada ; then
+               if ! _tc_use_if_iuse cxx ; then
+                       ewarn 'Ada requires a C++ compiler, disabled due to 
USE="-cxx"'
+               else
+                       prevAdaSLOT=$(gnatmake -v 2>&1 | sed -n '2 p' | sed 
's:^[^0-9]*\([0-9]\+\).*:\1:' | sed 's:2021:10:' )
+                       if [[ -z "${prevAdaSLOT}" ]] ; then
+                               die 'Ada requires an Ada compiler'
+                       elif [[ ${SLOT} -lt ${prevAdaSLOT} ]] ; then
+                               die 'Ada cannot be built with a newer compiler'
+                       fi
+               fi
+       fi
 }
 
 #---->> pkg_setup <<----
 
 toolchain_pkg_setup() {
        # We don't want to use the installed compiler's specs to build gcc
        unset GCC_SPECS
 
        # bug #265283
        unset LANGUAGES
 
        # See 
https://www.gnu.org/software/make/manual/html_node/Parallel-Output.html
        # Avoid really confusing logs from subconfigure spam, makes logs far
        # more legible.
        MAKEOPTS="--output-sync=line ${MAKEOPTS}"
-- 
2.43.2


Reply via email to