File tree Expand file tree Collapse file tree 3 files changed +36
-3
lines changed Expand file tree Collapse file tree 3 files changed +36
-3
lines changed Original file line number Diff line number Diff line change @@ -217,7 +217,7 @@ use creader::Library;
217217use schema:: { METADATA_HEADER , rustc_version} ;
218218
219219use rustc:: hir:: svh:: Svh ;
220- use rustc:: session:: Session ;
220+ use rustc:: session:: { config , Session } ;
221221use rustc:: session:: filesearch:: { FileSearch , FileMatches , FileDoesntMatch } ;
222222use rustc:: session:: search_paths:: PathKind ;
223223use rustc:: util:: common;
@@ -355,6 +355,11 @@ impl<'a> Context<'a> {
355355 "can't find crate for `{}`{}" ,
356356 self . ident,
357357 add) ;
358+
359+ if ( self . ident == "std" || self . ident == "core" )
360+ && self . triple != config:: host_triple ( ) {
361+ err. note ( & format ! ( "the `{}` target may not be installed" , self . triple) ) ;
362+ }
358363 err. span_label ( self . span , & format ! ( "can't find crate" ) ) ;
359364 err
360365 } ;
Original file line number Diff line number Diff line change 1+ // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
2+ // file at the top-level directory of this distribution and at
3+ // http://rust-lang.org/COPYRIGHT.
4+ //
5+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+ // option. This file may not be copied, modified, or distributed
9+ // except according to those terms.
10+
11+ // Tests that compiling for a target which is not installed will result in a helpful
12+ // error message.
13+
14+ // compile-flags: --target=s390x-unknown-linux-gnu
15+ // ignore s390x
16+
17+ // error-pattern:target may not be installed
18+ fn main ( ) { }
Original file line number Diff line number Diff line change @@ -1334,8 +1334,18 @@ actual:\n\
13341334 // FIXME (#9639): This needs to handle non-utf8 paths
13351335 let mut args = vec ! [ input_file. to_str( ) . unwrap( ) . to_owned( ) ,
13361336 "-L" . to_owned( ) ,
1337- self . config. build_base. to_str( ) . unwrap( ) . to_owned( ) ,
1338- format!( "--target={}" , target) ] ;
1337+ self . config. build_base. to_str( ) . unwrap( ) . to_owned( ) ] ;
1338+
1339+ // Optionally prevent default --target if specified in test compile-flags.
1340+ let custom_target = self . props . compile_flags
1341+ . iter ( )
1342+ . fold ( false , |acc, ref x| acc || x. starts_with ( "--target" ) ) ;
1343+
1344+ if !custom_target {
1345+ args. extend ( vec ! [
1346+ format!( "--target={}" , target) ,
1347+ ] ) ;
1348+ }
13391349
13401350 if let Some ( revision) = self . revision {
13411351 args. extend ( vec ! [
You can’t perform that action at this time.
0 commit comments