Skip to content

Commit

Permalink
Rollup merge of rust-lang#49158 - varkor:compiletest-triples, r=rkruppe
Browse files Browse the repository at this point in the history
Make compiletest do exact matching on triples

This avoids the issues of the previous substring matching, ensuring `ARCH_TABLE` and `OS_TABLE` will no longer contain redundant entries. Fixes rust-lang#48893.

r? @rkruppe
  • Loading branch information
kennytm committed Mar 22, 2018
2 parents 20eaf35 + 61e1fbc commit c945725
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/test/codegen/abi-main-signature-16bit-c-int.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
// ignore-mips
// ignore-mips64
// ignore-powerpc
// ignore-powerpc64
// ignore-s390x
// ignore-sparc
// ignore-wasm32
Expand Down
2 changes: 2 additions & 0 deletions src/test/codegen/fastcall-inreg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
// ignore-mips
// ignore-mips64
// ignore-msp430
// ignore-powerpc64
// ignore-powerpc64le
// ignore-powerpc
// ignore-r600
// ignore-amdgcn
Expand Down
2 changes: 2 additions & 0 deletions src/test/codegen/global_asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
// ignore-mips
// ignore-mips64
// ignore-msp430
// ignore-powerpc64
// ignore-powerpc64le
// ignore-powerpc
// ignore-r600
// ignore-amdgcn
Expand Down
2 changes: 2 additions & 0 deletions src/test/codegen/global_asm_include.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
// ignore-mips
// ignore-mips64
// ignore-msp430
// ignore-powerpc64
// ignore-powerpc64le
// ignore-powerpc
// ignore-r600
// ignore-amdgcn
Expand Down
2 changes: 2 additions & 0 deletions src/test/codegen/global_asm_x2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
// ignore-mips
// ignore-mips64
// ignore-msp430
// ignore-powerpc64
// ignore-powerpc64le
// ignore-powerpc
// ignore-r600
// ignore-amdgcn
Expand Down
1 change: 1 addition & 0 deletions src/test/codegen/repr-transparent-aggregates-1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
// ignore-mips
// ignore-mips64
// ignore-powerpc
// ignore-powerpc64
// See repr-transparent.rs

#![crate_type="lib"]
Expand Down
33 changes: 26 additions & 7 deletions src/tools/compiletest/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,42 +14,59 @@ use common::Config;
/// Conversion table from triple OS name to Rust SYSNAME
const OS_TABLE: &'static [(&'static str, &'static str)] = &[
("android", "android"),
("androideabi", "android"),
("bitrig", "bitrig"),
("cloudabi", "cloudabi"),
("darwin", "macos"),
("dragonfly", "dragonfly"),
("emscripten", "emscripten"),
("freebsd", "freebsd"),
("fuchsia", "fuchsia"),
("haiku", "haiku"),
("ios", "ios"),
("l4re", "l4re"),
("linux", "linux"),
("mingw32", "windows"),
("netbsd", "netbsd"),
("openbsd", "openbsd"),
("redox", "redox"),
("solaris", "solaris"),
("win32", "windows"),
("windows", "windows"),
("solaris", "solaris"),
("emscripten", "emscripten"),
];

const ARCH_TABLE: &'static [(&'static str, &'static str)] = &[
("aarch64", "aarch64"),
("amd64", "x86_64"),
("arm", "arm"),
("arm64", "aarch64"),
("armv4t", "arm"),
("armv5te", "arm"),
("armv7", "arm"),
("armv7s", "arm"),
("asmjs", "asmjs"),
("hexagon", "hexagon"),
("i386", "x86"),
("i586", "x86"),
("i686", "x86"),
("mips64", "mips64"),
("mips", "mips"),
("mips64", "mips64"),
("mips64el", "mips64"),
("mipsel", "mips"),
("msp430", "msp430"),
("powerpc", "powerpc"),
("powerpc64", "powerpc64"),
("powerpc64le", "powerpc64"),
("s390x", "s390x"),
("sparc", "sparc"),
("sparc64", "sparc64"),
("sparcv9", "sparc64"),
("thumbv6m", "thumb"),
("thumbv7em", "thumb"),
("thumbv7m", "thumb"),
("wasm32", "wasm32"),
("x86_64", "x86_64"),
("xcore", "xcore"),
("asmjs", "asmjs"),
("wasm32", "wasm32"),
];

pub fn matches_os(triple: &str, name: &str) -> bool {
Expand All @@ -58,16 +75,18 @@ pub fn matches_os(triple: &str, name: &str) -> bool {
if triple == "wasm32-unknown-unknown" {
return name == "emscripten" || name == "wasm32-bare"
}
let triple: Vec<_> = triple.split('-').collect();
for &(triple_os, os) in OS_TABLE {
if triple.contains(triple_os) {
if triple.contains(&triple_os) {
return os == name;
}
}
panic!("Cannot determine OS from triple");
}
pub fn get_arch(triple: &str) -> &'static str {
let triple: Vec<_> = triple.split('-').collect();
for &(triple_arch, arch) in ARCH_TABLE {
if triple.contains(triple_arch) {
if triple.contains(&triple_arch) {
return arch;
}
}
Expand Down

0 comments on commit c945725

Please sign in to comment.