@@ -37,6 +37,17 @@ use std::process::Command;
37
37
use std:: str:: FromStr ;
38
38
use std:: time:: Instant ;
39
39
40
+ fn target_feature_from_env ( var : & str , name : & str , target_features : & mut Vec < String > ) {
41
+ if let Ok ( s) = env:: var ( var) {
42
+ if s == "true" {
43
+ target_features. push ( format ! ( "+{}" , name) ) ;
44
+ }
45
+ if s == "false" {
46
+ target_features. push ( format ! ( "-{}" , name) ) ;
47
+ }
48
+ }
49
+ }
50
+
40
51
fn main ( ) {
41
52
let mut args = env:: args_os ( ) . skip ( 1 ) . collect :: < Vec < _ > > ( ) ;
42
53
@@ -107,6 +118,8 @@ fn main() {
107
118
env:: join_paths ( & dylib_path) . unwrap ( ) ) ;
108
119
let mut maybe_crate = None ;
109
120
121
+ let mut target_features = Vec :: new ( ) ;
122
+
110
123
if let Some ( target) = target {
111
124
// The stage0 compiler has a special sysroot distinct from what we
112
125
// actually downloaded, so we just always pass the `--sysroot` option.
@@ -235,29 +248,12 @@ fn main() {
235
248
}
236
249
}
237
250
238
- let mut target_features = Vec :: new ( ) ;
239
-
240
- if let Ok ( s) = env:: var ( "RUSTC_CRT_STATIC" ) {
241
- if s == "true" {
242
- target_features. push ( "+crt-static" ) ;
243
- }
244
- if s == "false" {
245
- target_features. push ( "-crt-static" ) ;
246
- }
247
- }
248
-
249
- if let Ok ( s) = env:: var ( "RUSTC_CRT_INCLUDED" ) {
250
- if s == "true" {
251
- target_features. push ( "+crt-included" ) ;
252
- }
253
- if s == "false" {
254
- target_features. push ( "-crt-included" ) ;
255
- }
256
- }
257
-
258
- if !target_features. is_empty ( ) {
259
- cmd. arg ( "-C" ) . arg ( format ! ( "target-feature={}" , target_features. join( "," ) ) ) ;
260
- }
251
+ target_feature_from_env ( "RUSTC_CRT_STATIC" ,
252
+ "crt-static" ,
253
+ & mut target_features) ;
254
+ target_feature_from_env ( "RUSTC_CRT_INCLUDED" ,
255
+ "crt-included" ,
256
+ & mut target_features) ;
261
257
262
258
// When running miri tests, we need to generate MIR for all libraries
263
259
if env:: var ( "TEST_MIRI" ) . ok ( ) . map_or ( false , |val| val == "true" ) {
@@ -276,6 +272,17 @@ fn main() {
276
272
if let Ok ( host_linker) = env:: var ( "RUSTC_HOST_LINKER" ) {
277
273
cmd. arg ( format ! ( "-Clinker={}" , host_linker) ) ;
278
274
}
275
+
276
+ target_feature_from_env ( "RUSTC_HOST_CRT_STATIC" ,
277
+ "crt-static" ,
278
+ & mut target_features) ;
279
+ target_feature_from_env ( "RUSTC_HOST_CRT_INCLUDED" ,
280
+ "crt-included" ,
281
+ & mut target_features) ;
282
+ }
283
+
284
+ if !target_features. is_empty ( ) {
285
+ cmd. arg ( "-C" ) . arg ( format ! ( "target-feature={}" , target_features. join( "," ) ) ) ;
279
286
}
280
287
281
288
if env:: var_os ( "RUSTC_PARALLEL_QUERIES" ) . is_some ( ) {
0 commit comments