@@ -205,6 +205,43 @@ fn copy_self_contained_objects(
205205 target_deps
206206}
207207
208+ fn add_target_api_features_cargo (
209+ builder : & Builder < ' _ > ,
210+ target : TargetSelection ,
211+ cargo : & mut Cargo ,
212+ ) {
213+ if let Some ( api_features) = builder. target_api_feature ( target) {
214+ for api_feature in api_features {
215+ cargo. rustflag ( "--cfg" ) ;
216+ cargo. rustflag ( & format ! ( "target_api_feature=\" {}\" " , api_feature) ) ;
217+ }
218+ } else {
219+ if target. contains ( "windows" ) {
220+ // all `target_api_feature`s for the currently officially supported
221+ // windows version for rust
222+ const WINDOWS_VERSIONS : [ & str ; 12 ] = [
223+ "3.10.511" , // NT 3.1
224+ "3.10.528" , // NT 3.1 SP3
225+ "3.50.807" , // NT 3.5
226+ "3.51.1057" , // NT 3.51
227+ "4.0.1381" , // NT 4
228+ "5.0.2195" , // 2000
229+ "5.1.2600" , // XP
230+ "5.2.3790" , // XP 64bit, Server 2003
231+ "6.0.6000" , // Vista, Server 2008
232+ "6.0.6001" , // Vista SP1, Server 2008 SP1
233+ "6.0.6002" , // Vista SP2, Server 2008 SP2
234+ "6.1.7600" , // 7, Server 2008 R2
235+ ] ;
236+
237+ for v in & WINDOWS_VERSIONS {
238+ cargo. rustflag ( "--cfg" ) ;
239+ cargo. rustflag ( & format ! ( "target_api_feature=\" {}\" " , v) ) ;
240+ }
241+ }
242+ }
243+ }
244+
208245/// Configure cargo to compile the standard library, adding appropriate env vars
209246/// and such.
210247pub fn std_cargo ( builder : & Builder < ' _ > , target : TargetSelection , stage : u32 , cargo : & mut Cargo ) {
@@ -296,6 +333,8 @@ pub fn std_cargo(builder: &Builder<'_>, target: TargetSelection, stage: u32, car
296333 if target. contains ( "riscv" ) {
297334 cargo. rustflag ( "-Cforce-unwind-tables=yes" ) ;
298335 }
336+
337+ add_target_api_features_cargo ( builder, target, cargo) ;
299338}
300339
301340#[ derive( Debug , Copy , Clone , PartialEq , Eq , Hash ) ]
@@ -604,28 +643,7 @@ pub fn rustc_cargo_env(builder: &Builder<'_>, cargo: &mut Cargo, target: TargetS
604643 }
605644 }
606645
607- if target. contains ( "windows" ) {
608- // all `target_api_feature`s for the currently officially supported
609- // windows version for rust
610- const WINDOWS_VERSIONS : [ & str ; 12 ] = [
611- "3.10.511" , // NT 3.1
612- "3.10.528" , // NT 3.1 SP3
613- "3.50.807" , // NT 3.5
614- "3.51.1057" , // NT 3.51
615- "4.0.1381" , // NT 4
616- "5.0.2195" , // 2000
617- "5.1.2600" , // XP
618- "5.2.3790" , // XP 64bit, Server 2003
619- "6.0.6000" , // Vista, Server 2008
620- "6.0.6001" , // Vista SP1, Server 2008 SP1
621- "6.0.6002" , // Vista SP2, Server 2008 SP2
622- "6.1.7600" , // 7, Server 2008 R2
623- ] ;
624-
625- for v in & WINDOWS_VERSIONS {
626- cargo. rustflag ( & format ! ( "--cfg=target_api_feature=\" {}\" " , v) ) ;
627- }
628- }
646+ add_target_api_features_cargo ( builder, target, cargo) ;
629647}
630648
631649#[ derive( Debug , Copy , Clone , PartialEq , Eq , Hash ) ]
0 commit comments