Skip to content

Commit 198c809

Browse files
committed
set the correct executable for initial_{rustc,cargo}
Due to the way the paths initial_rustc and initial_cargo were constructed before this commit, they mixed \ and / for path separators and they omitted the .exe suffix. This worked fine up until now, as Windows is capable of handling the mixed path separators and the Command::new API adds the ".exe" suffix if missing from the executable. This resulted in paths that didn't actually exist on disk though, due to the missing .exe suffix. This commit fixes that by adding the .exe suffix to initial_rustc and initial_cargo when --build is Windows.
1 parent fcb6ff5 commit 198c809

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

src/bootstrap/src/core/config/config.rs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1452,14 +1452,24 @@ impl Config {
14521452
config.out = crate::utils::helpers::absolute(&config.out);
14531453
}
14541454

1455+
// Hacky way to determine the executable suffix for the build target. We cannot use
1456+
// std::env::consts::EXE_SUFFIX as the build target might not be the target bootstrap was
1457+
// compiled with.
1458+
let initial_exe_suffix = if config.build.triple.contains("windows") { ".exe" } else { "" };
1459+
14551460
config.initial_rustc = if let Some(rustc) = rustc {
14561461
if !flags.skip_stage0_validation {
14571462
config.check_stage0_version(&rustc, "rustc");
14581463
}
14591464
rustc
14601465
} else {
14611466
config.download_beta_toolchain();
1462-
config.out.join(config.build.triple).join("stage0/bin/rustc")
1467+
config
1468+
.out
1469+
.join(config.build.triple)
1470+
.join("stage0")
1471+
.join("bin")
1472+
.join(format!("rustc{initial_exe_suffix}"))
14631473
};
14641474

14651475
config.initial_cargo = if let Some(cargo) = cargo {
@@ -1469,7 +1479,12 @@ impl Config {
14691479
cargo
14701480
} else {
14711481
config.download_beta_toolchain();
1472-
config.out.join(config.build.triple).join("stage0/bin/cargo")
1482+
config
1483+
.out
1484+
.join(config.build.triple)
1485+
.join("stage0")
1486+
.join("bin")
1487+
.join(format!("cargo{initial_exe_suffix}"))
14731488
};
14741489

14751490
// NOTE: it's important this comes *after* we set `initial_rustc` just above.

0 commit comments

Comments
 (0)