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 @@ -1115,6 +1115,7 @@ pub fn default_lib_output() -> CrateType {
1115
1115
pub fn default_configuration ( sess : & Session ) -> ast:: CrateConfig {
1116
1116
let end = & sess. target . target . target_endian ;
1117
1117
let arch = & sess. target . target . arch ;
1118
+ let cpu = & sess. target . target . options . cpu ;
1118
1119
let wordsz = & sess. target . target . target_pointer_width ;
1119
1120
let os = & sess. target . target . target_os ;
1120
1121
let env = & sess. target . target . target_env ;
@@ -1136,6 +1137,10 @@ pub fn default_configuration(sess: &Session) -> ast::CrateConfig {
1136
1137
ret. insert ( ( Symbol :: intern ( "target_pointer_width" ) , Some ( Symbol :: intern ( wordsz) ) ) ) ;
1137
1138
ret. insert ( ( Symbol :: intern ( "target_env" ) , Some ( Symbol :: intern ( env) ) ) ) ;
1138
1139
ret. insert ( ( Symbol :: intern ( "target_vendor" ) , Some ( Symbol :: intern ( vendor) ) ) ) ;
1140
+ if sess. target . target . options . is_specific_cpu ( ) {
1141
+ ret. insert ( ( Symbol :: intern ( "target_cpu" ) , Some ( Symbol :: intern ( cpu) ) ) ) ;
1142
+ }
1143
+
1139
1144
if sess. target . target . options . has_elf_tls {
1140
1145
ret. insert ( ( Symbol :: intern ( "target_thread_local" ) , None ) ) ;
1141
1146
}
Original file line number Diff line number Diff line change @@ -807,6 +807,12 @@ impl Target {
807
807
}
808
808
}
809
809
810
+ impl TargetOptions {
811
+ pub fn is_specific_cpu ( & self ) -> bool {
812
+ self . cpu != "generic"
813
+ }
814
+ }
815
+
810
816
impl ToJson for Target {
811
817
fn to_json ( & self ) -> Json {
812
818
let mut d = BTreeMap :: new ( ) ;
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