Skip to content

Commit 8468724

Browse files
authored
RUST-2177 Fix WASM compilation failures (#521)
1 parent cc292ea commit 8468724

File tree

10 files changed

+26
-26
lines changed

10 files changed

+26
-26
lines changed

.evergreen/MSRV-Cargo.toml.diff

-10
Original file line numberDiff line numberDiff line change
@@ -1,10 +0,0 @@
1-
--- Cargo.toml 2024-12-12 10:00:04
2-
+++ Cargo.toml.msrv 2024-12-12 10:20:57
3-
@@ -57,6 +57,7 @@
4-
5-
[dependencies]
6-
ahash = "0.8.0"
7-
+bumpalo = "=3.14.0"
8-
chrono = { version = "0.4.15", features = ["std"], default-features = false, optional = true }
9-
rand = "0.8"
10-
serde = { version = "1.0", features = ["derive"] }

.evergreen/compile-only.sh

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ if [ ! -z "$TARGET" ]; then
1010
# renamed in newer versions of rustc
1111
TARGET="wasm32-wasip1"
1212
fi
13+
if [[ "$TARGET" = "wasm32-unknown-unknown" ]]; then
14+
export RUSTFLAGS='--cfg getrandom_backend="wasm_js"'
15+
fi
1316
rustup target add $TARGET --toolchain $RUST_VERSION
1417
TARGET="--target=$TARGET"
1518
fi

.evergreen/config.yml

+7-7
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,9 @@ axes:
216216
- id: "extra-rust-versions"
217217
values:
218218
- id: "min"
219-
display_name: "1.71.1 (minimum supported version)"
219+
display_name: "1.81 (minimum supported version)"
220220
variables:
221-
RUST_VERSION: "1.71.1"
221+
RUST_VERSION: "1.81"
222222
MSRV: "true"
223223
- id: "nightly"
224224
display_name: "nightly"
@@ -242,7 +242,7 @@ buildvariants:
242242
name: "tests"
243243
display_name: "Tests"
244244
run_on:
245-
- ubuntu1804-test
245+
- ubuntu2204-small
246246
tasks:
247247
- name: "test"
248248

@@ -252,15 +252,15 @@ buildvariants:
252252
extra-targets: "*"
253253
display_name: "Compile on Rust ${extra-rust-versions} (${extra-targets})"
254254
run_on:
255-
- ubuntu1804-test
255+
- ubuntu2204-small
256256
tasks:
257257
- name: "compile-only"
258258

259259
-
260260
name: "lint"
261261
display_name: "Lint"
262262
run_on:
263-
- ubuntu1804-test
263+
- ubuntu2204-small
264264
tasks:
265265
- name: "check-clippy"
266266
- name: "check-rustfmt"
@@ -270,14 +270,14 @@ buildvariants:
270270
name: "fuzz"
271271
display_name: "Raw BSON Fuzzer"
272272
run_on:
273-
- ubuntu1804-test
273+
- ubuntu2204-small
274274
tasks:
275275
- name: "run-fuzzer"
276276

277277
-
278278
name: "wasm"
279279
display_name: "WASM"
280280
run_on:
281-
- ubuntu1804-test
281+
- ubuntu2204-small
282282
tasks:
283283
- name: "wasm-test"

.evergreen/run-wasm-tests.sh

+7-3
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,14 @@ set -o errexit
44

55
. ~/.cargo/env
66

7-
rustup update 1.81
8-
rustup default 1.81
9-
107
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
118

9+
# install nvm
10+
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
11+
. ~/.nvm/nvm.sh
12+
# install node
13+
nvm install --no-progress node
14+
node --version
15+
1216
cd $(dirname $0)/../wasm-test
1317
wasm-pack test --node

Cargo.toml

+4-2
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,12 @@ serde_with-3 = { package = "serde_with", version = "3.1.0", optional = true }
7373
time = { version = "0.3.9", features = ["formatting", "parsing", "macros", "large-dates"] }
7474
bitvec = "1.0.1"
7575
serde_path_to_error = { version = "0.1.16", optional = true }
76+
7677
[target.'cfg(all(target_arch = "wasm32", target_os = "unknown"))'.dependencies]
7778
js-sys = "0.3"
79+
uuid = { version = "1.1.2", features = ["serde", "v4", "js"] }
80+
getrandom = { version = "0.2", features = ["js"] }
81+
getrandom_03 = { package = "getrandom", version = "0.3", features = ["wasm_js"] }
7882

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

9092
[package.metadata.docs.rs]
9193
all-features = true

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ This crate compiles to the `wasm32-unknown-unknown` target; when doing so, the `
269269

270270
## Minimum supported Rust version (MSRV)
271271

272-
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.
272+
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.
273273

274274
## Contributing
275275

clippy.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
msrv = "1.71.1"
1+
msrv = "1.81"

src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@
277277
//!
278278
//! ## Minimum supported Rust version (MSRV)
279279
//!
280-
//! The MSRV for this crate is currently 1.71.1. This will be rarely be increased, and if it ever
280+
//! The MSRV for this crate is currently 1.81. This will be rarely be increased, and if it ever
281281
//! is, it will only happen in a minor or major version release.
282282
283283
#![allow(clippy::cognitive_complexity, clippy::derive_partial_eq_without_eq)]

wasm-test/.cargo/config.toml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[build]
2+
rustflags = ["--cfg", "getrandom_backend=\"wasm_js\""]

wasm-test/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ crate-type = ["cdylib", "rlib"]
1111

1212
[dependencies]
1313
bson = { path = ".." }
14-
getrandom = { version = "0.2", features = ["js"] }
1514

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

0 commit comments

Comments
 (0)