From 990c297ffb86af3d6d80172effcee8fb8b83e304 Mon Sep 17 00:00:00 2001 From: Jubilee Young Date: Sat, 19 Mar 2022 19:36:42 -0700 Subject: Filter for all features instead of any Adds regression tests for feature logic Co-authored-by: bjorn3 Co-authored-by: Simonas Kazlauskas --- compiler/rustc_codegen_llvm/src/llvm_util.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'compiler/rustc_codegen_llvm/src') diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs b/compiler/rustc_codegen_llvm/src/llvm_util.rs index e70866a3b70..abcdb81c0e2 100644 --- a/compiler/rustc_codegen_llvm/src/llvm_util.rs +++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs @@ -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 { let target_machine = create_informational_target_machine(sess); let mut features: Vec = @@ -238,13 +240,14 @@ pub fn target_features(sess: &Session) -> Vec { 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(); -- cgit 1.4.1-3-g733a5