From e6c7149f4a2e099f2f27a53083c41ee6dd7b0343 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/substrate/pwasm-alloc/src/lib.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/substrate/substrate/pwasm-alloc/src/lib.rs b/substrate/substrate/pwasm-alloc/src/lib.rs index 85be153815..bf4e33f133 100644 --- a/substrate/substrate/pwasm-alloc/src/lib.rs +++ b/substrate/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 3347bf8962687b5d864b0a6c5f048204b076ffd8 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/substrate/pwasm-alloc/src/lib.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/substrate/substrate/pwasm-alloc/src/lib.rs b/substrate/substrate/pwasm-alloc/src/lib.rs index bf4e33f133..3cb2ae662e 100644 --- a/substrate/substrate/pwasm-alloc/src/lib.rs +++ b/substrate/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 39440341fe12f2d78cc4e6c5f54f3dcacdadf0d1 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/substrate/pwasm-alloc/src/lib.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/substrate/substrate/pwasm-alloc/src/lib.rs b/substrate/substrate/pwasm-alloc/src/lib.rs index 3cb2ae662e..7dbfb562a9 100644 --- a/substrate/substrate/pwasm-alloc/src/lib.rs +++ b/substrate/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 3dc129b6db46a3626c3fd23ffd0ea03d14f319b8 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 --- substrate/polkadot/parachain/test-chains/basic_add/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/substrate/polkadot/parachain/test-chains/basic_add/src/lib.rs b/substrate/polkadot/parachain/test-chains/basic_add/src/lib.rs index be21a8dec8..1ef898f1dc 100644 --- a/substrate/polkadot/parachain/test-chains/basic_add/src/lib.rs +++ b/substrate/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 9b330fdce26750f10ffafa46c1c387f030f24b09 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 --- substrate/polkadot/parachain/test-chains/basic_add/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/substrate/polkadot/parachain/test-chains/basic_add/Cargo.toml b/substrate/polkadot/parachain/test-chains/basic_add/Cargo.toml index dd0fc4050d..41e745ca1a 100644 --- a/substrate/polkadot/parachain/test-chains/basic_add/Cargo.toml +++ b/substrate/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"