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

OS System Rust package pecularities cause wasm-pack build not to work on Quickstart from wasm-book #1342

Closed
daidoji opened this issue Oct 27, 2023 · 2 comments · Fixed by #1343

Comments

@daidoji
Copy link
Contributor

daidoji commented Oct 27, 2023

🐛 Bug description

Summary:

  1. I attempted to complete the Quickstart "hello-wasm" from the wasm-book.
  2. Got error for no wasm32-unknown-unknown target.
  3. Followed instructions for non-rustup install of that target with slight alterations for my particular OS below.
  4. Still got a weird error
  5. Followed up and explored a bit and point out where I think the issue is in wasm-build.

Got this error.

(keri) daidoji@darkstar:~/ssi/cesride/wasm$ wasm-pack build
[INFO]: 🎯  Checking for the Wasm target...
Error: wasm32-unknown-unknown target not found in sysroot: "/usr"

Used rustc from the following path: "/usr/bin/rustc"
It looks like Rustup is not being used. For non-Rustup setups, the wasm32-unknown-unknown target needs to be installed manually. See https://rustwasm.github.io/wasm-pack/book/prerequisites/non-rustup-setups.html on how to do this.

Caused by: wasm32-unknown-unknown target not found in sysroot: "/usr"

Used rustc from the following path: "/usr/bin/rustc"
It looks like Rustup is not being used. For non-Rustup setups, the wasm32-unknown-unknown target needs to be installed manually. See https://rustwasm.github.io/wasm-pack/book/prerequisites/non-rustup-setups.html on how to do this.

Attempted to follow the instructions in the error message (ie https://rustwasm.github.io/wasm-pack/book/prerequisites/non-rustup-setups.html). However, I'm using Slackware Linux (-current) and the system rust package (not installed with rustup). Slackware seems to install rustlib to /usr/lib64/rustlib/. So I put the files there thinking it would be no big deal.

Got the same error. ie)

(keri) daidoji@darkstar:~/ssi/cesride/wasm$ rustc --print sysroot
/usr
(keri) daidoji@darkstar:~/ssi/cesride/wasm$ ls /usr/lib64/rustlib/
components   manifest-cargo.gz           manifest-rust-src.gz                           manifest-rustfmt-preview.gz  uninstall.sh*
etc/         manifest-clippy-preview.gz  manifest-rust-std-x86_64-unknown-linux-gnu.gz  rust-installer-version       wasm32-unknown-unknown/
install.log  manifest-rust-docs.gz       manifest-rustc.gz                              src/                         x86_64-unknown-linux-gnu/

Then I ran with RUST_LOG, wasm-build is def looking in /usr/lib/rustlib

(keri) daidoji@darkstar:~/ssi/cesride/wasm$ RUST_LOG=info wasm-pack build
[INFO  wasm_pack::command] Running build command...
[INFO  wasm_pack::command::build] Checking rustc version...
[INFO  wasm_pack::command::build] rustc version is 70.
[INFO  wasm_pack::command::build] Checking crate configuration...
[INFO  wasm_pack::command::build] Crate is correctly configured.
[INFO  wasm_pack::command::build] Checking for wasm-target...
[INFO]: 🎯  Checking for the Wasm target...
[INFO  wasm_pack::build::wasm_target] Looking for wasm32-unknown-unknown in "/usr/lib/rustlib"
[INFO  wasm_pack::build::wasm_target] Failed to find wasm32-unknown-unknown in "/usr/lib/rustlib"
...

However, rustc seems to know where those target files are located

(keri) daidoji@darkstar:~/ssi/cesride/wasm/hello-wasm$ rustc --target wasm32-unknown-unknown --print target-libdir
/usr/lib64/rustlib/wasm32-unknown-unknown/lib

I tried putting a softlink where wasm-build is expecting those files to live but then I got this weird error but I'm too new to Rust to figure out what that means exactly.

(keri) daidoji@darkstar:~/ssi/cesride/waqm/hello-wasm$ sudo ln -s /usr/lib64/rustlib /usr/lib/rustlib
(keri) daidoji@darkstar:~/ssi/cesride/wasm/hello-wasm$ wasm-pack build
[INFO]: 🎯  Checking for the Wasm target...
[INFO]: 🌀  Compiling to Wasm...
   Compiling proc-macro2 v1.0.69
   Compiling unicode-ident v1.0.12
   Compiling wasm-bindgen-shared v0.2.87
   Compiling once_cell v1.18.0
   Compiling bumpalo v3.14.0
   Compiling log v0.4.20
   Compiling wasm-bindgen v0.2.87
   Compiling cfg-if v1.0.0
error[E0514]: found crate `core` compiled by an incompatible version of rustc
  |
  = note: the following crate versions were found:
          crate `core` compiled by rustc 1.70.0 (90c541806 2023-05-31): /usr/lib64/rustlib/wasm32-unknown-unknown/lib/libcore-fd7d76a056998c87.rlib
  = help: please recompile that crate using this compiler (rustc 1.70.0 (90c541806 2023-05-31) (built from a source tarball)) (consider running `cargo clean` first)

error[E0514]: found crate `compiler_builtins` compiled by an incompatible version of rustc
  |
  = note: the following crate versions were found:
          crate `compiler_builtins` compiled by rustc 1.70.0 (90c541806 2023-05-31): /usr/lib64/rustlib/wasm32-unknown-unknown/lib/libcompiler_builtins-b4a59f6f2c0f4614.rlib
  = help: please recompile that crate using this compiler (rustc 1.70.0 (90c541806 2023-05-31) (built from a source tarball)) (consider running `cargo clean` first)

For more information about this error, try `rustc --explain E0514`.
error: could not compile `cfg-if` (lib) due to 2 previous errors
warning: build failed, waiting for other jobs to finish...
Error: Compiling your crate to WebAssembly failed
Caused by: Compiling your crate to WebAssembly failed
Caused by: failed to execute `cargo build`: exited with exit status: 101
  full command: cd "/home/daidoji/ssi/cesride/wasm/hello-wasm" && "cargo" "build" "--lib" "--release" "--target" "wasm32-unknown-unknown"

🤔 Expected Behavior

The Quickstart Hello-wasm guide should work even though I'm using a non-rustup env.

👟 Steps to reproduce

Oh sorry, there should be enough from above. I literally couldn't get through the quickstart guide so running it on a slackware system should produce the same issue.

Wasm-pack starting point

Looks like this is the guilty culprit. Instead of using this and instead using whatever rustc --target wasm32-unknown-unknown --print target-libdir is doing to locate that directory seems like the right way to go about it. Glad to submit a PR if someone can point me in the right direction. Still learning Rust and wasm-pack.

🌍 Your environment

Include the relevant details of your environment.
wasm-pack version: wasm-pack 0.12.1
rustc version: rustc 1.70.0 (90c541806 2023-05-31) (built from a source tarball)

@daidoji
Copy link
Contributor Author

daidoji commented Oct 27, 2023

@drager
Copy link
Member

drager commented Nov 13, 2023

Fixed in #1343

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

Successfully merging a pull request may close this issue.

2 participants