File tree 3 files changed +29
-0
lines changed
3 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -1453,6 +1453,7 @@ pub fn default_lib_output() -> CrateType {
1453
1453
pub fn default_configuration ( sess : & Session ) -> ast:: CrateConfig {
1454
1454
let end = & sess. target . target . target_endian ;
1455
1455
let arch = & sess. target . target . arch ;
1456
+ let cpu = & sess. target . target . options . cpu ;
1456
1457
let wordsz = & sess. target . target . target_pointer_width ;
1457
1458
let os = & sess. target . target . target_os ;
1458
1459
let env = & sess. target . target . target_env ;
@@ -1482,6 +1483,10 @@ pub fn default_configuration(sess: &Session) -> ast::CrateConfig {
1482
1483
Symbol :: intern ( "target_vendor" ) ,
1483
1484
Some ( Symbol :: intern ( vendor) ) ,
1484
1485
) ) ;
1486
+ if sess. target . target . options . is_specific_cpu ( ) {
1487
+ ret. insert ( ( Symbol :: intern ( "target_cpu" ) , Some ( Symbol :: intern ( cpu) ) ) ) ;
1488
+ }
1489
+
1485
1490
if sess. target . target . options . has_elf_tls {
1486
1491
ret. insert ( ( Symbol :: intern ( "target_thread_local" ) , None ) ) ;
1487
1492
}
Original file line number Diff line number Diff line change @@ -856,6 +856,12 @@ impl Default for TargetOptions {
856
856
}
857
857
}
858
858
859
+ impl TargetOptions {
860
+ pub fn is_specific_cpu ( & self ) -> bool {
861
+ self . cpu != "generic"
862
+ }
863
+ }
864
+
859
865
impl Target {
860
866
/// Given a function ABI, turn it into the correct ABI for this target.
861
867
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