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

wasm32-unknown-unkown target without rustup? #545

Closed
CodeMan99 opened this issue Feb 16, 2019 · 10 comments
Closed

wasm32-unknown-unkown target without rustup? #545

CodeMan99 opened this issue Feb 16, 2019 · 10 comments
Assignees
Labels
Milestone

Comments

@CodeMan99
Copy link

I am trying to follow the Rust and WebAssembly tutorial, but I am stuck at "Build the Project".

What I have done

I am completely new to both rust and WebAssembly, so here is literally everything I have done, in order.

  1. git clone git@github.com:rust-lang/rust.git.
  2. Compiled rust from source.
  3. Installed rust at ~/.local/bin/rustc.
  4. git clone git@github.com:rust-lang/cargo.git.
  5. Compiled cargo from source (using the stage0 cargo binary from step 2).
  6. cp target/release/cargo ~/.local/bin/cargo.
  7. Setup ~/.cargo/config with install.root as ~/.local.
  8. cargo install cargo-generate.
  9. cargo generate --git https://github.com/rustwasm/wasm-pack-template.
  10. cargo install wasm-pack - and yes, I really did this after generating my project. The documentation is lacking here.
  11. I followed reddit directions to install "wasm32-unknown-unknown" and verified the result is in ~/.local/lib/rustlib/wasm32-unknown-unknown.

ERRORS

It is at this point I am now stuck.

wasm-pack error

wasm-pack build is complaining that I don't have rustup installed. Which is true, but I don't really understand why that's a problem.

cargo error

cargo build --target=wasm32-unknown-unknown is throwing the following error.

error: failed to run `rustc` to learn about target-specific information

Caused by:
  process didn't exit successfully: `sccache rustc - --crate-name ___ --print=file-names --target wasm32-unknown-unknown --crate-type bin --crate-type rlib --crate-type dylib --crate-type cdylib --crate-type staticlib --crate-type proc-macro` (exit code: 1)
--- stderr
error: Could not create LLVM TargetMachine for triple: wasm32-unknown-unknown: No available targets are compatible with triple "wasm32-unknown-unknown"

rustup installer error

curl https://sh.rustup.rs -sSf | sh is complaining that I have an existing install of rust.

info: downloading installer
error: it looks like you have an existing installation of Rust at:
error: /home/code_m/.local/bin
error: rustup cannot be installed alongside Rust. Please uninstall first
error: if this is what you want, restart the installation with `-y'
error: cannot install while Rust is installed

This error also doesn't make any sense to me since it appears that rustup does more than just install rustc.

Report Elsewhere

I would really rather not completely start over just to install the rustup tool. Please help me by telling me where else I should be reporting some of these errors.

@Pauan
Copy link
Contributor

Pauan commented Feb 16, 2019

since it appears that rustup does more than just install rustc.

Indeed, rustup is the official all-in-one Rust tool for:

  • Installing and managing multiple Rust versions (including having both Stable and Nightly installed at the same time, which is very useful)

  • Installing and managing multiple build targets (including wasm32-unknown-unknown)

  • Easily updating Rust to the latest version

Is there a particular reason you chose to manually compile Rust rather than use rustup?

What OS are you using? It looks like some flavor of Linux.

Which is true, but I don't really understand why that's a problem.

wasm-pack installs itself into the rustup directory, to avoid polluting your system with things spread all over the place.

It also uses rustup to check whether you have the wasm32-unknown-unknown target installed, and if not it then installs it.

Since rustup is the standard way to use Rust, and since it is supported across all platforms, it's easier for wasm-pack to use it instead of creating custom ad-hoc solutions.

But maybe there's a way we can support using wasm-pack without rustup?

The documentation is lacking here.

Is there anything we can do to improve that?

I took a look at the tutorial and it makes it clear that you need rustup, and it also says to install wasm-pack first, and then create the project.

Are you following a different tutorial somewhere else?

@CodeMan99
Copy link
Author

Is there anything we can do to improve that?

I took a look at the tutorial and it makes it clear that you need rustup, and it also says to install wasm-pack first, and then create the project.

I think the simplest thing would be to give an example usage when defining the tool for the first time.

The reason I didn't install it right away is that is was clear to me that wasm-pack was a collection of multiple tools. There was a possibility in my mind that the configuration from wasm-pack-template would allow cargo to take over the building portion.

Giving an example usage of wasm-pack would help indicate the tutorial will be using the tool directly for building later.

@CodeMan99 CodeMan99 reopened this Feb 16, 2019
@CodeMan99
Copy link
Author

What OS are you using? It looks like some flavor of Linux.

I am running Ubuntu 18.04.2 in a Virtual Box environment.

@fitzgen
Copy link
Member

fitzgen commented Feb 19, 2019

I think it is worth supporting non-rustup workflows if possible, or at least if the w32-u-u target is installed, we shouldn't need rustup and if the target is not installed and rustup is not available, we should have a meaningful/helpful error message.


I think the simplest thing would be to give an example usage when defining the tool for the first time.

FWIW, it says right above there that you need rustup:

You will need the standard Rust toolchain, including rustup, rustc, and cargo.

@Pauan
Copy link
Contributor

Pauan commented Feb 19, 2019

@fitzgen or at least if the w32-u-u target is installed

Currently it uses rustup to detect whether wasm32-unknown-unknown is installed, so how would we do that without rustup?

@CodeMan99
Copy link
Author

@fitzgen That's precisely the issue I had. The words

the standard Rust toolchain

meant absolutely nothing to me. I had never used the rust toolchain before, so there was still no indication (for me) that the rustup tool did more than install rustc.

That said, in the text you quoted I was referring to wasm-pack. Again, I had never seen the tool before. So without an example output I felt lost. To be completely fair, the cli gif in the README is pretty good. If that same gif appeared in rustwasm & wasm-pack books, it could be helpful for folk who understand by example.

@fitzgen
Copy link
Member

fitzgen commented Feb 19, 2019

Currently it uses rustup to detect whether wasm32-unknown-unknown is installed, so how would we do that without rustup?

We could try compiling a hello world (add a and b) crate to wasm and see if it works or not. This is essentially what configure does when checking whether there is a working C/C++ compiler.

@ashleygwilliams
Copy link
Member

there's a somewhat stale PR that was attempting to do this- i am going to work on a release today for tomorrow and i'll see if we can get it in

@ashleygwilliams
Copy link
Member

#451

@ashleygwilliams
Copy link
Member

this should be solved with #552 which landed as #577 - it will be released in 0.7.0 tonight! please try it out and let us know how it works for you! if you have any trouble please file a new issue :)

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

5 participants