Companion: wasm-builder support stable Rust (#6967)

* Companion: wasm-builder support stable Rust

* update lockfile for {"substrate"}

---------

Co-authored-by: parity-processbot <>
This commit is contained in:
Bastian Köcher
2023-03-29 12:11:15 +02:00
committed by GitHub
parent faa2d5b09e
commit 8b1645faf0
6 changed files with 202 additions and 198 deletions
+185 -183
View File
File diff suppressed because it is too large Load Diff
@@ -17,10 +17,6 @@
//! Basic parachain that adds a number as part of its state. //! Basic parachain that adds a number as part of its state.
#![no_std] #![no_std]
#![cfg_attr(
not(feature = "std"),
feature(core_intrinsics, lang_items, core_panic_info, alloc_error_handler)
)]
use parity_scale_codec::{Decode, Encode}; use parity_scale_codec::{Decode, Encode};
use tiny_keccak::{Hasher as _, Keccak}; use tiny_keccak::{Hasher as _, Keccak};
@@ -10,6 +10,7 @@ edition.workspace = true
[build-dependencies] [build-dependencies]
substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "master" } substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "master" }
rustversion = "1.0.6"
[features] [features]
default = [ "std" ] default = [ "std" ]
@@ -17,5 +17,17 @@
use substrate_wasm_builder::WasmBuilder; use substrate_wasm_builder::WasmBuilder;
fn main() { fn main() {
WasmBuilder::new().with_current_project().export_heap_base().build() WasmBuilder::new().with_current_project().export_heap_base().build();
enable_alloc_error_handler();
} }
#[rustversion::before(1.68)]
fn enable_alloc_error_handler() {
if !cfg!(feature = "std") {
println!("cargo:rustc-cfg=enable_alloc_error_handler");
}
}
#[rustversion::since(1.68)]
fn enable_alloc_error_handler() {}
@@ -17,10 +17,7 @@
//! Basic parachain that executes forever. //! Basic parachain that executes forever.
#![no_std] #![no_std]
#![cfg_attr( #![cfg_attr(enable_alloc_error_handler, feature(alloc_error_handler))]
not(feature = "std"),
feature(core_intrinsics, lang_items, core_panic_info, alloc_error_handler)
)]
// Make the WASM binary available. // Make the WASM binary available.
#[cfg(feature = "std")] #[cfg(feature = "std")]
@@ -39,10 +36,10 @@ pub fn wasm_binary_unwrap() -> &'static [u8] {
#[panic_handler] #[panic_handler]
#[no_mangle] #[no_mangle]
pub fn panic(_info: &core::panic::PanicInfo) -> ! { pub fn panic(_info: &core::panic::PanicInfo) -> ! {
core::intrinsics::abort() core::arch::wasm32::unreachable();
} }
#[cfg(not(feature = "std"))] #[cfg(enable_alloc_error_handler)]
#[alloc_error_handler] #[alloc_error_handler]
#[no_mangle] #[no_mangle]
pub fn oom(_: core::alloc::Layout) -> ! { pub fn oom(_: core::alloc::Layout) -> ! {
@@ -17,10 +17,6 @@
//! Basic parachain that adds a number as part of its state. //! Basic parachain that adds a number as part of its state.
#![no_std] #![no_std]
#![cfg_attr(
not(feature = "std"),
feature(core_intrinsics, lang_items, core_panic_info, alloc_error_handler)
)]
use parity_scale_codec::{Decode, Encode}; use parity_scale_codec::{Decode, Encode};
use sp_std::vec::Vec; use sp_std::vec::Vec;