@@ -212,6 +212,19 @@ pub fn fix_nested_cargo_env(cmd: &mut Command) {
212
212
cmd. env ( "PATH" , sanitized_path ( orig_path) ) ;
213
213
}
214
214
215
+ /// Check if the three UEFI targets are installed via rustup (only
216
+ /// supported since nightly-2022-11-10).
217
+ fn is_target_installed ( target : & str ) -> Result < bool > {
218
+ let output = Command :: new ( "rustup" )
219
+ . args ( [ "target" , "list" , "--installed" ] )
220
+ . output ( ) ?;
221
+ if !output. status . success ( ) {
222
+ bail ! ( "failed to get installed targets" ) ;
223
+ }
224
+ let stdout = String :: from_utf8 ( output. stdout ) ?;
225
+ Ok ( stdout. lines ( ) . any ( |x| x == target) )
226
+ }
227
+
215
228
#[ derive( Debug ) ]
216
229
pub struct Cargo {
217
230
pub action : CargoAction ,
@@ -261,6 +274,7 @@ impl Cargo {
261
274
CargoAction :: Miri => {
262
275
action = "miri" ;
263
276
sub_action = Some ( "test" ) ;
277
+ cmd. env ( "MIRIFLAGS" , "-Zmiri-strict-provenance" ) ;
264
278
}
265
279
CargoAction :: Test => {
266
280
action = "test" ;
@@ -277,6 +291,13 @@ impl Cargo {
277
291
278
292
if let Some ( target) = self . target {
279
293
cmd. args ( [ "--target" , target. as_triple ( ) ] ) ;
294
+
295
+ // If the target is not installed, use build-std. Keep this
296
+ // around until our minimum-supported nightly version is at
297
+ // least 2022-11-10.
298
+ if !is_target_installed ( target. as_triple ( ) ) ? {
299
+ cmd. args ( [ "-Zbuild-std=core,alloc" ] ) ;
300
+ }
280
301
}
281
302
282
303
if self . packages . is_empty ( ) {
0 commit comments