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

Consider gating APIs that require winapi/advapi32/libc behind a feature #89

Closed
LaylBongers opened this issue Dec 28, 2015 · 9 comments
Closed
Labels
F-new-int Functionality: new, within Rand

Comments

@LaylBongers
Copy link

Some crates (such as various vector math libraries) do not require things like cryptographically secure RNG. It might be beneficial to provide a way to use rand with these features disabled, even if they're enabled by default.

@Xaeroxe
Copy link

Xaeroxe commented Jun 5, 2017

Might I ask, to what end? Having functions available in a crate that you don't use doesn't seem to hurt the final binary.

@alexcrichton alexcrichton added the F-new-int Functionality: new, within Rand label Jun 14, 2017
@aochagavia
Copy link
Contributor

A concrete example: today I was trying to compile a program to WebAssembly, but it was impossible because rand relies on libc.

@dhardy
Copy link
Member

dhardy commented Nov 30, 2017

That's a sound argument, if somewhat unfortunate (is there any proposal to use a fake libc when compiling for WASM?).

If we were to do this, it would be preferable to have the feature enabled by default (because frequently used functionality like thread_rng and random relies on it), but this could make it difficult linking rand without the feature (same as no_std: if any crate "forgets" to not depend on default features, Cargo will enable them).

I see you just added #197; is this enough to fix your problem or do you still have linker issues?

@aochagavia
Copy link
Contributor

I just discovered an update to libc was published today, which provides compatibility with wasm. That, together with my PR allows things to compile, though I haven't tested the resulting code on the browser.

@pitdicker
Copy link
Contributor

I don't think it is helpful to keep this issue open. The original issue about gating APIs that require linking behind a feature gate is solved now that we have the std feature. Only OsRng required linking to WinAPI, libc etc.

@dhardy
Copy link
Member

dhardy commented Mar 3, 2018

Yes, we have native WASM support now. If rand won't compile on a specific platform, please open an issue regarding that platform, not a general one.

@dhardy dhardy closed this as completed Mar 3, 2018
@huangjj27
Copy link

it seems compiled in yew will cause failure. Is it caused by the thread_rng function ?

@vks
Copy link
Collaborator

vks commented May 9, 2018 via email

@pitdicker
Copy link
Contributor

This would be a breaking change.

Be careful to know the state of the issue when replying from e-mail 😄.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-new-int Functionality: new, within Rand
Projects
None yet
Development

No branches or pull requests

8 participants