Skip to content

WASM compilation fails when multivalue returns is turned on #649

Closed
@eastside

Description

@eastside

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions