diff options
| author | Jubilee Young <workingjubilee@gmail.com> | 2022-03-19 19:36:42 -0700 |
|---|---|---|
| committer | Jubilee Young <workingjubilee@gmail.com> | 2022-03-22 15:20:01 -0700 |
| commit | 990c297ffb86af3d6d80172effcee8fb8b83e304 (patch) | |
| tree | 015fae5d70c3be23ad953b63e37dcb231abd797d /compiler/rustc_codegen_llvm | |
| parent | b807d5970bd5b20d2dd22d76a05a4f65dbea03a5 (diff) | |
| download | rust-990c297ffb86af3d6d80172effcee8fb8b83e304.tar.gz rust-990c297ffb86af3d6d80172effcee8fb8b83e304.zip | |
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>
Diffstat (limited to 'compiler/rustc_codegen_llvm')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/llvm_util.rs | 9 |
1 files changed, 6 insertions, 3 deletions
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<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(); |
