File tree 3 files changed +23
-1
lines changed
compiler/rustc_codegen_llvm/src
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(
164
164
165
165
let code_model = to_llvm_code_model ( sess. code_model ( ) ) ;
166
166
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 ( ) ) ) ;
168
169
let mut singlethread = sess. target . singlethread ;
169
170
170
171
// On the wasm target once the `atomics` feature is enabled that means that
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) ]
15
16
#![ recursion_limit = "256" ]
16
17
17
18
use 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;
10
10
use rustc_target:: spec:: { MergeFunctions , PanicStrategy } ;
11
11
use std:: ffi:: CString ;
12
12
13
+ use std:: detect;
13
14
use std:: slice;
14
15
use std:: str;
15
16
use std:: sync:: atomic:: { AtomicBool , Ordering } ;
@@ -221,6 +222,25 @@ pub fn target_cpu(sess: &Session) -> &str {
221
222
handle_native ( name)
222
223
}
223
224
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
+
224
244
pub fn tune_cpu ( sess : & Session ) -> Option < & str > {
225
245
match sess. opts . debugging_opts . tune_cpu {
226
246
Some ( ref s) => Some ( handle_native ( & * * s) ) ,
You can’t perform that action at this time.
0 commit comments