rustc disagrees with emcc about WASM struct ABI in parameters #88152
Labels
A-ABI
Area: Concerning the application binary interface (ABI)
C-bug
Category: This is a bug.
O-emscripten
Target: 50% off wasm32-unknown-musl. the savings come out of stdio.h, but hey, you get SDL!
O-wasm
Target: WASM (WebAssembly), http://webassembly.org/
I have the following Rust code, being compiled with
cargo +nightly build --target wasm32-unknown-unknown
And the following C++ code, compiled with
emcc -std=c++17 test.cpp target/wasm32-unknown-unknown/debug/libem.a -ldl -lpthread -lm -g -o main.html --emrun -sWASM=1
(using the emscripten sdk)I expected to see this happen: The code would compile without warnings and run fine.
Instead, this happened:
emcc shows up the following warning:
and running
main.html
in the browser throws the following error (to be expected based on the warning)Seems like rustc believes that the signature for
fn({u8, u8})
should be(i32, i32) -> void
, whereas emcc believes it should be(i32) -> void
.A lot of other function signatures work (including returning
Option
), it's specifically when such a struct is a parameter that this happens.I'm not sure which side is at fault here, but an incompatibility between Rust and emcc means that it won't be possible to use WASM with C++ programs that embed a little Rust (or vice versa), which seems like a problem worth highlighting. I think there are other ways to compile C++ to WASM via clang that I need to check out next.
Meta
Version info
cc @fitzgen
The text was updated successfully, but these errors were encountered: