Skip to content
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

WASM compilation fails when multivalue returns is turned on #649

Closed
eastside opened this issue Jun 13, 2023 · 3 comments
Closed

WASM compilation fails when multivalue returns is turned on #649

eastside opened this issue Jun 13, 2023 · 3 comments

Comments

@eastside
Copy link

I was looking at using bincode for a WASM project. However, it looks like compilation fails when multi-value returns are turned on.

Here are some steps to reproduce.

Cargo.toml

[package]
name = "my-bincode-lib"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
bincode = "1.3.3"
serde = { version = "1.0.164", features = ["derive"] }

[lib]
crate-type = ["cdylib"]

src/lib.rs

#[no_mangle]
pub extern "C" fn main() {
    bincode::serialize("hello world".as_bytes()).unwrap();
}

Then compile to WASM with multi-value returns enabled by typing the following into terminal:

RUSTFLAGS="-C target-feature=+multivalue" cargo build --target=wasm32-unknown-unknown

This results in the following error:

          >>> defined as (i32) -> i32 in /Users/adam/wasmtime/my-bincode-lib/target/wasm32-unknown-unknown/debug/deps/libbincode-f593fd3a6c844b6e.rlib(bincode-f593fd3a6c844b6e.bincode.aeaae391-cgu.2.rcgu.o)
          >>> defined as (i32, i32) -> void in /Users/adam/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/wasm32-unknown-unknown/lib/libstd-d66a635e2d91bd07.rlib(std-d66a635e2d91bd07.std.148725e7-cgu.0.rcgu.o)
          
error: could not compile `my-bincode-lib` (lib) due to previous error
@eastside
Copy link
Author

I should also note that if you compile without multi-value returns turned on, everything compiles nicely.

$ cargo build --target=wasm32-unknown-unknown
   Compiling serde v1.0.164
   Compiling bincode v1.3.3
   Compiling my-bincode-lib v0.1.0 (/Users/adam/wasmtime/my-bincode-lib)
    Finished dev [unoptimized + debuginfo] target(s) in 3.44s

@VictorKoenders
Copy link
Contributor

Is this an issue in bincode specifically? From that issue it appears to be rust related

@VictorKoenders
Copy link
Contributor

Going to close this as it does not seem to be a bincode issue, but rather an issue in rust itself. If there is something we can do in bincode to fix this feel free to re-open this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants