Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Kobzol committed Jan 24, 2025
1 parent ef94563 commit 17dc8aa
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 54 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
rust-version: [ 1.78.0, stable, beta, nightly ]
rust-version: [ 1.80.0, stable, beta, nightly ]
steps:
- name: Checkout sources
uses: actions/checkout@v2
Expand Down Expand Up @@ -45,7 +45,7 @@ jobs:
- name: Install stable toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: 1.78.0
toolchain: 1.80.0
components: clippy, rustfmt, llvm-tools-preview

- name: Build
Expand Down
64 changes: 24 additions & 40 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 3 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "cargo-pgo"
version = "0.2.8"
edition = "2021"
rust-version = "1.78.0"
rust-version = "1.80.0"

description = "Cargo subcommand for optimizing Rust binaries with PGO and BOLT."
repository = "https://github.com/kobzol/cargo-pgo"
Expand Down Expand Up @@ -30,9 +30,9 @@ which = "7"
clap = { version = "4.5", features = ["derive"] }
log = "0.4"
env_logger = "0.11"
colored = "2"
colored = "3"
cargo_metadata = "0.19"
humansize = "1"
humansize = "2"
semver = "1"
tempfile = "3.14"
regex = "1.11"
Expand All @@ -42,6 +42,3 @@ walkdir = "2.5"
shellwords = "1.1"
blake3 = "1.4"
version_check = "0.9"

[dev-dependencies]
version_check = "0.9"
1 change: 1 addition & 0 deletions src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ pub fn cargo_command_with_rustflags(
env.insert("RUSTFLAGS".to_string(), existing_rustflags);
}
(false, _) => {
panic!("FOO");
// If there's no RUSTFLAGS, and Cargo doesn't support `--config` yet, just use
// RUSTFLAGS.
env.insert("RUSTFLAGS".to_string(), serialized_rustflags);

Check failure on line 92 in src/build.rs

View workflow job for this annotation

GitHub Actions / Test (stable)

unreachable statement

Check failure on line 92 in src/build.rs

View workflow job for this annotation

GitHub Actions / Test on Windows

unreachable statement

Check failure on line 92 in src/build.rs

View workflow job for this annotation

GitHub Actions / Test (beta)

unreachable statement
Expand Down
5 changes: 2 additions & 3 deletions src/pgo/optimize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ use anyhow::anyhow;
use cargo_metadata::diagnostic::DiagnosticLevel;
use cargo_metadata::{CompilerMessage, Message};
use colored::Colorize;
use humansize::file_size_opts::BINARY;
use humansize::FileSize;
use humansize::{format_size, BINARY};
use once_cell::sync::OnceCell;
use regex::Regex;
use rustc_demangle::{demangle, Demangle};
Expand Down Expand Up @@ -153,7 +152,7 @@ fn print_pgo_profile_stats(stats: &ProfileStats, pgo_dir: &Path) -> anyhow::Resu
} else {
"file"
},
stats.total_size.file_size(BINARY).unwrap().yellow(),
format_size(stats.total_size, BINARY).yellow(),
cli_format_path(pgo_dir.display())
);
Ok(())
Expand Down
12 changes: 9 additions & 3 deletions tests/integration/pgo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,10 +325,16 @@ rustflags = ["-Ctarget-cpu=native"]
),
);

eprintln!("{}", &format!(
r#"
[target.{}]
rustflags = ["-Ctarget-cpu=native"]
"#,
target
));
let output = project.cmd(&["build", "--", "-v"]).run()?;
println!("{}", output.stderr());
assert!(output.stderr().contains("-Ctarget-cpu=native"));
assert!(output.stderr().contains("-Cprofile-generate"));
output.assert_stderr_contains("-Ctarget-cpu=native");
output.assert_stderr_contains("-Cprofile-generate");
output.assert_ok();

Ok(())
Expand Down
9 changes: 9 additions & 0 deletions tests/integration/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ pub trait OutputExt {
fn assert_ok(self) -> Self;
fn assert_error(self) -> Self;

fn assert_stderr_contains(&self, needle: &str);

fn stdout(&self) -> String;
fn stderr(&self) -> String;
}
Expand All @@ -190,6 +192,13 @@ impl OutputExt for Output {
self
}

fn assert_stderr_contains(&self, needle: &str) {
let stderr = self.stderr();
if !stderr.contains(needle) {
panic!("STDERR\n{stderr}\nDOES NOT CONTAIN\n{needle}");
}
}

fn stdout(&self) -> String {
String::from_utf8_lossy(&self.stdout).to_string()
}
Expand Down

0 comments on commit 17dc8aa

Please sign in to comment.