Skip to content

Commit

Permalink
Companion: wasm-builder support stable Rust (paritytech#6967)
Browse files Browse the repository at this point in the history
* Companion: wasm-builder support stable Rust

* update lockfile for {"substrate"}

---------

Co-authored-by: parity-processbot <>
  • Loading branch information
bkchr authored and girazoki committed Jun 19, 2023
1 parent d4ae302 commit 543f573
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 15 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions parachain/test-parachains/adder/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@
//! Basic parachain that adds a number as part of its state.

#![no_std]
#![cfg_attr(
not(feature = "std"),
feature(core_intrinsics, lang_items, core_panic_info, alloc_error_handler)
)]

use parity_scale_codec::{Decode, Encode};
use tiny_keccak::{Hasher as _, Keccak};
Expand Down
1 change: 1 addition & 0 deletions parachain/test-parachains/halt/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ edition.workspace = true

[build-dependencies]
substrate-wasm-builder = { git = "https://github.com/moondance-labs/substrate", branch = "tanssi-polkadot-v0.9.40" }
rustversion = "1.0.6"

[features]
default = [ "std" ]
Expand Down
14 changes: 13 additions & 1 deletion parachain/test-parachains/halt/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,17 @@
use substrate_wasm_builder::WasmBuilder;

fn main() {
WasmBuilder::new().with_current_project().export_heap_base().build()
WasmBuilder::new().with_current_project().export_heap_base().build();

enable_alloc_error_handler();
}

#[rustversion::before(1.68)]
fn enable_alloc_error_handler() {
if !cfg!(feature = "std") {
println!("cargo:rustc-cfg=enable_alloc_error_handler");
}
}

#[rustversion::since(1.68)]
fn enable_alloc_error_handler() {}
9 changes: 3 additions & 6 deletions parachain/test-parachains/halt/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@
//! Basic parachain that executes forever.

#![no_std]
#![cfg_attr(
not(feature = "std"),
feature(core_intrinsics, lang_items, core_panic_info, alloc_error_handler)
)]
#![cfg_attr(enable_alloc_error_handler, feature(alloc_error_handler))]

// Make the WASM binary available.
#[cfg(feature = "std")]
Expand All @@ -39,10 +36,10 @@ pub fn wasm_binary_unwrap() -> &'static [u8] {
#[panic_handler]
#[no_mangle]
pub fn panic(_info: &core::panic::PanicInfo) -> ! {
core::intrinsics::abort()
core::arch::wasm32::unreachable();
}

#[cfg(not(feature = "std"))]
#[cfg(enable_alloc_error_handler)]
#[alloc_error_handler]
#[no_mangle]
pub fn oom(_: core::alloc::Layout) -> ! {
Expand Down
4 changes: 0 additions & 4 deletions parachain/test-parachains/undying/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@
//! Basic parachain that adds a number as part of its state.

#![no_std]
#![cfg_attr(
not(feature = "std"),
feature(core_intrinsics, lang_items, core_panic_info, alloc_error_handler)
)]

use parity_scale_codec::{Decode, Encode};
use sp_std::vec::Vec;
Expand Down

0 comments on commit 543f573

Please sign in to comment.