rustwasm / book

The Rust and WebAssembly Book
https://rustwasm.github.io/docs/book/
MIT License
1.75k stars 211 forks source link

Cannot build first example #87

Closed slowkow closed 6 years ago

slowkow commented 6 years ago

I'm just trying to follow the steps in the tutorial. Any tips would be greatly appreciated! I may be missing something obvious, because I've never worked with Rust or wasm before.

https://rustwasm.github.io/book/game-of-life/hello-world.html

My steps:

cargo generate --git https://github.com/rustwasm/wasm-pack-template

# I called my project try-wasm

cd try-wasm

wasm-pack init

I get:

  [1/8] 🔧  Checking crate configuration...
  [2/8] 🎯  Adding WASM target...
- [3/8] 🌀  Compiling to WASM...
Compilation of your program failed. stderr:

Here is the full output:

Compilation of your program failed. stderr:
$ wasm-pack init

  [1/8] 🔧  Checking crate configuration...
  [2/8] 🎯  Adding WASM target...
- [3/8] 🌀  Compiling to WASM...
Compilation of your program failed. stderr:

    Updating registry `https://github.com/rust-lang/crates.io-index`
 Downloading wasm-bindgen v0.2.19
 Downloading wasm-bindgen-macro v0.2.19
 Downloading wasm-bindgen-macro-support v0.2.19
 Downloading wasm-bindgen-shared v0.2.19
 Downloading wasm-bindgen-backend v0.2.19
   Compiling proc-macro2 v0.4.15
   Compiling unicode-xid v0.1.0
   Compiling version_check v0.1.4
   Compiling ryu v0.2.6
   Compiling serde v1.0.75
   Compiling wasm-bindgen-shared v0.2.19
   Compiling itoa v0.4.2
   Compiling cfg-if v0.1.5
   Compiling log v0.4.4
   Compiling lazy_static v1.1.0
   Compiling quote v0.6.8
   Compiling syn v0.14.9
   Compiling serde_json v1.0.26
   Compiling serde_derive v1.0.75
   Compiling wasm-bindgen-backend v0.2.19
   Compiling wasm-bindgen-macro-support v0.2.19
   Compiling wasm-bindgen-macro v0.2.19
   Compiling wasm-bindgen v0.2.19
   Compiling try-wasm v0.1.0 (file:///Users/slowikow/Dropbox/work/github.com/slowkow/try-wasm)
warning: function is never used: `set_panic_hook`
  --> src/utils.rs:11:9
   |
11 |         pub fn set_panic_hook() {}
   |         ^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: #[warn(dead_code)] on by default

error: linking with `rust-lld` failed: signal: 6
  |
  = note: "rust-lld" "-flavor" "wasm" "-L" "/Users/slowikow/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/wasm32-unknown-unknown/lib" "/Users/slowikow/Dropbox/work/github.com/slowkow/try-wasm/target/wasm32-unknown-unknown/release/deps/umap_wasm.umap_wasm.bkno5jfr-cgu.0.rcgu.o" "/Users/slowikow/Dropbox/work/github.com/slowkow/try-wasm/target/wasm32-unknown-unknown/release/deps/umap_wasm.umap_wasm.bkno5jfr-cgu.1.rcgu.o" "/Users/slowikow/Dropbox/work/github.com/slowkow/try-wasm/target/wasm32-unknown-unknown/release/deps/umap_wasm.umap_wasm.bkno5jfr-cgu.2.rcgu.o" "-o" "/Users/slowikow/Dropbox/work/github.com/slowkow/try-wasm/target/wasm32-unknown-unknown/release/deps/umap_wasm.wasm" "/Users/slowikow/Dropbox/work/github.com/slowkow/try-wasm/target/wasm32-unknown-unknown/release/deps/umap_wasm.44e0i2zwvzwfmnu7.rcgu.o" "--gc-sections" "-O3" "-L" "/Users/slowikow/Dropbox/work/github.com/slowkow/try-wasm/target/wasm32-unknown-unknown/release/deps" "-L" "/Users/slowikow/Dropbox/work/github.com/slowkow/try-wasm/target/release/deps" "-L" "/Users/slowikow/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/wasm32-unknown-unknown/lib" "/Users/slowikow/Dropbox/work/github.com/slowkow/try-wasm/target/wasm32-unknown-unknown/release/deps/libwasm_bindgen-f9f62e4f9e995bb5.rlib" "/Users/slowikow/Dropbox/work/github.com/slowkow/try-wasm/target/wasm32-unknown-unknown/release/deps/libcfg_if-954cfacc8a40931a.rlib" "/Users/slowikow/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/wasm32-unknown-unknown/lib/libstd-b0efc82f64d03095.rlib" "/Users/slowikow/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/wasm32-unknown-unknown/lib/libpanic_abort-4f93017645c0d252.rlib" "/Users/slowikow/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/wasm32-unknown-unknown/lib/libunwind-c43a3d8cf78f9d5a.rlib" "/Users/slowikow/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/wasm32-unknown-unknown/lib/liblibc-68373f2b6bc18151.rlib" "/Users/slowikow/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/wasm32-unknown-unknown/lib/liballoc_system-40a64b71ec5a8f18.rlib" "/Users/slowikow/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/wasm32-unknown-unknown/lib/libdlmalloc-f6caffaf44cc60a0.rlib" "/Users/slowikow/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/wasm32-unknown-unknown/lib/liballoc-863f2b2485046aef.rlib" "/Users/slowikow/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/wasm32-unknown-unknown/lib/libcore-21433d3b7663b55b.rlib" "/Users/slowikow/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/wasm32-unknown-unknown/lib/libcompiler_builtins-bf63ca2c3bc4de53.rlib" "--no-threads" "-z" "stack-size=1048576" "--stack-first" "--allow-undefined" "--no-entry" "--export-table"
  = note: dyld: Library not loaded: @rpath/libLLVM.dylib
            Referenced from: /Users/slowikow/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/bin/rust-lld
            Reason: image not found

error: aborting due to previous error

error: Could not compile `try-wasm`.

To learn more, run the command again with --verbose.


Versions:

cargo 1.28.0 (96a2c7d16 2018-07-13)

wasm-pack 0.4.2

rustc 1.28.0 (9634041f0 2018-07-30)

rustup 1.13.0 (ea9259c1b 2018-07-16)

$ rust-lldb --version
lldb-902.0.79.7
  Swift-4.1
fitzgen commented 6 years ago

This was an upstream rustc bug that has since been fixed in the latest nightlies

rustup update nightly

should do the trick for you!

If not, feel free to reopen :)

fitzgen commented 6 years ago

Looks like it still isn't fixed on OSX; follow https://github.com/rust-lang/rust/issues/53813#issuecomment-418050165 for updates