Skip to content

Can't work with wasm32-wasi target from rustc-2021-01-13 #2471

Closed as not planned
@passchaos

Description

@passchaos

rust version: rustc 1.52.0-nightly (a143517d4 2021-02-16)
wasm-bindgen: 0.2.71
wasm-bindgen-cli: 0.2.71

use wasm_bindgen::prelude::*;

#[wasm_bindgen]
pub fn greet(_name: &str) {
}

With the above code and cdylib crate-type, I can generate js bindgings on target wasm32-unknown-unknown using wasm-bindgen cli, but not on target wasm32-wasi.

Ths error info when generating binding for wasm32-wasi:

thread 'main' panicked at 'assertion failed: `(left == right)`
  left: `1`,
 right: `0`', $HOME/.cargo/registry/src/***-df7c3c540f42cdbd/wasm-bindgen-cli-support-0.2.71/src/js/binding.rs:165:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Different parameters(--target) of wasm-bindgen cli are tried, and the same error is reported

I checked the difference, the left part of the figure below is wasm32-unknown-unknown target wat info(only contain greet related), the right part is the wasm32-wasi target wat info, It can be seen that the function interface forms generated by the two platforms are different

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions