|
8 | 8 | // option. This file may not be copied, modified, or distributed |
9 | 9 | // except according to those terms. |
10 | 10 |
|
| 11 | +use attributes; |
11 | 12 | use back::bytecode::{self, RLIB_BYTECODE_EXTENSION}; |
12 | 13 | use back::lto::{self, ModuleBuffer, ThinBuffer}; |
13 | 14 | use back::link::{self, get_linker, remove}; |
@@ -111,31 +112,6 @@ pub fn write_output_file( |
111 | 112 | } |
112 | 113 | } |
113 | 114 |
|
114 | | -// On android, we by default compile for armv7 processors. This enables |
115 | | -// things like double word CAS instructions (rather than emulating them) |
116 | | -// which are *far* more efficient. This is obviously undesirable in some |
117 | | -// cases, so if any sort of target feature is specified we don't append v7 |
118 | | -// to the feature list. |
119 | | -// |
120 | | -// On iOS only armv7 and newer are supported. So it is useful to |
121 | | -// get all hardware potential via VFP3 (hardware floating point) |
122 | | -// and NEON (SIMD) instructions supported by LLVM. |
123 | | -// Note that without those flags various linking errors might |
124 | | -// arise as some of intrinsics are converted into function calls |
125 | | -// and nobody provides implementations those functions |
126 | | -fn target_feature(sess: &Session) -> String { |
127 | | - let rustc_features = [ |
128 | | - "crt-static", |
129 | | - ]; |
130 | | - let requested_features = sess.opts.cg.target_feature.split(','); |
131 | | - let llvm_features = requested_features.filter(|f| { |
132 | | - !rustc_features.iter().any(|s| f.contains(s)) |
133 | | - }); |
134 | | - format!("{},{}", |
135 | | - sess.target.target.options.features, |
136 | | - llvm_features.collect::<Vec<_>>().join(",")) |
137 | | -} |
138 | | - |
139 | 115 | fn get_llvm_opt_level(optimize: config::OptLevel) -> llvm::CodeGenOptLevel { |
140 | 116 | match optimize { |
141 | 117 | config::OptLevel::No => llvm::CodeGenOptLevel::None, |
@@ -203,7 +179,10 @@ pub fn target_machine_factory(sess: &Session, find_features: bool) |
203 | 179 | None => &*sess.target.target.options.cpu |
204 | 180 | }; |
205 | 181 | let cpu = CString::new(cpu.as_bytes()).unwrap(); |
206 | | - let features = CString::new(target_feature(sess).as_bytes()).unwrap(); |
| 182 | + let features = attributes::llvm_target_features(sess) |
| 183 | + .collect::<Vec<_>>() |
| 184 | + .join(","); |
| 185 | + let features = CString::new(features).unwrap(); |
207 | 186 | let is_pie_binary = !find_features && is_pie_binary(sess); |
208 | 187 | let trap_unreachable = sess.target.target.options.trap_unreachable; |
209 | 188 |
|
|
0 commit comments