diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 5c3ca97fd..973c44d6a 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -57,10 +57,10 @@ jobs: steps: - uses: actions/checkout@v3 - run: rustup update - - uses: stellar/binaries@v30 + - uses: stellar/binaries@v37 with: name: cargo-semver-checks - version: 0.35.0 + version: 0.40.0 - run: cargo semver-checks build-and-test: @@ -103,8 +103,8 @@ jobs: - run: rustup update - run: cargo version - run: rustup target add ${{ matrix.sys.target }} - - run: rustup target add wasm32-unknown-unknown - - uses: stellar/binaries@v18 + - run: rustup target add wasm32v1-none + - uses: stellar/binaries@v37 with: name: cargo-hack version: 0.5.28 @@ -112,10 +112,10 @@ jobs: name: Clear test snapshots for checking no diffs exists after test run run: rm -fr **/test_snapshots - name: Build for wasm - run: cargo-hack hack build --target wasm32-unknown-unknown --profile release + run: cargo-hack hack build --target wasm32v1-none --profile release --workspace --exclude soroban-spec --exclude soroban-spec-rust --exclude soroban-ledger-snapshot - name: Wasm Size run: | - cd target/wasm32-unknown-unknown/release/ && \ + cd target/wasm32v1-none/release/ && \ for i in *.wasm ; do \ ls -l "$i"; \ done @@ -138,10 +138,10 @@ jobs: - uses: actions/checkout@v3 - uses: stellar/actions/rust-cache@main - run: rustup install nightly - - uses: stellar/binaries@v15 + - uses: stellar/binaries@v37 with: name: cargo-fuzz - version: 0.11.2 + version: 0.12.0 - run: make build-fuzz - name: Check no diffs exist run: git add -N . && git diff HEAD --exit-code @@ -182,7 +182,7 @@ jobs: matrix: sys: - os: ubuntu-latest - target: wasm32-unknown-unknown + target: wasm32v1-none cargo-hack-feature-options: '' - os: ubuntu-latest target: x86_64-unknown-linux-gnu diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9747c64be..df0acb4ac 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -13,14 +13,14 @@ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh Install rust stable: ``` rustup install stable -rustup +stable target add wasm32-unknown-unknown +rustup +stable target add wasm32v1-none rustup +stable component add rust-src ``` Install rust nightly: ``` rustup install nightly -rustup +nightly target add wasm32-unknown-unknown +rustup +nightly target add wasm32v1-none rustup +nightly component add rust-src ``` diff --git a/Cargo.toml b/Cargo.toml index 2d1951e6e..98e292175 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ members = [ [workspace.package] version = "22.0.7" -rust-version = "1.79.0" +rust-version = "1.84.0" [workspace.dependencies] soroban-sdk = { version = "22.0.7", path = "soroban-sdk" } diff --git a/Makefile b/Makefile index 53e41999c..998048171 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,9 @@ all: check test export RUSTFLAGS=-Dwarnings CARGO_DOC_ARGS?=--open +NATIVE_ONLY_CRATES:=soroban-spec soroban-spec-rust soroban-ledger-snapshot +NATIVE_PACKAGE_ARGS:=$(foreach i,$(NATIVE_ONLY_CRATES), --package $(i)) +WASM_EXCLUDE_ARGS:=$(foreach i,$(NATIVE_ONLY_CRATES), --exclude $(i)) doc: fmt cargo test --doc -p soroban-sdk -p soroban-sdk-macros --features testutils,hazmat @@ -12,15 +15,16 @@ test: fmt build cargo hack --feature-powerset --ignore-unknown-features --features testutils --exclude-features docs test build: fmt - cargo hack build --target wasm32-unknown-unknown --release - cd target/wasm32-unknown-unknown/release/ && \ + cargo hack build --release $(NATIVE_PACKAGE_ARGS) + cargo hack build --target wasm32v1-none --release --workspace $(WASM_EXCLUDE_ARGS) + cd target/wasm32v1-none/release/ && \ for i in *.wasm ; do \ ls -l "$$i"; \ done check: build fmt cargo hack --feature-powerset --exclude-features docs check - cargo hack check --release --target wasm32-unknown-unknown + cargo hack check --release --target wasm32v1-none --workspace $(WASM_EXCLUDE_ARGS) build-fuzz: cd tests/fuzz/fuzz && cargo +nightly fuzz check diff --git a/deny.toml b/deny.toml index bfb266ad9..1501ce22e 100644 --- a/deny.toml +++ b/deny.toml @@ -21,7 +21,7 @@ # list here is effectively saying which targets you are building for. targets = [ { triple = "x86_64-unknown-linux-gnu" }, - { triple = "wasm32-unknown-unknown" } + { triple = "wasm32v1-none" } # The triple can be any string, but only the target triples built in to # rustc (as of 1.40) can be checked against actual config expressions #{ triple = "x86_64-unknown-linux-musl" }, diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 90ff24e80..2f28ebc44 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,4 +1,4 @@ [toolchain] -channel = "1.81" -targets = ["wasm32-unknown-unknown"] +channel = "stable" +targets = ["wasm32v1-none"] components = ["rustc", "cargo", "rustfmt", "clippy", "rust-src"] diff --git a/soroban-sdk/src/alloc.rs b/soroban-sdk/src/alloc.rs index 492416fb3..4e4abb8d6 100644 --- a/soroban-sdk/src/alloc.rs +++ b/soroban-sdk/src/alloc.rs @@ -76,6 +76,7 @@ pub struct BumpPointer; unsafe impl GlobalAlloc for BumpPointer { #[inline(always)] + #[allow(static_mut_refs)] unsafe fn alloc(&self, layout: Layout) -> *mut u8 { let (bytes, align) = (layout.size(), layout.align()); let ptr = LOCAL_ALLOCATOR.alloc(bytes, align); diff --git a/soroban-sdk/src/lib.rs b/soroban-sdk/src/lib.rs index 0461ac237..c070feb53 100644 --- a/soroban-sdk/src/lib.rs +++ b/soroban-sdk/src/lib.rs @@ -59,34 +59,12 @@ pub mod _migrating; compile_error!("'testutils' feature is not supported on 'wasm' target"); // When used in a no_std contract, provide a panic handler as one is required. -#[cfg(all(not(feature = "alloc"), target_family = "wasm"))] +#[cfg(target_family = "wasm")] #[panic_handler] fn handle_panic(_: &core::panic::PanicInfo) -> ! { core::arch::wasm32::unreachable() } -// This is a bit subtle: we want to provide a narrowly-scoped feature `"alloc"` -// that provides support for the `alloc` crate and its types, while using our -// allocator (defined below in module `alloc`). We want to do this without -// changing the user-interface a lot (in particular keeping users writing -// `#[no_std]` and mostly not-using the stdlib casually, because it has many -// components that produce large code footprint). -// -// This is _almost_ possible without involving `std` but unfortunately there's -// still an allocation-error handler (`alloc_error_handler`) that there's no -// stable way to install if one only uses the `alloc` crate, so we pull in a -// dependency on `std` here (for now). When the stabilization of the allocation -// error handler registration function happens in some future Rust version, or -// it gets removed which it looks like work is heading towards instead, we can -// remove std. -// -// See these issues for more details: -// - https://github.com/rust-lang/rust/issues/51540 -// - https://github.com/rust-lang/rust/issues/66740 -// - https://github.com/rust-lang/rust/issues/66741 -#[cfg(all(feature = "alloc", target_family = "wasm"))] -extern crate std; - // Here we provide a `#[global_allocator]` that is a minimal non-freeing bump // allocator, appropriate for a WASM blob that runs a single contract call. #[cfg(all(feature = "alloc", target_family = "wasm"))] diff --git a/soroban-sdk/src/tests/contractimport.rs b/soroban-sdk/src/tests/contractimport.rs index bccd95dcc..d769cd74d 100644 --- a/soroban-sdk/src/tests/contractimport.rs +++ b/soroban-sdk/src/tests/contractimport.rs @@ -5,16 +5,12 @@ use stellar_xdr::{ScSpecEntry, ScSpecFunctionInputV0, ScSpecFunctionV0, ScSpecTy mod addcontract { use crate as soroban_sdk; - soroban_sdk::contractimport!( - file = "../target/wasm32-unknown-unknown/release/test_add_u64.wasm" - ); + soroban_sdk::contractimport!(file = "../target/wasm32v1-none/release/test_add_u64.wasm"); } mod addcontract_u128 { use crate as soroban_sdk; - soroban_sdk::contractimport!( - file = "../target/wasm32-unknown-unknown/release/test_add_u128.wasm" - ); + soroban_sdk::contractimport!(file = "../target/wasm32v1-none/release/test_add_u128.wasm"); } mod subcontract { diff --git a/soroban-sdk/src/tests/contractimport_with_error.rs b/soroban-sdk/src/tests/contractimport_with_error.rs index fba3aa1f3..5063a6d64 100644 --- a/soroban-sdk/src/tests/contractimport_with_error.rs +++ b/soroban-sdk/src/tests/contractimport_with_error.rs @@ -3,9 +3,7 @@ use soroban_sdk::{contract, contractimpl, symbol_short, Address, Env, Symbol}; mod errcontract { use crate as soroban_sdk; - soroban_sdk::contractimport!( - file = "../target/wasm32-unknown-unknown/release/test_errors.wasm" - ); + soroban_sdk::contractimport!(file = "../target/wasm32v1-none/release/test_errors.wasm"); } #[contract] diff --git a/soroban-spec-rust/src/lib.rs b/soroban-spec-rust/src/lib.rs index be075710e..73319d99e 100644 --- a/soroban-spec-rust/src/lib.rs +++ b/soroban-spec-rust/src/lib.rs @@ -123,8 +123,7 @@ mod test { use super::{generate, ToFormattedString}; use soroban_spec::read::from_wasm; - const EXAMPLE_WASM: &[u8] = - include_bytes!("../../target/wasm32-unknown-unknown/release/test_udt.wasm"); + const EXAMPLE_WASM: &[u8] = include_bytes!("../../target/wasm32v1-none/release/test_udt.wasm"); #[test] fn example() { diff --git a/tests/alloc/src/test.rs b/tests/alloc/src/test.rs index 37c21a097..52177afbe 100644 --- a/tests/alloc/src/test.rs +++ b/tests/alloc/src/test.rs @@ -4,9 +4,7 @@ use soroban_sdk::{testutils::EnvTestConfig, vec, Env}; use crate::{Contract, ContractClient}; mod imported { - soroban_sdk::contractimport!( - file = "../../target/wasm32-unknown-unknown/release/test_alloc.wasm" - ); + soroban_sdk::contractimport!(file = "../../target/wasm32v1-none/release/test_alloc.wasm"); } macro_rules! tests { diff --git a/tests/import_contract/src/lib.rs b/tests/import_contract/src/lib.rs index 19daa3de2..33af0f5c6 100644 --- a/tests/import_contract/src/lib.rs +++ b/tests/import_contract/src/lib.rs @@ -2,9 +2,7 @@ use soroban_sdk::{contract, contractimpl, Address, Env}; mod addcontract { - soroban_sdk::contractimport!( - file = "../../target/wasm32-unknown-unknown/release/test_add_u64.wasm" - ); + soroban_sdk::contractimport!(file = "../../target/wasm32v1-none/release/test_add_u64.wasm"); } #[contract]