Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions collector/src/bin/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1207,6 +1207,7 @@ fn main_result() -> anyhow::Result<i32> {
Path::new(TOOLCHAIN_CACHE_DIRECTORY),
commit.sha,
&require_host_target_tuple(),
Profile::Check,
&codegen_backends.0,
))
.map_err(SysrootDownloadError::as_anyhow_error)?;
Expand Down Expand Up @@ -1585,6 +1586,7 @@ async fn run_benchmark_job(
Path::new(TOOLCHAIN_CACHE_DIRECTORY),
commit.sha.clone(),
job.target().as_str(),
job.profile().into(),
&[job.backend().into()],
)
.await
Expand Down
29 changes: 27 additions & 2 deletions collector/src/toolchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ impl Sysroot {
cache_directory: &Path,
sha: String,
triple: &str,
profile: Profile,
backends: &[CodegenBackend],
) -> Result<Self, SysrootDownloadError> {
// The structure of this directory is load-bearing.
Expand All @@ -59,6 +60,7 @@ impl Sysroot {
};

let requires_cranelift = backends.contains(&CodegenBackend::Cranelift);
let requires_clippy = profile == Profile::Clippy;

let stamp = SysrootStamp::load_from_dir(&cache_directory);
match stamp {
Expand All @@ -69,6 +71,9 @@ impl Sysroot {
if requires_cranelift && !stamp.cranelift {
download.get_and_extract(Component::Cranelift).await?;
}
if requires_clippy && !stamp.clippy {
download.get_and_extract(Component::Clippy).await?;
}
}
Err(_) => {
log::debug!(
Expand All @@ -83,12 +88,16 @@ impl Sysroot {
if requires_cranelift {
download.get_and_extract(Component::Cranelift).await?;
}
if requires_clippy {
download.get_and_extract(Component::Clippy).await?;
}
}
}

// Update the stamp
let stamp = SysrootStamp {
cranelift: requires_cranelift,
clippy: requires_clippy,
};
stamp
.store_to_dir(&cache_directory)
Expand Down Expand Up @@ -127,6 +136,8 @@ const SYSROOT_STAMP_FILENAME: &str = ".sysroot-stamp.json";
struct SysrootStamp {
/// Was Cranelift downloaded as a part of the sysroot?
cranelift: bool,
/// Was Clippy downloaded as a part of the sysroot?
clippy: bool,
}

impl SysrootStamp {
Expand Down Expand Up @@ -158,6 +169,7 @@ enum Component {
Std,
RustSrc,
Cranelift,
Clippy,
}

impl fmt::Display for Component {
Expand All @@ -168,6 +180,7 @@ impl fmt::Display for Component {
Component::Std => write!(f, "rust-std"),
Component::RustSrc => write!(f, "rust-src"),
Component::Cranelift => write!(f, "rustc-codegen-cranelift"),
Component::Clippy => write!(f, "clippy"),
}
}
}
Expand Down Expand Up @@ -280,12 +293,13 @@ impl SysrootDownload {
let mut archive = Archive::new(reader);
let prefix = match component {
Component::Std => format!("rust-std-{}", self.triple),
Component::Cranelift => format!("{component}-preview"),
_ => component.to_string(),
Component::Clippy | Component::Cranelift => format!("{component}-preview"),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the clippy component actually named clippy-preview?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is indeed, I tried it locally. I think that rustup ignores the preview part, but we can't get rid of it, or something. The whole preview thing is pretty broken (but also Hyrumized at this point).

Component::Cargo | Component::Rustc | Component::RustSrc => component.to_string(),
};

let unpack_into = &self.cache_directory;

let mut file_found = false;
for entry in archive.entries()? {
let mut entry = entry?;
let path = entry.path()?.into_owned();
Expand All @@ -298,6 +312,7 @@ impl SysrootDownload {
} else {
continue;
};
file_found = true;
fs::create_dir_all(path.parent().unwrap()).with_context(|| {
format!(
"could not create intermediate directories for {}",
Expand All @@ -307,6 +322,13 @@ impl SysrootDownload {
entry.unpack(path)?;
}

if !file_found {
eprintln!("Did not find any file to unpack in component {component:?}");
return Err(anyhow::anyhow!(
"Did not find any file to unpack in component {component:?}"
));
}

Ok(())
}
}
Expand Down Expand Up @@ -497,6 +519,9 @@ pub fn get_local_toolchain(
if codegen_backends.contains(&CodegenBackend::Cranelift) {
additional_components.push("rustc-codegen-cranelift");
}
if profiles.contains(&Profile::Clippy) {
additional_components.push("clippy");
}

let mut cmd = Command::new("rustup-toolchain-install-master");
cmd.arg(toolchain);
Expand Down
Loading