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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions .evergreen/MSRV-Cargo.toml.diff
Original file line number Diff line number Diff line change
@@ -1,10 +0,0 @@
--- Cargo.toml 2024-12-12 10:00:04
+++ Cargo.toml.msrv 2024-12-12 10:20:57
@@ -57,6 +57,7 @@

[dependencies]
ahash = "0.8.0"
+bumpalo = "=3.14.0"
chrono = { version = "0.4.15", features = ["std"], default-features = false, optional = true }
rand = "0.8"
serde = { version = "1.0", features = ["derive"] }
3 changes: 3 additions & 0 deletions .evergreen/compile-only.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ if [ ! -z "$TARGET" ]; then
# renamed in newer versions of rustc
TARGET="wasm32-wasip1"
fi
if [[ "$TARGET" = "wasm32-unknown-unknown" ]]; then
export RUSTFLAGS='--cfg getrandom_backend="wasm_js"'
fi
rustup target add $TARGET --toolchain $RUST_VERSION
TARGET="--target=$TARGET"
fi
Expand Down
14 changes: 7 additions & 7 deletions .evergreen/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,9 @@ axes:
- id: "extra-rust-versions"
values:
- id: "min"
display_name: "1.71.1 (minimum supported version)"
display_name: "1.81 (minimum supported version)"
variables:
RUST_VERSION: "1.71.1"
RUST_VERSION: "1.81"
MSRV: "true"
- id: "nightly"
display_name: "nightly"
Expand All @@ -242,7 +242,7 @@ buildvariants:
name: "tests"
display_name: "Tests"
run_on:
- ubuntu1804-test
- ubuntu2204-small
tasks:
- name: "test"

Expand All @@ -252,15 +252,15 @@ buildvariants:
extra-targets: "*"
display_name: "Compile on Rust ${extra-rust-versions} (${extra-targets})"
run_on:
- ubuntu1804-test
- ubuntu2204-small
tasks:
- name: "compile-only"

-
name: "lint"
display_name: "Lint"
run_on:
- ubuntu1804-test
- ubuntu2204-small
tasks:
- name: "check-clippy"
- name: "check-rustfmt"
Expand All @@ -270,14 +270,14 @@ buildvariants:
name: "fuzz"
display_name: "Raw BSON Fuzzer"
run_on:
- ubuntu1804-test
- ubuntu2204-small
tasks:
- name: "run-fuzzer"

-
name: "wasm"
display_name: "WASM"
run_on:
- ubuntu1804-test
- ubuntu2204-small
tasks:
- name: "wasm-test"
10 changes: 7 additions & 3 deletions .evergreen/run-wasm-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@ set -o errexit

. ~/.cargo/env

rustup update 1.81
rustup default 1.81

curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh

# install nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
. ~/.nvm/nvm.sh
# install node
nvm install --no-progress node
node --version

cd $(dirname $0)/../wasm-test
wasm-pack test --node
6 changes: 4 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,12 @@ serde_with-3 = { package = "serde_with", version = "3.1.0", optional = true }
time = { version = "0.3.9", features = ["formatting", "parsing", "macros", "large-dates"] }
bitvec = "1.0.1"
serde_path_to_error = { version = "0.1.16", optional = true }

[target.'cfg(all(target_arch = "wasm32", target_os = "unknown"))'.dependencies]
js-sys = "0.3"
uuid = { version = "1.1.2", features = ["serde", "v4", "js"] }
getrandom = { version = "0.2", features = ["js"] }
getrandom_03 = { package = "getrandom", version = "0.3", features = ["wasm_js"] }

[dev-dependencies]
assert_matches = "1.2"
Expand All @@ -84,8 +88,6 @@ proptest = "1.0.0"
serde_bytes = "0.11"
serde_path_to_error = "0.1.16"
chrono = { version = "0.4", features = ["serde", "clock", "std"], default-features = false }
[target.'cfg(all(target_arch = "wasm32", target_os = "unknown"))'.dev-dependencies]
getrandom = { version = "0.2", features = ["js"] }

[package.metadata.docs.rs]
all-features = true
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ This crate compiles to the `wasm32-unknown-unknown` target; when doing so, the `

## Minimum supported Rust version (MSRV)

The MSRV for this crate is currently 1.71.1. Increases to the MSRV will only happen in a minor or major version release, and will be to a Rust version at least six months old.
The MSRV for this crate is currently 1.81. Increases to the MSRV will only happen in a minor or major version release, and will be to a Rust version at least six months old.

## Contributing

Expand Down
2 changes: 1 addition & 1 deletion clippy.toml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
msrv = "1.71.1"
msrv = "1.81"
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@
//!
//! ## Minimum supported Rust version (MSRV)
//!
//! The MSRV for this crate is currently 1.71.1. This will be rarely be increased, and if it ever
//! The MSRV for this crate is currently 1.81. This will be rarely be increased, and if it ever
//! is, it will only happen in a minor or major version release.

#![allow(clippy::cognitive_complexity, clippy::derive_partial_eq_without_eq)]
Expand Down
2 changes: 2 additions & 0 deletions wasm-test/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[build]
rustflags = ["--cfg", "getrandom_backend=\"wasm_js\""]
1 change: 0 additions & 1 deletion wasm-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ crate-type = ["cdylib", "rlib"]

[dependencies]
bson = { path = ".." }
getrandom = { version = "0.2", features = ["js"] }

[dev-dependencies]
wasm-bindgen-test = "0.3.0"