0xPolygonZero / plonky2

Apache License 2.0
745 stars 273 forks source link

Failed to build for wasm32-unknown-unknown with no_std #1527

Closed gshep closed 5 months ago

gshep commented 5 months ago

Hi,

I was playing with plonky2 for wasm32-unknown-unknown target without default features and found out that plonky2_maybe_rayon erroneously pulls std in.

Here is an example reproducing the issue.

Cargo.toml

```toml [package] name = "plonky2-mayberayon" version = "0.1.0" edition = "2021" [dependencies] sp-io = { version = "30.0.0", default-features = false } plonky2_maybe_rayon = { git = "https://github.com/0xPolygonZero/plonky2.git", default-features = false } [features] default = ["std"] std = ["sp-io/std"] ```

src/lib.rs

```rust #![no_std] extern crate sp_io; extern crate plonky2_maybe_rayon; ```

cargo b --target=wasm32-unknown-unknown --no-default-features

...
   Compiling plonky2-mayberayon v0.1.0 (/home/user/devel/gear-tech/plonky2-mayberayon)
error[E0152]: duplicate lang item in crate `std` (which `plonky2_maybe_rayon` depends on): `panic_impl`.
  |
  = note: the lang item is first defined in crate `sp_io` (which `plonky2_mayberayon` depends on)
  = note: first definition in `sp_io` loaded from /home/user/devel/gear-tech/plonky2-mayberayon/target/wasm32-unknown-unknown/debug/deps/libsp_io-27b44a1938535aab.rmeta
  = note: second definition in `std` loaded from /home/user/.rustup/toolchains/nightly-2023-04-25-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-unknown/lib/libstd-bdf48c82ab858a37.rlib

For more information about this error, try `rustc --explain E0152`.
error: could not compile `plonky2-mayberayon` (lib) due to 1 previous error
warning: build failed, waiting for other jobs to finish...