diff options
| author | Pietro Albini <pietro.albini@ferrous-systems.com> | 2024-07-08 15:16:28 +0200 |
|---|---|---|
| committer | Pietro Albini <pietro.albini@ferrous-systems.com> | 2024-07-08 15:16:28 +0200 |
| commit | 198c809dd1b06d398c44f570c9635af640895ce9 (patch) | |
| tree | f0ebcdf24fe7b0772f7f77f9f82b7b5b9eb52291 /src/bootstrap | |
| parent | fcb6ff5171fd41c988a6c449f76ff34c2c2d5a43 (diff) | |
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.
Diffstat (limited to 'src/bootstrap')
| -rw-r--r-- | src/bootstrap/src/core/config/config.rs | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index 6664c5b451c..882bae8aeb6 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -1452,6 +1452,11 @@ impl Config { config.out = crate::utils::helpers::absolute(&config.out); } + // Hacky way to determine the executable suffix for the build target. We cannot use + // std::env::consts::EXE_SUFFIX as the build target might not be the target bootstrap was + // compiled with. + let initial_exe_suffix = if config.build.triple.contains("windows") { ".exe" } else { "" }; + config.initial_rustc = if let Some(rustc) = rustc { if !flags.skip_stage0_validation { config.check_stage0_version(&rustc, "rustc"); @@ -1459,7 +1464,12 @@ impl Config { rustc } else { config.download_beta_toolchain(); - config.out.join(config.build.triple).join("stage0/bin/rustc") + config + .out + .join(config.build.triple) + .join("stage0") + .join("bin") + .join(format!("rustc{initial_exe_suffix}")) }; config.initial_cargo = if let Some(cargo) = cargo { @@ -1469,7 +1479,12 @@ impl Config { cargo } else { config.download_beta_toolchain(); - config.out.join(config.build.triple).join("stage0/bin/cargo") + config + .out + .join(config.build.triple) + .join("stage0") + .join("bin") + .join(format!("cargo{initial_exe_suffix}")) }; // NOTE: it's important this comes *after* we set `initial_rustc` just above. |
