download beta compiler toolchain in bootstrap if it doesn't yet exist
This is needed for when the shell scripts bypass python altogether and run the downloaded bootstrap directly. Changes are mainly provided from @jyn514, I just fixed the review notes. Signed-off-by: ozkanonur <work@onurozkan.dev>
This commit is contained in:
parent
356c651e6d
commit
eeec73244d
@ -223,25 +223,34 @@ pub struct Config {
|
||||
pub reuse: Option<PathBuf>,
|
||||
pub cargo_native_static: bool,
|
||||
pub configure_args: Vec<String>,
|
||||
pub out: PathBuf,
|
||||
pub rust_info: channel::GitInfo,
|
||||
|
||||
// These are either the stage0 downloaded binaries or the locally installed ones.
|
||||
pub initial_cargo: PathBuf,
|
||||
pub initial_rustc: PathBuf,
|
||||
|
||||
#[cfg(not(test))]
|
||||
initial_rustfmt: RefCell<RustfmtState>,
|
||||
#[cfg(test)]
|
||||
pub initial_rustfmt: RefCell<RustfmtState>,
|
||||
pub out: PathBuf,
|
||||
pub rust_info: channel::GitInfo,
|
||||
}
|
||||
|
||||
#[derive(Default, Deserialize)]
|
||||
#[cfg_attr(test, derive(Clone))]
|
||||
pub struct Stage0Metadata {
|
||||
pub compiler: CompilerMetadata,
|
||||
pub config: Stage0Config,
|
||||
pub checksums_sha256: HashMap<String, String>,
|
||||
pub rustfmt: Option<RustfmtMetadata>,
|
||||
}
|
||||
#[derive(Default, Deserialize)]
|
||||
#[cfg_attr(test, derive(Clone))]
|
||||
pub struct CompilerMetadata {
|
||||
pub date: String,
|
||||
pub version: String,
|
||||
}
|
||||
|
||||
#[derive(Default, Deserialize)]
|
||||
#[cfg_attr(test, derive(Clone))]
|
||||
pub struct Stage0Config {
|
||||
@ -989,10 +998,10 @@ fn parse_inner<'a>(args: &[String], get_toml: impl 'a + Fn(&Path) -> TomlConfig)
|
||||
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_rustc = build.rustc.map(PathBuf::from).unwrap_or_else(|| {
|
||||
config.download_beta_toolchain();
|
||||
config.out.join(config.build.triple).join("stage0/bin/rustc")
|
||||
});
|
||||
config.initial_cargo = build
|
||||
.cargo
|
||||
.map(PathBuf::from)
|
||||
|
@ -367,26 +367,70 @@ pub(crate) fn maybe_download_rustfmt(&self) -> Option<PathBuf> {
|
||||
|
||||
pub(crate) fn download_ci_rustc(&self, commit: &str) {
|
||||
self.verbose(&format!("using downloaded stage2 artifacts from CI (commit {commit})"));
|
||||
|
||||
let version = self.artifact_version_part(commit);
|
||||
// download-rustc doesn't need its own cargo, it can just use beta's. But it does need the
|
||||
// `rustc_private` crates for tools.
|
||||
let extra_components = ["rustc-dev"];
|
||||
|
||||
self.download_toolchain(
|
||||
&version,
|
||||
"ci-rustc",
|
||||
commit,
|
||||
&extra_components,
|
||||
Self::download_ci_component,
|
||||
);
|
||||
}
|
||||
|
||||
pub(crate) fn download_beta_toolchain(&self) {
|
||||
self.verbose(&format!("downloading stage0 beta artifacts"));
|
||||
|
||||
let date = &self.stage0_metadata.compiler.date;
|
||||
let version = &self.stage0_metadata.compiler.version;
|
||||
let extra_components = ["cargo"];
|
||||
|
||||
let download_beta_component = |config: &Config, filename, prefix: &_, date: &_| {
|
||||
config.download_component(DownloadSource::Dist, filename, prefix, date, "stage0")
|
||||
};
|
||||
|
||||
self.download_toolchain(
|
||||
version,
|
||||
"stage0",
|
||||
date,
|
||||
&extra_components,
|
||||
download_beta_component,
|
||||
);
|
||||
}
|
||||
|
||||
fn download_toolchain(
|
||||
&self,
|
||||
// FIXME(ozkanonur) use CompilerMetadata instead of `version: &str`
|
||||
version: &str,
|
||||
sysroot: &str,
|
||||
stamp_key: &str,
|
||||
extra_components: &[&str],
|
||||
download_component: fn(&Config, String, &str, &str),
|
||||
) {
|
||||
let host = self.build.triple;
|
||||
let bin_root = self.out.join(host).join("ci-rustc");
|
||||
let bin_root = self.out.join(host).join(sysroot);
|
||||
let rustc_stamp = bin_root.join(".rustc-stamp");
|
||||
|
||||
if !bin_root.join("bin").join("rustc").exists() || program_out_of_date(&rustc_stamp, commit)
|
||||
if !bin_root.join("bin").join(exe("rustc", self.build)).exists()
|
||||
|| program_out_of_date(&rustc_stamp, stamp_key)
|
||||
{
|
||||
if bin_root.exists() {
|
||||
t!(fs::remove_dir_all(&bin_root));
|
||||
}
|
||||
let filename = format!("rust-std-{version}-{host}.tar.xz");
|
||||
let pattern = format!("rust-std-{host}");
|
||||
self.download_ci_component(filename, &pattern, commit);
|
||||
download_component(self, filename, &pattern, stamp_key);
|
||||
let filename = format!("rustc-{version}-{host}.tar.xz");
|
||||
self.download_ci_component(filename, "rustc", commit);
|
||||
// download-rustc doesn't need its own cargo, it can just use beta's.
|
||||
let filename = format!("rustc-dev-{version}-{host}.tar.xz");
|
||||
self.download_ci_component(filename, "rustc-dev", commit);
|
||||
let filename = format!("rust-src-{version}.tar.xz");
|
||||
self.download_ci_component(filename, "rust-src", commit);
|
||||
download_component(self, filename, "rustc", stamp_key);
|
||||
|
||||
for component in extra_components {
|
||||
let filename = format!("{component}-{version}-{host}.tar.xz");
|
||||
download_component(self, filename, component, stamp_key);
|
||||
}
|
||||
|
||||
if self.should_fix_bins_and_dylibs() {
|
||||
self.fix_bin_or_dylib(&bin_root.join("bin").join("rustc"));
|
||||
@ -403,7 +447,7 @@ pub(crate) fn download_ci_rustc(&self, commit: &str) {
|
||||
}
|
||||
}
|
||||
|
||||
t!(fs::write(rustc_stamp, commit));
|
||||
t!(fs::write(rustc_stamp, stamp_key));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1133,7 +1133,7 @@ fn run(self, builder: &Builder<'_>) {
|
||||
if builder.config.channel == "dev" || builder.config.channel == "nightly" {
|
||||
builder.info("fmt check");
|
||||
if builder.initial_rustfmt().is_none() {
|
||||
let inferred_rustfmt_dir = builder.config.initial_rustc.parent().unwrap();
|
||||
let inferred_rustfmt_dir = builder.initial_rustc.parent().unwrap();
|
||||
eprintln!(
|
||||
"\
|
||||
error: no `rustfmt` binary found in {PATH}
|
||||
|
Loading…
Reference in New Issue
Block a user