Skip to content

Commit

Permalink
contracts: Update to Polkavm 0.5 (#2945)
Browse files Browse the repository at this point in the history
This will allow us to change to the target supporting atomics and makes
the linker file no longer necessary.
  • Loading branch information
athei authored Jan 17, 2024
1 parent 8b28031 commit c1c0e62
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 18 deletions.
30 changes: 25 additions & 5 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion substrate/frame/contracts/fixtures/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ parity-wasm = "0.45.0"
tempfile = "3.8.1"
toml = "0.8.2"
twox-hash = "1.6.3"
polkavm-linker = { version = "0.4.0", optional = true }
polkavm-linker = { version = "0.5.0", optional = true }
anyhow = "1.0.0"

[features]
Expand Down
15 changes: 8 additions & 7 deletions substrate/frame/contracts/fixtures/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,12 @@ fn post_process_wasm(input_path: &Path, output_path: &Path) -> Result<()> {
/// Build contracts for RISC-V.
#[cfg(feature = "riscv")]
fn invoke_riscv_build(current_dir: &Path) -> Result<()> {
let encoded_rustflags =
["-Crelocation-model=pie", "-Clink-arg=--emit-relocs", "-Clink-arg=-Tmemory.ld"]
.join("\x1f");

fs::write(current_dir.join("memory.ld"), include_bytes!("./build/riscv_memory_layout.ld"))?;
let encoded_rustflags = [
"-Crelocation-model=pie",
"-Clink-arg=--emit-relocs",
"-Clink-arg=--export-dynamic-symbol=__polkavm_symbol_export_hack__*",
]
.join("\x1f");

let build_res = Command::new(env::var("CARGO")?)
.current_dir(current_dir)
Expand All @@ -247,7 +248,7 @@ fn invoke_riscv_build(current_dir: &Path) -> Result<()> {
.env("CARGO_ENCODED_RUSTFLAGS", encoded_rustflags)
.env("RUSTUP_TOOLCHAIN", "rve-nightly")
.env("RUSTUP_HOME", env::var("RUSTUP_HOME").unwrap_or_default())
.args(["build", "--release", "--target=riscv32em-unknown-none-elf"])
.args(["build", "--release", "--target=riscv32ema-unknown-none-elf"])
.output()
.expect("failed to execute process");

Expand Down Expand Up @@ -288,7 +289,7 @@ fn write_output(build_dir: &Path, out_dir: &Path, entries: Vec<Entry>) -> Result

#[cfg(feature = "riscv")]
post_process_riscv(
&build_dir.join("target/riscv32em-unknown-none-elf/release").join(entry.name()),
&build_dir.join("target/riscv32ema-unknown-none-elf/release").join(entry.name()),
&out_dir.join(entry.out_riscv_filename()),
)?;

Expand Down
2 changes: 1 addition & 1 deletion substrate/frame/contracts/fixtures/build/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ edition = "2021"
[dependencies]
uapi = { package = 'pallet-contracts-uapi', path = "", default-features = false }
common = { package = 'pallet-contracts-fixtures-common', path = "" }
polkavm-derive = '0.4.0'
polkavm-derive = '0.5.0'

[profile.release]
opt-level = 3
Expand Down

This file was deleted.

0 comments on commit c1c0e62

Please sign in to comment.