From defd393d9a989a21b5ca6faef5147437504f9967 Mon Sep 17 00:00:00 2001 From: Andrew Jones Date: Mon, 5 Dec 2022 20:00:29 +0000 Subject: [PATCH] Remove rust toolchain channel check (#848) * Remove assert_channel check * Add RUSTC_BOOTSTRAP for building on stable --- crates/build/src/lib.rs | 7 ++++++- crates/build/src/util/mod.rs | 29 ----------------------------- 2 files changed, 6 insertions(+), 30 deletions(-) diff --git a/crates/build/src/lib.rs b/crates/build/src/lib.rs index f71314903..893952f92 100644 --- a/crates/build/src/lib.rs +++ b/crates/build/src/lib.rs @@ -256,10 +256,15 @@ fn exec_cargo_for_wasm_target( } else { args.push("-Zbuild-std-features=panic_immediate_abort"); } - let env = vec![( + let mut env = vec![( "RUSTFLAGS", Some("-C link-arg=-zstack-size=65536 -C link-arg=--import-memory -Clinker-plugin-lto -C target-cpu=mvp"), )]; + if rustc_version::version_meta()?.channel == rustc_version::Channel::Stable { + // Allow nightly features on a stable toolchain + env.push(("RUSTC_BOOTSTRAP", Some("1"))) + } + util::invoke_cargo(command, &args, manifest_path.directory(), verbosity, env)?; Ok(()) diff --git a/crates/build/src/util/mod.rs b/crates/build/src/util/mod.rs index 70fb3c987..43bfcc4cb 100644 --- a/crates/build/src/util/mod.rs +++ b/crates/build/src/util/mod.rs @@ -22,37 +22,12 @@ use anyhow::{ Context, Result, }; -use rustc_version::Channel; -use semver::Version; use std::{ ffi::OsStr, path::Path, process::Command, }; -/// This makes sure we are building with a minimum `stable` toolchain version. -fn assert_channel() -> Result<()> { - let meta = rustc_version::version_meta()?; - let min_version = Version::new(1, 63, 0); - match meta.channel { - Channel::Stable if meta.semver >= min_version => Ok(()), - Channel::Stable => { - anyhow::bail!( - "The minimum Rust version is {}. You are using {}.", - min_version, - meta.semver - ) - } - _ => { - anyhow::bail!( - "Using the {:?} channel is not supported. \ - Contracts should be built using a \"stable\" toolchain.", - format!("{:?}", meta.channel).to_lowercase(), - ) - } - } -} - // Returns the current Rust toolchain formatted by `-`. pub(crate) fn rust_toolchain() -> Result { let meta = rustc_version::version_meta()?; @@ -85,7 +60,6 @@ where S: AsRef, P: AsRef, { - assert_channel()?; let cargo = std::env::var("CARGO").unwrap_or_else(|_| "cargo".to_string()); let mut cmd = Command::new(cargo); @@ -101,9 +75,6 @@ where cmd.current_dir(path); } - // Allow nightly features on a stable toolchain - cmd.env("RUSTC_BOOTSTRAP", "1"); - cmd.arg(command); cmd.args(args); match verbosity {