File tree 3 files changed +13
-10
lines changed
compiler/rustc_codegen_llvm/src
3 files changed +13
-10
lines changed Original file line number Diff line number Diff line change 12
12
#![ feature( in_band_lifetimes) ]
13
13
#![ feature( nll) ]
14
14
#![ feature( or_patterns) ]
15
- #![ feature( stdsimd) ]
16
15
#![ recursion_limit = "256" ]
17
16
18
17
use back:: write:: { create_informational_target_machine, create_target_machine} ;
Original file line number Diff line number Diff line change @@ -1708,6 +1708,10 @@ extern "C" {
1708
1708
PM : & PassManager < ' _ > ,
1709
1709
) ;
1710
1710
1711
+ pub fn LLVMGetHostCPUFeatures ( ) -> * mut c_char ;
1712
+
1713
+ pub fn LLVMDisposeMessage ( message : * mut c_char ) ;
1714
+
1711
1715
// Stuff that's in llvm-wrapper/ because it's not upstream yet.
1712
1716
1713
1717
/// Opens an object file.
Original file line number Diff line number Diff line change @@ -8,9 +8,8 @@ use rustc_session::config::PrintRequest;
8
8
use rustc_session:: Session ;
9
9
use rustc_span:: symbol:: Symbol ;
10
10
use rustc_target:: spec:: { MergeFunctions , PanicStrategy } ;
11
- use std:: ffi:: CString ;
11
+ use std:: ffi:: { CStr , CString } ;
12
12
13
- use std:: detect;
14
13
use std:: slice;
15
14
use std:: str;
16
15
use std:: sync:: atomic:: { AtomicBool , Ordering } ;
@@ -223,19 +222,20 @@ pub fn target_cpu(sess: &Session) -> &str {
223
222
}
224
223
225
224
pub fn handle_native_features ( sess : & Session ) -> Vec < String > {
226
- const LLVM_NOT_RECOGNIZED : & [ & str ] = & [ "tsc" ] ;
227
-
228
225
match sess. opts . cg . target_cpu {
229
226
Some ( ref s) => {
230
227
if s != "native" {
231
228
return vec ! [ ] ;
232
229
}
233
230
234
- detect:: features ( )
235
- . map ( |( feature, support) | ( to_llvm_feature ( sess, feature) , support) )
236
- . filter ( |( feature, _) | !LLVM_NOT_RECOGNIZED . contains ( feature) )
237
- . map ( |( feature, support) | ( if support { "+" } else { "-" } ) . to_owned ( ) + feature)
238
- . collect ( )
231
+ let ptr = unsafe { llvm:: LLVMGetHostCPUFeatures ( ) } ;
232
+ let str = unsafe { CStr :: from_ptr ( ptr) . to_string_lossy ( ) } ;
233
+
234
+ let features = str. split ( "," ) . map ( |s| s. to_owned ( ) ) . collect ( ) ;
235
+
236
+ unsafe { llvm:: LLVMDisposeMessage ( ptr) } ;
237
+
238
+ features
239
239
}
240
240
None => vec ! [ ] ,
241
241
}
You can’t perform that action at this time.
0 commit comments