Skip to content

Commit ceff2ca

Browse files
committed
Tweak and add test for detecting libraries with mismatching target triples.
Closes #10814.
1 parent 830c82d commit ceff2ca

File tree

4 files changed

+38
-7
lines changed

4 files changed

+38
-7
lines changed

Diff for: src/librustc/metadata/loader.rs

+5-7
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,8 @@ impl<'a> Context<'a> {
307307
format!("found possibly newer version of crate `{}`",
308308
self.ident)
309309
} else if self.rejected_via_triple.len() > 0 {
310-
format!("found incorrect triple for crate `{}`", self.ident)
310+
format!("couldn't find crate `{}` with expected target triple {}",
311+
self.ident, self.triple)
311312
} else {
312313
format!("can't find crate for `{}`", self.ident)
313314
};
@@ -318,15 +319,12 @@ impl<'a> Context<'a> {
318319
};
319320
self.sess.span_err(self.span, message.as_slice());
320321

321-
let mismatches = self.rejected_via_triple.iter();
322322
if self.rejected_via_triple.len() > 0 {
323-
self.sess.span_note(self.span,
324-
format!("expected triple of {}",
325-
self.triple).as_slice());
323+
let mismatches = self.rejected_via_triple.iter();
326324
for (i, &CrateMismatch{ ref path, ref got }) in mismatches.enumerate() {
327325
self.sess.fileline_note(self.span,
328-
format!("crate `{}` path {}{}, triple {}: {}",
329-
self.ident, "#", i+1, got, path.display()).as_slice());
326+
format!("crate `{}`, path #{}, triple {}: {}",
327+
self.ident, i+1, got, path.display()).as_slice());
330328
}
331329
}
332330
if self.rejected_via_hash.len() > 0 {
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
-include ../tools.mk
2+
3+
# Issue #10814
4+
#
5+
# these are no_std to avoid having to have the standard library or any
6+
# linkers/assemblers for the relevant platform
7+
8+
all:
9+
$(RUSTC) foo.rs --target=i686-unknown-linux-gnu
10+
$(RUSTC) bar.rs --target=x86_64-unknown-linux-gnu 2>&1 \
11+
| grep "couldn't find crate .foo. with expected target triple x86_64-unknown-linux-gnu"

Diff for: src/test/run-make/mismatching-target-triples/bar.rs

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Copyright 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+
#![no_std]
11+
extern crate foo;

Diff for: src/test/run-make/mismatching-target-triples/foo.rs

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Copyright 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+
#![no_std]
11+
#![crate_type = "lib"]

0 commit comments

Comments
 (0)