Description
I have started learning wasm-bindgen recently.And even with first example js-hello-world there was a weird problem. https://github.com/rust-lang-nursery/rust-wasm
I did as was written, set rustc to nightly, then:
rustup target add wasm32-unknown-unknown
cargo install wasm-bindgen-cli
cargo new js-hello-world --lib
This is Cargo.toml:
[package]
name = "js-hello-world"
version = "0.1.0"
authors = ["Grigoriy Markelov <[email protected]>"]
[dependencies]
wasm-bindgen = "0.2.1"
[lib]
crate-type = ["cdylib"]
And lib.rs:
#![feature(proc_macro, wasm_custom_section, wasm_import_module)]
extern crate wasm_bindgen;
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
extern {
fn alert(s: &str);
}
#[wasm_bindgen]
pub fn greet(name: &str) {
alert(&format!("Hello, {}!", name));
}
Now when I build:
cargo build --target=wasm32-unknown-unknown -vv
Compilation actually hangs not consuming even cpu resources:
Fresh unicode-xid v0.1.0
Fresh serde v1.0.37
Fresh fnv v1.0.6
Fresh num-traits v0.2.2
Fresh dtoa v0.4.2
Fresh itoa v0.4.1
Fresh proc-macro2 v0.3.6
Fresh serde_json v1.0.13
Fresh quote v0.5.1
Fresh syn v0.13.1
Fresh serde_derive_internals v0.23.0
Fresh serde_derive v1.0.37
Fresh wasm-bindgen-shared v0.2.1
Fresh wasm-bindgen-backend v0.2.1
Fresh wasm-bindgen-macro v0.2.1
Fresh wasm-bindgen v0.2.1
Compiling js-hello-world v0.1.0 (file:///home/markelovg/container/js-hello-world)
Running rustc --crate-name js_hello_world src/lib.rs --crate-type cdylib --emit=dep-info,link -C debuginfo=2 -C metadata=a4ec1c36c55eb3a5 --out-dir /home/markelovg/container/js-hello-world/target/wasm32-unknown-unknown/debug/deps --target wasm32-unknown-unknown -C incremental=/home/markelovg/container/js-hello-world/target/wasm32-unknown-unknown/debug/incremental -L dependency=/home/markelovg/container/js-hello-world/target/wasm32-unknown-unknown/debug/deps -L dependency=/home/markelovg/container/js-hello-world/target/debug/deps --extern wasm_bindgen=/home/markelovg/container/js-hello-world/target/wasm32-unknown-unknown/debug/deps/libwasm_bindgen-a2e136f9a24e6618.rlib
This libwasm_bingden-a2e136f9a24e6618.rlib dependency exists in my project but nothing then happens.
In task manager I have lld -flavor wasm -L ~/.rustup/toolchain/nightly-i686-unknown-linux-gnu/lib/rustlib/wasm32-unknown-unknown/lib ~/myproject/target/wasm32-/debug/deps/longnames.rcgu.o etc and it doesn't consume cpu