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

Companion: wasm-builder support stable Rust #6967

Merged
merged 3 commits into from
Mar 29, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 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/paritytech/substrate", branch = "master" }
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