Open elichai opened 5 years ago
Based on that error message alone I'm unable to tell you why it happens. Can you perhaps post a minimal reproduction of your problem?
@koute Yes: https://github.com/elichai/cargo-web-test
Ah, right. It's natural that it doesn't work as AFAIK wasm32-unknown-unknown
in general doesn't support linking with non-Rust code. (In theory it's possible, but you'd have to compile the C code manually, and then manually hook it up in your Rust module imports.)
By the way, this is unrelated to your issue, but it's interesting that your example doesn't compile on nightly (with vanilla cargo
):
$ rustup run nightly rustc --version
rustc 1.38.0-nightly (4560cb830 2019-07-28)
$ rustup run nightly cargo rustc --target wasm32-unknown-unknown --profile test
error: linking with `rust-lld` failed: exit code: 1
|
...snip...
= note: rust-lld: error: /tmp/cargo-web-test/target/wasm32-unknown-unknown/debug/build/testweb-dfe6cd8f46074fe6/out/liblinkme.a: archive has no index; run ranlib to add one
error: aborting due to previous error
error: Could not compile `testweb`.
while it does on stable:
$ rustup run stable rustc --version
rustc 1.36.0 (a53f9df32 2019-07-03)
$ rustup run stable cargo rustc --target wasm32-unknown-unknown --profile test
Finished dev [unoptimized + debuginfo] target(s) in 0.14s
It might be worthwhile to create a rustc
issue for this. (:
This works with wasm-pack easily.
as long as you have clang there's no reason it won't compile the C code to wasm32-unknown-unknown
Hi, Running
cargo web test --target=asmjs-unknown-emscripten
the tests pass smoothly. But If I runcargo web test --target=wasm32-unknown-unknown
I get the following:The
a_c_function
is a C function provided that I use in rust. why does it fail? how can I fix this?