-
-
Notifications
You must be signed in to change notification settings - Fork 749
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
Web Assembly support #1016
Comments
@alexcrichton thoughts?
…On Fri, Nov 9, 2018 at 4:50 AM Zrzka ***@***.***> wrote:
Is there a way how to add Web Assembly support?
I tried to compile it with wasm-pack and it fails, because libc is empty
for the wasm target (see this issue
<rust-lang/libc#861> or Does it make sense to
support WASM? <rust-lang/libc#858>). And then
there's a long list of errors like this one:
error[E0412]: cannot find type `c_int` in this scope
--> /Users/robertvojta/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-sys-0.9.39/src/aes.rs:3:24
|
3 | pub const AES_ENCRYPT: c_int = 1;
| ^^^^^ not found in this scope
help: possible candidate is found in another module, you can import it into scope
|
1 | use std::os::raw::c_int;
|
Which is because of the empty libc.
Was searching for a while and I've found a script
<https://ip6.li/node/129> to compile openssl to wasm. So, it's possible.
I wonder, Rust & WASM plays nicely together, we have the wasm-pack, does
it make sense to support WASM in this crate, so, I can use it as a
dependency in Cargo.toml without any additional hassle? Just thinking aloud
...
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#1016>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABY2UQk1YcefYYf7n3gwt71tOIc7zKbJks5utXoxgaJpZM4YWhkI>
.
|
Unfortunately the fact that For the wasm target it's still an open question how Rust and C code interoperate. Only very very new Clang compilers have support for the For the time being the |
Thanks for the reply! I asked because I'm working on a crate, which is written in Rust and should be usable as a Rust crate, node module and also in the browser via wasm. And it just happened that I need some openssl functionality like cert generation, ecs, ... Will have to think about it more :) |
For now we'd recommend using all-rust solutions (if they exist) for the |
Yeah, bleeding edge technologies problems = was expecting this ;) I have to figure out another way. Thanks again! Feel free to close this issue, I'm happy with these answers. |
Any solutions to this issue so far? |
up |
@alexcrichton I need to "cargo build --target=wasm32-unknown-emscripten" my project with an openssl dependency. You said there might be a way forward? |
Sorry I don't have any specific advice here. I've never done this myself but if someone figures it out I'm happy to add support here. |
I just learned that someone figured out how to compile openssl to WASM via the wasienv toolchain. If you take a look at their build script, does it look like you could configure cargo to use these options for the wasm32-wasi target? I'd be happy to test the result, but I currently have no idea how I could get cargo to use their configuration when compiling the rust-openssl crate. I just started to learn Rust, and know even less about C/C++ :( |
Hi @alexcrichton, I've seen you help with various GitHub issues related to editing I found this instruction for setting up the wasm32-wasi target for interop with C. From what I can tell, the goal is to configure the linker and its sysroot to point to an installation of this. Unfortunately I don't know what a linker or a sysroot is, or how to write a I tried this
But this doesn't fix the compilation error, it still looks like the one below. Not sure what's going on, but it doesn't seem to use the right
|
I've also tried
which changes the output to
If I further try
I get
|
It looks like you figured out how to compile with the right flags, so you're at the point I could possibly reach. That looks like something in OpenSSL is trying to include |
I'm getting there @alexcrichton ! But I need your help. I am able to successfully compile using:
However, I still get import errors when trying to run the resulting https://wiki.openssl.org/index.php/Compilation_and_Installation#Configure_Options How do I do that? So far, only the |
I think that may depend on the errors you're getting as to what the fix is. If the solution is to pass those two options to the configure script, are you building OpenSSL yourself or relying on something like |
@alexcrichton I'm relying on |
Oh for learning about |
@alexcrichton I checked that out ofc, but it only mentions replacing dependencies, not modifying their build config. Are you suggesting I should clone and modify |
Sorry I don't have the time right now to walk you through editing sources of upstream dependencies. I can try to offer help but this is all best-effort on my part. |
So can we use openssl for wasm or not? |
I just successfully built wasm32-wasi with openssl-src-rs v300, features |
@yihuang could you please provide some details on how you managed to do that? |
Meanwhile I continued on what @Jonas-Metzger has started. I also try to build a rust project that has rust-openssl as dependency. The target is I'm currently using the following script
I had to add Any suggestions on how to proceed are very welcome. Here is an error log:
|
I was just just playing around, didn't tested the result, but the build process succeeded. In a project that use openssl as dependency, I updated the cargo file like this:
update the
And build like this:
I guess the secret is just update to most recent version of |
Thanks @yihuang. I've tried what you suggested and the build for wasm32-wasi target went further but still failed with fatal error when trying to find pthread.h and netdb.h header files. Unfortunately threads are not yet supported by wasi-sdk. Is there a way to build rust-openssl without a thread support? |
@zavalyshyn FYI, it looks like wasi-sdk recently released experimental threading support. Not sure if this can unblock your experimentation. |
wasm32-wasi-preview1-threads was added to cargo so any news on this? |
@yihuang I tried your changes which you posted but still getting same errors (before even doing changes)
can you please post detailed build setup if you have it somewhere ? |
Is there a way how to add Web Assembly support?
I tried to compile it with
wasm-pack
and it fails, becauselibc
is empty for thewasm
target (see this issue or Does it make sense to support WASM?). And then there's a long list of errors like this one:Which is because of the empty
libc
.Was searching for a while and I've found a script to compile
openssl
towasm
. So, it's possible.I wonder, Rust & WASM plays nicely together, we have the
wasm-pack
, does it make sense to support WASM in this crate, so, I can use it as a dependency in Cargo.toml without any additional hassle? Just thinking aloud ...The text was updated successfully, but these errors were encountered: