Print all features with --print target-features, including aliases and tied features
This commit is contained in:
parent
c5d82ed7a4
commit
102a5d867c
1 changed files with 19 additions and 16 deletions
|
@ -292,30 +292,33 @@ fn llvm_target_features(tm: &llvm::TargetMachine) -> Vec<(&str, &str)> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn print_target_features(sess: &Session, tm: &llvm::TargetMachine) {
|
fn print_target_features(sess: &Session, tm: &llvm::TargetMachine) {
|
||||||
let mut target_features = llvm_target_features(tm);
|
let mut llvm_target_features = llvm_target_features(tm);
|
||||||
|
let mut known_llvm_target_features = FxHashSet::<&'static str>::default();
|
||||||
let mut rustc_target_features = supported_target_features(sess)
|
let mut rustc_target_features = supported_target_features(sess)
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|(feature, _gate)| {
|
.map(|(feature, _gate)| {
|
||||||
for llvm_feature in to_llvm_features(sess, *feature) {
|
let desc = if let Some(llvm_feature) = to_llvm_features(sess, *feature).first() {
|
||||||
// LLVM asserts that these are sorted. LLVM and Rust both use byte comparison for these strings.
|
// LLVM asserts that these are sorted. LLVM and Rust both use byte comparison for these strings.
|
||||||
match target_features.binary_search_by_key(&llvm_feature, |(f, _d)| f).ok().map(
|
match llvm_target_features.binary_search_by_key(&llvm_feature, |(f, _d)| f).ok() {
|
||||||
|index| {
|
Some(index) => {
|
||||||
let (_f, desc) = target_features.remove(index);
|
known_llvm_target_features.insert(llvm_feature);
|
||||||
(*feature, desc)
|
llvm_target_features[index].1
|
||||||
},
|
}
|
||||||
) {
|
None => "",
|
||||||
Some(v) => return Some(v),
|
|
||||||
None => {}
|
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
None
|
""
|
||||||
|
};
|
||||||
|
(*feature, desc)
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
rustc_target_features.extend_from_slice(&[(
|
rustc_target_features.extend_from_slice(&[(
|
||||||
"crt-static",
|
"crt-static",
|
||||||
"Enables C Run-time Libraries to be statically linked",
|
"Enables C Run-time Libraries to be statically linked",
|
||||||
)]);
|
)]);
|
||||||
let max_feature_len = target_features
|
llvm_target_features.retain(|(f, _d)| !known_llvm_target_features.contains(f));
|
||||||
|
|
||||||
|
let max_feature_len = llvm_target_features
|
||||||
.iter()
|
.iter()
|
||||||
.chain(rustc_target_features.iter())
|
.chain(rustc_target_features.iter())
|
||||||
.map(|(feature, _desc)| feature.len())
|
.map(|(feature, _desc)| feature.len())
|
||||||
|
@ -327,10 +330,10 @@ fn print_target_features(sess: &Session, tm: &llvm::TargetMachine) {
|
||||||
println!(" {1:0$} - {2}.", max_feature_len, feature, desc);
|
println!(" {1:0$} - {2}.", max_feature_len, feature, desc);
|
||||||
}
|
}
|
||||||
println!("\nCode-generation features supported by LLVM for this target:");
|
println!("\nCode-generation features supported by LLVM for this target:");
|
||||||
for (feature, desc) in &target_features {
|
for (feature, desc) in &llvm_target_features {
|
||||||
println!(" {1:0$} - {2}.", max_feature_len, feature, desc);
|
println!(" {1:0$} - {2}.", max_feature_len, feature, desc);
|
||||||
}
|
}
|
||||||
if target_features.is_empty() {
|
if llvm_target_features.is_empty() {
|
||||||
println!(" Target features listing is not supported by this LLVM version.");
|
println!(" Target features listing is not supported by this LLVM version.");
|
||||||
}
|
}
|
||||||
println!("\nUse +feature to enable a feature, or -feature to disable it.");
|
println!("\nUse +feature to enable a feature, or -feature to disable it.");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue