From cec3da5c069dcee7556226acfbdd54b1420d7a5c Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Wed, 13 Jun 2018 21:47:47 +0700 Subject: [PATCH 1/5] Fixes WasmAllocator to reflect recent nightly API changes --- substrate/pwasm-alloc/src/lib.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/substrate/pwasm-alloc/src/lib.rs b/substrate/pwasm-alloc/src/lib.rs index 85be153815059..bf4e33f133890 100644 --- a/substrate/pwasm-alloc/src/lib.rs +++ b/substrate/pwasm-alloc/src/lib.rs @@ -20,16 +20,16 @@ mod __impl { extern crate alloc; extern crate pwasm_libc; - use self::alloc::heap::{GlobalAlloc, Layout, Opaque}; + use core::alloc::{GlobalAlloc, Layout}; use super::WasmAllocator; unsafe impl GlobalAlloc for WasmAllocator { - unsafe fn alloc(&self, layout: Layout) -> *mut Opaque { - pwasm_libc::malloc(layout.size()) as *mut Opaque + unsafe fn alloc(&self, layout: Layout) -> *mut u8 { + pwasm_libc::malloc(layout.size()) as *mut u8 } - unsafe fn dealloc(&self, ptr: *mut Opaque, _layout: Layout) { + unsafe fn dealloc(&self, ptr: *mut u8, _layout: Layout) { pwasm_libc::free(ptr as *mut u8) } } From 3ed1c6273baadf0a3bb05284273a3f6adaa4cd9c Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Wed, 13 Jun 2018 22:00:48 +0700 Subject: [PATCH 2/5] Removes unneeded feature and crate import --- substrate/pwasm-alloc/src/lib.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/substrate/pwasm-alloc/src/lib.rs b/substrate/pwasm-alloc/src/lib.rs index bf4e33f133890..3cb2ae662ed07 100644 --- a/substrate/pwasm-alloc/src/lib.rs +++ b/substrate/pwasm-alloc/src/lib.rs @@ -2,7 +2,6 @@ #![cfg_attr(feature = "strict", deny(warnings))] #![no_std] #![crate_type = "rlib"] -#![cfg_attr(feature = "nightly", feature(global_allocator))] #![cfg_attr(feature = "nightly", feature(alloc))] #![cfg_attr(feature = "nightly", feature(allocator_api))] @@ -17,7 +16,6 @@ static ALLOCATOR: WasmAllocator = WasmAllocator; #[cfg(feature = "nightly")] mod __impl { - extern crate alloc; extern crate pwasm_libc; use core::alloc::{GlobalAlloc, Layout}; From 4658b7b1b9da23cee414589dd203d5463d3908b2 Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Wed, 13 Jun 2018 22:03:43 +0700 Subject: [PATCH 3/5] Removes unneeded feature attrs --- substrate/pwasm-alloc/src/lib.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/substrate/pwasm-alloc/src/lib.rs b/substrate/pwasm-alloc/src/lib.rs index 3cb2ae662ed07..7dbfb562a91d1 100644 --- a/substrate/pwasm-alloc/src/lib.rs +++ b/substrate/pwasm-alloc/src/lib.rs @@ -2,8 +2,6 @@ #![cfg_attr(feature = "strict", deny(warnings))] #![no_std] #![crate_type = "rlib"] -#![cfg_attr(feature = "nightly", feature(alloc))] -#![cfg_attr(feature = "nightly", feature(allocator_api))] //! Custom allocator crate for wasm From 181b41edbf344a86470753b2f38db15d499ee571 Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Thu, 14 Jun 2018 19:14:40 +0700 Subject: [PATCH 4/5] Removes unneeded `global_allocator` attribute --- polkadot/parachain/test-chains/basic_add/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/polkadot/parachain/test-chains/basic_add/src/lib.rs b/polkadot/parachain/test-chains/basic_add/src/lib.rs index be21a8dec8caa..1ef898f1dc3f5 100644 --- a/polkadot/parachain/test-chains/basic_add/src/lib.rs +++ b/polkadot/parachain/test-chains/basic_add/src/lib.rs @@ -17,7 +17,7 @@ //! Basic parachain that adds a number as part of its state. #![cfg_attr(not(feature = "std"), no_std)] -#![cfg_attr(not(feature = "std"), feature(alloc, core_intrinsics, global_allocator, lang_items, panic_implementation))] +#![cfg_attr(not(feature = "std"), feature(alloc, core_intrinsics, lang_items, panic_implementation))] #[cfg(not(feature = "std"))] extern crate alloc; From e909d897be6c05e631c2ef52abe1a73cb56761bb Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Thu, 14 Jun 2018 19:24:28 +0700 Subject: [PATCH 5/5] Override wee_alloc dependency to use recent state Revision 4e9f23f points to a master after https://github.com/rustwasm/wee_alloc/pull/45 was merged --- polkadot/parachain/test-chains/basic_add/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/polkadot/parachain/test-chains/basic_add/Cargo.toml b/polkadot/parachain/test-chains/basic_add/Cargo.toml index dd0fc4050d925..41e745ca1a4b2 100644 --- a/polkadot/parachain/test-chains/basic_add/Cargo.toml +++ b/polkadot/parachain/test-chains/basic_add/Cargo.toml @@ -9,7 +9,7 @@ crate-type = ["cdylib"] [dependencies] polkadot-parachain = { path = "../../", default-features = false } -wee_alloc = "0.4.0" +wee_alloc = { git = "https://github.com/rustwasm/wee_alloc", rev = "4e9f23fff1f2474962085ca693f8884db666889f" } tiny-keccak = "1.4" pwasm-libc = "0.2"