Skip to content

internal: Support specific tags for PGO #19618

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 18, 2025
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
12 changes: 6 additions & 6 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -42,24 +42,24 @@ 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
code-target: linux-armhf
- 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 }}
Expand Down
20 changes: 14 additions & 6 deletions xtask/src/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
};

Expand Down Expand Up @@ -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)
}
Expand Down