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

can't run wasm-pack build on aarch64 #754

Closed
rolandoam opened this issue Dec 13, 2019 · 7 comments
Closed

can't run wasm-pack build on aarch64 #754

rolandoam opened this issue Dec 13, 2019 · 7 comments

Comments

@rolandoam
Copy link

🐛 Bug description

I'm trying to follow the tutorial at https://rustwasm.github.io/book/game-of-life/hello-world.html but I'm failing at the step wasm-pack build:

$ wasm-pack build
[INFO]: Checking for the Wasm target...
[INFO]: Compiling to Wasm...
   Compiling cfg-if v0.1.10
   Compiling wasm-bindgen v0.2.55
   Compiling console_error_panic_hook v0.1.6
   Compiling wasm-game-of-lift v0.1.0 (/workspace/personal/wasm-game-of-lift)
warning: function is never used: `set_panic_hook`
 --> src/utils.rs:1:1
  |
1 | pub fn set_panic_hook() {
  | ^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: `#[warn(dead_code)]` on by default

error: linker `rust-lld` not found
  |
  = note: No such file or directory (os error 2)

error: aborting due to previous error

error: could not compile `wasm-game-of-lift`.

To learn more, run the command again with --verbose.
Error: Compiling your crate to WebAssembly failed

🤔 Expected Behavior

It should build the project as explained in the tutorial

👟 Steps to reproduce

Follow the steps of the tutorial (https://rustwasm.github.io/book/game-of-life/hello-world.html) on an aarch64 machine.

🌍 Your environment

Include the relevant details of your environment.
wasm-pack version: 0.8.1
rustc version: 1.39.0
arch: aarch64

@csmoe
Copy link
Member

csmoe commented Dec 15, 2019

It's a rustc issue actually, cc rust-lang/rust#52362

@rolandoam
Copy link
Author

thanks. I read that thread before posting here, but it's not clear to me what's the actionable item: what's the path for me to got wasm-pack working on aarch64?

@rolandoam
Copy link
Author

Here's what I've done so far:

  • Install lld for my platform (aarch64)
  • build clean
  • RUSTFLAGS="-C linker=lld" wasm-pack build

It uses system lld instead of rust-lld, but it fails to link:

error: linking with `lld` failed: exit code: 1
  |
  = note: "lld" "lld" "-flavor" "wasm" "--no-threads" "-z" "stack-size=1048576" "--stack-first" "--allow-undefined" "--fatal-warnings" "--no-demangle" "--export-dynamic" "--no-entry" "-L" "/home/rolando/.rustup/toolchains/nightly-aarch64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-unknown/lib" "/workspace/personal/wasm-game-of-lift/target/wasm32-unknown-unknown/release/deps/wasm_game_of_lift.wasm_game_of_lift.1m39vor3-cgu.0.rcgu.o" "/workspace/personal/wasm-game-of-lift/target/wasm32-unknown-unknown/release/deps/wasm_game_of_lift.wasm_game_of_lift.1m39vor3-cgu.1.rcgu.o" "-o" "/workspace/personal/wasm-game-of-lift/target/wasm32-unknown-unknown/release/deps/wasm_game_of_lift.wasm" "--export" "greet" "--export" "__wbindgen_describe___wbg_alert_277e04e9c7cf615d" "--export" "__wbindgen_describe_greet" "--export" "__wbindgen_realloc" "--export" "__wbindgen_drop_anyref_slice" "--export" "__wbindgen_free" "--export" "__wbindgen_anyref_heap_live_count_impl" "--export" "__wbindgen_anyref_table_dealloc" "--export" "__wbindgen_anyref_table_alloc" "--export" "__wbindgen_malloc" "--export" "__wbindgen_exn_store" "--export" "__wbindgen_describe___wbg_stack_558ba5917b466edd" "--export" "__wbindgen_describe___wbg_new_59cb74e423758ede" "--export" "__wbindgen_describe___wbg_error_4bb6c2a97407129a" "--export=__heap_base" "--export=__data_end" "/workspace/personal/wasm-game-of-lift/target/wasm32-unknown-unknown/release/deps/wasm_game_of_lift.1pkjenqo96m835m7.rcgu.o" "--gc-sections" "-O2" "-L" "/workspace/personal/wasm-game-of-lift/target/wasm32-unknown-unknown/release/deps" "-L" "/workspace/personal/wasm-game-of-lift/target/release/deps" "-L" "/home/rolando/.rustup/toolchains/nightly-aarch64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-unknown/lib" "/workspace/personal/wasm-game-of-lift/target/wasm32-unknown-unknown/release/deps/libconsole_error_panic_hook-0a516942002e613a.rlib" "/workspace/personal/wasm-game-of-lift/target/wasm32-unknown-unknown/release/deps/libwasm_bindgen-a3574d0798b5de2d.rlib" "/workspace/personal/wasm-game-of-lift/target/wasm32-unknown-unknown/release/deps/libcfg_if-4bdfaf34eb74bdee.rlib" "/home/rolando/.rustup/toolchains/nightly-aarch64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-unknown/lib/libstd-c2131952dee6981b.rlib" "/home/rolando/.rustup/toolchains/nightly-aarch64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-unknown/lib/libpanic_abort-99d87686429b3c25.rlib" "/home/rolando/.rustup/toolchains/nightly-aarch64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-unknown/lib/libdlmalloc-b0e3b93b4b00306a.rlib" "/home/rolando/.rustup/toolchains/nightly-aarch64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-unknown/lib/libhashbrown-22547cbbd8b4170e.rlib" "/home/rolando/.rustup/toolchains/nightly-aarch64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-unknown/lib/librustc_std_workspace_alloc-a3b0a997514d182c.rlib" "/home/rolando/.rustup/toolchains/nightly-aarch64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-unknown/lib/libbacktrace-6bea3698c14490a7.rlib" "/home/rolando/.rustup/toolchains/nightly-aarch64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-unknown/lib/librustc_demangle-5e410385f7b0ce25.rlib" "/home/rolando/.rustup/toolchains/nightly-aarch64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-unknown/lib/libunwind-d22e73129408416c.rlib" "/home/rolando/.rustup/toolchains/nightly-aarch64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-unknown/lib/libcfg_if-6086fc8e9507d3a7.rlib" "/home/rolando/.rustup/toolchains/nightly-aarch64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-unknown/lib/liblibc-03c593ffc10dc85c.rlib" "/home/rolando/.rustup/toolchains/nightly-aarch64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-unknown/lib/liballoc-f45cf6dd5288fae6.rlib" "/home/rolando/.rustup/toolchains/nightly-aarch64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-unknown/lib/librustc_std_workspace_core-52967bf557793cb8.rlib" "/home/rolando/.rustup/toolchains/nightly-aarch64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-unknown/lib/libcore-e8d7b2177f178b16.rlib" "/home/rolando/.rustup/toolchains/nightly-aarch64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-unknown/lib/libcompiler_builtins-c75133791021e562.rlib" "--no-entry"
  = note: lld: error: /workspace/personal/wasm-game-of-lift/target/wasm32-unknown-unknown/release/deps/wasm_game_of_lift.wasm_game_of_lift.1m39vor3-cgu.1.rcgu.o: Bad section type

@Choons
Copy link

Choons commented Dec 23, 2019

same problem here. I'm trying to get it working on an aarch64 Android phone using Termux & their Rust pkg. Been trying to read their source code and they bundle in Cargo as well as maybe wasm32-unknown-unknown(?), but do so in a rustlib/aarch64-linux-android/lib directory instead of a separate 'wasm32-unknown-unknown' folder. Also, despite apparently using rustup in the build process, rustup isn't installed with the pkg and you can't install it with rust already installed. I tried that adding the 'wasm32-unknown-unknown' folder manually process, but it wasn't compatible even though the version numbers matched.

I saw 'wasm-ld' is installed in my packages along with a bunch off llvm stuff and Googled around finally finding this little gem https://medium.com/@richardanaya/write-web-assembly-with-llvm-fbee788b2817 . I tried llc -mtriple=wasm32-unknown-unknown -O3 -filetype=obj main.ll -o main.o
wasm-ld main.o -o main.wasm --no-entry -allow-undefined on that IR snippet he gave and it worked outputting a nice small .wasm file. SO I know something in there knows about wasm32-unknown-unknown! Now I am just trying to figure out how to get it all working together. I'm a Rust/WebAssembly noob so I'm not clear on what/how to get rust code to that IR code stage so hopefully this helps someone and they can help me too.

@Choons
Copy link

Choons commented Dec 24, 2019

I also found this exceptionally well-written guide about the inner workings of the rustc compiler that fills in a lot of gaps for me: https://rust-lang.github.io/rustc-guide/

@Choons
Copy link

Choons commented Dec 25, 2019

I posted the same question to Termux issues as well and the solution (at least for me) was to do pkg install rust-std-wasm32 instead of their general rust pkg. Not sure if that helps the OP here, but maybe it helps others like me.

@rolandoam
Copy link
Author

rolandoam commented Jan 4, 2020

thanks @Choons ! that did the trick. Here's what I did:

  • Uninstall local rust toolchain (rustup self uninstall)
  • Install rust from OS package manager (apt install -t testing rustc)
  • Install the wasm32 std lib the same way
  • Follow the setup from the wasm wiki

It finally worked :) thanks! I'll close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants