Skip to content

feat(wasm-builder): add support for new wasm32v1-none target#7008

Merged
bkchr merged 26 commits intoparitytech:masterfrom
StackOverflowExcept1on:wasm32v1-none
Feb 9, 2025
Merged

feat(wasm-builder): add support for new wasm32v1-none target#7008
bkchr merged 26 commits intoparitytech:masterfrom
StackOverflowExcept1on:wasm32v1-none

Conversation

@StackOverflowExcept1on
Copy link
Copy Markdown
Contributor

@StackOverflowExcept1on StackOverflowExcept1on commented Dec 27, 2024

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 target that disables all "post-MVP" WASM features except mutable-globals.

Previously, your rust-toolchain.toml looked like this:

[toolchain]
channel = "stable"
components = ["rust-src"]
targets = ["wasm32-unknown-unknown"]
profile = "default"

It should now be updated to something like this:

[toolchain]
channel = "stable"
targets = ["wasm32v1-none"]
profile = "default"

To build the runtime:

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!

@bkchr bkchr added the T17-primitives Changes to primitives that are not covered by any other label. label Dec 27, 2024
@github-actions github-actions bot requested a review from bkchr December 27, 2024 19:24
@github-actions
Copy link
Copy Markdown
Contributor

Review required! Latest push from author must always be reviewed

@bkchr bkchr enabled auto-merge January 2, 2025 09:55
@StackOverflowExcept1on
Copy link
Copy Markdown
Contributor Author

How do I pass CI checks like SemVer and other?

@jasl
Copy link
Copy Markdown
Contributor

jasl commented Jan 8, 2025

Ping @bkchr It seems the CI won't trigger.

@jasl
Copy link
Copy Markdown
Contributor

jasl commented Jan 8, 2025

@StackOverflowExcept1on
Copy link
Copy Markdown
Contributor Author

StackOverflowExcept1on commented Jan 8, 2025

@jasl @bkchr I'll fix that in the next 30 minutes. Also wondering if we'll have to update the runners tomorrow, since the new version 1.84 will be stable tomorrow. I mean that the wasm32-unknown-unknown target should be replaced by wasm32v1-none on runners. We should come to something one on CI. Perhaps we should also replace all occurrences of “wasm32-unknown-unknown”.

auto-merge was automatically disabled January 8, 2025 17:19

Head branch was pushed to by a user without write access

@github-actions github-actions bot requested review from bkchr and koute January 8, 2025 17:19
@jasl
Copy link
Copy Markdown
Contributor

jasl commented Jan 8, 2025

@jasl @bkchr I'll fix that in the next 30 minutes. Also wondering if we'll have to update the runners tomorrow, since the new version 1.84 will be stable tomorrow. I mean that the wasm32-unknown-unknown target should be replaced by wasm32v1-none on runners. We should come to something one on CI. Perhaps we should also replace all occurrences of “wasm32-unknown-unknown”.

I'm not Parity staff, so I don't know...
I remember there was a critical accident in history by updating the Rust version, so I propose we not update CI.
Let Parity guys update their facilities.

@bkchr
Copy link
Copy Markdown
Member

bkchr commented Jan 8, 2025

Actually I realized something, @StackOverflowExcept1on can we change the pr to make the new target optional? So, it should still accept the wasm32-unknown-unknown target, but print some warning.

@StackOverflowExcept1on
Copy link
Copy Markdown
Contributor Author

@bkchr For now, do you want to use an environment variable like FORCE_NEW_WASM_TARGET to switch to wasm32v1-none and remove the warning?

@jasl
Copy link
Copy Markdown
Contributor

jasl commented Jan 8, 2025

Several required CI checks fail. Maybe the latest patch has trouble

@StackOverflowExcept1on
Copy link
Copy Markdown
Contributor Author

@jasl I think it's some kind of problem with std hitting wasmv1-none (it doesn't support it). It may have happened after recent merge of master.

andresilva added a commit to andresilva/polkadot.nix that referenced this pull request Apr 8, 2025
with paritytech/polkadot-sdk#7008
and NixOS/nixpkgs#383875 we can now
build the runtimes again using a stable rust compiler and no
hacks.

tests are also working.
andresilva added a commit to andresilva/nixpkgs that referenced this pull request Apr 8, 2025
with paritytech/polkadot-sdk#7008
and NixOS#383875 we can now
build the runtimes again using a stable rust compiler and no
hacks.

tests are also working again.
andresilva added a commit to andresilva/polkadot.nix that referenced this pull request Apr 8, 2025
with paritytech/polkadot-sdk#7008
and NixOS/nixpkgs#383875 we can now
build the runtimes again using a stable rust compiler and no
hacks.

tests are also working.
thadouk added a commit to AventusDAO/avn-parachain that referenced this pull request Jan 29, 2026
Additionally drops wasm-unknown-unknown depedency in favor of
`wasm32v1-none` to align with polkadot-sdk feature:

feat(wasm-builder): add support for new `wasm32v1-none` target
polkadot-sdk PR: [#7008](paritytech/polkadot-sdk#7008)
Resolves [#5777](paritytech/polkadot-sdk#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!

Jira:
- SYS-4677
- SYS-4551
thadouk added a commit to AventusDAO/avn-parachain that referenced this pull request Jan 29, 2026
Additionally drops wasm-unknown-unknown depedency in favor of
`wasm32v1-none` to align with polkadot-sdk feature:

feat(wasm-builder): add support for new `wasm32v1-none` target
polkadot-sdk PR: [#7008](paritytech/polkadot-sdk#7008)
Resolves [#5777](paritytech/polkadot-sdk#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!

Jira:
- SYS-4677
- SYS-4551
thadouk added a commit to AventusDAO/avn-parachain that referenced this pull request Jan 29, 2026
Additionally, drops wasm-unknown-unknown dependency in favour of
`wasm32v1-none` to align with polkadot-sdk feature:

feat(wasm-builder): add support for new `wasm32v1-none` target
polkadot-sdk PR: [#7008](paritytech/polkadot-sdk#7008)
Resolves [#5777](paritytech/polkadot-sdk#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!

Jira:
- SYS-4677
- SYS-4551
thadouk added a commit to AventusDAO/avn-parachain that referenced this pull request Jan 29, 2026
Changes toolchain and CI to use Rust 1.87.0

Additionally, drops wasm-unknown-unknown dependency in favour of
`wasm32v1-none` to align with polkadot-sdk feature:

feat(wasm-builder): add support for new `wasm32v1-none` target
polkadot-sdk PR: [#7008](paritytech/polkadot-sdk#7008)
Resolves [#5777](paritytech/polkadot-sdk#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!

Jira:
- SYS-4677
- SYS-4551
thadouk added a commit to AventusDAO/avn-parachain that referenced this pull request Feb 2, 2026
Changes toolchain and CI to use Rust 1.87.0

Additionally, drops wasm-unknown-unknown dependency in favour of
`wasm32v1-none` to align with polkadot-sdk feature:

feat(wasm-builder): add support for new `wasm32v1-none` target
polkadot-sdk PR: [#7008](paritytech/polkadot-sdk#7008)
Resolves [#5777](paritytech/polkadot-sdk#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!

Jira:
- SYS-4677
- SYS-4551
thadouk added a commit to AventusDAO/avn-parachain that referenced this pull request Feb 2, 2026
Changes toolchain and CI to use Rust 1.87.0

Additionally, drops wasm-unknown-unknown dependency in favour of
`wasm32v1-none` to align with polkadot-sdk feature:

feat(wasm-builder): add support for new `wasm32v1-none` target
polkadot-sdk PR: [#7008](paritytech/polkadot-sdk#7008)
Resolves [#5777](paritytech/polkadot-sdk#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!

Jira:
- SYS-4677
- SYS-4551
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T17-primitives Changes to primitives that are not covered by any other label.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Consider removing useless -sign-ext flag in substrate-wasm-builder

5 participants