mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-22 13:51:05 +00:00
Initial support for building RISC-V runtimes targeting PolkaVM (#3179)
This PR adds initial support for building RISC-V runtimes targeting PolkaVM. - Setting the `SUBSTRATE_RUNTIME_TARGET=riscv` environment variable will now build a RISC-V runtime instead of a WASM runtime. - This only adds support for *building* runtimes; running them will need a PolkaVM-based executor, which I will add in a future PR. - Only building the minimal runtime is supported (building the Polkadot runtime doesn't work *yet* due to one of the dependencies). - The builder now sets a `substrate_runtime` cfg flag when building the runtimes, with the idea being that instead of doing `#[cfg(not(feature = "std"))]` or `#[cfg(target_arch = "wasm32")]` to detect that we're building a runtime you'll do `#[cfg(substrate_runtime)]`. (Switching the whole codebase to use this will be done in a future PR; I deliberately didn't do this here to keep this PR minimal and reviewable.) - Further renaming of things (e.g. types, environment variables and proc macro attributes having "wasm" in their name) to be target-agnostic will also be done in a future refactoring PR (while keeping backwards compatibility where it makes sense; I don't intend to break anyone's workflow or create unnecessary churn). - This PR also fixes two bugs in the `wasm-builder` crate: * The `RUSTC` environment variable is now removed when invoking the compiler. This prevents the toolchain version from being overridden when called from a `build.rs` script. * When parsing the `rustup toolchain list` output the `(default)` is now properly stripped and not treated as part of the version. - I've also added a minimal CI job that makes sure this doesn't break in the future. (cc @paritytech/ci) cc @athei ------ Also, just a fun little tidbit: quickly comparing the size of the built runtimes it seems that the PolkaVM runtime is slightly smaller than the WASM one. (`production` build, with the `names` section substracted from the WASM's size to keep things fair, since for the PolkaVM runtime we're currently stripping out everything) - `.wasm`: 625505 bytes - `.wasm` (after wasm-opt -O3): 563205 bytes - `.wasm` (after wasm-opt -Os): 562987 bytes - `.wasm` (after wasm-opt -Oz): 536852 bytes - `.polkavm`: ~~580338 bytes~~ 550476 bytes (after enabling extra target features; I'll add those in another PR once we have an executor working) --------- Co-authored-by: Bastian Köcher <git@kchr.de>
This commit is contained in:
Generated
+60
-5
@@ -9571,7 +9571,7 @@ dependencies = [
|
||||
"anyhow",
|
||||
"frame-system",
|
||||
"parity-wasm",
|
||||
"polkavm-linker",
|
||||
"polkavm-linker 0.5.0",
|
||||
"sp-runtime",
|
||||
"tempfile",
|
||||
"toml 0.8.8",
|
||||
@@ -9633,7 +9633,7 @@ dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"parity-scale-codec",
|
||||
"paste",
|
||||
"polkavm-derive",
|
||||
"polkavm-derive 0.5.0",
|
||||
"scale-info",
|
||||
]
|
||||
|
||||
@@ -13711,28 +13711,65 @@ version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "88b4e215c80fe876147f3d58158d5dfeae7dabdd6047e175af77095b78d0035c"
|
||||
|
||||
[[package]]
|
||||
name = "polkavm-common"
|
||||
version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "92c99f7eee94e7be43ba37eef65ad0ee8cbaf89b7c00001c3f6d2be985cb1817"
|
||||
|
||||
[[package]]
|
||||
name = "polkavm-derive"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6380dbe1fb03ecc74ad55d841cfc75480222d153ba69ddcb00977866cbdabdb8"
|
||||
dependencies = [
|
||||
"polkavm-derive-impl",
|
||||
"polkavm-derive-impl 0.5.0",
|
||||
"syn 2.0.48",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "polkavm-derive"
|
||||
version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "79fa916f7962348bd1bb1a65a83401675e6fc86c51a0fdbcf92a3108e58e6125"
|
||||
dependencies = [
|
||||
"polkavm-derive-impl-macro",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "polkavm-derive-impl"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dc8211b3365bbafb2fb32057d68b0e1ca55d079f5cf6f9da9b98079b94b3987d"
|
||||
dependencies = [
|
||||
"polkavm-common",
|
||||
"polkavm-common 0.5.0",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.48",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "polkavm-derive-impl"
|
||||
version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c10b2654a8a10a83c260bfb93e97b262cf0017494ab94a65d389e0eda6de6c9c"
|
||||
dependencies = [
|
||||
"polkavm-common 0.8.0",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.48",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "polkavm-derive-impl-macro"
|
||||
version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "15e85319a0d5129dc9f021c62607e0804f5fb777a05cdda44d750ac0732def66"
|
||||
dependencies = [
|
||||
"polkavm-derive-impl 0.8.0",
|
||||
"syn 2.0.48",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "polkavm-linker"
|
||||
version = "0.5.0"
|
||||
@@ -13743,7 +13780,22 @@ dependencies = [
|
||||
"hashbrown 0.14.3",
|
||||
"log",
|
||||
"object 0.32.2",
|
||||
"polkavm-common",
|
||||
"polkavm-common 0.5.0",
|
||||
"regalloc2 0.9.3",
|
||||
"rustc-demangle",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "polkavm-linker"
|
||||
version = "0.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1bc03593918a5890f96c276fb1e34ab77002bea1f9136cdcb55107c241011ab7"
|
||||
dependencies = [
|
||||
"gimli 0.28.0",
|
||||
"hashbrown 0.14.3",
|
||||
"log",
|
||||
"object 0.32.2",
|
||||
"polkavm-common 0.8.0",
|
||||
"regalloc2 0.9.3",
|
||||
"rustc-demangle",
|
||||
]
|
||||
@@ -17945,6 +17997,7 @@ dependencies = [
|
||||
"sp-externalities 0.25.0",
|
||||
"sp-metadata-ir",
|
||||
"sp-runtime",
|
||||
"sp-runtime-interface 24.0.0",
|
||||
"sp-state-machine",
|
||||
"sp-std 14.0.0",
|
||||
"sp-test-primitives",
|
||||
@@ -18632,6 +18685,7 @@ dependencies = [
|
||||
"bytes",
|
||||
"impl-trait-for-tuples",
|
||||
"parity-scale-codec",
|
||||
"polkavm-derive 0.8.0",
|
||||
"primitive-types",
|
||||
"rustversion",
|
||||
"sp-core",
|
||||
@@ -19647,6 +19701,7 @@ dependencies = [
|
||||
"console",
|
||||
"filetime",
|
||||
"parity-wasm",
|
||||
"polkavm-linker 0.8.1",
|
||||
"sp-maybe-compressed-blob",
|
||||
"strum 0.24.1",
|
||||
"tempfile",
|
||||
|
||||
Reference in New Issue
Block a user