C FFI functions have incorrect signatures in wasm bundle when targeting wasm32-unknown-unknown #63626
Labels
A-FFI
Area: Foreign function interface (FFI)
O-wasm
Target: WASM (WebAssembly), http://webassembly.org/
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
We have a crate called
mruby-sys
which uses thecc
crate to build a C static library. Building this library fails to link when building thewasm32-unknown-unknown
target due to function signature mismatches. When using the same build process for the C code with clang-8, the code links and is runnable in node via itsWebAssembly
infrastructure. This code links and runs correctly when targetingx86_64-apple-darwin
andx86_64-unknown-linux-gnu
.Our full investigation: artichoke/artichoke#172 (comment).
The function that fails to link has the following prototype in
ext.h
:mrb_value
is a struct with the following definition:mrb_sys_class_of_value
has the following signature when compiling the C lib standalone:the Rust compiled version has this signature:
and results in this linker error:
with this rustc:
I'm not sure what is going on here, or if the bug is in
cc
,bindgen
,rustc
, orrust-lld
. Any ideas on what is going on?The text was updated successfully, but these errors were encountered: