Skip to content

Commit 1b519ae

Browse files
committed
workaround cargo bugs on windows
1 parent ff0715c commit 1b519ae

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/bootstrap/src/bin/rustc.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
//! never get replaced.
1717
1818
use std::env;
19-
use std::path::PathBuf;
19+
use std::path::{Path, PathBuf};
2020
use std::process::{Child, Command};
2121
use std::time::Instant;
2222

@@ -83,7 +83,12 @@ fn main() {
8383
} else {
8484
// Cargo doesn't respect RUSTC_WRAPPER for version information >:(
8585
// don't remove the first arg if we're being run as RUSTC instead of RUSTC_WRAPPER.
86-
if args[0] == env::current_exe().expect("couldn't get path to rustc shim") {
86+
// Cargo also sometimes doesn't pass the `.exe` suffix on Windows - add it manually.
87+
let current_exe = env::current_exe().expect("couldn't get path to rustc shim");
88+
// NOTE: we intentionally pass the name of the host, not the target.
89+
let host = env::var("CFG_COMPILER_BUILD_TRIPLE").unwrap();
90+
let arg0 = exe(args[0].to_str().expect("only utf8 paths are supported"), &host);
91+
if Path::new(&arg0) == current_exe {
8792
args.remove(0);
8893
}
8994
rustc_real

src/bootstrap/src/core/builder.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2022,7 +2022,11 @@ impl<'a> Builder<'a> {
20222022
// Environment variables *required* throughout the build
20232023
//
20242024
// FIXME: should update code to not require this env var
2025+
2026+
// The host this new compiler will *run* on.
20252027
cargo.env("CFG_COMPILER_HOST_TRIPLE", target.triple);
2028+
// The host this new compiler is being *built* on.
2029+
cargo.env("CFG_COMPILER_BUILD_TRIPLE", compiler.host.triple);
20262030

20272031
// Set this for all builds to make sure doc builds also get it.
20282032
cargo.env("CFG_RELEASE_CHANNEL", &self.config.channel);

0 commit comments

Comments
 (0)