Skip to content

Commit acc63bc

Browse files
committed
Add support for target aliases
1 parent e1cce06 commit acc63bc

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

compiler/rustc_session/src/config.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1433,7 +1433,7 @@ fn parse_target_triple(matches: &getopts::Matches, error_format: ErrorOutputType
14331433
early_error(error_format, &format!("target file {:?} does not exist", path))
14341434
})
14351435
}
1436-
Some(target) => TargetTriple::TargetTriple(target),
1436+
Some(target) => TargetTriple::from_alias(target),
14371437
_ => TargetTriple::from_triple(host_triple()),
14381438
}
14391439
}

compiler/rustc_target/src/spec/mod.rs

+18
Original file line numberDiff line numberDiff line change
@@ -1800,6 +1800,24 @@ impl TargetTriple {
18001800
Ok(TargetTriple::TargetPath(canonicalized_path))
18011801
}
18021802

1803+
/// Creates a target triple from its alias
1804+
pub fn from_alias(triple: String) -> Self {
1805+
macro_rules! target_aliases {
1806+
( $(($alias:literal, $target:literal ),)+ ) => {
1807+
match triple.as_str() {
1808+
$( $alias => TargetTriple::from_triple($target), )+
1809+
_ => TargetTriple::TargetTriple(triple),
1810+
}
1811+
}
1812+
}
1813+
1814+
target_aliases! {
1815+
// `x86_64-pc-solaris` is an alias for `x86_64_sun_solaris` for backwards compatibility reasons.
1816+
// (See <https://github.com./rust-lang/rust/issues/40531>.)
1817+
("x86_64-pc-solaris", "x86_64-sun-solaris"),
1818+
}
1819+
}
1820+
18031821
/// Returns a string triple for this target.
18041822
///
18051823
/// If this target is a path, the file name (without extension) is returned.

0 commit comments

Comments
 (0)