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

Improved error reporting when target sysroot is missing. #37424

Merged
merged 1 commit into from
Nov 18, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/librustc_metadata/locator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ use creader::Library;
use schema::{METADATA_HEADER, rustc_version};

use rustc::hir::svh::Svh;
use rustc::session::Session;
use rustc::session::{config, Session};
use rustc::session::filesearch::{FileSearch, FileMatches, FileDoesntMatch};
use rustc::session::search_paths::PathKind;
use rustc::util::common;
Expand Down Expand Up @@ -355,6 +355,11 @@ impl<'a> Context<'a> {
"can't find crate for `{}`{}",
self.ident,
add);

if (self.ident == "std" || self.ident == "core")
&& self.triple != config::host_triple() {
err.note(&format!("the `{}` target may not be installed", self.triple));
}
err.span_label(self.span, &format!("can't find crate"));
err
};
Expand Down
18 changes: 18 additions & 0 deletions src/test/compile-fail/issue-37131.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// Tests that compiling for a target which is not installed will result in a helpful
// error message.

// compile-flags: --target=s390x-unknown-linux-gnu
// ignore s390x

// error-pattern:target may not be installed
fn main() { }
14 changes: 12 additions & 2 deletions src/tools/compiletest/src/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1334,8 +1334,18 @@ actual:\n\
// FIXME (#9639): This needs to handle non-utf8 paths
let mut args = vec![input_file.to_str().unwrap().to_owned(),
"-L".to_owned(),
self.config.build_base.to_str().unwrap().to_owned(),
format!("--target={}", target)];
self.config.build_base.to_str().unwrap().to_owned()];

// Optionally prevent default --target if specified in test compile-flags.
let custom_target = self.props.compile_flags
.iter()
.fold(false, |acc, ref x| acc || x.starts_with("--target"));

if !custom_target {
args.extend(vec![
format!("--target={}", target),
]);
}

if let Some(revision) = self.revision {
args.extend(vec![
Expand Down