From 03c19754c38067f532f5f60eb49b7cef99e0cc76 Mon Sep 17 00:00:00 2001 From: jyn Date: Sat, 9 Dec 2023 11:49:07 -0500 Subject: [PATCH] workaround cargo bugs on windows --- src/bootstrap/src/bin/rustc.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/bootstrap/src/bin/rustc.rs b/src/bootstrap/src/bin/rustc.rs index 7ca6a78bb509f..9ae7380526330 100644 --- a/src/bootstrap/src/bin/rustc.rs +++ b/src/bootstrap/src/bin/rustc.rs @@ -16,7 +16,7 @@ //! never get replaced. use std::env; -use std::path::PathBuf; +use std::path::{Path, PathBuf}; use std::process::{Child, Command}; use std::time::Instant; @@ -85,7 +85,10 @@ fn main() { } else { // Cargo doesn't respect RUSTC_WRAPPER for version information >:( // don't remove the first arg if we're being run as RUSTC instead of RUSTC_WRAPPER. - if args[0] == env::current_exe().expect("couldn't get path to rustc shim") { + // Cargo also sometimes doesn't pass the `.exe` suffix on Windows - add it manually. + let current_exe = env::current_exe().expect("couldn't get path to rustc shim"); + let arg0 = exe(args[0].to_str().expect("only utf8 paths are supported"), &target_name); + if Path::new(&arg0) == current_exe { args.remove(0); } rustc_real