Repository: rust
Issue: dash: `x.py install` removes rustc and cargo, without installing them
Labels: T-bootstrap,C-bug,regression-untriaged

With https://static.rust-lang.org/dist/rustc-1.83.0-src.tar.xz I create this config.toml
```
# Use different pre-set defaults than the global defaults.
#
# See `src/bootstrap/defaults` for more information.
# Note that this has no default value (x.py uses the defaults in `config.example.toml`).
profile = 'dist'

[llvm]

# Indicates whether the LLVM build is a Release or Debug build
optimize = true

# Whether to build LLVM as a dynamically linked library (as opposed to statically linked).
# Under the hood, this passes `--shared` to llvm-config.
# NOTE: To avoid performing LTO multiple times, we suggest setting this to `true` when `thin-lto` is enabled.
link-shared = true

[build]

# Which triples to build libraries (core/alloc/std/test/proc_macro) for. Each of these triples will
# be bootstrapped from the build triple themselves. In other words, this is the list of triples for
# which to build a library that can CROSS-COMPILE to that triple.
#
# Defaults to `host`. If you set this explicitly, you likely want to add all
# host triples to this list as well in order for those host toolchains to be
# able to compile programs for their native target.
target = ['x86_64-unknown-linux-gnu']

# Instead of downloading the src/stage0 version of Cargo specified, use
# this Cargo binary instead to build all Rust code
# If you set this, you likely want to set `rustc` as well.
cargo = '/usr/local/bin/cargo'

# Instead of downloading the src/stage0 version of the compiler
# specified, use this rustc binary instead as the stage0 snapshot compiler.
# If you set this, you likely want to set `cargo` as well.
rustc = '/usr/local/bin/rustc'

# Whether to build documentation by default. If false, rustdoc and
# friends will still be compiled but they will not be used to generate any
# documentation.
#
# You can still build documentation when this is disabled by explicitly passing paths,
# e.g. `x doc library`.
docs = false

# Enable a build of the extended Rust tool set which is not only the compiler
# but also tools such as Cargo. This will also produce "combined installers"
# which are used to install Rust and Cargo together.
# The `tools` (check `config.example.toml` to see its default value) option specifies
# which tools should be built if `extended = true`.
#
# This is disabled by default.
extended = true

# Build the sanitizer runtimes
sanitizers = true

# Build the profiler runtime (required when compiling with options that depend
# on this runtime, such as `-C profile-generate` or `-C instrument-coverage`).
profiler = true

# Arguments passed to the `./configure` script, used during distcheck. You
# probably won't fill this in but rather it's filled in by the `./configure`
# script. Useful for debugging.
configure-args = ['--enable-optimize-llvm', '--enable-extended', '--llvm-root=/usr/local', '--enable-profiler', '--enable-llvm-link-shared', '--enable-sanitizers', '--enable-local-rust', '--disable-docs', '--target=x86_64-unknown-linux-gnu']

[install]

[rust]

[target.x86_64-unknown-linux-gnu]

# Path to the `llvm-config` binary of the installation of a custom LLVM to link
# against. Note that if this is specified we don't compile LLVM at all for this
# target.
llvm-config = '/usr/local/bin/llvm-config'

[dist]
```
by running `../configure  --enable-optimize-llvm --enable-extended --llvm-root=/usr/local --enable-profiler --enable-llvm-link-shared --enable-sanitizers --enable-local-rust --disable-docs --target=x86_64-unknown-linux-gnu`.  Doing then `x.py -j1 build && x.py -j1 install` does print
```
…
   Compiling proc-macro-srv-cli v0.0.0 (/src/rustc-1.83.0-src/src/tools/rust-analyzer/crates/proc-macro-srv-cli)
    Finished `release` profile [optimized] target(s) in 4m 39s
Dist rustc-nightly-x86_64-unknown-linux-gnu
        finished in 32.652 seconds
Installing stage2 rustc (x86_64-unknown-linux-gnu)
install: uninstalling component 'rustc'
install: creating uninstall script at /usr/local/lib/rustlib/uninstall.sh
install: installing component 'rustc'

    rustc installed.

Uplifting rustc (stage1 -> stage3)
Building tool cargo (stage2 -> stage3, x86_64-unknown-linux-gnu)
    Finished `release` profile [optimized] target(s) in 33.90s
Dist cargo-nightly-x86_64-unknown-linux-gnu
        finished in 19.542 seconds
Installing stage2 cargo (x86_64-unknown-linux-gnu)
install: uninstalling component 'cargo'
install: creating uninstall script at /usr/local/lib/rustlib/uninstall.sh
install: installing component 'cargo'

    cargo installed.

Building tool rust-analyzer (stage2 -> stage3, x86_64-unknown-linux-gnu)
thread 'main' panicked at src/core/build_steps/compile.rs:2239:19:
failed to execute command: cd "/src/rustc-1.83.0-src" && env -u MAKEFLAGS -u MFLAGS AR_x86_64_unknown_linux_gnu="ar" CARGO_INCREMENTAL="0" CARGO_PROFILE_RELEASE_DEBUG="0" CARGO_PROFILE_RELEASE_DEBUG_ASSERTIONS="false" CARGO_PROFILE_RELEASE_OVERFLOW_CHECKS="false" CARGO_PROFILE_RELEASE_STRIP="false" CARGO_TARGET_DIR="/src/rustc-1.83.0-src/A/build/x86_64-unknown-linux-gnu/stage2-tools" CC_x86_64_unknown_linux_gnu="cc" CFG_COMPILER_BUILD_TRIPLE="x86_64-unknown-linux-gnu" CFG_COMPILER_HOST_TRIPLE="x86_64-unknown-linux-gnu" CFG_RELEASE="1.83.0-nightly" CFG_RELEASE_CHANNEL="nightly" CFG_RELEASE_NUM="1.83.0" CFG_VERSION="1.83.0-nightly (90b35a623 2024-11-26) (built from a source tarball)" CFG_VER_DATE="2024-11-26" CFG_VER_HASH="90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf" CFLAGS_x86_64_unknown_linux_gnu="-ffunction-sections -fdata-sections -fPIC -m64" CXXFLAGS_x86_64_unknown_linux_gnu="-ffunction-sections -fdata-sections -fPIC -m64" CXX_x86_64_unknown_linux_gnu="c++" DOC_RUST_LANG_ORG_CHANNEL="https://doc.rust-lang.org/nightly" FORCE_ON_BROKEN_PIPE_KILL="-Zon-broken-pipe=kill" LIBC_CHECK_CFG="1" LIBRARY_PATH="/usr/local/lib" LZMA_API_STATIC="1" RANLIB_x86_64_unknown_linux_gnu="ar s" REAL_LIBRARY_PATH_VAR="LD_LIBRARY_PATH" RUSTBUILD_NATIVE_DIR="/src/rustc-1.83.0-src/A/build/x86_64-unknown-linux-gnu/native" RUSTC="/src/rustc-1.83.0-src/A/build/bootstrap/debug/rustc" RUSTC_ALLOW_FEATURES="rustc_private,proc_macro_internals,proc_macro_diagnostic,proc_macro_span,proc_macro_span_shrink,proc_macro_def_site" RUSTC_BOOTSTRAP="1" RUSTC_BREAK_ON_ICE="1" RUSTC_ERROR_METADATA_DST="/src/rustc-1.83.0-src/A/build/tmp/extended-error-metadata" RUSTC_HOST_FLAGS="-Zunstable-options --check-cfg=cfg(bootstrap)" RUSTC_INSTALL_BINDIR="bin" RUSTC_LIBDIR="/src/rustc-1.83.0-src/A/build/x86_64-unknown-linux-gnu/stage2/lib" RUSTC_LINK_STD_INTO_RUSTC_DRIVER="1" RUSTC_LINT_FLAGS="-Wrust_2018_idioms -Wunused_lifetimes -Dwarnings" RUSTC_REAL="/src/rustc-1.83.0-src/A/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" RUSTC_SNAPSHOT="/src/rustc-1.83.0-src/A/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" RUSTC_SNAPSHOT_LIBDIR="/src/rustc-1.83.0-src/A/build/x86_64-unknown-linux-gnu/stage2/lib" RUSTC_STAGE="2" RUSTC_SYSROOT="/src/rustc-1.83.0-src/A/build/x86_64-unknown-linux-gnu/stage2" RUSTC_TLS_MODEL_INITIAL_EXEC="1" RUSTC_VERBOSE="0" RUSTC_WRAPPER="/src/rustc-1.83.0-src/A/build/bootstrap/debug/rustc" RUSTDOC="/src/rustc-1.83.0-src/A/build/bootstrap/debug/rustdoc" RUSTDOCFLAGS="-Z threads=1 --cfg=windows_raw_dylib -Csymbol-mangling-version=v0 -Zunstable-options --check-cfg=cfg(bootstrap) --check-cfg=cfg(llvm_enzyme) --check-cfg=cfg(parallel_compiler) --check-cfg=cfg(rust_analyzer) -Dwarnings -Wrustdoc::invalid_codeblock_attributes --crate-version 1.83.0-nightly\t(90b35a623\t2024-11-26)\t(built\tfrom\ta\tsource\ttarball) --cfg=parallel_compiler" RUSTDOC_REAL="/path/to/nowhere/rustdoc/not/required" RUSTFLAGS="-Z threads=1 --cfg=windows_raw_dylib -Csymbol-mangling-version=v0 -Zunstable-options --check-cfg=cfg(bootstrap) --check-cfg=cfg(llvm_enzyme) --check-cfg=cfg(parallel_compiler) --check-cfg=cfg(rust_analyzer) -Zmacro-backtrace -Csplit-debuginfo=off --cfg=parallel_compiler -Clink-args=-Wl,-z,origin -Clink-args=-Wl,-rpath,$ORIGIN/../lib -Zunstable-options" RUST_TEST_THREADS="1" SYSROOT="/src/rustc-1.83.0-src/A/build/x86_64-unknown-linux-gnu/stage2" __CARGO_DEFAULT_LIB_METADATA="nightlytool-rustc" "/usr/local/bin/cargo" "build" "--target" "x86_64-unknown-linux-gnu" "--release" "-Zbinary-dep-depinfo" "-j" "1" "--manifest-path" "/src/rustc-1.83.0-src/src/tools/rust-analyzer/Cargo.toml" "--features" "in-rust-tree" "--message-format" "json-render-diagnostics"
ERROR: No such file or directory (os error 2)
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Build completed unsuccessfully in 0:18:26
```
At this moment rustc and cargo are not anymore installed under /usr/local/bin.  The same upgrade procedure has worked for 1.82, 1.81, 1.80, so this is a regression.