diff --git a/src/bootstrap/CHANGELOG.md b/src/bootstrap/CHANGELOG.md index 64b74ecc9defd..a9f2bac6230c9 100644 --- a/src/bootstrap/CHANGELOG.md +++ b/src/bootstrap/CHANGELOG.md @@ -7,6 +7,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [Changes since the last major version] +## [Version 3] - 2022-10-20 +- The names of the sysroot directories have changed. Previously they were `stage0`, `stage0-sysroot`, `stage1`, and `stage2`. Now they are `bootstrap-sysroot`, `stage0-sysroot`, `stage1-sysroot`, and `stage2-sysroot`. If you've created a rustup toolchain using these sysroots with `rustup toolchain link mytoolchain build/stage1`, you will need to update them by running `rustup toolchain remove mytoolchain && rustup toolchain link mytoolchain build/stage1-sysroot`. [#103286](https://github.com/rust-lang/rust/pull/103286) - Vendoring is no longer done automatically when building from git sources. To use vendoring, run `cargo vendor` manually, or use the pre-vendored `rustc-src` tarball. - `llvm-libunwind` now accepts `in-tree` (formerly true), `system` or `no` (formerly false) [#77703](https://github.com/rust-lang/rust/pull/77703) - The options `infodir`, `localstatedir`, and `gpg-password-file` are no longer allowed in config.toml. Previously, they were ignored without warning. Note that `infodir` and `localstatedir` are still accepted by `./configure`, with a warning. [#82451](https://github.com/rust-lang/rust/pull/82451) diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py index 57128685d9110..4a5e11ea44b91 100644 --- a/src/bootstrap/bootstrap.py +++ b/src/bootstrap/bootstrap.py @@ -571,7 +571,7 @@ def rustc_stamp(self): >>> rb = RustBuild() >>> rb.build_dir = "build" - >>> rb.rustc_stamp() == os.path.join("build", "stage0", ".rustc-stamp") + >>> rb.rustc_stamp() == os.path.join("build", "bootstrap-sysroot", ".rustc-stamp") True """ return os.path.join(self.bin_root(), '.rustc-stamp') @@ -588,16 +588,16 @@ def bin_root(self): >>> rb = RustBuild() >>> rb.build_dir = "build" - >>> rb.bin_root() == os.path.join("build", "stage0") + >>> rb.bin_root() == os.path.join("build", "bootstrap-sysroot") True When the 'build' property is given should be a nested directory: >>> rb.build = "devel" - >>> rb.bin_root() == os.path.join("build", "devel", "stage0") + >>> rb.bin_root() == os.path.join("build", "devel", "bootstrap-sysroot") True """ - subdir = "stage0" + subdir = "bootstrap-sysroot" return os.path.join(self.build_dir, self.build, subdir) def get_toml(self, key, section=None): diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs index 0deed3f990d03..0c9c8a142b710 100644 --- a/src/bootstrap/compile.rs +++ b/src/bootstrap/compile.rs @@ -1122,16 +1122,11 @@ impl Step for Sysroot { let compiler = self.compiler; let host_dir = builder.out.join(&compiler.host.triple); - let sysroot_dir = |stage| { - if stage == 0 { - host_dir.join("stage0-sysroot") - } else if builder.download_rustc() && compiler.stage != builder.top_stage { - host_dir.join("ci-rustc-sysroot") - } else { - host_dir.join(format!("stage{}", stage)) - } + let sysroot = if builder.download_rustc() { + host_dir.join("ci-rustc-sysroot") + } else { + host_dir.join(format!("stage{}-sysroot", compiler.stage)) }; - let sysroot = sysroot_dir(compiler.stage); let _ = fs::remove_dir_all(&sysroot); t!(fs::create_dir_all(&sysroot)); diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index babf09d2b9334..4f82e7422bab6 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -967,14 +967,12 @@ impl Config { config.out = crate::util::absolute(&config.out); } - config.initial_rustc = build - .rustc - .map(PathBuf::from) - .unwrap_or_else(|| config.out.join(config.build.triple).join("stage0/bin/rustc")); - config.initial_cargo = build - .cargo - .map(PathBuf::from) - .unwrap_or_else(|| config.out.join(config.build.triple).join("stage0/bin/cargo")); + config.initial_rustc = build.rustc.map(PathBuf::from).unwrap_or_else(|| { + config.out.join(config.build.triple).join("bootstrap-sysroot/bin/rustc") + }); + config.initial_cargo = build.cargo.map(PathBuf::from).unwrap_or_else(|| { + config.out.join(config.build.triple).join("bootstrap-sysroot/bin/cargo") + }); // NOTE: it's important this comes *after* we set `initial_rustc` just above. if config.dry_run() { @@ -1291,7 +1289,7 @@ impl Config { // If using a system toolchain for bootstrapping, see if that has rustfmt available. let host = config.build; let rustfmt_path = config.initial_rustc.with_file_name(exe("rustfmt", host)); - let bin_root = config.out.join(host.triple).join("stage0"); + let bin_root = config.out.join(host.triple).join("bootstrap-sysroot"); if !rustfmt_path.starts_with(&bin_root) { // Using a system-provided toolchain; we shouldn't download rustfmt. *config.initial_rustfmt.borrow_mut() = RustfmtState::SystemToolchain(rustfmt_path); @@ -1649,9 +1647,34 @@ impl Config { compiler/ or library/" ); } - - Some(commit.to_string()) } +fn maybe_download_rustfmt(builder: &Builder<'_>) -> Option { + let RustfmtMetadata { date, version } = builder.config.stage0_metadata.rustfmt.as_ref()?; + let channel = format!("{version}-{date}"); + + let host = builder.config.build; + let rustfmt_path = builder.config.initial_rustc.with_file_name(exe("rustfmt", host)); + let bin_root = builder.config.out.join(host.triple).join("bootstrap-sysroot"); + let rustfmt_stamp = bin_root.join(".rustfmt-stamp"); + if rustfmt_path.exists() && !program_out_of_date(&rustfmt_stamp, &channel) { + return Some(rustfmt_path); + } + + let filename = format!("rustfmt-{version}-{build}.tar.xz", build = host.triple); + download_component( + builder, + DownloadSource::Dist, + filename, + "rustfmt-preview", + &date, + "bootstrap-sysroot", + ); + + builder.fix_bin_or_dylib(&bin_root.join("bin").join("rustfmt")); + builder.fix_bin_or_dylib(&bin_root.join("bin").join("cargo-fmt")); + + builder.create(&rustfmt_stamp, &channel); + Some(rustfmt_path) } fn set(field: &mut T, val: Option) { diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index f4fa556b97450..e4f1d0b0ae064 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -191,7 +191,7 @@ const LLVM_TOOLS: &[&str] = &[ /// LLD file names for all flavors. const LLD_FILE_NAMES: &[&str] = &["ld.lld", "ld64.lld", "lld-link", "wasm-ld"]; -pub const VERSION: usize = 2; +pub const VERSION: usize = 3; /// Extra --check-cfg to add when building /// (Mode restriction, config name, config values (if any)) diff --git a/src/ci/pgo.sh b/src/ci/pgo.sh index cbe32920a7458..232d497155e01 100755 --- a/src/ci/pgo.sh +++ b/src/ci/pgo.sh @@ -23,9 +23,9 @@ fi # The various build artifacts used in other commands: to launch rustc builds, build the perf # collector, and run benchmarks to gather profiling data BUILD_ARTIFACTS=$BUILD_ROOT/build/$PGO_HOST -RUSTC_STAGE_0=$BUILD_ARTIFACTS/stage0/bin/rustc -CARGO_STAGE_0=$BUILD_ARTIFACTS/stage0/bin/cargo -RUSTC_STAGE_2=$BUILD_ARTIFACTS/stage2/bin/rustc +RUSTC_STAGE_0=$BUILD_ARTIFACTS/bootstrap-sysroot/bin/rustc +CARGO_STAGE_0=$BUILD_ARTIFACTS/bootstrap-sysroot/bin/cargo +RUSTC_STAGE_2=$BUILD_ARTIFACTS/stage2-sysroot/bin/rustc # Windows needs these to have the .exe extension if isWindows; then @@ -226,5 +226,5 @@ else fi echo "Rustc binary size" -ls -la ./build/$PGO_HOST/stage2/bin -ls -la ./build/$PGO_HOST/stage2/lib +ls -la ./build/$PGO_HOST/stage2-sysroot/bin +ls -la ./build/$PGO_HOST/stage2-sysroot/lib