From 718b34605e04717d8ef2629e548173039f6c37d0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bastian=20K=C3=B6cher?= <git@kchr.de>
Date: Sun, 15 Sep 2019 09:14:43 +0200
Subject: [PATCH] Enable nice wasm panic messages by default

By accident it was already enabled in master for quite some time. To
make sure that we don't blow up the wasm binary size, I compiled the
binary with the feature enabled and disabled. With nice panic messages
enabled, the binary size increases by 908 bytes. Given the value that
this feature brings, I think it is okay to have these panic messages
enabled by default.
---
 core/sr-io/Cargo.toml     |  1 -
 core/sr-io/without_std.rs | 15 ++-------------
 srml/aura/Cargo.toml      |  2 +-
 srml/babe/Cargo.toml      |  2 +-
 4 files changed, 4 insertions(+), 16 deletions(-)

diff --git a/core/sr-io/Cargo.toml b/core/sr-io/Cargo.toml
index f3122f0e30..7382cfb002 100644
--- a/core/sr-io/Cargo.toml
+++ b/core/sr-io/Cargo.toml
@@ -37,6 +37,5 @@ std = [
 ]
 nightly = []
 strict = []
-wasm-nice-panic-message = []
 no_panic_handler = []
 no_oom = []
diff --git a/core/sr-io/without_std.rs b/core/sr-io/without_std.rs
index 6803b41ebd..0ff1702f90 100644
--- a/core/sr-io/without_std.rs
+++ b/core/sr-io/without_std.rs
@@ -28,19 +28,8 @@ use codec::Decode;
 #[no_mangle]
 pub fn panic(info: &PanicInfo) -> ! {
 	unsafe {
-		#[cfg(feature = "wasm-nice-panic-message")]
-		{
-			let message = rstd::alloc::format!("{}", info);
-			extern_functions_host_impl::ext_print_utf8(message.as_ptr() as *const u8, message.len() as u32);
-		}
-		#[cfg(not(feature = "wasm-nice-panic-message"))]
-		{
-			if let Some(loc) = info.location() {
-				extern_functions_host_impl::ext_print_utf8(loc.file().as_ptr() as *const u8, loc.file().len() as u32);
-				extern_functions_host_impl::ext_print_num(loc.line() as u64);
-				extern_functions_host_impl::ext_print_num(loc.column() as u64);
-			}
-		}
+		let message = rstd::alloc::format!("{}", info);
+		extern_functions_host_impl::ext_print_utf8(message.as_ptr() as *const u8, message.len() as u32);
 		intrinsics::abort()
 	}
 }
diff --git a/srml/aura/Cargo.toml b/srml/aura/Cargo.toml
index 961c178c34..d7d6f8c9cf 100644
--- a/srml/aura/Cargo.toml
+++ b/srml/aura/Cargo.toml
@@ -13,7 +13,7 @@ rstd = { package = "sr-std", path = "../../core/sr-std", default-features = fals
 serde = { version = "1.0", optional = true }
 session = { package = "srml-session", path = "../session", default-features = false }
 sr-primitives = { path = "../../core/sr-primitives", default-features = false }
-runtime-io ={ package = "sr-io", path = "../../core/sr-io", default-features = false, features = [ "wasm-nice-panic-message" ] }
+runtime-io ={ package = "sr-io", path = "../../core/sr-io", default-features = false }
 support = { package = "srml-support", path = "../support", default-features = false }
 substrate-consensus-aura-primitives = { path = "../../core/consensus/aura/primitives", default-features = false}
 system = { package = "srml-system", path = "../system", default-features = false }
diff --git a/srml/babe/Cargo.toml b/srml/babe/Cargo.toml
index 35828fdb1c..3819bb14c7 100644
--- a/srml/babe/Cargo.toml
+++ b/srml/babe/Cargo.toml
@@ -17,7 +17,7 @@ system = { package = "srml-system", path = "../system", default-features = false
 timestamp = { package = "srml-timestamp", path = "../timestamp", default-features = false }
 session = { package = "srml-session", path = "../session", default-features = false }
 babe-primitives = { package = "substrate-consensus-babe-primitives", path = "../../core/consensus/babe/primitives", default-features = false }
-runtime-io ={ package = "sr-io", path = "../../core/sr-io", default-features = false, features = [ "wasm-nice-panic-message" ] }
+runtime-io ={ package = "sr-io", path = "../../core/sr-io", default-features = false }
 
 [dev-dependencies]
 lazy_static = "1.3.0"
-- 
GitLab