Skip to content

Add wasm32v1-none Support #828

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
May 23, 2025
Merged

Conversation

bushrat011899
Copy link
Contributor

Objective

uuid has support for no_std, and support for wasm32-unknown-unknown, but it currently doesn't have support for the alternative wasm32v1-none. Attempting to compile uuid with the v4 and js features on wasm32v1-none causes a compilation error due to getrandom.

Solution

Based on wasm32v1-none and wasm32-unknown-unknown documentation, and this compilation failure condition in getrandom, the configuration condition uuid should use for possibly-web Wasm is:

all(target_arch = "wasm32", any(target_os = "unknown", target_os = "none"))

That is, 32-bit Wasm with either an unknown OS (wasm32-unknown-unknown) or none (wasm32v1-none). The target_vendor condition is omitted based on the recommendations from the official Rust documentation linked above.


Notes

  • I have also removed the implicit std features from js-sys and wasm-bindgen, and moved them into uuid/std. This may not be required, as wasm32-unknown-unknown still compiles without these std features enabled, but doing so reduces the chance of downstream issues.
  • I've added a CI task "MVP Web" to ensure this particular target continues to compile going forward. Note that due to development dependency feature unification on older versions of Rust, you may need to use -Z avoid-dev-deps to test the target locally.

@KodrAus
Copy link
Member

KodrAus commented May 23, 2025

Thanks for working on this @bushrat011899! Just so I follow properly, we treat the wasm32v1-none target the same as wasm32-unknown-unknown with respect to our source of randomness? That is, if you enable the js feature of uuid you'll get our internal RNG support, but if you enable rng-rand or rng-getrandom you'll get theirs?

@bushrat011899
Copy link
Contributor Author

Just so I follow properly, we treat the wasm32v1-none target the same as wasm32-unknown-unknown with respect to our source of randomness? That is, if you enable the js feature of uuid you'll get our internal RNG support, but if you enable rng-rand or rng-getrandom you'll get theirs?

Correct, the only difference between wasm32v1-none and wasm32-unknown-unknown is wasm32v1-none does not have a pre-built std implementation, and it explicitly uses the mvp target-cpu, which provides much better backwards compatibility with older web browsers. There's some further details in the documentation for the target. But the general plan is for wasm32-unknown-unknown to be the "bleeding edge" of Wasm, implementing all features and functionality in the spec that is "generally available", while the wasm32vX-none target(s) will strictly adhere to the X'th Web Assembly Core Spec for a more stable level of compatibility.

The no_std component here is a slightly more controversial choice, but is motivated by the fact that wasm32-unknown-unknown simply panics when certain elements from the std library are used, since they just have stub implementations. Making wasm32v1-none no_std avoids those footguns entirely, and is a better direction for Wasm on the web (IMO, at least until std can use the JS runtime and assume its existence somehow)

Copy link
Member

@KodrAus KodrAus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @bushrat011899! This looks great to me.

@KodrAus KodrAus merged commit c54cadc into uuid-rs:main May 23, 2025
22 checks passed
kodiakhq bot pushed a commit to pdylanross/fatigue that referenced this pull request May 23, 2025
Bumps uuid from 1.16.0 to 1.17.0.

Release notes
Sourced from uuid's releases.

v1.17.0
What's Changed

Added convenience implementation TryFrom for std by @​Nahuel-M in uuid-rs/uuid#819
Update OSX builds to arm by @​KodrAus in uuid-rs/uuid#825
Replace derive(Hash) with manual impl in Uuid by @​diopoex in uuid-rs/uuid#824
Add wasm32v1-none Support by @​bushrat011899 in uuid-rs/uuid#828
Prepare for 1.17.0 release by @​KodrAus in uuid-rs/uuid#829

New Contributors

@​Nahuel-M made their first contribution in uuid-rs/uuid#819
@​diopoex made their first contribution in uuid-rs/uuid#824

Full Changelog: uuid-rs/[email protected]



Commits

2fd9b61 Merge pull request #829 from uuid-rs/cargo/v1.17.0
ed0d385 prepare for 1.17.0 release
c54cadc Merge pull request #828 from bushrat011899/wasm32v1-none
625d769 Fix typo in MVP Web CI
9d638e0 Add MVP Web CI Task
83dc528 Add wasm32v1-none support
5fbd843 Merge pull request #824 from diopoex/main
6635ae4 Merge pull request #825 from uuid-rs/ci/aarch64-apple-darwin
b2370f2 update toolchain for outdated job
c74ad33 update OSX builds to arm
Additional commits viewable in compare view




Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


Dependabot commands and options

You can trigger Dependabot actions by commenting on this PR:

@dependabot rebase will rebase this PR
@dependabot recreate will recreate this PR, overwriting any edits that have been made to it
@dependabot merge will merge this PR after your CI passes on it
@dependabot squash and merge will squash and merge this PR after your CI passes on it
@dependabot cancel merge will cancel a previously requested merge and block automerging
@dependabot reopen will reopen this PR if it is closed
@dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
@dependabot show <dependency name> ignore conditions will show all of the ignore conditions of the specified dependency
@dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
@dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
@dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
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