-
Notifications
You must be signed in to change notification settings - Fork 431
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
Support wasm32-unknown-emscripten #444
Conversation
First time someone opened a PR for me 😄. It seems my fix didn't work because the combination of featurres and target-specific features is not yet supported by cargo rust-lang/cargo#1197. I'll try just duplicating the |
This does not seem correct, as wasm32-unknown-emscripten is a Unix, and thus both the unix impl and the stdweb impl would get compiled in. I'm pretty sure the unix implementation works just fine, so I'm not entirely sure what this is trying to fix. |
@CryZe Yes, that is what I am looking at at the moment. But compiling LLVM for emscripten takes a while... Do you already have a fix? |
The chrono / time crates ran into the target feature problem as well. Nothing related to emscripten though, idk what emscripten has to do with this. |
Alright, I read a bit further about what is going on here and it seems to me like you should just bring in stdweb when the feature is activated (even though it's unused) but keep the unix implementation for emscripten. |
I have fixed it up enough to compile with
I am not really jumping on finding the cause of that... |
Why would the emscripten target use the stdweb implementation though, it already has a working implementation :( |
src/rngs/os.rs
Outdated
@@ -147,6 +147,7 @@ impl RngCore for OsRng { | |||
|
|||
#[cfg(all(unix, | |||
not(target_os = "cloudabi"), | |||
not(all(target_os = "emscripten", feature = "stdweb")), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't check the architecture, but the other impl checks the architecture. This leaves a hole where no impl is compiled in.
Cargo.toml
Outdated
@@ -50,6 +50,10 @@ fuchsia-zircon = { version = "0.3.2", optional = true } | |||
# use with `--target wasm32-unknown-unknown --features=stdweb` | |||
stdweb = { version = "0.4", optional = true } | |||
|
|||
[target.wasm32-unknown-emscripten.dependencies] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This completely ignores the existence of the asmjs target or the experimental target.
src/rngs/os.rs
Outdated
@@ -660,8 +661,7 @@ mod imp { | |||
} | |||
|
|||
#[cfg(all(target_arch = "wasm32", | |||
not(target_os = "emscripten"), | |||
not(feature = "stdweb")))] | |||
not(any(target_os = "emscripten", feature = "stdweb"))))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We still have no reason why the stdweb implementation is even used for the emscripten target, which was already working perfectly fine.
@CryZe I don't care about the WASM/js targets at all and don't know much about them either t.b.h., just trying to help out. Can you help me out with a little background? As I understand it, emscripten emulates a basic Unix environment. Because we have a generic Unix implementation that reads from Stdweb is an alternative for 'bare' webassembly, which lives behind the What is the idea of the different targets? I can keep Would this be right?
|
In my opinion it should be:
You may be right that the stdweb implementation may be more cryptographically correct, but until we are sure about that I'd trust the emscripten implementation more. The thing is that with the cargo bug, the stdweb feature accidentally gets carried over to the emscripten targets. So having the stdweb feature activated on those targets isn't really an indicator that you actually want the stdweb feature over the actual emscripten implementation. Rough explanation of the individual targets:
|
Thank you! With that approach I see changing only the line you pointed out does the trick. |
This looks good now 👍 |
@CryZe @pitdicker Thanks for your fixes! I'll inform the yew's author to make a test for the game of life.| Update: |
I don't know much about this issue, but it looks like this PR is ready. @huangjj27 you can further discuss in #442 I guess. |
this pr is trying to fix #442