From d3f59a071293996a84bd57125bcf7f83ca80d706 Mon Sep 17 00:00:00 2001 From: brenzi Date: Wed, 1 May 2019 20:09:12 +0200 Subject: [PATCH] + adding compiler features for no_std environments other than wasm (i.e. SGX) (#2421) --- substrate/core/sr-io/Cargo.toml | 2 ++ substrate/core/sr-io/without_std.rs | 2 ++ substrate/core/sr-std/Cargo.toml | 1 + substrate/core/sr-std/without_std.rs | 1 + 4 files changed, 6 insertions(+) mode change 100644 => 100755 substrate/core/sr-std/without_std.rs diff --git a/substrate/core/sr-io/Cargo.toml b/substrate/core/sr-io/Cargo.toml index 645caf54b2..afbce1c81f 100644 --- a/substrate/core/sr-io/Cargo.toml +++ b/substrate/core/sr-io/Cargo.toml @@ -35,3 +35,5 @@ std = [ nightly = [] strict = [] wasm-nice-panic-message = [] +no_panic_handler = [] +no_oom = [] diff --git a/substrate/core/sr-io/without_std.rs b/substrate/core/sr-io/without_std.rs index b60a3ded1f..2f2b482f5e 100644 --- a/substrate/core/sr-io/without_std.rs +++ b/substrate/core/sr-io/without_std.rs @@ -22,6 +22,7 @@ use core::{intrinsics, panic::PanicInfo}; use rstd::{vec::Vec, cell::Cell}; use primitives::Blake2Hasher; +#[cfg(not(feature = "no_panic_handler"))] #[panic_handler] #[no_mangle] pub fn panic(info: &PanicInfo) -> ! { @@ -43,6 +44,7 @@ pub fn panic(info: &PanicInfo) -> ! { } } +#[cfg(not(feature = "no_oom"))] #[alloc_error_handler] pub extern fn oom(_: ::core::alloc::Layout) -> ! { static OOM_MSG: &str = "Runtime memory exhausted. Aborting"; diff --git a/substrate/core/sr-std/Cargo.toml b/substrate/core/sr-std/Cargo.toml index 2c4a63af1b..b941fea1d1 100644 --- a/substrate/core/sr-std/Cargo.toml +++ b/substrate/core/sr-std/Cargo.toml @@ -13,3 +13,4 @@ default = ["std"] std = [] nightly = [] strict = [] +no_global_allocator = [] diff --git a/substrate/core/sr-std/without_std.rs b/substrate/core/sr-std/without_std.rs old mode 100644 new mode 100755 index b9287c00d5..71a2c01c29 --- a/substrate/core/sr-std/without_std.rs +++ b/substrate/core/sr-std/without_std.rs @@ -26,6 +26,7 @@ extern "C" { /// Wasm allocator pub struct WasmAllocator; +#[cfg(not(feature = "no_global_allocator"))] #[global_allocator] static ALLOCATOR: WasmAllocator = WasmAllocator;