Skip to content

Commit 5645405

Browse files
committed
workaround cargo bugs on windows
1 parent 118b6e4 commit 5645405

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/bootstrap/src/bin/rustc.rs

+7-2
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

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

src/bootstrap/src/core/builder.rs

+4
Original file line numberDiff line numberDiff line change
@@ -2014,7 +2014,11 @@ impl<'a> Builder<'a> {
20142014
// Environment variables *required* throughout the build
20152015
//
20162016
// FIXME: should update code to not require this env var
2017+
2018+
// The host this new compiler will *run* on.
20172019
cargo.env("CFG_COMPILER_HOST_TRIPLE", target.triple);
2020+
// The host this new compiler is being *built* on.
2021+
cargo.env("CFG_COMPILER_BUILD_TRIPLE", compiler.host.triple);
20182022

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

0 commit comments

Comments
 (0)