Skip to content

RUST-2177 Fix WASM compilation failures #521

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 13, 2025

Conversation

abr-egn
Copy link
Contributor

@abr-egn abr-egn commented Mar 11, 2025

RUST-2177

Boy, it sure would be nice if the ecosystem around WASM would stabilize a bit.

There were three five six things going on here:

  • uuid now requires the js feature when compiled on the wasm32.unknown.unknown target (credit to Isabel for finding this one)
  • the dependency tree now includes both getrandom 0.2.x and 0.3.x (from ahash and rand respectively); we had a conditional flag set in dev-dependencies for 0.2.x but we didn't have the equivalent (named a different thing - wasm_js instead of js) for 0.3.x.
  • getrandom 0.3.x also requires that cfg(getrandom_backend=wasm_js) be enabled; normally the way to set custom cfg variables is by setting the RUSTFLAGS env variable, but for the WASM test program actual compilation is controlled by the wasm-pack wrapper scripts which fail to propagate that variable, so we have to set it in .cargo/config.toml instead.
  • The checks in getrandom (both 0.2.x and 0.3.x) were moved from runtime to compile-time, so the feature additions are now in the bson crate in the target-specific dependencies section rather than being at the binary target/dev-dependency level.
  • The version of node installed on the test host was old enough to have broken behavior, and we were running on old enough hosts that they didn't have new enough glibc (!!) to install current node, so I updated to use newer hosts and install node locally for the tests.
  • getrandom 0.3.x requires rust >= 1.80 for WASI support, so per our new policy I just bumped the crate MSRV from 1.71.1 up to 1.81 (the most recent version outside of the six month window).

@abr-egn abr-egn marked this pull request as draft March 11, 2025 17:56
@abr-egn abr-egn marked this pull request as ready for review March 13, 2025 14:41
@abr-egn abr-egn requested a review from isabelatkinson March 13, 2025 14:41
@abr-egn abr-egn merged commit 8468724 into mongodb:main Mar 13, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants