Skip to content

Commit 69b3536

Browse files
authored
Remove faulty support for wasm64-unknown-unknown (#551)
This removes the previously in #303 added support for `wasm64-unknown-unknown`. `wasm-bindgen` does in fact not support the Memory64 proposal. The reason it still compiled is that `wasm-bindgen` emits panicking stubs for any target it doesn't support. However, during runtime this would have failed.
1 parent d2ddafb commit 69b3536

File tree

5 files changed

+14
-34
lines changed

5 files changed

+14
-34
lines changed

.github/workflows/build.yml

-17
Original file line numberDiff line numberDiff line change
@@ -58,23 +58,6 @@ jobs:
5858
- name: Build Tests
5959
run: cross test --no-run --target=${{ matrix.target }} --features=std
6060

61-
wasm64:
62-
name: Wasm64
63-
runs-on: ubuntu-22.04
64-
steps:
65-
- uses: actions/checkout@v4
66-
- uses: dtolnay/rust-toolchain@nightly # Need to build libstd
67-
with:
68-
components: rust-src
69-
- uses: Swatinem/rust-cache@v2
70-
- name: Build and Link tests (build-std)
71-
env:
72-
RUSTFLAGS: -Dwarnings --cfg getrandom_backend="wasm_js"
73-
# This target is Tier 3, so we have to build libstd ourselves.
74-
# We currently cannot run these tests because wasm-bindgen-test-runner
75-
# does not yet support memory64.
76-
run: cargo test --no-run -Z build-std=std,panic_abort --target=wasm64-unknown-unknown
77-
7861
tier2:
7962
name: Tier 2
8063
runs-on: ubuntu-22.04

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ wasi = { version = "0.13", default-features = false }
6363
windows-targets = "0.52"
6464

6565
# wasm_js
66-
[target.'cfg(all(getrandom_backend = "wasm_js", any(target_arch = "wasm32", target_arch = "wasm64"), target_os = "unknown"))'.dependencies]
66+
[target.'cfg(all(getrandom_backend = "wasm_js", target_arch = "wasm32", target_os = "unknown"))'.dependencies]
6767
wasm-bindgen = { version = "0.2.89", default-features = false }
6868
js-sys = "0.3"
6969
[target.'cfg(all(getrandom_backend = "wasm_js", getrandom_browser_test, target_arch = "wasm32", target_os = "unknown"))'.dev-dependencies]

README.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,15 @@ Pull Requests that add support for new targets to `getrandom` are always welcome
7676
`getrandom` also provides optional (opt-in) backends, which allow users to customize the source
7777
of randomness based on their specific needs:
7878

79-
| Backend name | Target | Target Triple | Implementation
80-
| ----------------- | -------------------- | -------------------- | --------------
81-
| `linux_getrandom` | Linux, Android | `*‑linux‑*` | [`getrandom`][1] system call (without `/dev/urandom` fallback). Bumps minimum supported Linux kernel version to 3.17 and Android API level to 23 (Marshmallow).
82-
| `linux_rustix` | Linux, Android | `*‑linux‑*` | Same as `linux_getrandom`, but uses [`rustix`] instead of `libc`.
83-
| `rdrand` | x86, x86-64 | `x86_64-*`, `i686-*` | [`RDRAND`] instruction
84-
| `rndr` | AArch64 | `aarch64-*` | [`RNDR`] register
85-
| `esp_idf` | ESP-IDF | `*‑espidf` | [`esp_fill_random`]. WARNING: can return low-quality entropy without proper hardware configuration!
86-
| `wasm_js` | Web Browser, Node.js | `wasm*‑*‑unknown` | [`Crypto.getRandomValues`] if available, then [`crypto.randomFillSync`] if on Node.js (see [WebAssembly support])
87-
| `custom` | All targets | `*` | User-provided custom implementation (see [custom backend])
79+
| Backend name | Target | Target Triple | Implementation
80+
| ----------------- | -------------------- | ------------------------ | --------------
81+
| `linux_getrandom` | Linux, Android | `*‑linux‑*` | [`getrandom`][1] system call (without `/dev/urandom` fallback). Bumps minimum supported Linux kernel version to 3.17 and Android API level to 23 (Marshmallow).
82+
| `linux_rustix` | Linux, Android | `*‑linux‑*` | Same as `linux_getrandom`, but uses [`rustix`] instead of `libc`.
83+
| `rdrand` | x86, x86-64 | `x86_64-*`, `i686-*` | [`RDRAND`] instruction
84+
| `rndr` | AArch64 | `aarch64-*` | [`RNDR`] register
85+
| `esp_idf` | ESP-IDF | `*‑espidf` | [`esp_fill_random`]. WARNING: can return low-quality entropy without proper hardware configuration!
86+
| `wasm_js` | Web Browser, Node.js | `wasm32‑unknown‑unknown` | [`Crypto.getRandomValues`] if available, then [`crypto.randomFillSync`] if on Node.js (see [WebAssembly support])
87+
| `custom` | All targets | `*` | User-provided custom implementation (see [custom backend])
8888

8989
Opt-in backends can be enabled using the `getrandom_backend` configuration flag.
9090
The flag can be set either by specifying the `rustflags` field in

src/backends.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,11 @@ cfg_if! {
149149
mod rdrand;
150150
pub use rdrand::*;
151151
} else if #[cfg(all(
152-
any(target_arch = "wasm32", target_arch = "wasm64"),
152+
target_arch = "wasm32",
153153
target_os = "unknown",
154154
))] {
155-
compile_error!("the wasm*-unknown-unknown targets are not supported by \
156-
default, you may need to enable the \"wasm_js\" \
155+
compile_error!("the wasm32-unknown-unknown targets are not supported \
156+
by default, you may need to enable the \"wasm_js\" \
157157
configuration flag. For more information see: \
158158
https://docs.rs/getrandom/#webassembly-support");
159159
} else {

src/backends/wasm_js.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@ use std::{mem::MaybeUninit, thread_local};
66

77
pub use crate::util::{inner_u32, inner_u64};
88

9-
#[cfg(not(all(
10-
any(target_arch = "wasm32", target_arch = "wasm64"),
11-
target_os = "unknown",
12-
)))]
9+
#[cfg(not(all(target_arch = "wasm32", target_os = "unknown",)))]
1310
compile_error!("`wasm_js` backend can be enabled only for OS-less WASM targets!");
1411

1512
use js_sys::{global, Function, Uint8Array};

0 commit comments

Comments
 (0)