Skip to content

Commit

Permalink
Remove rust toolchain channel check (#848)
Browse files Browse the repository at this point in the history
* Remove assert_channel check

* Add RUSTC_BOOTSTRAP for building on stable
  • Loading branch information
ascjones authored Dec 5, 2022
1 parent 2c30998 commit defd393
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 30 deletions.
7 changes: 6 additions & 1 deletion crates/build/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
Expand Down
29 changes: 0 additions & 29 deletions crates/build/src/util/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<channel>-<target-triple>`.
pub(crate) fn rust_toolchain() -> Result<String> {
let meta = rustc_version::version_meta()?;
Expand Down Expand Up @@ -85,7 +60,6 @@ where
S: AsRef<OsStr>,
P: AsRef<Path>,
{
assert_channel()?;
let cargo = std::env::var("CARGO").unwrap_or_else(|_| "cargo".to_string());
let mut cmd = Command::new(cargo);

Expand All @@ -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 {
Expand Down

0 comments on commit defd393

Please sign in to comment.