about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src
diff options
context:
space:
mode:
authorAndrew Sun <me@andrewsun.com>2021-01-07 23:25:19 -0500
committerAndrew Sun <me@andrewsun.com>2021-01-07 23:25:19 -0500
commitbc4c5bac408f96db0a0e1c8934ff0c403b3986d3 (patch)
treeac9c7c9aa95b6801ba9c00e564eb133871f440aa /compiler/rustc_codegen_llvm/src
parentbf801590503447cc5b1ddd520b39d2957d90368b (diff)
downloadrust-bc4c5bac408f96db0a0e1c8934ff0c403b3986d3.tar.gz
rust-bc4c5bac408f96db0a0e1c8934ff0c403b3986d3.zip
Use LLVMGetHostCPUFeatures instead of stdsimd
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
-rw-r--r--compiler/rustc_codegen_llvm/src/lib.rs1
-rw-r--r--compiler/rustc_codegen_llvm/src/llvm/ffi.rs4
-rw-r--r--compiler/rustc_codegen_llvm/src/llvm_util.rs18
3 files changed, 13 insertions, 10 deletions
diff --git a/compiler/rustc_codegen_llvm/src/lib.rs b/compiler/rustc_codegen_llvm/src/lib.rs
index 502f3b44af1..92ac770aca5 100644
--- a/compiler/rustc_codegen_llvm/src/lib.rs
+++ b/compiler/rustc_codegen_llvm/src/lib.rs
@@ -12,7 +12,6 @@
 #![feature(in_band_lifetimes)]
 #![feature(nll)]
 #![feature(or_patterns)]
-#![feature(stdsimd)]
 #![recursion_limit = "256"]
 
 use back::write::{create_informational_target_machine, create_target_machine};
diff --git a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs
index 707aaa2b53f..e359d9f8c9c 100644
--- a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs
+++ b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs
@@ -1708,6 +1708,10 @@ extern "C" {
         PM: &PassManager<'_>,
     );
 
+    pub fn LLVMGetHostCPUFeatures() -> *mut c_char;
+
+    pub fn LLVMDisposeMessage(message: *mut c_char);
+
     // Stuff that's in llvm-wrapper/ because it's not upstream yet.
 
     /// Opens an object file.
diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs b/compiler/rustc_codegen_llvm/src/llvm_util.rs
index 2da06e6babe..e0771313f76 100644
--- a/compiler/rustc_codegen_llvm/src/llvm_util.rs
+++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs
@@ -8,9 +8,8 @@ use rustc_session::config::PrintRequest;
 use rustc_session::Session;
 use rustc_span::symbol::Symbol;
 use rustc_target::spec::{MergeFunctions, PanicStrategy};
-use std::ffi::CString;
+use std::ffi::{CStr, CString};
 
-use std::detect;
 use std::slice;
 use std::str;
 use std::sync::atomic::{AtomicBool, Ordering};
@@ -223,19 +222,20 @@ pub fn target_cpu(sess: &Session) -> &str {
 }
 
 pub fn handle_native_features(sess: &Session) -> Vec<String> {
-    const LLVM_NOT_RECOGNIZED: &[&str] = &["tsc"];
-
     match sess.opts.cg.target_cpu {
         Some(ref s) => {
             if s != "native" {
                 return vec![];
             }
 
-            detect::features()
-                .map(|(feature, support)| (to_llvm_feature(sess, feature), support))
-                .filter(|(feature, _)| !LLVM_NOT_RECOGNIZED.contains(feature))
-                .map(|(feature, support)| (if support { "+" } else { "-" }).to_owned() + feature)
-                .collect()
+            let ptr = unsafe { llvm::LLVMGetHostCPUFeatures() };
+            let str = unsafe { CStr::from_ptr(ptr).to_string_lossy() };
+
+            let features = str.split(",").map(|s| s.to_owned()).collect();
+
+            unsafe { llvm::LLVMDisposeMessage(ptr) };
+
+            features
         }
         None => vec![],
     }