Skip to content

rand with stdweb feature is not compatible with wasm32-unkown-emscripten target or --nodejs in wasm32-unkown-unknown target #442

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

Closed
huangjj27 opened this issue May 12, 2018 · 4 comments · Fixed by #444

Comments

@huangjj27
Copy link

Hi, everyon! I was trying to use rand in wasm32-unknown-unknown target, so I added the stdweb features in cargo.toml:

[dependencies]
# ...

# FIXME: after the 0.5 version of rand is released on crates.io, lock the version.
rand = { git = "https://github.com/rust-lang-nursery/rand", features = ["stdweb"] }

and it did work fine with the target.

However, in this build, it fails me with such given error:

Testing for wasm32-unknown-emscripten...

# ...many irrelevant logs reduced

   Compiling rand v0.5.0-pre.1 (https://github.com/rust-lang-nursery/rand#b1c35856)
error[E0463]: can't find crate for `stdweb`
   --> /home/travis/.cargo/git/checkouts/rand-02690058d91f0548/b1c3585/src/lib.rs:193:1
    |
193 | extern crate stdweb;
    | ^^^^^^^^^^^^^^^^^^^^ can't find crate
error: aborting due to previous error
For more information about this error, try `rustc --explain E0463`.
error: Could not compile `rand`.

Is it a compatiblity issue between these 2 wasm target?

@huangjj27
Copy link
Author

I found the stdweb crate will be included when using wasm32-* target:

// lib.rs: 191-193 
#[cfg(all(target_arch = "wasm32", feature = "stdweb"))]
#[macro_use]
extern crate stdweb;

So I think this is a compatiblity bug

@pitdicker
Copy link
Contributor

@huangjj27 Thank you for opening the issue. I think one problem is that we have this in cargo.toml:

[target.wasm32-unknown-unknown.dependencies]
stdweb = { version = "0.4", optional = true }

Also OsRng contained a line to not use stdweb in combination with emscripten.

I have tried a fix in https://github.com/pitdicker/rand/tree/emscripten, but have trouble testing it out locally. Can you give it a try?

@huangjj27
Copy link
Author

huangjj27 commented May 12, 2018

@pitdicker I'm sorry I don't have emscripten locally neither. maybe you can make a PR to check the test? I just make a PR #444 . Let's see if we can fix the problem

@huangjj27 huangjj27 changed the title rand with stdweb feature is not compatible with wasm32-unkown-emscripten target rand with stdweb feature is not compatible with wasm32-unkown-emscripten target or --nodejs in wasm32-unkown-unknown target May 12, 2018
@huangjj27
Copy link
Author

It seen fix the problem, but causing another.

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 a pull request may close this issue.

2 participants