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 @@ -1453,6 +1453,7 @@ pub fn default_lib_output() -> CrateType {
14531453pub fn default_configuration ( sess : & Session ) -> ast:: CrateConfig {
14541454 let end = & sess. target . target . target_endian ;
14551455 let arch = & sess. target . target . arch ;
1456+ let cpu = & sess. target . target . options . cpu ;
14561457 let wordsz = & sess. target . target . target_pointer_width ;
14571458 let os = & sess. target . target . target_os ;
14581459 let env = & sess. target . target . target_env ;
@@ -1482,6 +1483,10 @@ pub fn default_configuration(sess: &Session) -> ast::CrateConfig {
14821483 Symbol :: intern ( "target_vendor" ) ,
14831484 Some ( Symbol :: intern ( vendor) ) ,
14841485 ) ) ;
1486+ if sess. target . target . options . is_specific_cpu ( ) {
1487+ ret. insert ( ( Symbol :: intern ( "target_cpu" ) , Some ( Symbol :: intern ( cpu) ) ) ) ;
1488+ }
1489+
14851490 if sess. target . target . options . has_elf_tls {
14861491 ret. insert ( ( Symbol :: intern ( "target_thread_local" ) , None ) ) ;
14871492 }
Original file line number Diff line number Diff line change @@ -856,6 +856,12 @@ impl Default for TargetOptions {
856856 }
857857}
858858
859+ impl TargetOptions {
860+ pub fn is_specific_cpu ( & self ) -> bool {
861+ self . cpu != "generic"
862+ }
863+ }
864+
859865impl Target {
860866 /// Given a function ABI, turn it into the correct ABI for this target.
861867 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