Skip to content

wasm crate works only as workspace non-member #12274

@deepink-mas

Description

@deepink-mas

Problem

I have the following (minimal) example wasm crate (it is a soroban smart contract):

src/lib.rs:

#![no_std]
use soroban_sdk::{contractimpl, vec, Env, Symbol, Vec};

pub struct Contract;

#[contractimpl]
impl Contract {
    pub fn hello(env: Env, to: Symbol) -> Vec<Symbol> {
        vec![&env, Symbol::short("Hello"), to]
    }
}

which builds (cargo b --target wasm32-unknown-unknown) fine with this Cargo.toml:

[package]
name = "soroban"
version = "0.1.0"
edition = "2021"

[dependencies]
soroban-sdk = "0.8.6"

however if I place it into a workspace:

[workspace]
members = ["soroban-workspace"]
exclude = ["soroban"]

[workspace.dependencies]
soroban-sdk = "0.8.6"

then it fails with the following error:

   Compiling soroban-sdk v0.8.6
error[E0152]: found duplicate lang item `panic_impl`
  --> /home/werk/.cargo/registry/src/github.com-1ecc6299db9ec823/soroban-sdk-0.8.6/src/lib.rs:51:1
   |
51 | fn handle_panic(_: &core::panic::PanicInfo) -> ! {
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: the lang item is first defined in crate `std` (which `soroban_env_common` depends on)
   = note: first definition in `std` loaded from /usr/lib/rust/1.69.0/lib/rustlib/wasm32-unknown-unknown/lib/libstd-2dad762beb228465.rlib
   = note: second definition in the local crate (`soroban_sdk`)

Steps

  1. move working wasm crate into workspace
  2. cargo b --target wasm32-unknown-unknown
  3. it now fails with duplicate lang item panic_impl

Possible Solution(s)

No response

Notes

No response

Version

$ cargo version --verbose
cargo 1.69.0-nightly
release: 1.69.0-nightly
host: x86_64-unknown-linux-gnu
libgit2: 1.5.0 (sys:0.16.0 vendored)
libcurl: 8.1.0 (sys:0.4.59+curl-7.86.0 system ssl:GnuTLS/3.8.0 (NSS/3.89.1) (OpenSSL/3.0.8))
os: Gentoo Linux 2.13 [64-bit]

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-features2Area: issues specifically related to the v2 feature resolverA-workspacesArea: workspacesC-bugCategory: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions