File tree Expand file tree Collapse file tree 3 files changed +29
-0
lines changed Expand file tree Collapse file tree 3 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -1397,6 +1397,7 @@ pub fn default_lib_output() -> CrateType {
1397
1397
pub fn default_configuration ( sess : & Session ) -> ast:: CrateConfig {
1398
1398
let end = & sess. target . target . target_endian ;
1399
1399
let arch = & sess. target . target . arch ;
1400
+ let cpu = & sess. target . target . options . cpu ;
1400
1401
let wordsz = & sess. target . target . target_pointer_width ;
1401
1402
let os = & sess. target . target . target_os ;
1402
1403
let env = & sess. target . target . target_env ;
@@ -1426,6 +1427,10 @@ pub fn default_configuration(sess: &Session) -> ast::CrateConfig {
1426
1427
Symbol :: intern ( "target_vendor" ) ,
1427
1428
Some ( Symbol :: intern ( vendor) ) ,
1428
1429
) ) ;
1430
+ if sess. target . target . options . is_specific_cpu ( ) {
1431
+ ret. insert ( ( Symbol :: intern ( "target_cpu" ) , Some ( Symbol :: intern ( cpu) ) ) ) ;
1432
+ }
1433
+
1429
1434
if sess. target . target . options . has_elf_tls {
1430
1435
ret. insert ( ( Symbol :: intern ( "target_thread_local" ) , None ) ) ;
1431
1436
}
Original file line number Diff line number Diff line change @@ -788,6 +788,12 @@ impl Default for TargetOptions {
788
788
}
789
789
}
790
790
791
+ impl TargetOptions {
792
+ pub fn is_specific_cpu ( & self ) -> bool {
793
+ self . cpu != "generic"
794
+ }
795
+ }
796
+
791
797
impl Target {
792
798
/// Given a function ABI, turn it into the correct ABI for this target.
793
799
pub fn adjust_abi ( & self , abi : Abi ) -> Abi {
Original file line number Diff line number Diff line change
1
+ // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2
+ // file at the top-level directory of this distribution and at
3
+ // http://rust-lang.org/COPYRIGHT.
4
+ //
5
+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6
+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7
+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8
+ // option. This file may not be copied, modified, or distributed
9
+ // except according to those terms.
10
+
11
+ pub fn main ( ) {
12
+ if cfg ! ( target_cpu = "cortex-a8" ) {
13
+ println ! ( "Running on Cortex A8!" ) ;
14
+ } else {
15
+ println ! ( "Running on an arbitrary cpu" ) ;
16
+ }
17
+ }
18
+
You can’t perform that action at this time.
0 commit comments