Skip to content
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

Improve parsing of rustc artifacts #1755

Merged
merged 1 commit into from
Nov 26, 2023
Merged
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
14 changes: 11 additions & 3 deletions collector/src/compile/execute/profiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,15 +298,23 @@ impl<'a> Processor for ProfileProcessor<'a> {
let tmp_eprintln_file = filepath(data.cwd, "eprintln");
let eprintln_file = filepath(self.output_dir, &out_file("eprintln"));

#[allow(dead_code)]
#[derive(serde::Deserialize)]
struct RustcMessage<'a> {
#[serde(rename = "$message_type")]
message_type: &'a str,
}

let mut final_file = io::BufWriter::new(std::fs::File::create(&eprintln_file)?);
for line in io::BufReader::new(std::fs::File::open(&tmp_eprintln_file)?).lines()
{
let line = line?;

// rustc under Cargo currently ~always emits artifact
// messages -- which we don't want in final
// eprintln output. These messages generally look like:
// {"artifact":"/tmp/.tmpjIe45J/...","emit":"dep-info"}
if line.starts_with(r#"{"artifact":"#) {
// eprintln output. These messages contain a $message_type tag since
// https://github.com/rust-lang/rust/pull/115691.
if serde_json::from_str::<RustcMessage>(&line).is_ok() {
continue;
}

Expand Down
Loading