Rollup merge of #80073 - kulikjak:add-target-alias-support, r=varkor

Add support for target aliases

Closes #68214, see that for more info.

`@varkor`
This commit is contained in:
Yuki Okushi 2020-12-17 11:44:08 +09:00 committed by GitHub
commit 0b1e71899e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 1 deletions

View File

@ -1491,7 +1491,7 @@ fn parse_target_triple(matches: &getopts::Matches, error_format: ErrorOutputType
early_error(error_format, &format!("target file {:?} does not exist", path)) early_error(error_format, &format!("target file {:?} does not exist", path))
}) })
} }
Some(target) => TargetTriple::TargetTriple(target), Some(target) => TargetTriple::from_alias(target),
_ => TargetTriple::from_triple(host_triple()), _ => TargetTriple::from_triple(host_triple()),
} }
} }

View File

@ -1800,6 +1800,24 @@ pub fn from_path(path: &Path) -> Result<Self, io::Error> {
Ok(TargetTriple::TargetPath(canonicalized_path)) Ok(TargetTriple::TargetPath(canonicalized_path))
} }
/// Creates a target triple from its alias
pub fn from_alias(triple: String) -> Self {
macro_rules! target_aliases {
( $(($alias:literal, $target:literal ),)+ ) => {
match triple.as_str() {
$( $alias => TargetTriple::from_triple($target), )+
_ => TargetTriple::TargetTriple(triple),
}
}
}
target_aliases! {
// `x86_64-pc-solaris` is an alias for `x86_64_sun_solaris` for backwards compatibility reasons.
// (See <https://github.com/rust-lang/rust/issues/40531>.)
("x86_64-pc-solaris", "x86_64-sun-solaris"),
}
}
/// Returns a string triple for this target. /// Returns a string triple for this target.
/// ///
/// If this target is a path, the file name (without extension) is returned. /// If this target is a path, the file name (without extension) is returned.