Filter for all features instead of any
Adds regression tests for feature logic Co-authored-by: bjorn3 <bjorn3@users.noreply.github.com> Co-authored-by: Simonas Kazlauskas <git@kazlauskas.me>
This commit is contained in:
parent
b807d5970b
commit
990c297ffb
2 changed files with 70 additions and 3 deletions
|
@ -229,6 +229,8 @@ pub fn check_tied_features(
|
|||
None
|
||||
}
|
||||
|
||||
// Used to generate cfg variables and apply features
|
||||
// Must express features in the way Rust understands them
|
||||
pub fn target_features(sess: &Session) -> Vec<Symbol> {
|
||||
let target_machine = create_informational_target_machine(sess);
|
||||
let mut features: Vec<Symbol> =
|
||||
|
@ -238,13 +240,14 @@ pub fn target_features(sess: &Session) -> Vec<Symbol> {
|
|||
if sess.is_nightly_build() || gate.is_none() { Some(feature) } else { None }
|
||||
})
|
||||
.filter(|feature| {
|
||||
// check that all features in a given smallvec are enabled
|
||||
for llvm_feature in to_llvm_features(sess, feature) {
|
||||
let cstr = SmallCStr::new(llvm_feature);
|
||||
if unsafe { llvm::LLVMRustHasFeature(target_machine, cstr.as_ptr()) } {
|
||||
return true;
|
||||
if !unsafe { llvm::LLVMRustHasFeature(target_machine, cstr.as_ptr()) } {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
false
|
||||
true
|
||||
})
|
||||
.map(|feature| Symbol::intern(feature))
|
||||
.collect();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue