-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
rustc disagrees with emcc about WASM struct ABI in parameters #88152
Comments
This might be because I'm building with
|
Relevant commentary in #83763 |
Yeah, this is an unfortunate historical mistake, but one which can't be fixed without breaking a bunch of code (everything that uses The I don't know anything about the emscripten target. |
@fitzgen thanks!
Seems like C++ is a bit more challenging, can't get iostream to work. |
@Manishearth the Emscripten link errors you were getting can be solved using this tip, or this one. |
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: