Skip to content

Commit d75521a

Browse files
authored
Rollup merge of #85590 - jam1garner:tool-bootstrap-su-fix, r=Mark-Simulacrum
Fix bootstrap using host exe suffix for cargo When attempting to cross compile rustc (for example, from Linux to Windows) and tell it to build cargo/tools, the following error occurs: ``` thread 'main' panicked at 'src.symlink_metadata() failed with No such file or directory (os error 2)', src/bootstrap/lib.rs:1196:24 ``` Relevant part of stack trace: <details> ``` 2: bootstrap::Build::copy at ./src/bootstrap/lib.rs:1196:24 3: <bootstrap::tool::ToolBuild as bootstrap::builder::Step>::run at ./src/bootstrap/tool.rs:220:13 ``` </details> If I add `-vvv` (which seemed to be the recommended course for debugging a similar issue according to [zulip logs](https://zulip-archive.rust-lang.org/182449tcompilerhelp/19655failedtobootstrap.html)), it shows: ``` Copy ".../rust/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-pc-windows-gnu/release/cargo" to ".../rust/build/x86_64-unknown-linux-gnu/stage2-tools-bin/cargo" ``` and when taking a look at the contents of `build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-pc-windows-gnu/release` it contains `cargo.exe`, but no `cargo`. I tried to study the surrounding code to make sure this was the intended behavior and while I can't be 100% certain, it does seem that using the exe suffix for the `compiler.host` target instead of the `target` target won't have the desired behavior when cross-compiling to/from Windows.
2 parents ae6a1a7 + 903e369 commit d75521a

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/bootstrap/tool.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,8 @@ impl Step for ToolBuild {
217217
if tool == "tidy" {
218218
tool = "rust-tidy";
219219
}
220-
let cargo_out =
221-
builder.cargo_out(compiler, self.mode, target).join(exe(tool, compiler.host));
222-
let bin = builder.tools_dir(compiler).join(exe(tool, compiler.host));
220+
let cargo_out = builder.cargo_out(compiler, self.mode, target).join(exe(tool, target));
221+
let bin = builder.tools_dir(compiler).join(exe(tool, target));
223222
builder.copy(&cargo_out, &bin);
224223
Some(bin)
225224
}

0 commit comments

Comments
 (0)