Skip to content

chacha: fix wasm32-unknown-unknown build#1086

Closed
ordian wants to merge 4 commits intorust-random:masterfrom
ordian:chacha-fix-no-std
Closed

chacha: fix wasm32-unknown-unknown build#1086
ordian wants to merge 4 commits intorust-random:masterfrom
ordian:chacha-fix-no-std

Conversation

@ordian
Copy link
Copy Markdown

@ordian ordian commented Jan 11, 2021

rand_chacha pulls rand_core/getrandom feature, which it doesn't seem to require.
This breaks wasm32-unknown-unknown builds.

@newpavlov
Copy link
Copy Markdown
Member

Ideally, in addition to the std feature, I think it will be worth to add an enabled by default getrandom feature, which will enable rand_core/getrandom, so users will be able to use SeedableRng::from_entropy without enabling the std feature. It's also worth to check the other RNG crates and introduce similar changes.

ppv-lite86 = { version = "0.2.8", default-features = false, features = ["simd"] }

[features]
default = ["std"]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

rand_core/std enables rand_core/getrandom, so I don't think we need to have rand_core/getrandom listed separately here?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks, I find it a bit surprising though. Extracted getrandom in a separate feature now in 19de8ba.
Let me know if there is anything else that needs to be changed.

Copy link
Copy Markdown
Member

@newpavlov newpavlov left a comment

Choose a reason for hiding this comment

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

Looks good!

Copy link
Copy Markdown
Member

@dhardy dhardy left a comment

Choose a reason for hiding this comment

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

I'm not actually sure how this helps — are you sure it isn't another dependency which depends on rand_core/std or rand_core/getrandom? (Assuming you are already disabling default features for rand_chacha in your build.)

Regarding adding the getrandom feature I don't see any harm, but it's also not really difficult to depend on rand_core/getrandom directly where required.


[dependencies]
rand_core = { path = "../rand_core", version = "0.6.0" }
rand_core = { path = "../rand_core", version = "0.6.0", default-features = false }
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

rand_core doesn't have any default features, so this change does nothing IIUC

@ordian
Copy link
Copy Markdown
Author

ordian commented Jan 12, 2021

I'm not actually sure how this helps — are you sure it isn't another dependency which depends on rand_core/std or rand_core/getrandom? (Assuming you are already disabling default features for rand_chacha in your build.)

Regarding adding the getrandom feature I don't see any harm, but it's also not really difficult to depend on rand_core/getrandom directly where required.

Oh, you're right. I somehow overlooked the lack of default features. In my case the problem was caused by cargo's feature resolver v1 pulling optional crates it shouldn't have.

@ordian ordian closed this Jan 12, 2021
@ordian ordian deleted the chacha-fix-no-std branch January 12, 2021 14:09
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.

4 participants