Skip to content

Commit

Permalink
Add support for target aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
kulikjak committed Dec 16, 2020
1 parent e1cce06 commit acc63bc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/rustc_session/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1433,7 +1433,7 @@ fn parse_target_triple(matches: &getopts::Matches, error_format: ErrorOutputType
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()),
}
}
Expand Down
18 changes: 18 additions & 0 deletions compiler/rustc_target/src/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1800,6 +1800,24 @@ impl TargetTriple {
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.
///
/// If this target is a path, the file name (without extension) is returned.
Expand Down

0 comments on commit acc63bc

Please sign in to comment.