I’m trying to compile a rust library to target webassembly so I can use it within a web page.
cargo build --target=wasm32-unknown-unknown
But it fails with this:
error: The multicore feature flag is not supported on wasm32 architectures without atomics
--> /home/andrew/.cargo/registry/src/index.crates.io-6f17d22bba15001f/halo2_proofs-0.3.0/src/multicore.rs:10:1
|
10 | / compile_error!(
11 | | "The multicore feature flag is not supported on wasm32 architectures without atomics"
12 | | );
| |_^
error[E0432]: unresolved imports `maybe_rayon::current_num_threads`, `maybe_rayon::iter::IndexedParallelIterator`
--> /home/andrew/.cargo/registry/src/index.crates.io-6f17d22bba15001f/halo2_proofs-0.3.0/src/multicore.rs:20:23
|
20 | pub use maybe_rayon::{current_num_threads, iter::IndexedParallelIterator};
| ^^^^^^^^^^^^^^^^^^^ ^^^^^^-----------------------
| | | |
| | | help: a similar name exists in the module: `IntoParallelIterator`
| | no `IndexedParallelIterator` in `iter`
| no `current_num_threads` in the root
error[E0277]: expected a `Fn<(&impl Fn() -> T + Send + Sync, Result<T, E>)>` closure, found `impl Fn(T, Result<T, E>) -> Result<T, E> + Send + Sync`
--> /home/andrew/.cargo/registry/src/index.crates.io-6f17d22bba15001f/halo2_proofs-0.3.0/src/multicore.rs:56:35
|
56 | self.try_fold(&identity, &fold_op)
| -------- ^^^^^^^ expected an `Fn<(&impl Fn() -> T + Send + Sync, Result<T, E>)>` closure, found `impl Fn(T, Result<T, E>) -> Result<T, E> + Send + Sync`
| |
| required by a bound introduced by this call
|
= note: expected a closure with arguments `(T, Result<_, _>)`
found a closure with arguments `(&impl Fn() -> T + Send + Sync, Result<_, _>)`
= note: required for `&impl Fn(T, Result<T, E>) -> Result<T, E> + Send + Sync` to implement `FnMut<(&impl Fn() -> T + Send + Sync, Result<T, E>)>`
note: required by a bound in `try_fold`
--> /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/iter/traits/iterator.rs:2296:5
error[E0277]: expected a `FnOnce<(&impl Fn() -> T + Send + Sync, Result<T, E>)>` closure, found `impl Fn(T, Result<T, E>) -> Result<T, E> + Send + Sync`
--> /home/andrew/.cargo/registry/src/index.crates.io-6f17d22bba15001f/halo2_proofs-0.3.0/src/multicore.rs:56:34
|
56 | self.try_fold(&identity, &fold_op)
| -------- ^^^^^^^^ expected an `FnOnce<(&impl Fn() -> T + Send + Sync, Result<T, E>)>` closure, found `impl Fn(T, Result<T, E>) -> Result<T, E> + Send + Sync`
| |
| required by a bound introduced by this call
|
= note: expected a closure with arguments `(T, Result<_, _>)`
found a closure with arguments `(&impl Fn() -> T + Send + Sync, Result<_, _>)`
note: required by a bound in `try_fold`
--> /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/iter/traits/iterator.rs:2296:5
Some errors have detailed explanations: E0277, E0432.
For more information about an error, try `rustc --explain E0277`.
error: could not compile `halo2_proofs` (lib) due to 4 previous errors
To try to resolve the first issue, I added this to a new .cargo\config
file (I also tried .cargo\config.toml
):
[target.wasm32-unknown-unknown]
rustflags = ["-C", "target-feature=+atomics,+bulk-memory"]
But that made no difference.
Any suggestions?