Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit 4e0e8c1

Browse files
authored
Get rid of in-substrate usages of core_intrinsics feature (#4823)
* Remove usage of unneeded Rust feature core_intrinsics * core::intrinsics::abort -> arch::wasm32::unreachable * Don't publish `core::intrinsics`. * Disable panic_handler and alloc_error_handler for no_std non wasm builds
1 parent 584ac4f commit 4e0e8c1

File tree

5 files changed

+8
-7
lines changed

5 files changed

+8
-7
lines changed

primitives/application-crypto/Cargo.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,9 @@ std = [ "full_crypto", "sp-core/std", "codec/std", "serde", "sp-std/std", "sp-io
2121
# or Intel SGX.
2222
# For the regular wasm runtime builds this should not be used.
2323
full_crypto = [
24-
"sp-core/full_crypto"
24+
"sp-core/full_crypto",
25+
# Don't add `panic_handler` and `alloc_error_handler` since they are expected to be provided
26+
# by the user anyway.
27+
"sp-io/disable_panic_handler",
28+
"sp-io/disable_oom",
2529
]

primitives/io/src/lib.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
#![cfg_attr(not(feature = "std"), no_std)]
2222
#![cfg_attr(not(feature = "std"), feature(alloc_error_handler))]
23-
#![cfg_attr(not(feature = "std"), feature(core_intrinsics))]
2423

2524
#![cfg_attr(feature = "std",
2625
doc = "Substrate runtime standard library as compiled when linked with Rust's standard library.")]
@@ -892,7 +891,7 @@ pub fn panic(info: &core::panic::PanicInfo) -> ! {
892891
unsafe {
893892
let message = sp_std::alloc::format!("{}", info);
894893
logging::log(LogLevel::Error, "runtime", message.as_bytes());
895-
core::intrinsics::abort()
894+
core::arch::wasm32::unreachable();
896895
}
897896
}
898897

@@ -902,7 +901,7 @@ pub fn panic(info: &core::panic::PanicInfo) -> ! {
902901
pub fn oom(_: core::alloc::Layout) -> ! {
903902
unsafe {
904903
logging::log(LogLevel::Error, "runtime", b"Runtime memory exhausted. Aborting");
905-
core::intrinsics::abort();
904+
core::arch::wasm32::unreachable();
906905
}
907906
}
908907

primitives/sandbox/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
3737
#![warn(missing_docs)]
3838
#![cfg_attr(not(feature = "std"), no_std)]
39-
#![cfg_attr(not(feature = "std"), feature(core_intrinsics))]
4039

4140
use sp_std::prelude::*;
4241

primitives/std/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
//! or client/alloc to be used with any code that depends on the runtime.
1919
2020
#![cfg_attr(not(feature = "std"), no_std)]
21-
#![cfg_attr(not(feature = "std"), feature(core_intrinsics))]
21+
2222

2323
#![cfg_attr(feature = "std",
2424
doc = "Substrate runtime standard library as compiled when linked with Rust's standard library.")]

primitives/std/without_std.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ pub use core::convert;
2727
pub use core::default;
2828
pub use core::fmt;
2929
pub use core::hash;
30-
pub use core::intrinsics;
3130
pub use core::iter;
3231
pub use core::marker;
3332
pub use core::mem;

0 commit comments

Comments
 (0)