@@ -212,6 +212,19 @@ pub fn fix_nested_cargo_env(cmd: &mut Command) {
212212 cmd. env ( "PATH" , sanitized_path ( orig_path) ) ;
213213}
214214
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+
215228#[ derive( Debug ) ]
216229pub struct Cargo {
217230 pub action : CargoAction ,
@@ -261,6 +274,7 @@ impl Cargo {
261274 CargoAction :: Miri => {
262275 action = "miri" ;
263276 sub_action = Some ( "test" ) ;
277+ cmd. env ( "MIRIFLAGS" , "-Zmiri-strict-provenance" ) ;
264278 }
265279 CargoAction :: Test => {
266280 action = "test" ;
@@ -277,6 +291,13 @@ impl Cargo {
277291
278292 if let Some ( target) = self . target {
279293 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+ }
280301 }
281302
282303 if self . packages . is_empty ( ) {
0 commit comments