librustc_back: filter targets for only valid ones
Since we can know which targets are instantiable on a particular host, it does not make sense to list invalid targets in the target print code. Filter the list of targets to only include the targets that can be instantiated.
This commit is contained in:
parent
bd194a77d5
commit
54c61ff959
2 changed files with 10 additions and 2 deletions
|
|
@ -71,7 +71,7 @@ macro_rules! supported_targets {
|
|||
$(mod $module;)*
|
||||
|
||||
/// List of supported targets
|
||||
pub const TARGETS: &'static [&'static str] = &[$($triple),*];
|
||||
const TARGETS: &'static [&'static str] = &[$($triple),*];
|
||||
|
||||
fn load_specific(target: &str) -> TargetResult {
|
||||
match target {
|
||||
|
|
@ -91,6 +91,14 @@ macro_rules! supported_targets {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn get_targets() -> Box<Iterator<Item=String>> {
|
||||
Box::new(TARGETS.iter().filter_map(|t| -> Option<String> {
|
||||
load_specific(t)
|
||||
.map(|t| t.llvm_target)
|
||||
.ok()
|
||||
}))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test_json_encode_decode {
|
||||
use serialize::json::ToJson;
|
||||
|
|
|
|||
|
|
@ -609,7 +609,7 @@ impl RustcDefaultCalls {
|
|||
for req in &sess.opts.prints {
|
||||
match *req {
|
||||
PrintRequest::TargetList => {
|
||||
let mut targets = rustc_back::target::TARGETS.to_vec();
|
||||
let mut targets = rustc_back::target::get_targets().collect::<Vec<String>>();
|
||||
targets.sort();
|
||||
println!("{}", targets.join("\n"));
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue