@@ -37,6 +37,17 @@ use std::process::Command;
3737use std:: str:: FromStr ;
3838use std:: time:: Instant ;
3939
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+
4051fn main ( ) {
4152 let mut args = env:: args_os ( ) . skip ( 1 ) . collect :: < Vec < _ > > ( ) ;
4253
@@ -107,6 +118,8 @@ fn main() {
107118 env:: join_paths ( & dylib_path) . unwrap ( ) ) ;
108119 let mut maybe_crate = None ;
109120
121+ let mut target_features = Vec :: new ( ) ;
122+
110123 if let Some ( target) = target {
111124 // The stage0 compiler has a special sysroot distinct from what we
112125 // actually downloaded, so we just always pass the `--sysroot` option.
@@ -235,29 +248,12 @@ fn main() {
235248 }
236249 }
237250
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) ;
261257
262258 // When running miri tests, we need to generate MIR for all libraries
263259 if env:: var ( "TEST_MIRI" ) . ok ( ) . map_or ( false , |val| val == "true" ) {
@@ -276,6 +272,17 @@ fn main() {
276272 if let Ok ( host_linker) = env:: var ( "RUSTC_HOST_LINKER" ) {
277273 cmd. arg ( format ! ( "-Clinker={}" , host_linker) ) ;
278274 }
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( "," ) ) ) ;
279286 }
280287
281288 if env:: var_os ( "RUSTC_PARALLEL_QUERIES" ) . is_some ( ) {
0 commit comments