Skip to content

Conversation

@fnando
Copy link
Member

@fnando fnando commented May 2, 2025

What

Continuing #1988.

This pull requests selects the proper target based on your running rust version.

$ rustup override set 1.82.0
info: override toolchain for '/Users/fnando/Projects/stellar/hello' set to '1.82.0-aarch64-apple-darwin'

$ stellar contract build
❌ error: rust version 1.82.0 cannot be used to build contracts

$ rustup override set 1.83.0
info: override toolchain for '/Users/fnando/Projects/stellar/hello' set to '1.83.0-aarch64-apple-darwin'

$ stellar contract build
❌ error: rust version 1.83.0 cannot be used to build contracts

$ rustup override set 1.81.0
info: override toolchain for '/Users/fnando/Projects/stellar/hello' set to '1.81.0-aarch64-apple-darwin'

$ stellar contract build
ℹ️ CARGO_BUILD_RUSTFLAGS=--remap-path-prefix=/Users/fnando/.cargo/registry/src= cargo rustc --manifest-path=contracts/foo/Cargo.toml --crate-type=cdylib --target=wasm32-unknown-unknown --release
    Finished `release` profile [optimized] target(s) in 0.04s
ℹ️ Build Summary:
  Wasm File: target/wasm32-unknown-unknown/release/foo.wasm
  Wasm Hash: 89123eaa2902ec32e26db0141e2d0247e5e00846489f4d8b17d597a85466e863
  Exported Functions: 2 found
    • _
    • hello
✅ Build Complete
ℹ️ CARGO_BUILD_RUSTFLAGS=--remap-path-prefix=/Users/fnando/.cargo/registry/src= cargo rustc --manifest-path=contracts/hello_world/Cargo.toml --crate-type=cdylib --target=wasm32-unknown-unknown --release
    Finished `release` profile [optimized] target(s) in 0.04s
ℹ️ Build Summary:
  Wasm File: target/wasm32-unknown-unknown/release/hello_world.wasm
  Wasm Hash: 89123eaa2902ec32e26db0141e2d0247e5e00846489f4d8b17d597a85466e863
  Exported Functions: 2 found
    • _
    • hello
✅ Build Complete
ℹ️ CARGO_BUILD_RUSTFLAGS=--remap-path-prefix=/Users/fnando/.cargo/registry/src= cargo rustc --manifest-path=contracts/test/Cargo.toml --crate-type=cdylib --target=wasm32-unknown-unknown --release
    Finished `release` profile [optimized] target(s) in 0.04s
ℹ️ Build Summary:
  Wasm File: target/wasm32-unknown-unknown/release/test.wasm
  Wasm Hash: 89123eaa2902ec32e26db0141e2d0247e5e00846489f4d8b17d597a85466e863
  Exported Functions: 2 found
    • _
    • hello
✅ Build Complete

$ rustup override set 1.86.0
info: override toolchain for '/Users/fnando/Projects/stellar/hello' set to '1.86.0-aarch64-apple-darwin'

$ stellar contract build
ℹ️ CARGO_BUILD_RUSTFLAGS=--remap-path-prefix=/Users/fnando/.cargo/registry/src= cargo rustc --manifest-path=contracts/foo/Cargo.toml --crate-type=cdylib --target=wasm32v1-none --release
    Finished `release` profile [optimized] target(s) in 0.11s
ℹ️ Build Summary:
  Wasm File: target/wasm32v1-none/release/foo.wasm
  Wasm Hash: c358c50c6b37d298a28552ff8a901d73b4eb92647938f0635918c1bef3bf2ff8
  Exported Functions: 2 found
    • _
    • hello
✅ Build Complete
ℹ️ CARGO_BUILD_RUSTFLAGS=--remap-path-prefix=/Users/fnando/.cargo/registry/src= cargo rustc --manifest-path=contracts/hello_world/Cargo.toml --crate-type=cdylib --target=wasm32v1-none --release
    Finished `release` profile [optimized] target(s) in 0.04s
ℹ️ Build Summary:
  Wasm File: target/wasm32v1-none/release/hello_world.wasm
  Wasm Hash: c358c50c6b37d298a28552ff8a901d73b4eb92647938f0635918c1bef3bf2ff8
  Exported Functions: 2 found
    • _
    • hello
✅ Build Complete
ℹ️ CARGO_BUILD_RUSTFLAGS=--remap-path-prefix=/Users/fnando/.cargo/registry/src= cargo rustc --manifest-path=contracts/test/Cargo.toml --crate-type=cdylib --target=wasm32v1-none --release
    Finished `release` profile [optimized] target(s) in 0.04s
ℹ️ Build Summary:
  Wasm File: target/wasm32v1-none/release/test.wasm
  Wasm Hash: c358c50c6b37d298a28552ff8a901d73b4eb92647938f0635918c1bef3bf2ff8
  Exported Functions: 2 found
    • _
    • hello
✅ Build Complete

$ rustup override set 1.84.0
info: override toolchain for '/Users/fnando/Projects/stellar/hello' set to '1.84.0-aarch64-apple-darwin'

$ stellar contract build
ℹ️ CARGO_BUILD_RUSTFLAGS=--remap-path-prefix=/Users/fnando/.cargo/registry/src= cargo rustc --manifest-path=contracts/foo/Cargo.toml --crate-type=cdylib --target=wasm32v1-none --release
   Compiling proc-macro2 v1.0.86
   Compiling unicode-ident v1.0.13
   Compiling serde v1.0.210
   Compiling serde_json v1.0.128
   Compiling itoa v1.0.11
   Compiling ryu v1.0.18
   Compiling memchr v2.7.4
   Compiling strsim v0.11.1
   Compiling ident_case v1.0.1
   Compiling autocfg v1.3.0
   Compiling fnv v1.0.7
   Compiling thiserror v1.0.63
   Compiling typenum v1.17.0
   Compiling base32 v0.4.0
   Compiling version_check v0.9.5
   Compiling semver v1.0.23
   Compiling escape-bytes v0.1.1
   Compiling libc v0.2.158
   Compiling either v1.13.0
   Compiling hashbrown v0.14.5
   Compiling num-traits v0.2.19
   Compiling equivalent v1.0.1
   Compiling generic-array v0.14.7
   Compiling prettyplease v0.2.22
   Compiling cfg-if v1.0.0
   Compiling base64 v0.13.1
   Compiling itertools v0.11.0
   Compiling static_assertions v1.1.0
   Compiling rustc_version v0.4.1
   Compiling ethnum v1.5.0
   Compiling quote v1.0.37
   Compiling indexmap v2.5.0
   Compiling syn v2.0.77
   Compiling cpufeatures v0.2.14
   Compiling num-integer v0.1.46
   Compiling wasmparser v0.116.1
   Compiling num-bigint v0.4.6
   Compiling crypto-common v0.1.6
   Compiling block-buffer v0.10.4
   Compiling digest v0.10.7
   Compiling sha2 v0.10.8
   Compiling darling_core v0.20.10
   Compiling serde_derive v1.0.210
   Compiling thiserror-impl v1.0.63
   Compiling num-derive v0.4.2
   Compiling bytes-lit v0.0.5
   Compiling darling_macro v0.20.10
   Compiling darling v0.20.10
   Compiling serde_with_macros v3.9.0
   Compiling serde_with v3.9.0
   Compiling hex v0.4.3
   Compiling crate-git-revision v0.0.6
   Compiling stellar-strkey v0.0.8
   Compiling stellar-xdr v21.2.0
   Compiling soroban-env-common v21.2.1
   Compiling soroban-sdk-macros v21.7.0
   Compiling soroban-spec v21.7.0
   Compiling soroban-spec-rust v21.7.0
   Compiling soroban-env-macros v21.2.1
   Compiling soroban-env-guest v21.2.1
   Compiling soroban-sdk v21.7.0
   Compiling foo v0.0.0 (/Users/fnando/Projects/stellar/hello/contracts/foo)
    Finished `release` profile [optimized] target(s) in 15.23s
ℹ️ Build Summary:
  Wasm File: target/wasm32v1-none/release/foo.wasm
  Wasm Hash: 760dae254be0d102b10cbe4b2ff38b08b83bd8765c5f8cdc2fedde3d2debbac6
  Exported Functions: 2 found
    • _
    • hello
✅ Build Complete
ℹ️ CARGO_BUILD_RUSTFLAGS=--remap-path-prefix=/Users/fnando/.cargo/registry/src= cargo rustc --manifest-path=contracts/hello_world/Cargo.toml --crate-type=cdylib --target=wasm32v1-none --release
   Compiling hello-world v0.0.0 (/Users/fnando/Projects/stellar/hello/contracts/hello_world)
    Finished `release` profile [optimized] target(s) in 0.16s
ℹ️ Build Summary:
  Wasm File: target/wasm32v1-none/release/hello_world.wasm
  Wasm Hash: 760dae254be0d102b10cbe4b2ff38b08b83bd8765c5f8cdc2fedde3d2debbac6
  Exported Functions: 2 found
    • _
    • hello
✅ Build Complete
ℹ️ CARGO_BUILD_RUSTFLAGS=--remap-path-prefix=/Users/fnando/.cargo/registry/src= cargo rustc --manifest-path=contracts/test/Cargo.toml --crate-type=cdylib --target=wasm32v1-none --release
   Compiling test v0.0.0 (/Users/fnando/Projects/stellar/hello/contracts/test)
    Finished `release` profile [optimized] target(s) in 0.16s
ℹ️ Build Summary:
  Wasm File: target/wasm32v1-none/release/test.wasm
  Wasm Hash: 760dae254be0d102b10cbe4b2ff38b08b83bd8765c5f8cdc2fedde3d2debbac6
  Exported Functions: 2 found
    • _
    • hello
✅ Build Complete

Why

So users can build smart contracts independently of the rust version they're using.

Known limitations

N/A

@fnando fnando requested a review from a team as a code owner May 2, 2025 18:28
@github-project-automation github-project-automation bot moved this to Backlog (Not Ready) in DevX May 2, 2025
@fnando fnando force-pushed the wasm32v1-none-fnando branch from ff5566d to cca9aec Compare May 2, 2025 19:25
@fnando fnando requested review from graydon and leighmcculloch May 2, 2025 19:26
@fnando fnando enabled auto-merge (squash) May 6, 2025 17:30
@fnando fnando merged commit 141d417 into main May 6, 2025
32 of 33 checks passed
@fnando fnando deleted the wasm32v1-none-fnando branch May 6, 2025 17:44
@github-project-automation github-project-automation bot moved this from Backlog (Not Ready) to Done in DevX May 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants