-
Notifications
You must be signed in to change notification settings - Fork 816
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(wasm-builder): add support for new
wasm32v1-none
target (#7008)
# Description Resolves #5777 Previously `wasm-builder` used hacks such as `-Zbuild-std` (required `rust-src` component) and `RUSTC_BOOTSTRAP=1` to build WASM runtime without WASM features: `sign-ext`, `multivalue` and `reference-types`, but since Rust 1.84 (will be stable on 9 January, 2025) the situation has improved as there is new [`wasm32v1-none`](https://doc.rust-lang.org/beta/rustc/platform-support/wasm32v1-none.html) target that disables all "post-MVP" WASM features except `mutable-globals`. Previously, your `rust-toolchain.toml` looked like this: ```toml [toolchain] channel = "stable" components = ["rust-src"] targets = ["wasm32-unknown-unknown"] profile = "default" ``` It should now be updated to something like this: ```toml [toolchain] channel = "stable" targets = ["wasm32v1-none"] profile = "default" ``` To build the runtime: ```bash cargo build --package minimal-template-runtime --release ``` ## Integration If you are using Rust 1.84 and above, then install the `wasm32v1-none` target instead of `wasm32-unknown-unknown` as shown above. You can also remove the unnecessary `rust-src` component. Also note the slight differences in conditional compilation: - `wasm32-unknown-unknown`: `#[cfg(all(target_family = "wasm", target_os = "unknown"))]` - `wasm32v1-none`: `#[cfg(all(target_family = "wasm", target_os = "none"))]` Avoid using `target_os = "unknown"` in `#[cfg(...)]` or `#[cfg_attr(...)]` and instead use `target_family = "wasm"` or `target_arch = "wasm32"` in the runtime code. ## Review Notes Wasm builder requires the following prerequisites for building the WASM binary: - Rust >= 1.68 and Rust < 1.84: - `wasm32-unknown-unknown` target - `rust-src` component - Rust >= 1.84: - `wasm32v1-none` target - no more `-Zbuild-std` and `RUSTC_BOOTSTRAP=1` hacks and `rust-src` component requirements! --------- Co-authored-by: Bastian Köcher <[email protected]> Co-authored-by: Bastian Köcher <[email protected]>
- Loading branch information
1 parent
ea51bbf
commit 2970ab1
Showing
6 changed files
with
231 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0 | ||
# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json | ||
|
||
title: 'feat(wasm-builder): add support for new `wasm32v1-none` target' | ||
doc: | ||
- audience: Runtime Dev | ||
description: | | ||
Resolves [#5777](https://github.com/paritytech/polkadot-sdk/issues/5777) | ||
|
||
Previously `wasm-builder` used hacks such as `-Zbuild-std` (required `rust-src` component) and `RUSTC_BOOTSTRAP=1` to build WASM runtime without WASM features: `sign-ext`, `multivalue` and `reference-types`, but since Rust 1.84 (will be stable on 9 January, 2025) the situation has improved as there is new [`wasm32v1-none`](https://doc.rust-lang.org/beta/rustc/platform-support/wasm32v1-none.html) target that disables all "post-MVP" WASM features except `mutable-globals`. | ||
|
||
Wasm builder requires the following prerequisites for building the WASM binary: | ||
- Rust >= 1.68 and Rust < 1.84: | ||
- `wasm32-unknown-unknown` target | ||
- `rust-src` component | ||
- Rust >= 1.84: | ||
- `wasm32v1-none` target | ||
- no more `-Zbuild-std` and `RUSTC_BOOTSTRAP=1` hacks and `rust-src` component requirements! | ||
|
||
crates: | ||
- name: substrate-wasm-builder | ||
bump: minor | ||
validate: false | ||
- name: sp-consensus-beefy | ||
bump: patch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.