diff --git a/crates/build/src/lib.rs b/crates/build/src/lib.rs index 9999ace10..00598dcbb 100644 --- a/crates/build/src/lib.rs +++ b/crates/build/src/lib.rs @@ -308,16 +308,6 @@ fn exec_cargo_for_onchain_target( env.push(("RUSTC_BOOTSTRAP", Some("1".to_string()))) } - // newer rustc versions might emit unsupported instructions - if rustc_version::version_meta()?.semver >= Version::new(1, 70, 0) { - eprintln!( - "{} {}", - "warning:".yellow().bold(), - "You are using a rustc version that might emit unsupported wasm instructions. Build using a version lower than 1.70.0 to make sure your contract will deploy." - .bold() - ); - } - // merge target specific flags with the common flags (defined here) // We want to disable warnings here as they will be duplicates of the clippy pass. // However, if we want to do so with either `--cap-lints allow` or `-A diff --git a/crates/build/src/wasm_opt.rs b/crates/build/src/wasm_opt.rs index 0acefc9f3..afac079ce 100644 --- a/crates/build/src/wasm_opt.rs +++ b/crates/build/src/wasm_opt.rs @@ -18,6 +18,7 @@ use anyhow::Result; use wasm_opt::{ Feature, OptimizationOptions, + Pass, }; use std::{ @@ -68,9 +69,14 @@ impl WasmOptHandler { ); OptimizationOptions::from(self.optimization_level) - // Since rustc 1.70 `SignExt` can't be disabled anymore. Hence we have to allow it. .mvp_features_only() + // Since rustc 1.70 `SignExt` can't be disabled anymore. Hence we have to allow it, + // in order that the Wasm binary containing these instructions can be loaded. .enable_feature(Feature::SignExt) + // This pass will then remove any `signext` instructions in order that the resulting + // Wasm binary is compatible with older versions of `pallet-contracts` which do not + // support the `signext` instruction. + .add_pass(Pass::SignextLowering) // the memory in our module is imported, `wasm-opt` needs to be told that // the memory is initialized to zeroes, otherwise it won't run the // memory-packing pre-pass.