commit:     309a391f9ebb245e1016e3ff49a21398c212614b
Author:     Matt Jolly <kangie <AT> gentoo <DOT> org>
AuthorDate: Mon Nov 11 13:28:04 2024 +0000
Commit:     Matt Jolly <kangie <AT> gentoo <DOT> org>
CommitDate: Mon Nov 11 14:35:48 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=309a391f

dev-lang/rust: use rust.eclass for USE=system-bootstrap

Take advantage of rust.eclass for dependency generation and appropriate
bootstrap slot selection. Between the PATH manipulation that the eclass
performs and the exported `RUSTC` we should see significantly more
consistent bootstraps.

Without this change `eselect-rust` would determine which `rustc` to run,
resulting in build failures if an incorrect Rust was selected (which is
nearly always in the age of slotted Rust).

This is also one step towards removing USE=system-bootstrap entirely;
now that we can reliably (and trivially) select appropriate slots for
both dev-lang/rust and dev-lang/rust-bin we'll shortly be able to
avoid downloading bootstrap bins at all.

Bug: https://bugs.gentoo.org/943144
Closes: https://bugs.gentoo.org/943145
Signed-off-by: Matt Jolly <kangie <AT> gentoo.org>

 dev-lang/rust/rust-1.71.1-r100.ebuild | 56 +++++++----------------------------
 dev-lang/rust/rust-1.74.1-r100.ebuild | 53 ++++++---------------------------
 dev-lang/rust/rust-1.75.0-r100.ebuild | 56 +++++++----------------------------
 dev-lang/rust/rust-1.77.1-r100.ebuild | 55 +++++++---------------------------
 dev-lang/rust/rust-1.79.0-r100.ebuild | 53 ++++++---------------------------
 dev-lang/rust/rust-1.80.1-r100.ebuild | 53 ++++++---------------------------
 dev-lang/rust/rust-1.81.0-r100.ebuild | 53 ++++++---------------------------
 dev-lang/rust/rust-1.82.0-r100.ebuild | 53 ++++++---------------------------
 8 files changed, 75 insertions(+), 357 deletions(-)

diff --git a/dev-lang/rust/rust-1.71.1-r100.ebuild 
b/dev-lang/rust/rust-1.71.1-r100.ebuild
index d6cb947db404..66741c10fed6 100644
--- a/dev-lang/rust/rust-1.71.1-r100.ebuild
+++ b/dev-lang/rust/rust-1.71.1-r100.ebuild
@@ -6,8 +6,13 @@ EAPI=8
 LLVM_COMPAT=( 16 )
 PYTHON_COMPAT=( python3_{10..12} )
 
+# We only need this for system-bootstrap
+RUST_OPTIONAL=1
+RUST_MAX_VER=${PV}
+RUST_MIN_VER="$(ver_cut 1).$(($(ver_cut 2) - 1)).0"
+
 inherit check-reqs estack flag-o-matic llvm-r1 multiprocessing \
-       multilib multilib-build python-any-r1 rust-toolchain toolchain-funcs 
verify-sig
+       multilib multilib-build python-any-r1 rust rust-toolchain 
toolchain-funcs verify-sig
 
 if [[ ${PV} = *beta* ]]; then
        betaver=${PV//*beta}
@@ -20,8 +25,6 @@ else
        KEYWORDS="amd64 arm arm64 ~loong ~mips ppc ppc64 ~riscv sparc x86"
 fi
 
-S="${WORKDIR}/${MY_P}-src"
-
 RUST_STAGE0_VERSION="1.$(($(ver_cut 2) - 1)).0"
 
 DESCRIPTION="Language empowering everyone to build reliable and efficient 
software"
@@ -32,6 +35,7 @@ SRC_URI="
        verify-sig? ( https://static.rust-lang.org/dist/${SRC}.asc )
        !system-bootstrap? ( $(rust_all_arch_uris rust-${RUST_STAGE0_VERSION}) )
 "
+S="${WORKDIR}/${MY_P}-src"
 
 # keep in sync with llvm ebuild of the same version as bundled one.
 ALL_LLVM_TARGETS=( AArch64 AMDGPU ARM AVR BPF Hexagon Lanai LoongArch Mips 
MSP430
@@ -52,29 +56,13 @@ done
 LLVM_DEPEND+=( "       wasm? ( $(llvm_gen_dep 'sys-devel/lld:${LLVM_SLOT}') )" 
)
 LLVM_DEPEND+=( "       $(llvm_gen_dep 'sys-devel/llvm:${LLVM_SLOT}')" )
 
-# to bootstrap we need at least exactly previous version, or same.
-# most of the time previous versions fail to bootstrap with newer
-# for example 1.47.x, requires at least 1.46.x, 1.47.x is ok,
-# but it fails to bootstrap with 1.48.x
-# https://github.com/rust-lang/rust/blob/${PV}/src/stage0.json
-RUST_DEP_PREV="$(ver_cut 1).$(($(ver_cut 2) - 1))*"
-RUST_DEP_CURR="$(ver_cut 1).$(ver_cut 2)*"
-BOOTSTRAP_DEPEND="||
-       (
-               =dev-lang/rust-"${RUST_DEP_PREV}"
-               =dev-lang/rust-bin-"${RUST_DEP_PREV}"
-               =dev-lang/rust-"${RUST_DEP_CURR}"
-               =dev-lang/rust-bin-"${RUST_DEP_CURR}"
-       )
-"
-
 BDEPEND="${PYTHON_DEPS}
        app-eselect/eselect-rust
        || (
                >=sys-devel/gcc-4.7
                >=sys-devel/clang-3.5
        )
-       system-bootstrap? ( ${BOOTSTRAP_DEPEND} )
+       system-bootstrap? ( ${RUST_DEPEND} )
        !system-llvm? (
                >=dev-build/cmake-3.13.4
                app-alternatives/ninja
@@ -158,30 +146,6 @@ toml_usex() {
        usex "${1}" true false
 }
 
-bootstrap_rust_version_check() {
-       # never call from pkg_pretend. eselect-rust may be not installed yet.
-       [[ ${MERGE_TYPE} == binary ]] && return
-       local rustc_wanted="$(ver_cut 1).$(($(ver_cut 2) - 1))"
-       local rustc_toonew="$(ver_cut 1).$(($(ver_cut 2) + 1))"
-       local rustc_version=( $(eselect --brief rust show 2>/dev/null) )
-       rustc_version=${rustc_version[0]#rust-bin-}
-       rustc_version=${rustc_version#rust-}
-
-       [[ -z "${rustc_version}" ]] && die "Failed to determine rust version, 
check 'eselect rust' output"
-
-       if ver_test "${rustc_version}" -lt "${rustc_wanted}" ; then
-               eerror "Rust >=${rustc_wanted} is required"
-               eerror "please run 'eselect rust' and set correct rust version"
-               die "selected rust version is too old"
-       elif ver_test "${rustc_version}" -ge "${rustc_toonew}" ; then
-               eerror "Rust <${rustc_toonew} is required"
-               eerror "please run 'eselect rust' and set correct rust version"
-               die "selected rust version is too new"
-       else
-               einfo "Using rust ${rustc_version} to build"
-       fi
-}
-
 pre_build_checks() {
        local M=8192
        # multiply requirements by 1.3 if we are doing x86-multilib
@@ -236,7 +200,7 @@ pkg_setup() {
 
        export LIBGIT2_NO_PKG_CONFIG=1 #749381
 
-       use system-bootstrap && bootstrap_rust_version_check
+       use system-bootstrap && rust_pkg_setup
 
        if use system-llvm; then
                llvm-r1_pkg_setup
@@ -309,7 +273,7 @@ src_configure() {
        local rust_stage0_root
        if use system-bootstrap; then
                local printsysroot
-               printsysroot="$(rustc --print sysroot || die "Can't determine 
rust's sysroot")"
+               printsysroot="$(${RUSTC} --print --sysroot || die "Can't 
determine rust's sysroot")"
                rust_stage0_root="${printsysroot}"
        else
                rust_stage0_root="${WORKDIR}"/rust-stage0

diff --git a/dev-lang/rust/rust-1.74.1-r100.ebuild 
b/dev-lang/rust/rust-1.74.1-r100.ebuild
index bd474794968a..5e9c19aaab5e 100644
--- a/dev-lang/rust/rust-1.74.1-r100.ebuild
+++ b/dev-lang/rust/rust-1.74.1-r100.ebuild
@@ -6,8 +6,13 @@ EAPI=8
 LLVM_COMPAT=( 17 )
 PYTHON_COMPAT=( python3_{10..12} )
 
+# We only need this for system-bootstrap
+RUST_OPTIONAL=1
+RUST_MAX_VER=${PV}
+RUST_MIN_VER="$(ver_cut 1).$(($(ver_cut 2) - 1)).0"
+
 inherit check-reqs estack flag-o-matic llvm-r1 multiprocessing \
-       multilib multilib-build python-any-r1 rust-toolchain toolchain-funcs 
verify-sig
+       multilib multilib-build python-any-r1 rust rust-toolchain 
toolchain-funcs verify-sig
 
 if [[ ${PV} = *beta* ]]; then
        betaver=${PV//*beta}
@@ -53,29 +58,13 @@ done
 LLVM_DEPEND+=( "       wasm? ( $(llvm_gen_dep 'sys-devel/lld:${LLVM_SLOT}') )" 
)
 LLVM_DEPEND+=( "       $(llvm_gen_dep 'sys-devel/llvm:${LLVM_SLOT}')" )
 
-# to bootstrap we need at least exactly previous version, or same.
-# most of the time previous versions fail to bootstrap with newer
-# for example 1.47.x, requires at least 1.46.x, 1.47.x is ok,
-# but it fails to bootstrap with 1.48.x
-# https://github.com/rust-lang/rust/blob/${PV}/src/stage0.json
-RUST_DEP_PREV="$(ver_cut 1).$(($(ver_cut 2) - 1))*"
-RUST_DEP_CURR="$(ver_cut 1).$(ver_cut 2)*"
-BOOTSTRAP_DEPEND="||
-       (
-               =dev-lang/rust-"${RUST_DEP_PREV}"
-               =dev-lang/rust-bin-"${RUST_DEP_PREV}"
-               =dev-lang/rust-"${RUST_DEP_CURR}"
-               =dev-lang/rust-bin-"${RUST_DEP_CURR}"
-       )
-"
-
 BDEPEND="${PYTHON_DEPS}
        app-eselect/eselect-rust
        || (
                >=sys-devel/gcc-4.7
                >=sys-devel/clang-3.5
        )
-       system-bootstrap? ( ${BOOTSTRAP_DEPEND} )
+       system-bootstrap? ( ${RUST_DEPEND} )
        !system-llvm? (
                >=dev-build/cmake-3.13.4
                app-alternatives/ninja
@@ -164,30 +153,6 @@ toml_usex() {
        usex "${1}" true false
 }
 
-bootstrap_rust_version_check() {
-       # never call from pkg_pretend. eselect-rust may be not installed yet.
-       [[ ${MERGE_TYPE} == binary ]] && return
-       local rustc_wanted="$(ver_cut 1).$(($(ver_cut 2) - 1))"
-       local rustc_toonew="$(ver_cut 1).$(($(ver_cut 2) + 1))"
-       local rustc_version=( $(eselect --brief --root="${BROOT}" rust show 
2>/dev/null) )
-       rustc_version=${rustc_version[0]#rust-bin-}
-       rustc_version=${rustc_version#rust-}
-
-       [[ -z "${rustc_version}" ]] && die "Failed to determine rust version, 
check 'eselect rust' output"
-
-       if ver_test "${rustc_version}" -lt "${rustc_wanted}" ; then
-               eerror "Rust >=${rustc_wanted} is required"
-               eerror "please run 'eselect rust' and set correct rust version"
-               die "selected rust version is too old"
-       elif ver_test "${rustc_version}" -ge "${rustc_toonew}" ; then
-               eerror "Rust <${rustc_toonew} is required"
-               eerror "please run 'eselect rust' and set correct rust version"
-               die "selected rust version is too new"
-       else
-               einfo "Using rust ${rustc_version} to build"
-       fi
-}
-
 pre_build_checks() {
        local M=8192
        # multiply requirements by 1.3 if we are doing x86-multilib
@@ -254,7 +219,7 @@ pkg_setup() {
                        die "Must enable LLVM_TARGETS=${cross_llvm_target} 
matching CBUILD=${CBUILD} when cross-compiling"
        fi
 
-       use system-bootstrap && bootstrap_rust_version_check
+       use system-bootstrap && rust_pkg_setup
 
        if use system-llvm; then
                llvm-r1_pkg_setup
@@ -334,7 +299,7 @@ src_configure() {
        local rust_stage0_root
        if use system-bootstrap; then
                local printsysroot
-               printsysroot="$(rustc --print sysroot || die "Can't determine 
rust's sysroot")"
+               printsysroot="$(${RUSTC} --print --sysroot || die "Can't 
determine rust's sysroot")"
                rust_stage0_root="${printsysroot}"
        else
                rust_stage0_root="${WORKDIR}"/rust-stage0

diff --git a/dev-lang/rust/rust-1.75.0-r100.ebuild 
b/dev-lang/rust/rust-1.75.0-r100.ebuild
index 0517e38b84f4..447ec8612dd5 100644
--- a/dev-lang/rust/rust-1.75.0-r100.ebuild
+++ b/dev-lang/rust/rust-1.75.0-r100.ebuild
@@ -6,8 +6,13 @@ EAPI=8
 LLVM_COMPAT=( 17 )
 PYTHON_COMPAT=( python3_{10..12} )
 
+# We only need this for system-bootstrap
+RUST_OPTIONAL=1
+RUST_MAX_VER=${PV}
+RUST_MIN_VER="$(ver_cut 1).$(($(ver_cut 2) - 1)).0"
+
 inherit check-reqs estack flag-o-matic llvm-r1 multiprocessing \
-       multilib multilib-build python-any-r1 rust-toolchain toolchain-funcs 
verify-sig
+       multilib multilib-build python-any-r1 rust rust-toolchain 
toolchain-funcs verify-sig
 
 if [[ ${PV} = *beta* ]]; then
        betaver=${PV//*beta}
@@ -20,8 +25,6 @@ else
        KEYWORDS="amd64 arm arm64 ~loong ppc ppc64 ~riscv sparc x86"
 fi
 
-S="${WORKDIR}/${MY_P}-src"
-
 RUST_STAGE0_VERSION="1.$(($(ver_cut 2) - 1)).0"
 
 DESCRIPTION="Language empowering everyone to build reliable and efficient 
software"
@@ -32,6 +35,7 @@ SRC_URI="
        verify-sig? ( https://static.rust-lang.org/dist/${SRC}.asc )
        !system-bootstrap? ( $(rust_all_arch_uris rust-${RUST_STAGE0_VERSION}) )
 "
+S="${WORKDIR}/${MY_P}-src"
 
 # keep in sync with llvm ebuild of the same version as bundled one.
 ALL_LLVM_TARGETS=( AArch64 AMDGPU ARC ARM AVR BPF CSKY DirectX Hexagon Lanai
@@ -53,29 +57,13 @@ done
 LLVM_DEPEND+=( "       wasm? ( $(llvm_gen_dep 'sys-devel/lld:${LLVM_SLOT}') )" 
)
 LLVM_DEPEND+=( "       $(llvm_gen_dep 'sys-devel/llvm:${LLVM_SLOT}')" )
 
-# to bootstrap we need at least exactly previous version, or same.
-# most of the time previous versions fail to bootstrap with newer
-# for example 1.47.x, requires at least 1.46.x, 1.47.x is ok,
-# but it fails to bootstrap with 1.48.x
-# https://github.com/rust-lang/rust/blob/${PV}/src/stage0.json
-RUST_DEP_PREV="$(ver_cut 1).$(($(ver_cut 2) - 1))*"
-RUST_DEP_CURR="$(ver_cut 1).$(ver_cut 2)*"
-BOOTSTRAP_DEPEND="||
-       (
-               =dev-lang/rust-"${RUST_DEP_PREV}"
-               =dev-lang/rust-bin-"${RUST_DEP_PREV}"
-               =dev-lang/rust-"${RUST_DEP_CURR}"
-               =dev-lang/rust-bin-"${RUST_DEP_CURR}"
-       )
-"
-
 BDEPEND="${PYTHON_DEPS}
        app-eselect/eselect-rust
        || (
                >=sys-devel/gcc-4.7
                >=sys-devel/clang-3.5
        )
-       system-bootstrap? ( ${BOOTSTRAP_DEPEND} )
+       system-bootstrap? ( ${RUST_DEPEND} )
        !system-llvm? (
                >=dev-build/cmake-3.13.4
                app-alternatives/ninja
@@ -167,30 +155,6 @@ toml_usex() {
        usex "${1}" true false
 }
 
-bootstrap_rust_version_check() {
-       # never call from pkg_pretend. eselect-rust may be not installed yet.
-       [[ ${MERGE_TYPE} == binary ]] && return
-       local rustc_wanted="$(ver_cut 1).$(($(ver_cut 2) - 1))"
-       local rustc_toonew="$(ver_cut 1).$(($(ver_cut 2) + 1))"
-       local rustc_version=( $(eselect --brief --root="${BROOT}" rust show 
2>/dev/null) )
-       rustc_version=${rustc_version[0]#rust-bin-}
-       rustc_version=${rustc_version#rust-}
-
-       [[ -z "${rustc_version}" ]] && die "Failed to determine rust version, 
check 'eselect rust' output"
-
-       if ver_test "${rustc_version}" -lt "${rustc_wanted}" ; then
-               eerror "Rust >=${rustc_wanted} is required"
-               eerror "please run 'eselect rust' and set correct rust version"
-               die "selected rust version is too old"
-       elif ver_test "${rustc_version}" -ge "${rustc_toonew}" ; then
-               eerror "Rust <${rustc_toonew} is required"
-               eerror "please run 'eselect rust' and set correct rust version"
-               die "selected rust version is too new"
-       else
-               einfo "Using rust ${rustc_version} to build"
-       fi
-}
-
 pre_build_checks() {
        local M=8192
        # multiply requirements by 1.3 if we are doing x86-multilib
@@ -257,7 +221,7 @@ pkg_setup() {
                        die "Must enable LLVM_TARGETS=${cross_llvm_target} 
matching CBUILD=${CBUILD} when cross-compiling"
        fi
 
-       use system-bootstrap && bootstrap_rust_version_check
+       use system-bootstrap && rust_pkg_setup
 
        if use system-llvm; then
                llvm-r1_pkg_setup
@@ -337,7 +301,7 @@ src_configure() {
        local rust_stage0_root
        if use system-bootstrap; then
                local printsysroot
-               printsysroot="$(rustc --print sysroot || die "Can't determine 
rust's sysroot")"
+               printsysroot="$(${RUSTC} --print --sysroot || die "Can't 
determine rust's sysroot")"
                rust_stage0_root="${printsysroot}"
        else
                rust_stage0_root="${WORKDIR}"/rust-stage0

diff --git a/dev-lang/rust/rust-1.77.1-r100.ebuild 
b/dev-lang/rust/rust-1.77.1-r100.ebuild
index a6e6f0023b76..581eabab194f 100644
--- a/dev-lang/rust/rust-1.77.1-r100.ebuild
+++ b/dev-lang/rust/rust-1.77.1-r100.ebuild
@@ -6,8 +6,13 @@ EAPI=8
 LLVM_COMPAT=( 17 )
 PYTHON_COMPAT=( python3_{10..12} )
 
+# We only need this for system-bootstrap
+RUST_OPTIONAL=1
+RUST_MAX_VER=${PV}
+RUST_MIN_VER="$(ver_cut 1).$(($(ver_cut 2) - 1)).0"
+
 inherit check-reqs estack flag-o-matic llvm-r1 multiprocessing \
-       multilib multilib-build python-any-r1 rust-toolchain toolchain-funcs 
verify-sig
+       multilib multilib-build python-any-r1 rust rust-toolchain 
toolchain-funcs verify-sig
 
 if [[ ${PV} = *beta* ]]; then
        betaver=${PV//*beta}
@@ -19,7 +24,6 @@ else
        SRC="${MY_P}-src.tar.xz"
        KEYWORDS="amd64 arm arm64 ~loong ppc ppc64 ~riscv sparc x86"
 fi
-S="${WORKDIR}/${MY_P}-src"
 
 RUST_STAGE0_VERSION="1.$(($(ver_cut 2) - 1)).0"
 
@@ -31,6 +35,7 @@ SRC_URI="
        verify-sig? ( https://static.rust-lang.org/dist/${SRC}.asc )
        !system-bootstrap? ( $(rust_all_arch_uris rust-${RUST_STAGE0_VERSION}) )
 "
+S="${WORKDIR}/${MY_P}-src"
 
 # keep in sync with llvm ebuild of the same version as bundled one.
 ALL_LLVM_TARGETS=( AArch64 AMDGPU ARC ARM AVR BPF CSKY DirectX Hexagon Lanai
@@ -52,29 +57,13 @@ done
 LLVM_DEPEND+=( "       wasm? ( $(llvm_gen_dep 'sys-devel/lld:${LLVM_SLOT}') )" 
)
 LLVM_DEPEND+=( "       $(llvm_gen_dep 'sys-devel/llvm:${LLVM_SLOT}')" )
 
-# to bootstrap we need at least exactly previous version, or same.
-# most of the time previous versions fail to bootstrap with newer
-# for example 1.47.x, requires at least 1.46.x, 1.47.x is ok,
-# but it fails to bootstrap with 1.48.x
-# https://github.com/rust-lang/rust/blob/${PV}/src/stage0.json
-RUST_DEP_PREV="$(ver_cut 1).$(($(ver_cut 2) - 1))*"
-RUST_DEP_CURR="$(ver_cut 1).$(ver_cut 2)*"
-BOOTSTRAP_DEPEND="||
-       (
-               =dev-lang/rust-"${RUST_DEP_PREV}"
-               =dev-lang/rust-bin-"${RUST_DEP_PREV}"
-               =dev-lang/rust-"${RUST_DEP_CURR}"
-               =dev-lang/rust-bin-"${RUST_DEP_CURR}"
-       )
-"
-
 BDEPEND="${PYTHON_DEPS}
        app-eselect/eselect-rust
        || (
                >=sys-devel/gcc-4.7
                >=sys-devel/clang-3.5
        )
-       system-bootstrap? ( ${BOOTSTRAP_DEPEND} )
+       system-bootstrap? ( ${RUST_DEPEND} )
        !system-llvm? (
                >=dev-build/cmake-3.13.4
                app-alternatives/ninja
@@ -164,30 +153,6 @@ toml_usex() {
        usex "${1}" true false
 }
 
-bootstrap_rust_version_check() {
-       # never call from pkg_pretend. eselect-rust may be not installed yet.
-       [[ ${MERGE_TYPE} == binary ]] && return
-       local rustc_wanted="$(ver_cut 1).$(($(ver_cut 2) - 1))"
-       local rustc_toonew="$(ver_cut 1).$(($(ver_cut 2) + 1))"
-       local rustc_version=( $(eselect --brief --root="${BROOT}" rust show 
2>/dev/null) )
-       rustc_version=${rustc_version[0]#rust-bin-}
-       rustc_version=${rustc_version#rust-}
-
-       [[ -z "${rustc_version}" ]] && die "Failed to determine rust version, 
check 'eselect rust' output"
-
-       if ver_test "${rustc_version}" -lt "${rustc_wanted}" ; then
-               eerror "Rust >=${rustc_wanted} is required"
-               eerror "please run 'eselect rust' and set correct rust version"
-               die "selected rust version is too old"
-       elif ver_test "${rustc_version}" -ge "${rustc_toonew}" ; then
-               eerror "Rust <${rustc_toonew} is required"
-               eerror "please run 'eselect rust' and set correct rust version"
-               die "selected rust version is too new"
-       else
-               einfo "Using rust ${rustc_version} to build"
-       fi
-}
-
 pre_build_checks() {
        local M=8192
        # multiply requirements by 1.3 if we are doing x86-multilib
@@ -254,7 +219,7 @@ pkg_setup() {
                        die "Must enable LLVM_TARGETS=${cross_llvm_target} 
matching CBUILD=${CBUILD} when cross-compiling"
        fi
 
-       use system-bootstrap && bootstrap_rust_version_check
+       use system-bootstrap && rust_pkg_setup
 
        if use system-llvm; then
                llvm-r1_pkg_setup
@@ -334,7 +299,7 @@ src_configure() {
        local rust_stage0_root
        if use system-bootstrap; then
                local printsysroot
-               printsysroot="$(rustc --print sysroot || die "Can't determine 
rust's sysroot")"
+               printsysroot="$(${RUSTC} --print --sysroot || die "Can't 
determine rust's sysroot")"
                rust_stage0_root="${printsysroot}"
        else
                rust_stage0_root="${WORKDIR}"/rust-stage0

diff --git a/dev-lang/rust/rust-1.79.0-r100.ebuild 
b/dev-lang/rust/rust-1.79.0-r100.ebuild
index bf13cf11984a..5b7a5c245acf 100644
--- a/dev-lang/rust/rust-1.79.0-r100.ebuild
+++ b/dev-lang/rust/rust-1.79.0-r100.ebuild
@@ -6,8 +6,13 @@ EAPI=8
 LLVM_COMPAT=( 18 )
 PYTHON_COMPAT=( python3_{10..13} )
 
+# We only need this for system-bootstrap
+RUST_OPTIONAL=1
+RUST_MAX_VER=${PV}
+RUST_MIN_VER="$(ver_cut 1).$(($(ver_cut 2) - 1)).0"
+
 inherit check-reqs estack flag-o-matic llvm-r1 multiprocessing \
-       multilib multilib-build python-any-r1 rust-toolchain toolchain-funcs 
verify-sig
+       multilib multilib-build python-any-r1 rust rust-toolchain 
toolchain-funcs verify-sig
 
 if [[ ${PV} = *beta* ]]; then
        betaver=${PV//*beta}
@@ -52,29 +57,13 @@ done
 LLVM_DEPEND+=( "       wasm? ( $(llvm_gen_dep 'sys-devel/lld:${LLVM_SLOT}') )" 
)
 LLVM_DEPEND+=( "       $(llvm_gen_dep 'sys-devel/llvm:${LLVM_SLOT}')" )
 
-# to bootstrap we need at least exactly previous version, or same.
-# most of the time previous versions fail to bootstrap with newer
-# for example 1.47.x, requires at least 1.46.x, 1.47.x is ok,
-# but it fails to bootstrap with 1.48.x
-# https://github.com/rust-lang/rust/blob/${PV}/src/stage0.json
-RUST_DEP_PREV="$(ver_cut 1).$(($(ver_cut 2) - 1))*"
-RUST_DEP_CURR="$(ver_cut 1).$(ver_cut 2)*"
-BOOTSTRAP_DEPEND="||
-       (
-               =dev-lang/rust-"${RUST_DEP_PREV}"
-               =dev-lang/rust-bin-"${RUST_DEP_PREV}"
-               =dev-lang/rust-"${RUST_DEP_CURR}"
-               =dev-lang/rust-bin-"${RUST_DEP_CURR}"
-       )
-"
-
 BDEPEND="${PYTHON_DEPS}
        app-eselect/eselect-rust
        || (
                >=sys-devel/gcc-4.7
                >=sys-devel/clang-3.5
        )
-       system-bootstrap? ( ${BOOTSTRAP_DEPEND} )
+       system-bootstrap? ( ${RUST_DEPEND} )
        !system-llvm? (
                >=dev-build/cmake-3.13.4
                app-alternatives/ninja
@@ -164,30 +153,6 @@ toml_usex() {
        usex "${1}" true false
 }
 
-bootstrap_rust_version_check() {
-       # never call from pkg_pretend. eselect-rust may be not installed yet.
-       [[ ${MERGE_TYPE} == binary ]] && return
-       local rustc_wanted="$(ver_cut 1).$(($(ver_cut 2) - 1))"
-       local rustc_toonew="$(ver_cut 1).$(($(ver_cut 2) + 1))"
-       local rustc_version=( $(eselect --brief --root="${BROOT}" rust show 
2>/dev/null) )
-       rustc_version=${rustc_version[0]#rust-bin-}
-       rustc_version=${rustc_version#rust-}
-
-       [[ -z "${rustc_version}" ]] && die "Failed to determine rust version, 
check 'eselect rust' output"
-
-       if ver_test "${rustc_version}" -lt "${rustc_wanted}" ; then
-               eerror "Rust >=${rustc_wanted} is required"
-               eerror "please run 'eselect rust' and set correct rust version"
-               die "selected rust version is too old"
-       elif ver_test "${rustc_version}" -ge "${rustc_toonew}" ; then
-               eerror "Rust <${rustc_toonew} is required"
-               eerror "please run 'eselect rust' and set correct rust version"
-               die "selected rust version is too new"
-       else
-               einfo "Using rust ${rustc_version} to build"
-       fi
-}
-
 pre_build_checks() {
        local M=8192
        # multiply requirements by 1.3 if we are doing x86-multilib
@@ -254,7 +219,7 @@ pkg_setup() {
                        die "Must enable LLVM_TARGETS=${cross_llvm_target} 
matching CBUILD=${CBUILD} when cross-compiling"
        fi
 
-       use system-bootstrap && bootstrap_rust_version_check
+       use system-bootstrap && rust_pkg_setup
 
        if use system-llvm; then
                llvm-r1_pkg_setup
@@ -334,7 +299,7 @@ src_configure() {
        local rust_stage0_root
        if use system-bootstrap; then
                local printsysroot
-               printsysroot="$(rustc --print sysroot || die "Can't determine 
rust's sysroot")"
+               printsysroot="$(${RUSTC} --print --sysroot || die "Can't 
determine rust's sysroot")"
                rust_stage0_root="${printsysroot}"
        else
                rust_stage0_root="${WORKDIR}"/rust-stage0

diff --git a/dev-lang/rust/rust-1.80.1-r100.ebuild 
b/dev-lang/rust/rust-1.80.1-r100.ebuild
index 782d0f8d92f5..5fc784e616a9 100644
--- a/dev-lang/rust/rust-1.80.1-r100.ebuild
+++ b/dev-lang/rust/rust-1.80.1-r100.ebuild
@@ -6,8 +6,13 @@ EAPI=8
 LLVM_COMPAT=( 18 )
 PYTHON_COMPAT=( python3_{10..13} )
 
+# We only need this for system-bootstrap
+RUST_OPTIONAL=1
+RUST_MAX_VER=${PV}
+RUST_MIN_VER="$(ver_cut 1).$(($(ver_cut 2) - 1)).0"
+
 inherit check-reqs estack flag-o-matic llvm-r1 multiprocessing \
-       multilib multilib-build python-any-r1 rust-toolchain toolchain-funcs 
verify-sig
+       multilib multilib-build python-any-r1 rust rust-toolchain 
toolchain-funcs verify-sig
 
 if [[ ${PV} = *beta* ]]; then
        betaver=${PV//*beta}
@@ -52,29 +57,13 @@ done
 LLVM_DEPEND+=( "       wasm? ( $(llvm_gen_dep 'sys-devel/lld:${LLVM_SLOT}') )" 
)
 LLVM_DEPEND+=( "       $(llvm_gen_dep 'sys-devel/llvm:${LLVM_SLOT}')" )
 
-# to bootstrap we need at least exactly previous version, or same.
-# most of the time previous versions fail to bootstrap with newer
-# for example 1.47.x, requires at least 1.46.x, 1.47.x is ok,
-# but it fails to bootstrap with 1.48.x
-# https://github.com/rust-lang/rust/blob/${PV}/src/stage0.json
-RUST_DEP_PREV="$(ver_cut 1).$(($(ver_cut 2) - 1))*"
-RUST_DEP_CURR="$(ver_cut 1).$(ver_cut 2)*"
-BOOTSTRAP_DEPEND="||
-       (
-               =dev-lang/rust-"${RUST_DEP_PREV}"
-               =dev-lang/rust-bin-"${RUST_DEP_PREV}"
-               =dev-lang/rust-"${RUST_DEP_CURR}"
-               =dev-lang/rust-bin-"${RUST_DEP_CURR}"
-       )
-"
-
 BDEPEND="${PYTHON_DEPS}
        app-eselect/eselect-rust
        || (
                >=sys-devel/gcc-4.7
                >=sys-devel/clang-3.5
        )
-       system-bootstrap? ( ${BOOTSTRAP_DEPEND} )
+       system-bootstrap? ( ${RUST_DEPEND} )
        !system-llvm? (
                >=dev-build/cmake-3.13.4
                app-alternatives/ninja
@@ -163,30 +152,6 @@ toml_usex() {
        usex "${1}" true false
 }
 
-bootstrap_rust_version_check() {
-       # never call from pkg_pretend. eselect-rust may be not installed yet.
-       [[ ${MERGE_TYPE} == binary ]] && return
-       local rustc_wanted="$(ver_cut 1).$(($(ver_cut 2) - 1))"
-       local rustc_toonew="$(ver_cut 1).$(($(ver_cut 2) + 1))"
-       local rustc_version=( $(eselect --brief --root="${BROOT}" rust show 
2>/dev/null) )
-       rustc_version=${rustc_version[0]#rust-bin-}
-       rustc_version=${rustc_version#rust-}
-
-       [[ -z "${rustc_version}" ]] && die "Failed to determine rust version, 
check 'eselect rust' output"
-
-       if ver_test "${rustc_version}" -lt "${rustc_wanted}" ; then
-               eerror "Rust >=${rustc_wanted} is required"
-               eerror "please run 'eselect rust' and set correct rust version"
-               die "selected rust version is too old"
-       elif ver_test "${rustc_version}" -ge "${rustc_toonew}" ; then
-               eerror "Rust <${rustc_toonew} is required"
-               eerror "please run 'eselect rust' and set correct rust version"
-               die "selected rust version is too new"
-       else
-               einfo "Using rust ${rustc_version} to build"
-       fi
-}
-
 pre_build_checks() {
        local M=8192
        # multiply requirements by 1.3 if we are doing x86-multilib
@@ -253,7 +218,7 @@ pkg_setup() {
                        die "Must enable LLVM_TARGETS=${cross_llvm_target} 
matching CBUILD=${CBUILD} when cross-compiling"
        fi
 
-       use system-bootstrap && bootstrap_rust_version_check
+       use system-bootstrap && rust_pkg_setup
 
        if use system-llvm; then
                llvm-r1_pkg_setup
@@ -333,7 +298,7 @@ src_configure() {
        local rust_stage0_root
        if use system-bootstrap; then
                local printsysroot
-               printsysroot="$(rustc --print sysroot || die "Can't determine 
rust's sysroot")"
+               printsysroot="$(${RUSTC} --print --sysroot || die "Can't 
determine rust's sysroot")"
                rust_stage0_root="${printsysroot}"
        else
                rust_stage0_root="${WORKDIR}"/rust-stage0

diff --git a/dev-lang/rust/rust-1.81.0-r100.ebuild 
b/dev-lang/rust/rust-1.81.0-r100.ebuild
index a6316b4e46fb..996971d4956d 100644
--- a/dev-lang/rust/rust-1.81.0-r100.ebuild
+++ b/dev-lang/rust/rust-1.81.0-r100.ebuild
@@ -6,8 +6,13 @@ EAPI=8
 LLVM_COMPAT=( 18 )
 PYTHON_COMPAT=( python3_{10..13} )
 
+# We only need this for system-bootstrap
+RUST_OPTIONAL=1
+RUST_MAX_VER=${PV}
+RUST_MIN_VER="$(ver_cut 1).$(($(ver_cut 2) - 1)).0"
+
 inherit check-reqs estack flag-o-matic llvm-r1 multiprocessing optfeature \
-       multilib multilib-build python-any-r1 rust-toolchain toolchain-funcs 
verify-sig
+       multilib multilib-build python-any-r1 rust rust-toolchain 
toolchain-funcs verify-sig
 
 if [[ ${PV} = *beta* ]]; then
        betaver=${PV//*beta}
@@ -52,29 +57,13 @@ done
 LLVM_DEPEND+=( "       wasm? ( $(llvm_gen_dep 'sys-devel/lld:${LLVM_SLOT}') )" 
)
 LLVM_DEPEND+=( "       $(llvm_gen_dep 'sys-devel/llvm:${LLVM_SLOT}')" )
 
-# to bootstrap we need at least exactly previous version, or same.
-# most of the time previous versions fail to bootstrap with newer
-# for example 1.47.x, requires at least 1.46.x, 1.47.x is ok,
-# but it fails to bootstrap with 1.48.x
-# https://github.com/rust-lang/rust/blob/${PV}/src/stage0.json
-RUST_DEP_PREV="$(ver_cut 1).$(($(ver_cut 2) - 1))*"
-RUST_DEP_CURR="$(ver_cut 1).$(ver_cut 2)*"
-BOOTSTRAP_DEPEND="||
-       (
-               =dev-lang/rust-"${RUST_DEP_PREV}"
-               =dev-lang/rust-bin-"${RUST_DEP_PREV}"
-               =dev-lang/rust-"${RUST_DEP_CURR}"
-               =dev-lang/rust-bin-"${RUST_DEP_CURR}"
-       )
-"
-
 BDEPEND="${PYTHON_DEPS}
        app-eselect/eselect-rust
        || (
                >=sys-devel/gcc-4.7
                >=sys-devel/clang-3.5
        )
-       system-bootstrap? ( ${BOOTSTRAP_DEPEND} )
+       system-bootstrap? ( ${RUST_DEPEND} )
        !system-llvm? (
                >=dev-build/cmake-3.13.4
                app-alternatives/ninja
@@ -166,30 +155,6 @@ toml_usex() {
        usex "${1}" true false
 }
 
-bootstrap_rust_version_check() {
-       # never call from pkg_pretend. eselect-rust may be not installed yet.
-       [[ ${MERGE_TYPE} == binary ]] && return
-       local rustc_wanted="$(ver_cut 1).$(($(ver_cut 2) - 1))"
-       local rustc_toonew="$(ver_cut 1).$(($(ver_cut 2) + 1))"
-       local rustc_version=( $(eselect --brief --root="${BROOT}" rust show 
2>/dev/null) )
-       rustc_version=${rustc_version[0]#rust-bin-}
-       rustc_version=${rustc_version#rust-}
-
-       [[ -z "${rustc_version}" ]] && die "Failed to determine rust version, 
check 'eselect rust' output"
-
-       if ver_test "${rustc_version}" -lt "${rustc_wanted}" ; then
-               eerror "Rust >=${rustc_wanted} is required"
-               eerror "please run 'eselect rust' and set correct rust version"
-               die "selected rust version is too old"
-       elif ver_test "${rustc_version}" -ge "${rustc_toonew}" ; then
-               eerror "Rust <${rustc_toonew} is required"
-               eerror "please run 'eselect rust' and set correct rust version"
-               die "selected rust version is too new"
-       else
-               einfo "Using rust ${rustc_version} to build"
-       fi
-}
-
 pre_build_checks() {
        local M=8192
        # multiply requirements by 1.3 if we are doing x86-multilib
@@ -256,7 +221,7 @@ pkg_setup() {
                        die "Must enable LLVM_TARGETS=${cross_llvm_target} 
matching CBUILD=${CBUILD} when cross-compiling"
        fi
 
-       use system-bootstrap && bootstrap_rust_version_check
+       use system-bootstrap && rust_pkg_setup
 
        if use system-llvm; then
                llvm-r1_pkg_setup
@@ -336,7 +301,7 @@ src_configure() {
        local rust_stage0_root
        if use system-bootstrap; then
                local printsysroot
-               printsysroot="$(rustc --print sysroot || die "Can't determine 
rust's sysroot")"
+               printsysroot="$(${RUSTC} --print --sysroot || die "Can't 
determine rust's sysroot")"
                rust_stage0_root="${printsysroot}"
        else
                rust_stage0_root="${WORKDIR}"/rust-stage0

diff --git a/dev-lang/rust/rust-1.82.0-r100.ebuild 
b/dev-lang/rust/rust-1.82.0-r100.ebuild
index 6cba749daef5..0c12c72b72f2 100644
--- a/dev-lang/rust/rust-1.82.0-r100.ebuild
+++ b/dev-lang/rust/rust-1.82.0-r100.ebuild
@@ -6,8 +6,13 @@ EAPI=8
 LLVM_COMPAT=( 19 )
 PYTHON_COMPAT=( python3_{10..13} )
 
+# We only need this for system-bootstrap
+RUST_OPTIONAL=1
+RUST_MAX_VER=${PV}
+RUST_MIN_VER="$(ver_cut 1).$(($(ver_cut 2) - 1)).0"
+
 inherit check-reqs estack flag-o-matic llvm-r1 multiprocessing optfeature \
-       multilib multilib-build python-any-r1 rust-toolchain toolchain-funcs 
verify-sig
+       multilib multilib-build python-any-r1 rust rust-toolchain 
toolchain-funcs verify-sig
 
 if [[ ${PV} = *beta* ]]; then
        betaver=${PV//*beta}
@@ -52,29 +57,13 @@ done
 LLVM_DEPEND+=( "       wasm? ( $(llvm_gen_dep 'sys-devel/lld:${LLVM_SLOT}') )" 
)
 LLVM_DEPEND+=( "       $(llvm_gen_dep 'sys-devel/llvm:${LLVM_SLOT}')" )
 
-# to bootstrap we need at least exactly previous version, or same.
-# most of the time previous versions fail to bootstrap with newer
-# for example 1.47.x, requires at least 1.46.x, 1.47.x is ok,
-# but it fails to bootstrap with 1.48.x
-# https://github.com/rust-lang/rust/blob/${PV}/src/stage0.json
-RUST_DEP_PREV="$(ver_cut 1).$(($(ver_cut 2) - 1))*"
-RUST_DEP_CURR="$(ver_cut 1).$(ver_cut 2)*"
-BOOTSTRAP_DEPEND="||
-       (
-               =dev-lang/rust-"${RUST_DEP_PREV}"
-               =dev-lang/rust-bin-"${RUST_DEP_PREV}"
-               =dev-lang/rust-"${RUST_DEP_CURR}"
-               =dev-lang/rust-bin-"${RUST_DEP_CURR}"
-       )
-"
-
 BDEPEND="${PYTHON_DEPS}
        app-eselect/eselect-rust
        || (
                >=sys-devel/gcc-4.7
                >=sys-devel/clang-3.5
        )
-       system-bootstrap? ( ${BOOTSTRAP_DEPEND} )
+       system-bootstrap? ( ${RUST_DEPEND} )
        !system-llvm? (
                >=dev-build/cmake-3.13.4
                app-alternatives/ninja
@@ -163,30 +152,6 @@ toml_usex() {
        usex "${1}" true false
 }
 
-bootstrap_rust_version_check() {
-       # never call from pkg_pretend. eselect-rust may be not installed yet.
-       [[ ${MERGE_TYPE} == binary ]] && return
-       local rustc_wanted="$(ver_cut 1).$(($(ver_cut 2) - 1))"
-       local rustc_toonew="$(ver_cut 1).$(($(ver_cut 2) + 1))"
-       local rustc_version=( $(eselect --brief --root="${BROOT}" rust show 
2>/dev/null) )
-       rustc_version=${rustc_version[0]#rust-bin-}
-       rustc_version=${rustc_version#rust-}
-
-       [[ -z "${rustc_version}" ]] && die "Failed to determine rust version, 
check 'eselect rust' output"
-
-       if ver_test "${rustc_version}" -lt "${rustc_wanted}" ; then
-               eerror "Rust >=${rustc_wanted} is required"
-               eerror "please run 'eselect rust' and set correct rust version"
-               die "selected rust version is too old"
-       elif ver_test "${rustc_version}" -ge "${rustc_toonew}" ; then
-               eerror "Rust <${rustc_toonew} is required"
-               eerror "please run 'eselect rust' and set correct rust version"
-               die "selected rust version is too new"
-       else
-               einfo "Using rust ${rustc_version} to build"
-       fi
-}
-
 pre_build_checks() {
        local M=8192
        # multiply requirements by 1.3 if we are doing x86-multilib
@@ -253,7 +218,7 @@ pkg_setup() {
                        die "Must enable LLVM_TARGETS=${cross_llvm_target} 
matching CBUILD=${CBUILD} when cross-compiling"
        fi
 
-       use system-bootstrap && bootstrap_rust_version_check
+       use system-bootstrap && rust_pkg_setup
 
        if use system-llvm; then
                llvm-r1_pkg_setup
@@ -341,7 +306,7 @@ src_configure() {
        local rust_stage0_root
        if use system-bootstrap; then
                local printsysroot
-               printsysroot="$(rustc --print sysroot || die "Can't determine 
rust's sysroot")"
+               printsysroot="$(${RUSTC} --print sysroot || die "Can't 
determine rust's sysroot")"
                rust_stage0_root="${printsysroot}"
        else
                rust_stage0_root="${WORKDIR}"/rust-stage0

Reply via email to