RReverser / wasm-bindgen-rayon

An adapter for enabling Rayon-based concurrency on the Web with WebAssembly.
https://docs.rs/wasm-bindgen-rayon
Apache License 2.0
139 stars 17 forks source link

`wasm-bindgen-rayon` atomics/bulk-memory feature errors in workspace sub-directory builds #7

Open thor314 opened 3 months ago

thor314 commented 3 months ago

My workspace containing this project as a dependency fails to build, though the member subdir succeeds at building. Removal of that subdir allows the project to build as expected.

In my workspace I have:

.
├── wasm-client - where `wasm-bindgen-rayon` lives
└── other-stuff

I have wasm-client/.cargo/config.toml containing:

# tell Cargo to build targeting wasm32
[build]
target = "wasm32-unknown-unknown"

# compiler adjustments for wasm-bindgen-rayon
[target.wasm32-unknown-unknown]
rustflags = [
              # failed attempts to silence warnings for using unstable compiler options for atomics, issue persists (different issue, not related to this github issue)
              # "-Z", "unstable-options",
              # "-A", "unstable_features",
              "-C", "target-feature=+atomics,+bulk-memory,+mutable-globals",
            ]

[unstable]
build-std = ["panic_abort", "std"]

When I cargo check from root, I obtain error:

~/pl/tlsn-monorepo tk-debug-wasm-path !1 ?1 ❯ cargo check -q           1.81.0-nightly
error: Did you forget to enable `atomics` and `bulk-memory` features as outlined in wasm-bindgen-rayon README?

When I cargo check from wasm-client, I see only the warning:

warning: unstable feature specified for `-Ctarget-feature`: `atomics`
  |
  = note: this feature is not stably supported; its behavior can change in the future

I would like to be able to use this library as a dependency without limiting my use of cargo. I did not see any related issues in this repo. Do you have any suggestions?

sd2k commented 1 week ago

It's far from ideal but I've worked around this by putting wasm-bindgen-rayon and all parallel functionality behind a non-default feature flag, which at least lets me run cargo commands from my workspace root without errors. I don't know that helps or not in your case, I agree that a better solution would be good.

RReverser commented 5 days ago

If you are in a workspace, your .cargo folder with the config should be at the root, not in the subfolder, otherwise it will be ignored.