Skip to content

Commit 288c8af

Browse files
committed
Enable download of the Cranelift backend component in install_next
1 parent b5d9163 commit 288c8af

File tree

2 files changed

+27
-10
lines changed

2 files changed

+27
-10
lines changed

collector/src/bin/collector.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,11 @@ enum Commands {
539539
},
540540

541541
/// Installs the next commit for perf.rust-lang.org
542-
InstallNext,
542+
InstallNext {
543+
/// Install additional components to enable benchmarking of the given backends.
544+
#[arg(long = "backends", value_parser = EnumArgParser::<CodegenBackend>::default(), default_value = "Llvm")]
545+
codegen_backends: MultiEnumValue<CodegenBackend>,
546+
},
543547

544548
/// Download a crate into collector/benchmarks.
545549
Download(DownloadCommand),
@@ -854,8 +858,12 @@ fn main_result() -> anyhow::Result<i32> {
854858
runs,
855859
} => {
856860
let sha = commit.sha.to_string();
857-
let sysroot = Sysroot::install(sha.clone(), &target_triple)
858-
.with_context(|| format!("failed to install sysroot for {:?}", commit))?;
861+
let sysroot = Sysroot::install(
862+
sha.clone(),
863+
&target_triple,
864+
vec![CodegenBackend::Llvm],
865+
)
866+
.with_context(|| format!("failed to install sysroot for {:?}", commit))?;
859867

860868
let mut benchmarks = get_compile_benchmarks(
861869
&compile_benchmark_dir,
@@ -1030,7 +1038,7 @@ fn main_result() -> anyhow::Result<i32> {
10301038
Ok(0)
10311039
}
10321040

1033-
Commands::InstallNext => {
1041+
Commands::InstallNext { codegen_backends } => {
10341042
let last_sha = Command::new("git")
10351043
.arg("ls-remote")
10361044
.arg("https://github.com/rust-lang/rust.git")
@@ -1040,7 +1048,7 @@ fn main_result() -> anyhow::Result<i32> {
10401048
let last_sha = String::from_utf8(last_sha.stdout).expect("utf8");
10411049
let last_sha = last_sha.split_whitespace().next().expect(&last_sha);
10421050
let commit = get_commit_or_fake_it(last_sha).expect("success");
1043-
let mut sysroot = Sysroot::install(commit.sha, &target_triple)?;
1051+
let mut sysroot = Sysroot::install(commit.sha, &target_triple, codegen_backends.0)?;
10441052
sysroot.preserve(); // don't delete it
10451053

10461054
// Print the directory containing the toolchain.

collector/src/toolchain.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@ pub struct Sysroot {
2020
}
2121

2222
impl Sysroot {
23-
pub fn install(sha: String, triple: &str) -> anyhow::Result<Self> {
23+
pub fn install(
24+
sha: String,
25+
triple: &str,
26+
backends: Vec<CodegenBackend>,
27+
) -> anyhow::Result<Self> {
2428
let unpack_into = "cache";
2529

2630
fs::create_dir_all(unpack_into)?;
@@ -35,6 +39,9 @@ impl Sysroot {
3539
download.get_and_extract(Component::Std)?;
3640
download.get_and_extract(Component::Cargo)?;
3741
download.get_and_extract(Component::RustSrc)?;
42+
if backends.contains(&CodegenBackend::Cranelift) {
43+
download.get_and_extract(Component::Cranelift)?;
44+
}
3845

3946
let sysroot = download.into_sysroot()?;
4047

@@ -76,6 +83,7 @@ enum Component {
7683
Rustc,
7784
Std,
7885
RustSrc,
86+
Cranelift,
7987
}
8088

8189
impl fmt::Display for Component {
@@ -85,6 +93,7 @@ impl fmt::Display for Component {
8593
Component::Rustc => write!(f, "rustc"),
8694
Component::Std => write!(f, "rust-std"),
8795
Component::RustSrc => write!(f, "rust-src"),
96+
Component::Cranelift => write!(f, "rustc-codegen-cranelift"),
8897
}
8998
}
9099
}
@@ -187,10 +196,10 @@ impl SysrootDownload {
187196

188197
fn extract<T: Read>(&self, component: Component, reader: T) -> anyhow::Result<()> {
189198
let mut archive = Archive::new(reader);
190-
let prefix = if component == Component::Std {
191-
format!("rust-std-{}", self.triple)
192-
} else {
193-
component.to_string()
199+
let prefix = match component {
200+
Component::Std => format!("rust-std-{}", self.triple),
201+
Component::Cranelift => format!("{component}-preview"),
202+
_ => component.to_string(),
194203
};
195204

196205
let unpack_into = self.directory.join(&self.rust_sha);

0 commit comments

Comments
 (0)