Skip to content

Commit 29dfd1d

Browse files
committed
fe reports: capture verifier errors explicitly
1 parent bba3f3d commit 29dfd1d

3 files changed

Lines changed: 60 additions & 10 deletions

File tree

crates/fe/src/check.rs

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ use url::Url;
1717

1818
use crate::report::{
1919
copy_input_into_report, create_dir_all_utf8, create_report_staging_dir, enable_panic_report,
20-
normalize_report_out_path, panic_payload_to_string, tar_gz_dir, write_report_meta,
20+
is_verifier_error_text, normalize_report_out_path, panic_payload_to_string, tar_gz_dir,
21+
write_report_meta,
2122
};
2223

2324
#[derive(Debug, Clone)]
@@ -65,6 +66,13 @@ fn write_report_file(report: &ReportContext, rel: &str, contents: &str) {
6566
let _ = std::fs::write(path, contents);
6667
}
6768

69+
fn write_codegen_report_error(report: &ReportContext, contents: &str) {
70+
write_report_file(report, "errors/codegen_error.txt", contents);
71+
if is_verifier_error_text(contents) {
72+
write_report_file(report, "errors/verifier_error.txt", contents);
73+
}
74+
}
75+
6876
pub fn check(
6977
path: &Utf8PathBuf,
7078
dump_mir: bool,
@@ -568,7 +576,7 @@ fn check_ingot_and_dependencies(
568576
emit_codegen(db, root_mod, backend);
569577
}
570578
if let Some(report) = report {
571-
write_check_artifacts(db, root_mod, backend_kind, backend, report);
579+
has_errors |= write_check_artifacts(db, root_mod, backend_kind, backend, report);
572580
}
573581
}
574582

@@ -675,8 +683,10 @@ fn check_single_file(
675683
if emit_yul_min {
676684
emit_codegen(db, top_mod, backend);
677685
}
678-
if let Some(report) = report {
679-
write_check_artifacts(db, top_mod, backend_kind, backend, report);
686+
if let Some(report) = report
687+
&& write_check_artifacts(db, top_mod, backend_kind, backend, report)
688+
{
689+
return true;
680690
}
681691
} else {
682692
eprintln!("❌ Error: Could not process file {file_path}");
@@ -799,7 +809,7 @@ fn check_ingot_inner(
799809
emit_codegen(db, root_mod, backend);
800810
}
801811
if let Some(report) = report {
802-
write_check_artifacts(db, root_mod, backend_kind, backend, report);
812+
has_errors |= write_check_artifacts(db, root_mod, backend_kind, backend, report);
803813
}
804814
}
805815

@@ -923,7 +933,7 @@ fn write_check_artifacts(
923933
backend_kind: BackendKind,
924934
backend: &dyn Backend,
925935
report: &ReportContext,
926-
) {
936+
) -> bool {
927937
match lower_module(db, top_mod) {
928938
Ok(mir) => {
929939
write_report_file(
@@ -975,6 +985,7 @@ fn write_check_artifacts(
975985
Ok(Ok(output)) => match output {
976986
codegen::BackendOutput::Yul(yul) => {
977987
write_report_file(report, "artifacts/backend_output.yul", &yul);
988+
false
978989
}
979990
codegen::BackendOutput::Bytecode(bytes) => {
980991
write_report_file(
@@ -987,10 +998,13 @@ fn write_check_artifacts(
987998
"artifacts/backend_bytecode_len.txt",
988999
&format!("{}\n", bytes.len()),
9891000
);
1001+
false
9901002
}
9911003
},
9921004
Ok(Err(err)) => {
993-
write_report_file(report, "errors/codegen_error.txt", &format!("{err}"));
1005+
let err = format!("{err}");
1006+
write_codegen_report_error(report, &err);
1007+
true
9941008
}
9951009
Err(payload) => {
9961010
write_report_file(
@@ -1001,6 +1015,7 @@ fn write_check_artifacts(
10011015
panic_payload_to_string(payload.as_ref())
10021016
),
10031017
);
1018+
true
10041019
}
10051020
}
10061021
}

crates/fe/src/report.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,3 +335,30 @@ pub fn write_report_meta(root: &Utf8PathBuf, kind: &str, suite: Option<&str>) {
335335
write_best_effort(&meta.join("rustc.txt"), txt);
336336
}
337337
}
338+
339+
pub fn is_verifier_error_text(text: &str) -> bool {
340+
let normalized = text.to_ascii_lowercase();
341+
normalized.contains("verifierfailed")
342+
|| normalized.contains("verificationreport")
343+
|| normalized.contains("verifier failed")
344+
}
345+
346+
#[cfg(test)]
347+
mod tests {
348+
use super::is_verifier_error_text;
349+
350+
#[test]
351+
fn detects_verifier_error_markers() {
352+
assert!(is_verifier_error_text(
353+
"internal error: VerifierFailed { report: VerificationReport { ... } }"
354+
));
355+
assert!(is_verifier_error_text(
356+
"backend verifier failed while compiling module"
357+
));
358+
}
359+
360+
#[test]
361+
fn ignores_non_verifier_errors() {
362+
assert!(!is_verifier_error_text("failed to lower MIR"));
363+
}
364+
}

crates/fe/src/test.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
66
use crate::report::{
77
PanicReportGuard, ReportStaging, copy_input_into_report, create_dir_all_utf8,
8-
create_report_staging_root, enable_panic_report, normalize_report_out_path,
9-
panic_payload_to_string, sanitize_filename, tar_gz_dir, write_report_meta,
8+
create_report_staging_root, enable_panic_report, is_verifier_error_text,
9+
normalize_report_out_path, panic_payload_to_string, sanitize_filename, tar_gz_dir,
10+
write_report_meta,
1011
};
1112
use camino::Utf8PathBuf;
1213
use codegen::{
@@ -58,6 +59,13 @@ fn write_report_error(report: &ReportContext, filename: &str, contents: &str) {
5859
let _ = std::fs::write(dir.join(filename), contents);
5960
}
6061

62+
fn write_codegen_report_error(report: &ReportContext, contents: &str) {
63+
write_report_error(report, "codegen_error.txt", contents);
64+
if is_verifier_error_text(contents) {
65+
write_report_error(report, "verifier_error.txt", contents);
66+
}
67+
}
68+
6169
#[derive(Debug, Clone)]
6270
struct ReportContext {
6371
root_dir: Utf8PathBuf,
@@ -554,7 +562,7 @@ fn emit_with_catch_unwind<E: std::fmt::Display>(
554562
let msg = format!("Failed to emit test {backend_label}: {err}");
555563
eprintln!("{msg}");
556564
if let Some(report) = report {
557-
write_report_error(report, "codegen_error.txt", &msg);
565+
write_codegen_report_error(report, &msg);
558566
}
559567
Err(suite_error_result(suite, "codegen", msg))
560568
}

0 commit comments

Comments
 (0)