Closed fgrebenac closed 4 months ago
Could you provide specific information about the error?
Empty Rust project with only wasmedge-sdk dependency fails to build for aarch64-unknown-linux-gnu
target.
It fails on wasmedge-sys
, with following errors:
Compiling wasmedge-sys v0.17.5
error[E0277]: a value of type `Vec<*const i8>` cannot be built from an iterator over elements of type `*const u8`
--> /Users/fgrebenac/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wasmedge-sys-0.17.5/src/plugin.rs:58:72
|
58 | let c_strs: Vec<*const i8> = c_args.iter().map(|x| x.as_ptr()).collect();
| ^^^^^^^ value of type `Vec<*const i8>` cannot be built from `std::iter::Iterator<Item=*const u8>`
|
= help: the trait `FromIterator<*const u8>` is not implemented for `Vec<*const i8>`
= help: the trait `FromIterator<*const i8>` is implemented for `Vec<*const i8>`
= help: for that trait implementation, expected `i8`, found `u8`
note: the method call chain might not have had the expected associated types
--> /Users/fgrebenac/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wasmedge-sys-0.17.5/src/plugin.rs:58:52
|
54 | let c_args: Vec<CString> = preloads
| -------- this expression has type `Vec<&str>`
55 | .iter()
| ------ `Iterator::Item` is `&&str` here
56 | .map(|&x| std::ffi::CString::new(x).unwrap())
| -------------------------------------------- `Iterator::Item` changed to `CString` here
57 | .collect();
58 | let c_strs: Vec<*const i8> = c_args.iter().map(|x| x.as_ptr()).collect();
| ------ ^^^^^^^^^^^^^^^^^^^ `Iterator::Item` changed to `*const u8` here
| |
| `Iterator::Item` is `&CString` here
note: required by a bound in `collect`
--> /Users/fgrebenac/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/iter/traits/iterator.rs:1999:19
|
1999 | fn collect<B: FromIterator<Self::Item>>(self) -> B
| ^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Iterator::collect`
error[E0308]: mismatched types
--> /Users/fgrebenac/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wasmedge-sys-0.17.5/src/plugin.rs:60:49
|
60 | unsafe { ffi::WasmEdge_PluginInitWASINN(c_strs.as_ptr(), len) }
| ------------------------------ ^^^^^^^^^^^^^^^ expected `*const *const u8`, found `*const *const i8`
| |
| arguments to this function are incorrect
|
= note: expected raw pointer `*const *const u8`
found raw pointer `*const *const i8`
note: function defined here
--> /Users/fgrebenac/Work/Other/wasmedge-test/target/aarch64-unknown-linux-gnu/release/build/wasmedge-sys-75f5617d3409884f/out/wasmedge.rs:2296:12
|
2296 | pub fn WasmEdge_PluginInitWASINN(
| ^^^^^^^^^^^^^^^^^^^^^^^^^
What version of the SDK are you using?
I tried with wasmedge-sdk versions 0.13.2 and 0.13.5-newapi, and installed WasmEdge version is 0.13.5.
I understand the issue; it’s caused by bindgen treating c_char differently on different platforms (as i8 or u8). I’ll update a new patch to address this problem.
@L-jasmine are there any updates on this issue? I updated WasmEdge library and wasmedge-sdk crate versions to 0.14.0 and still can't get it to compile.
@fgrebenac please try https://github.com/second-state/wasmedge-rust-sdk/tree/0.13.x . I made some updates in this branch, give it a try and see if there are any other issues. If not, I will release it to crates.io. Thank you very much
@L-jasmine thanks for quick reply. Now the mentioned errors are resolved, but there are new ones. Most of them are
error[E0277]: the trait bound `ValType: From<WasmEdge_ValType>` is not satisfied
and
error[E0531]: cannot find unit struct, unit variant or constant `WasmEdge_ValType_I32` in module `ffi`
I'm getting them on my Mac too for the version on 0.13.x branch, but not on the 0.14.0 version. I think that if you merge this one commit from this 0.13.x branch with version 0.14.0 it should compile.
@fgrebenac Most of these errors are due to the fact that the branch matches wasmedge 0.13 and your computer has upgraded to 0.14, I made a response change in a new branch, you try this https://github.com/second-state/wasmedge-rust-sdk/tree/fix/cross-platform
@fgrebenac I updated the version of wasmedge-sys
, you can run cargo update
and try compiling again
@L-jasmine thank you, it compiles successfully now.
When I create new Rust project and add wasmedge-sdk dependency with wasi-nn feature enabled, build fails for
aarch64-unknown-linux-gnu
target.