rust: Enable building rust from stable, beta and nightly channels
PATCH v2 1/1 rust: Enable building rust from stable, beta and nightly channels
From: Alejandro Hernandez Samaniego <[email protected]>
Rust follows the train release model via the stable, beta and nightly channels, by default we build rust from the stable channel, however there are certain features which are only available in the beta or nightly channels.
Make these channels available by setting a RUST_CHANNEL variable which defaults to stable making this change transparent to the user.
The snapshot version used by rust during its compilation wont necessarily match the version being built, specially if were building from an unstable channel, to avoid confusion rename this to SNAPSHOT_VERSION and use RUST_VERSION for the version to be built, which is automatically defined to PV.
Append -beta or -nightly to rusts PV for signature awareness.
It is important to note that this does not build rust from the beta/nightly published tarball (which today build rust v1.67.0 and v1.68.0 respectively), instead this builds rust from the current selected version (1.66.0) and enables the beta/nightly features for that version.
Setting the variable RUST_CHANNEL=nightly results in the following:
$ rustc -Vv rustc 1.66.0-nightly
--- meta/recipes-devtools/rust/rust-snapshot.inc | 7 ++++--- meta/recipes-devtools/rust/rust-source.inc | 5 +++-- meta/recipes-devtools/rust/rust.inc | 6 +++++- 3 files changed, 12 insertions(+), 6 deletions(-)
meta/recipes-devtools/rust/rust-snapshot.inc +4 -3
@@ -5,7 +5,8 @@ ## The version is replicated here. ## TODO: find a way to add additional SRC_URIs based on the contents of an ## earlier SRC_URI. -RS_VERSION = "1.65.0" + +SNAPSHOT_VERSION = "1.65.0" CARGO_VERSION = "1.65.0" # TODO: Add hashes for other architecture toolchains as well. Make a script?
@@ -27,6 +28,6 @@ SRC_URI += " \ https://static.rust-lang.org/dist/${CARGO_SNAPSHOT}.tar.xz;name=cargo-snapshot-${RUST_BUILD_ARCH};subdir=rust-snapshot-components \ " -RUST_STD_SNAPSHOT = "rust-std-${RS_VERSION}-${RUST_BUILD_ARCH}-unknown-linux-gnu" -RUSTC_SNAPSHOT = "rustc-${RS_VERSION}-${RUST_BUILD_ARCH}-unknown-linux-gnu" +RUST_STD_SNAPSHOT = "rust-std-${SNAPSHOT_VERSION}-${RUST_BUILD_ARCH}-unknown-linux-gnu" +RUSTC_SNAPSHOT = "rustc-${SNAPSHOT_VERSION}-${RUST_BUILD_ARCH}-unknown-linux-gnu" CARGO_SNAPSHOT = "cargo-${CARGO_VERSION}-${RUST_BUILD_ARCH}-unknown-linux-gnu"
meta/recipes-devtools/rust/rust-source.inc +3 -2
@@ -1,4 +1,5 @@ -SRC_URI += "https://static.rust-lang.org/dist/rustc-${PV}-src.tar.xz;name=rust" +RUST_VERSION ?= "${@d.getVar('PV').split('-')[0]}" +SRC_URI += "https://static.rust-lang.org/dist/rustc-${RUST_VERSION}-src.tar.xz;name=rust" SRC_URI[rust.sha256sum] = "0dc176e34fae9871f855a6ba4cb30fa19d69c5b4428d29281a07419c4950715c" SRC_URI:append:class-target:pn-rust = " \
@@ -6,7 +7,7 @@ SRC_URI:append:class-target:pn-rust = " \ file://crossbeam_atomic.patch" SRC_URI:append:class-nativesdk:pn-nativesdk-rust = " file://hardcodepaths.patch" -RUSTSRC = "${WORKDIR}/rustc-${PV}-src" +RUSTSRC = "${WORKDIR}/rustc-${RUST_VERSION}-src" UPSTREAM_CHECK_URI = "https://forge.rust-lang.org/infra/other-installation-methods.html" UPSTREAM_CHECK_REGEX = "rustc-(?P<pver>\d+(\.\d+)+)-src"
meta/recipes-devtools/rust/rust.inc +5 -1
@@ -13,6 +13,10 @@ DEPENDS:append:class-nativesdk = " nativesdk-rust-llvm" S = "${RUSTSRC}" +# Use at your own risk, accepted values are stable, beta and nightly +RUST_CHANNEL ?= "stable" +PV:append = "${@bb.utils.contains('RUST_CHANNEL', 'stable', '', '-${RUST_CHANNEL}', d)}" + export FORCE_CRATE_HASH="${BB_TASKHASH}" RUST_ALTERNATE_EXE_PATH ?= "${STAGING_LIBDIR}/llvm-rust/bin/llvm-config"
@@ -116,7 +120,7 @@ python do_configure() { # [rust] config.add_section("rust") config.set("rust", "rpath", e(True)) - config.set("rust", "channel", e("stable")) + config.set("rust", "channel", e(d.expand("${RUST_CHANNEL}"))) # Whether or not to optimize the compiler and standard library config.set("rust", "optimize", e(True))
Signature · 1 line
2.34.1
Quoted 81 lines · Alejandro Hernandez Samaniego
From: Alejandro Hernandez Samaniego <[email protected]>
Rust follows the train release model via the stable, beta and nightly channels, by default we build rust from the stable channel, however there are certain features which are only available in the beta or nightly channels.
Make these channels available by setting a
RUST_CHANNELvariable which defaults to stable making this change transparent to the user.The snapshot version used by rust during its compilation wont necessarily match the version being built, specially if were building from an unstable channel, to avoid confusion rename this to
SNAPSHOT_VERSIONand useRUST_VERSIONfor the version to be built, which is automatically defined to PV.Append -beta or -nightly to rusts PV for signature awareness.
It is important to note that this does not build rust from the beta/nightly published tarball (which today build rust v1.67.0 and v1.68.0 respectively), instead this builds rust from the current selected version (1.66.0) and enables the beta/nightly features for that version.
Setting the variable RUST_CHANNEL=nightly results in the following:
$ rustc -Vv rustc 1.66.0-nightlySigned-off-by Alejandro Hernandez Samaniego <[email protected]>--- meta/recipes-devtools/rust/rust-snapshot.inc | 7 ++++--- meta/recipes-devtools/rust/rust-source.inc | 5 +++-- meta/recipes-devtools/rust/rust.inc | 6 +++++- 3 files changed, 12 insertions(+), 6 deletions(-)meta/recipes-devtools/rust/rust-snapshot.inc +4
-3@@ -5,7 +5,8 @@ ## The version is replicated here. ## TODO: find a way to add additional SRC_URIs based on the contents of an ## earlier SRC_URI. -RS_VERSION = "1.65.0" + +SNAPSHOT_VERSION = "1.65.0" CARGO_VERSION = "1.65.0" # TODO: Add hashes for other architecture toolchains as well. Make a script?@@ -27,6 +28,6 @@ SRC_URI += " \ https://static.rust-lang.org/dist/${CARGO_SNAPSHOT}.tar.xz;name=cargo-snapshot-${RUST_BUILD_ARCH};subdir=rust-snapshot-components \ " -RUST_STD_SNAPSHOT = "rust-std-${RS_VERSION}-${RUST_BUILD_ARCH}-unknown-linux-gnu" -RUSTC_SNAPSHOT = "rustc-${RS_VERSION}-${RUST_BUILD_ARCH}-unknown-linux-gnu" +RUST_STD_SNAPSHOT = "rust-std-${SNAPSHOT_VERSION}-${RUST_BUILD_ARCH}-unknown-linux-gnu" +RUSTC_SNAPSHOT = "rustc-${SNAPSHOT_VERSION}-${RUST_BUILD_ARCH}-unknown-linux-gnu" CARGO_SNAPSHOT = "cargo-${CARGO_VERSION}-${RUST_BUILD_ARCH}-unknown-linux-gnu"meta/recipes-devtools/rust/rust-source.inc +3
-2@@ -1,4 +1,5 @@ -SRC_URI += "https://static.rust-lang.org/dist/rustc-${PV}-src.tar.xz;name=rust" +RUST_VERSION ?= "${@d.getVar('PV').split('-')[0]}" +SRC_URI += "https://static.rust-lang.org/dist/rustc-${RUST_VERSION}-src.tar.xz;name=rust" SRC_URI[rust.sha256sum] = "0dc176e34fae9871f855a6ba4cb30fa19d69c5b4428d29281a07419c4950715c" SRC_URI:append:class-target:pn-rust = " \@@ -6,7 +7,7 @@ SRC_URI:append:class-target:pn-rust = " \ file://crossbeam_atomic.patch" SRC_URI:append:class-nativesdk:pn-nativesdk-rust = " file://hardcodepaths.patch" -RUSTSRC = "${WORKDIR}/rustc-${PV}-src" +RUSTSRC = "${WORKDIR}/rustc-${RUST_VERSION}-src" UPSTREAM_CHECK_URI = "https://forge.rust-lang.org/infra/other-installation-methods.html" UPSTREAM_CHECK_REGEX = "rustc-(?P<pver>\d+(\.\d+)+)-src"meta/recipes-devtools/rust/rust.inc +0
-0
meta/recipes-devtools/rust/rust.inc DEPENDS:append:class-nativesdk = " nativesdk-rust-llvm" · line 20
Quoted 8 lines
meta/recipes-devtools/rust/rust.inc +4
-0@@ -13,6 +13,10 @@ DEPENDS:append:class-nativesdk = " nativesdk-rust-llvm" S = "${RUSTSRC}" +# Use at your own risk, accepted values are stable, beta and nightly +RUST_CHANNEL ?= "stable" +PV:append = "${@bb.utils.contains('RUST_CHANNEL', 'stable', '', '-${RUST_CHANNEL}', d)}" + export FORCE_CRATE_HASH="${BB_TASKHASH}"
Did you try it with .= instead of append? I'd really prefer not to use append unless we have to, mainly so we lead by example...
Cheers,
Richard
Quoted 120 lines · Richard Purdie
Quoted 3 lines · Alejandro Hernandez Samaniego
From: Alejandro Hernandez Samaniego <[email protected]>
Rust follows the train release model via the stable, beta and nightly
channels,
Quoted 1 line
by default we build rust from the stable channel, however there are
certain
Quoted 3 lines
features which are only available in the beta or nightly channels.
Make these channels available by setting a
RUST_CHANNELvariable whichdefaults
Quoted 3 lines
to stable making this change transparent to the user.
The snapshot version used by rust during its compilation wont
necessarily match
Quoted 1 line
the version being built, specially if were building from an unstable
channel,
Quoted 1 line
to avoid confusion rename this to
SNAPSHOT_VERSIONand useRUST_VERSIONfor the
Quoted 5 lines
version to be built, which is automatically defined to PV.
Append -beta or -nightly to rusts PV for signature awareness.
It is important to note that this does not build rust from the
beta/nightly
Quoted 1 line
published tarball (which today build rust v1.67.0 and v1.68.0
respectively),
Quoted 1 line
instead this builds rust from the current selected version (1.66.0) and
enables
Quoted 7 lines
the beta/nightly features for that version.
Setting the variable RUST_CHANNEL=nightly results in the following:
$ rustc -Vv rustc 1.66.0-nightlyReview
Quoted 8 lines
Signed-off-by Alejandro Hernandez Samaniego <[email protected]>--- meta/recipes-devtools/rust/rust-snapshot.inc | 7 ++++--- meta/recipes-devtools/rust/rust-source.inc | 5 +++-- meta/recipes-devtools/rust/rust.inc | 6 +++++- 3 files changed, 12 insertions(+), 6 deletions(-)(quoted diff) +0
-0b/meta/recipes-devtools/rust/rust-snapshot.inc
meta/recipes-devtools/rust/rust-snapshot.inc line 6
Quoted 6 lines
index
222f34f9a8..6420bcff55100644meta/recipes-devtools/rust/rust-snapshot.inc +0
-0@@ -5,7 +5,8 @@ ## The version is replicated here. ## TODO: find a way to add additional SRC_URIs based on the contents ofan
meta/recipes-devtools/rust/rust-snapshot.inc
Quoted 7 lines
meta/recipes-devtools/rust/rust-snapshot.inc +2
-1## earlier SRC_URI. -RS_VERSION = "1.65.0" + +SNAPSHOT_VERSION = "1.65.0" CARGO_VERSION = "1.65.0" # TODO: Add hashes for other architecture toolchains as well. Make ascript?
meta/recipes-devtools/rust/rust-snapshot.inc SRC_URI += " \ · line 28
Quoted 2 lines
meta/recipes-devtools/rust/rust-snapshot.inc +0
-0@@ -27,6 +28,6 @@ SRC_URI += " \meta/recipes-devtools/rust/rust-snapshot.inc SRC_URI += " \ · line 30
Quoted 3 lines
meta/recipes-devtools/rust/rust-snapshot.inc +0
-1" -RUST_STD_SNAPSHOT ="rust-std-${RS_VERSION}-${RUST_BUILD_ARCH}-unknown-linux-gnu"
meta/recipes-devtools/rust/rust-snapshot.inc SRC_URI += " \ · line 31
Quoted 1 line
meta/recipes-devtools/rust/rust-snapshot.inc +0
-1-RUSTC_SNAPSHOT ="rustc-${RS_VERSION}-${RUST_BUILD_ARCH}-unknown-linux-gnu"
meta/recipes-devtools/rust/rust-snapshot.inc SRC_URI += " \ · line 31
Quoted 1 line
meta/recipes-devtools/rust/rust-snapshot.inc +1
-0+RUST_STD_SNAPSHOT ="rust-std-${SNAPSHOT_VERSION}-${RUST_BUILD_ARCH}-unknown-linux-gnu"
meta/recipes-devtools/rust/rust-snapshot.inc SRC_URI += " \ · line 32
Quoted 1 line
meta/recipes-devtools/rust/rust-snapshot.inc +1
-0+RUSTC_SNAPSHOT ="rustc-${SNAPSHOT_VERSION}-${RUST_BUILD_ARCH}-unknown-linux-gnu"
meta/recipes-devtools/rust/rust-snapshot.inc SRC_URI += " \ · line 33
Quoted 1 line
meta/recipes-devtools/rust/rust-snapshot.inc +0
-0CARGO_SNAPSHOT ="cargo-${CARGO_VERSION}-${RUST_BUILD_ARCH}-unknown-linux-gnu"
Review
Quoted 1 line
(quoted diff) +0
-0b/meta/recipes-devtools/rust/rust-source.inc
meta/recipes-devtools/rust/rust-source.inc line 1
Quoted 5 lines
index
1c511917e2..91a6c5a942100644meta/recipes-devtools/rust/rust-source.inc +0
-1@@ -1,4 +1,5 @@ -SRC_URI += "https://static.rust-lang.org/dist/rustc-${PV}-src.tar.xz;name=rust"
meta/recipes-devtools/rust/rust-source.inc line 2
Quoted 2 lines
meta/recipes-devtools/rust/rust-source.inc +2
-0+RUST_VERSION ?= "${@d.getVar('PV').split('-')[0]}" +SRC_URI += "https://static.rust-lang.org/dist/rustc-${RUST_VERSION}-src.tar.xz;name=rust
"meta/recipes-devtools/rust/rust-source.inc line 3
Quoted 1 line
meta/recipes-devtools/rust/rust-source.inc +0
-0SRC_URI[rust.sha256sum] ="
0dc176e34fae9871f855a6ba4cb30fa19d69c5b4428d29281a07419c4950715c"meta/recipes-devtools/rust/rust-source.inc SRC_URI:append:class-target:pn-rust = " \ · line 8
Quoted 5 lines
meta/recipes-devtools/rust/rust-source.inc +0
-0SRC_URI:append:class-target:pn-rust = " \@@ -6,7 +7,7 @@ SRC_URI:append:class-target:pn-rust = " \ file://crossbeam_atomic.patch" SRC_URI:append:class-nativesdk:pn-nativesdk-rust = "file://hardcodepaths.patch"
meta/recipes-devtools/rust/rust-source.inc SRC_URI:append:class-target:pn-rust = " \
Quoted 5 lines
meta/recipes-devtools/rust/rust-source.inc +1
-1-RUSTSRC = "${WORKDIR}/rustc-${PV}-src" +RUSTSRC = "${WORKDIR}/rustc-${RUST_VERSION}-src" UPSTREAM_CHECK_URI = "https://forge.rust-lang.org/infra/other-installation-methods.html"
Review
Quoted 2 lines
meta/recipes-devtools/rust/rust-source.inc +0
-0UPSTREAM_CHECK_REGEX = "rustc-(?P<pver>\d+(\.\d+)+)-src"(quoted diff) +0
-0b/meta/recipes-devtools/rust/rust.inc
meta/recipes-devtools/rust/rust.inc DEPENDS:append:class-nativesdk = "
Quoted 4 lines
index
8d25e7993a..37a04e1204100644meta/recipes-devtools/rust/rust.inc +0
-0@@ -13,6 +13,10 @@ DEPENDS:append:class-nativesdk = "nativesdk-rust-llvm"
meta/recipes-devtools/rust/rust.inc DEPENDS:append:class-nativesdk = " nativesdk-rust-llvm"
Quoted 6 lines
meta/recipes-devtools/rust/rust.inc +3
-0S = "${RUSTSRC}" +# Use at your own risk, accepted values are stable, beta and nightly +RUST_CHANNEL ?= "stable" +PV:append = "${@bb.utils.contains('RUST_CHANNEL', 'stable', '','-${RUST_CHANNEL}', d)}"
meta/recipes-devtools/rust/rust.inc DEPENDS:append:class-nativesdk = " nativesdk-rust-llvm" · line 20
Quoted 2 lines
meta/recipes-devtools/rust/rust.inc +1
-0+ export FORCE_CRATE_HASH="${BB_TASKHASH}"
Quoted 6 lines
Did you try it with .= instead of append? I'd really prefer not to use append unless we have to, mainly so we lead by example...
Cheers,
Richard
You are right, I should've done this with .= instead, my mistake, I will test it and send a v3.
Cheers,
Alejandro