Skip to content

Commit 0b1e718

Browse files
authored
Rollup merge of #80073 - kulikjak:add-target-alias-support, r=varkor
Add support for target aliases Closes #68214, see that for more info. `@varkor`
2 parents a5b1d22 + acc63bc commit 0b1e718

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

compiler/rustc_session/src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1491,7 +1491,7 @@ fn parse_target_triple(matches: &getopts::Matches, error_format: ErrorOutputType
14911491
early_error(error_format, &format!("target file {:?} does not exist", path))
14921492
})
14931493
}
1494-
Some(target) => TargetTriple::TargetTriple(target),
1494+
Some(target) => TargetTriple::from_alias(target),
14951495
_ => TargetTriple::from_triple(host_triple()),
14961496
}
14971497
}

compiler/rustc_target/src/spec/mod.rs

Lines changed: 18 additions & 0 deletions
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)