File tree Expand file tree Collapse file tree 3 files changed +23
-1
lines changed
compiler/rustc_codegen_llvm/src Expand file tree Collapse file tree 3 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -164,7 +164,8 @@ pub fn target_machine_factory(
164164
165165 let code_model = to_llvm_code_model ( sess. code_model ( ) ) ;
166166
167- let features = attributes:: llvm_target_features ( sess) . collect :: < Vec < _ > > ( ) ;
167+ let mut features = llvm_util:: handle_native_features ( sess) ;
168+ features. extend ( attributes:: llvm_target_features ( sess) . map ( |s| s. to_owned ( ) ) ) ;
168169 let mut singlethread = sess. target . singlethread ;
169170
170171 // On the wasm target once the `atomics` feature is enabled that means that
Original file line number Diff line number Diff line change 1212#![ feature( in_band_lifetimes) ]
1313#![ feature( nll) ]
1414#![ feature( or_patterns) ]
15+ #![ feature( stdsimd) ]
1516#![ recursion_limit = "256" ]
1617
1718use back:: write:: { create_informational_target_machine, create_target_machine} ;
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ use rustc_span::symbol::Symbol;
1010use rustc_target:: spec:: { MergeFunctions , PanicStrategy } ;
1111use std:: ffi:: CString ;
1212
13+ use std:: detect;
1314use std:: slice;
1415use std:: str;
1516use std:: sync:: atomic:: { AtomicBool , Ordering } ;
@@ -221,6 +222,25 @@ pub fn target_cpu(sess: &Session) -> &str {
221222 handle_native ( name)
222223}
223224
225+ pub fn handle_native_features ( sess : & Session ) -> Vec < String > {
226+ const LLVM_NOT_RECOGNIZED : & [ & str ] = & [ "tsc" ] ;
227+
228+ match sess. opts . cg . target_cpu {
229+ Some ( ref s) => {
230+ if s != "native" {
231+ return vec ! [ ] ;
232+ }
233+
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 ( )
239+ }
240+ None => vec ! [ ] ,
241+ }
242+ }
243+
224244pub fn tune_cpu ( sess : & Session ) -> Option < & str > {
225245 match sess. opts . debugging_opts . tune_cpu {
226246 Some ( ref s) => Some ( handle_native ( & * * s) ) ,
You can’t perform that action at this time.
0 commit comments