Skip to content
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

*: Drop generic wasm32-unknown-unknown support #2038

Merged
merged 9 commits into from
Apr 12, 2021

Conversation

mxinden
Copy link
Member

@mxinden mxinden commented Apr 9, 2021

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

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
@mxinden mxinden requested a review from tomaka April 9, 2021 16:55
@tomaka
Copy link
Member

tomaka commented Apr 12, 2021

After reading into the details, getrandom v0.2 doesn't actually change anything. It renames the wasm-bindgen and stdweb features to js, but doesn't fundamentally stops supporting wasm32-unknown-unknown.

A user of rust-libp2p can add an explicit dependency to getrandom in their Cargo.toml in order to enable the feature. This is exactly the same as before.

I believe it makes sense to no longer try to maintain this weird unknown variant that doesn't really make sense, so +1 for this PR. However, this PR doesn't make rust-libp2p stop working on that platform.

@mxinden mxinden merged commit 8ccb96a into libp2p:master Apr 12, 2021
@mxinden
Copy link
Member Author

mxinden commented Apr 12, 2021

Thanks @tomaka for the review.

A user of rust-libp2p can add an explicit dependency to getrandom in their Cargo.toml in order to enable the feature. This is exactly the same as before.

I believe it makes sense to no longer try to maintain this weird unknown variant that doesn't really make sense, so +1 for this PR. However, this PR doesn't make rust-libp2p stop working on that platform.

👍

elenaf9 pushed a commit to elenaf9/rust-libp2p that referenced this pull request Apr 16, 2021
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
AgeManning pushed a commit to sigp/rust-libp2p that referenced this pull request May 4, 2021
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
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