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-bindgen cli: error: import of '__wbg_buffer_*' doesn't have an adapter listed #2366

Closed
exrok opened this issue Nov 21, 2020 · 1 comment
Labels

Comments

@exrok
Copy link

exrok commented Nov 21, 2020

Describe the Bug

Using js_sys::Float32Array::view causes wasm-bindgen cli command to fail with error:

error: import of `__wbg_buffer_49131c283a06686f` doesn't have an adapter listed

when compiling in release mode.

Steps to Reproduce

src/main.rs

use wasm_bindgen::prelude::*;
#[wasm_bindgen]
pub fn start() {
    unsafe { js_sys::Float32Array::view(&[0.0f32]); }
}

cargo.toml

[package]
name = "wasmbug"
version = "0.1.0"
edition = "2018"

[dependencies]
wasm-bindgen = "0.2.68"
js-sys = "0.3.45"

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

Then with rust 1.48 on linux

> cargo build --target wasm32-unknown-unknown --release
...
  
> cd target/wasm32-unknown-unknown/release
> wasm-bindgen --version
wasm-bindgen 0.2.68
> wasm-bindgen --target web --no-typescript --out-dir . wasmbug.wasm
error: import of `__wbg_buffer_49131c283a06686f` doesn't have an adapter listed

Additional Context

Avoiding use of js_sys::Float32Array::view prevents the problem from occurring

Edit: only happens in release mode

@exrok
Copy link
Author

exrok commented Nov 22, 2020

Had RUSTFLAGS="-C target-cpu=native" in my environment which caused the issue.

@exrok exrok closed this as completed Nov 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant