diff --git a/src/tools/miri/miri-script/src/commands.rs b/src/tools/miri/miri-script/src/commands.rs index 7348acac5a9..b18c8453d66 100644 --- a/src/tools/miri/miri-script/src/commands.rs +++ b/src/tools/miri/miri-script/src/commands.rs @@ -503,9 +503,13 @@ fn run( // More flags that we will pass before `flags` // (because `flags` may contain `--`). let mut early_flags = Vec::::new(); - if let Some(target) = &target { - early_flags.push("--target".into()); - early_flags.push(target.into()); + + // In `dep` mode, the target is already passed via `MIRI_TEST_TARGET` + if !dep { + if let Some(target) = &target { + early_flags.push("--target".into()); + early_flags.push(target.into()); + } } early_flags.push("--edition".into()); early_flags.push(edition.as_deref().unwrap_or("2021").into()); diff --git a/src/tools/miri/tests/ui.rs b/src/tools/miri/tests/ui.rs index 10b29deefad..d405eb92ad1 100644 --- a/src/tools/miri/tests/ui.rs +++ b/src/tools/miri/tests/ui.rs @@ -337,6 +337,7 @@ fn run_dep_mode(target: String, args: impl Iterator) -> Result< let build_manager = BuildManager::one_off(config); let mut cmd = test_config.config.program.build(&test_config.config.out_dir); + cmd.arg("--target").arg(test_config.config.target.as_ref().unwrap()); // Build dependencies test_config.apply_custom(&mut cmd, &build_manager).unwrap();