Skip to content

Commit

Permalink
Prevent use with rust 1.82+ (#1371)
Browse files Browse the repository at this point in the history
### What
Prevent use with rust 1.82+. And run CI builds with 1.81.

### Why
stellar/rs-soroban-env#1469

Discussion:
https://stellarfoundation.slack.com/archives/C030Z9EHVQE/p1729217606684609
(cherry picked from commit 9e674f2)
  • Loading branch information
leighmcculloch committed Oct 23, 2024
1 parent 467fdf5 commit ddada99
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
1 change: 1 addition & 0 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 rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[toolchain]
channel = "stable"
channel = "1.81"
targets = ["wasm32-unknown-unknown"]
components = ["rustc", "cargo", "rustfmt", "clippy", "rust-src"]
3 changes: 3 additions & 0 deletions soroban-sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ exclude = ["test_snapshots/", "src/tests/"]
[lib]
doctest = false

[build-dependencies]
rustc_version = "0.4.1"

[dependencies]
soroban-sdk-macros = { workspace = true }
bytes-lit = "0.0.5"
Expand Down
8 changes: 8 additions & 0 deletions soroban-sdk/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
pub fn main() {
#[cfg(all(target_family = "wasm", target_os = "unknown"))]
if let Ok(version) = rustc_version::version() {
if version.major == 1 && version.minor >= 82 {
panic!("Rust compiler 1.82+ with target 'wasm32-unknown-unknown' is unsupported by the Soroban Environment, because the 'wasm32-unknown-unknown' target in Rust 1.82+ has features enabled that are not yet supported and not easily disabled: reference-types, multi-value. Use Rust 1.81 to build for the 'wasm32-unknown-unknown' target.");
}
}
}
6 changes: 0 additions & 6 deletions soroban-sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,6 @@
#[cfg(all(target_family = "wasm", feature = "testutils"))]
compile_error!("'testutils' feature is not supported on 'wasm' target");

#[cfg(all(target_family = "wasm", target_feature = "reference-types"))]
compile_error!("Compiler configuration is unsupported by Soroban Environment, because a Wasm target-feature is enabled that is not yet supported: reference-types. Use Rust 1.81 or older to get a compatible default configuration.");

#[cfg(all(target_family = "wasm", target_feature = "multivalue"))]
compile_error!("Compiler configuration is unsupported by Soroban Environment, because a Wasm target-feature is enabled that is not yet supported: multivalue. Use Rust 1.81 or older to get a compatible default configuration.");

// When used in a no_std contract, provide a panic handler as one is required.
#[cfg(all(not(feature = "alloc"), target_family = "wasm"))]
#[panic_handler]
Expand Down

0 comments on commit ddada99

Please sign in to comment.