Skip to content

Commit

Permalink
workaround cargo bugs on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
jyn514 committed Dec 9, 2023
1 parent 118b6e4 commit 5645405
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/bootstrap/src/bin/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -85,7 +85,12 @@ 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");
// NOTE: we intentionally pass the name of the host, not the target.
let host = env::var("CFG_COMPILER_BUILD_TRIPLE").unwrap();
let arg0 = exe(args[0].to_str().expect("only utf8 paths are supported"), &host);
if Path::new(&arg0) == current_exe {
args.remove(0);
}
rustc_real
Expand Down
4 changes: 4 additions & 0 deletions src/bootstrap/src/core/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2014,7 +2014,11 @@ impl<'a> Builder<'a> {
// Environment variables *required* throughout the build
//
// FIXME: should update code to not require this env var

// The host this new compiler will *run* on.
cargo.env("CFG_COMPILER_HOST_TRIPLE", target.triple);
// The host this new compiler is being *built* on.
cargo.env("CFG_COMPILER_BUILD_TRIPLE", compiler.host.triple);

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

0 comments on commit 5645405

Please sign in to comment.