From 8ccb96a9f34c98c188da379addcc819877e76112 Mon Sep 17 00:00:00 2001 From: Max Inden Date: Mon, 12 Apr 2021 21:41:48 +0200 Subject: [PATCH] *: Drop generic wasm32-unknown-unknown support (#2038) With `rand` `v0.8.0` platform support changed [1] due to its upgrade to `getrandom` `v0.2`. With `getrandom` `v0.2` `wasm32-unknown-unknown` is no longer supported out of the box: > This crate fully supports the wasm32-wasi and wasm32-unknown-emscripten > targets. However, the wasm32-unknown-unknown target is not automatically > supported since, from the target name alone, we cannot deduce which JavaScript > interface is in use (or if JavaScript is available at all). > > Instead, if the "js" Cargo feature is enabled, this crate will assume that you > are building for an environment containing JavaScript, and will call the > appropriate methods. Both web browser (main window and Web Workers) and > Node.js environments are supported, invoking the methods described above using > the wasm-bindgen toolchain. > > This feature has no effect on targets other than wasm32-unknown-unknown. This commit drops support for wasm32-unknown-unknown in favor of the two more specific targets wasm32-wasi and wasm32-unknown-emscripten. Note on `resolver = "2"`: The new resolver is required to prevent features being mixed, more specifically to prevent libp2p-noise to build with the `ring-resolver` feature. See [3] for details. --- [1] https://github.com/rust-random/rand/blob/master/CHANGELOG.md#platform-support [2] https://docs.rs/getrandom/0.2.2/getrandom/#webassembly-support [3] https://doc.rust-lang.org/nightly/cargo/reference/features.html#feature-resolver-version-2 --- .github/workflows/ci.yml | 20 ++++++++++++++++---- CHANGELOG.md | 4 ++++ Cargo.toml | 1 + 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6ad249b82a9..04ada7233c6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -56,11 +56,18 @@ jobs: - uses: actions/checkout@v2 - - name: Install Rust + - name: Install Rust wasm32-unknown-emscripten uses: actions-rs/toolchain@v1 with: toolchain: stable - target: wasm32-unknown-unknown + target: wasm32-unknown-emscripten + override: true + + - name: Install Rust wasm32-wasi + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + target: wasm32-wasi override: true - name: Install a recent version of clang @@ -85,10 +92,15 @@ jobs: path: target key: wasm-cargo-build-target-${{ hashFiles('Cargo.toml') }} - - name: Build on WASM + - name: Build on wasm32-unknown-emscripten + # TODO: also run `cargo test` + # TODO: ideally we would build `--workspace`, but not all crates compile for WASM + run: cargo build --target=wasm32-unknown-emscripten + + - name: Build on wasm32-wasi # TODO: also run `cargo test` # TODO: ideally we would build `--workspace`, but not all crates compile for WASM - run: cargo build --target=wasm32-unknown-unknown + run: cargo build --target=wasm32-wasi check-rustdoc-links: name: Check rustdoc intra-doc links diff --git a/CHANGELOG.md b/CHANGELOG.md index c164b5f0848..3cc3cae18c6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -55,6 +55,10 @@ - `libp2p-request-response` - `libp2p-swarm` - `libp2p-wasm-ext` + +- Drop support for `wasm32-unknown-unknown` in favor of + `wasm32-unknown-emscripten` and `wasm32-wasi` [PR + 2038](https://github.com/libp2p/rust-libp2p/pull/2038). ## Version 0.36.0 [2021-03-17] diff --git a/Cargo.toml b/Cargo.toml index 61e768f2a51..35d13bceea8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -100,6 +100,7 @@ env_logger = "0.8.1" tokio = { version = "1.0.1", features = ["io-util", "io-std", "macros", "rt", "rt-multi-thread"] } [workspace] +resolver = "2" members = [ "core", "misc/multiaddr",