Repository: rust
Issue: Bootstrap regression in 1.71.0
Labels: regression-from-stable-to-stable,T-bootstrap,C-bug

If I look at the bins that are part of `rustc`'s tarball in 1.70.0 I see this:
```shell
$ tar tvf old-release/rustc-1.70.0-aarch64-unknown-linux-gnu.tar.xz | rg 'rustc/bin/'
-rwxr-xr-x 12569/100       980 2023-07-22 14:15 rustc-1.70.0-aarch64-unknown-linux-gnu/rustc/bin/rust-gdb
-rwxr-xr-x 12569/100      1072 2023-07-22 14:15 rustc-1.70.0-aarch64-unknown-linux-gnu/rustc/bin/rust-lldb
-rwxr-xr-x 12569/100  13517832 2023-07-22 14:15 rustc-1.70.0-aarch64-unknown-linux-gnu/rustc/bin/rustdoc
-rwxr-xr-x 12569/100   2919232 2023-07-22 14:15 rustc-1.70.0-aarch64-unknown-linux-gnu/rustc/bin/rustc
-rwxr-xr-x 12569/100      2164 2023-07-22 14:15 rustc-1.70.0-aarch64-unknown-linux-gnu/rustc/bin/rust-gdbgui
```

But when I built Rust again in 1.71.0, and inspected the produced artifacts, I see:
```shell
$ tar tvf pre-patch/rustc-1.71.0-aarch64-unknown-linux-gnu.tar.xz | rg 'rustc/bin/'
-rwxr-xr-x 22314791/100    980 2023-07-31 20:34 rustc-1.71.0-aarch64-unknown-linux-gnu/rustc/bin/rust-gdb
-rwxr-xr-x 22314791/100   1072 2023-07-31 20:34 rustc-1.71.0-aarch64-unknown-linux-gnu/rustc/bin/rust-lldb
-rwxr-xr-x 22314791/100 13628504 2023-07-31 20:34 rustc-1.71.0-aarch64-unknown-linux-gnu/rustc/bin/rustdoc
-rwxr-xr-x 22314791/100  2919256 2023-07-31 20:34 rustc-1.71.0-aarch64-unknown-linux-gnu/rustc/bin/rustc
-rwxr-xr-x 22314791/100     2164 2023-07-31 20:34 rustc-1.71.0-aarch64-unknown-linux-gnu/rustc/bin/rust-gdbgui
-rwxr-xr-x 22314791/100  12758400 2023-07-31 20:34 rustc-1.71.0-aarch64-unknown-linux-gnu/rustc/bin/clippy-driver
-rwxr-xr-x 22314791/100   5902856 2023-07-31 20:34 rustc-1.71.0-aarch64-unknown-linux-gnu/rustc/bin/cargo-fmt
-rwxr-xr-x 22314791/100   6089640 2023-07-31 20:34 rustc-1.71.0-aarch64-unknown-linux-gnu/rustc/bin/rustfmt
-rwxr-xr-x 22314791/100   1815536 2023-07-31 20:34 rustc-1.71.0-aarch64-unknown-linux-gnu/rustc/bin/cargo-clippy
```

The difference being that `cargo-fmt`, `rustfmt`, `cargo-clippy`, and `clippy-driver` are now included.

I tracked this change down to this commit: https://github.com/rust-lang/rust/commit/6d99d6a9de9df76f47bccde605f5ec7f60bc2321, which was a part of https://github.com/rust-lang/rust/pull/110365 by @ozkanonur.

I validated my claim by applying this patch to Rust's source:
```diff
diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs
index b3791efaf58..70633f5b41c 100644
--- a/src/bootstrap/tool.rs
+++ b/src/bootstrap/tool.rs
@@ -790,7 +790,7 @@ fn run(mut $sel, $builder: &Builder<'_>) -> Option<PathBuf> {
                     allow_features: concat!($($allow_features)*),
                 })?;
 
-                if (false $(|| !$add_bins_to_sysroot.is_empty())?) && $sel.compiler.stage > 0 {
+                if false {
                     let bindir = $builder.sysroot($sel.compiler).join("bin");
                     t!(fs::create_dir_all(&bindir));
```

And upon re-building, inspecting the tarball again:
```shell
$ tar tvf post-patch/rustc-1.71.0-x86_64-unknown-linux-gnu.tar.xz | rg 'rustc/bin'
drwxr-xr-x 22314791/100      0 2023-08-01 00:16 rustc-1.71.0-x86_64-unknown-linux-gnu/rustc/bin
-rwxr-xr-x 22314791/100    980 2023-08-01 00:16 rustc-1.71.0-x86_64-unknown-linux-gnu/rustc/bin/rust-gdb
-rwxr-xr-x 22314791/100   1072 2023-08-01 00:16 rustc-1.71.0-x86_64-unknown-linux-gnu/rustc/bin/rust-lldb
-rwxr-xr-x 22314791/100 13462808 2023-08-01 00:16 rustc-1.71.0-x86_64-unknown-linux-gnu/rustc/bin/rustdoc
-rwxr-xr-x 22314791/100  2777920 2023-08-01 00:16 rustc-1.71.0-x86_64-unknown-linux-gnu/rustc/bin/rustc
-rwxr-xr-x 22314791/100     2164 2023-08-01 00:16 rustc-1.71.0-x86_64-unknown-linux-gnu/rustc/bin/rust-gdbgui
```

I spoke with @jyn514, who said:

> ah. hmm. that's likely a real bug. dist::Rustc needs to only package rustc/rustdoc, not blindly copy everything currently in the sysroot

One thing that isn't clear to me is why do the officially produced artifacts served through `static.rust-lang.org` not suffer from this:
```shell
$ curl -sSLN https://static.rust-lang.org/dist/2023-07-13/rustc-1.71.0-x86_64-unknown-linux-gnu.tar.xz | tar tvJ | rg 'rustc/bin/'
-rwxr-xr-x 1000/1000       980 2023-07-12 00:58 rustc-1.71.0-x86_64-unknown-linux-gnu/rustc/bin/rust-gdb
-rwxr-xr-x 1000/1000      1072 2023-07-12 00:58 rustc-1.71.0-x86_64-unknown-linux-gnu/rustc/bin/rust-lldb
-rwxr-xr-x 1000/1000  13481400 2023-07-12 00:58 rustc-1.71.0-x86_64-unknown-linux-gnu/rustc/bin/rustdoc
-rwxr-xr-x 1000/1000   2821488 2023-07-12 00:58 rustc-1.71.0-x86_64-unknown-linux-gnu/rustc/bin/rustc
-rwxr-xr-x 1000/1000      2164 2023-07-12 00:58 rustc-1.71.0-x86_64-unknown-linux-gnu/rustc/bin/rust-gdbgui
```