Rust: Provide a better error message when the target sysroot is not installed

Created on 13 Oct 2016  路  2Comments  路  Source: rust-lang/rust

Today when you compile for a target that does not exist rustc gives the standard message for failing to find a crate, for std. We can and should be more explicit about what this means. Actually what is almost certainly happening is that you don't have that target installed:

$ rustc --target=asmjs-unknown-emscripten hello.rs
error[E0463]: can't find crate for `std`

error: aborting due to previous error 

It could instead say:

$ rustc --target=asmjs-unknown-emscripten hello.rs
error[E0463]: can't find crate for `std`
note: the `asmjs-unknown-emscripten` target is not installed

error: aborting due to previous error 

A reasonable heuristic for printing this might be if the crate is named std or core and the sysroot is not overridden.

A-diagnostics E-easy

Most helpful comment

@brson When I run rustc --target=asmjs-unknown-emscripten hello.rs on rustc 1.14.0-nightly (ad19c32a5 2016-10-06) I get the error: error: Could not create LLVM TargetMachine for triple: asmjs-unknown-emscripten: No available targets are compatible with this triple.

All 2 comments

@brson When I run rustc --target=asmjs-unknown-emscripten hello.rs on rustc 1.14.0-nightly (ad19c32a5 2016-10-06) I get the error: error: Could not create LLVM TargetMachine for triple: asmjs-unknown-emscripten: No available targets are compatible with this triple.

I would like to try my hand at this if no one else has picked it up already.

I am fairly new to rust, so I might need some assistance getting the pull request into a something resembling a reasonable state.

Was this page helpful?
0 / 5 - 0 ratings