Use LLVMGetHostCPUFeatures instead of stdsimd
This commit is contained in:
parent
bf80159050
commit
bc4c5bac40
3 changed files with 13 additions and 10 deletions
|
@ -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};
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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![],
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue