Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove rust toolchain channel check #848

Merged
merged 2 commits into from
Dec 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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(()),
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This min version check can be replaced by adding rust_version to the ink crate, might be a more suitable location for it?

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");
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only required when doing cargo build so have moved it to exec_cargo_for_wasm_target.


cmd.arg(command);
cmd.args(args);
match verbosity {
Expand Down