Support specific revisions for pgo

This commit is contained in:
Laurențiu Nicola 2025-04-18 12:32:52 +03:00
parent ed737b545e
commit 0ba49a3777
2 changed files with 20 additions and 12 deletions

View file

@ -29,10 +29,10 @@ jobs:
- os: windows-latest
target: x86_64-pc-windows-msvc
code-target: win32-x64
pgo: clap-rs/clap
pgo: clap-rs/clap@v4.5.36
- os: windows-latest
target: i686-pc-windows-msvc
pgo: clap-rs/clap
pgo: clap-rs/clap@v4.5.36
- os: windows-latest
target: aarch64-pc-windows-msvc
code-target: win32-arm64
@ -42,12 +42,12 @@ jobs:
# Zig is not used because it doesn't work with PGO
container: quay.io/pypa/manylinux_2_28_x86_64
code-target: linux-x64
pgo: clap-rs/clap
pgo: clap-rs/clap@v4.5.36
- os: ubuntu-24.04-arm
target: aarch64-unknown-linux-gnu
container: quay.io/pypa/manylinux_2_28_aarch64
code-target: linux-arm64
pgo: clap-rs/clap
pgo: clap-rs/clap@v4.5.36
- os: ubuntu-latest
target: arm-unknown-linux-gnueabihf
zig_target: arm-unknown-linux-gnueabihf.2.28
@ -55,11 +55,11 @@ jobs:
- os: macos-13
target: x86_64-apple-darwin
code-target: darwin-x64
pgo: clap-rs/clap
pgo: clap-rs/clap@v4.5.36
- os: macos-14
target: aarch64-apple-darwin
code-target: darwin-arm64
pgo: clap-rs/clap
pgo: clap-rs/clap@v4.5.36
name: dist (${{ matrix.target }})
runs-on: ${{ matrix.os }}

View file

@ -180,8 +180,8 @@ fn gather_pgo_profile<'a>(
let (train_path, label) = match &train_crate {
PgoTrainingCrate::RustAnalyzer => (PathBuf::from("."), "itself"),
PgoTrainingCrate::GitHub(url) => {
(download_crate_for_training(sh, &pgo_dir, url)?, url.as_str())
PgoTrainingCrate::GitHub(repo) => {
(download_crate_for_training(sh, &pgo_dir, repo)?, repo.as_str())
}
};
@ -212,12 +212,20 @@ fn gather_pgo_profile<'a>(
}
/// Downloads a crate from GitHub, stores it into `pgo_dir` and returns a path to it.
fn download_crate_for_training(sh: &Shell, pgo_dir: &Path, url: &str) -> anyhow::Result<PathBuf> {
let normalized_path = url.replace("/", "-");
fn download_crate_for_training(sh: &Shell, pgo_dir: &Path, repo: &str) -> anyhow::Result<PathBuf> {
let mut it = repo.splitn(2, '@');
let repo = it.next().unwrap();
let revision = it.next();
// FIXME: switch to `--revision` here around 2035 or so
let revision =
if let Some(revision) = revision { &["--branch", revision] as &[&str] } else { &[] };
let normalized_path = repo.replace("/", "-");
let target_path = pgo_dir.join(normalized_path);
cmd!(sh, "git clone --depth 1 https://github.com/{url} {target_path}")
cmd!(sh, "git clone --depth 1 https://github.com/{repo} {revision...} {target_path}")
.run()
.with_context(|| "cannot download PGO training crate from {url}")?;
.with_context(|| "cannot download PGO training crate from {repo}")?;
Ok(target_path)
}