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 @@ -1492,6 +1492,7 @@ pub fn default_lib_output() -> CrateType {
1492
1492
pub fn default_configuration ( sess : & Session ) -> ast:: CrateConfig {
1493
1493
let end = & sess. target . target . target_endian ;
1494
1494
let arch = & sess. target . target . arch ;
1495
+ let cpu = & sess. target . target . options . cpu ;
1495
1496
let wordsz = & sess. target . target . target_pointer_width ;
1496
1497
let os = & sess. target . target . target_os ;
1497
1498
let env = & sess. target . target . target_env ;
@@ -1521,6 +1522,10 @@ pub fn default_configuration(sess: &Session) -> ast::CrateConfig {
1521
1522
Symbol :: intern ( "target_vendor" ) ,
1522
1523
Some ( Symbol :: intern ( vendor) ) ,
1523
1524
) ) ;
1525
+ if sess. target . target . options . is_specific_cpu ( ) {
1526
+ ret. insert ( ( Symbol :: intern ( "target_cpu" ) , Some ( Symbol :: intern ( cpu) ) ) ) ;
1527
+ }
1528
+
1524
1529
if sess. target . target . options . has_elf_tls {
1525
1530
ret. insert ( ( sym:: target_thread_local, None ) ) ;
1526
1531
}
Original file line number Diff line number Diff line change @@ -853,6 +853,12 @@ impl Default for TargetOptions {
853
853
}
854
854
}
855
855
856
+ impl TargetOptions {
857
+ pub fn is_specific_cpu ( & self ) -> bool {
858
+ self . cpu != "generic"
859
+ }
860
+ }
861
+
856
862
impl Target {
857
863
/// Given a function ABI, turn it into the correct ABI for this target.
858
864
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