#366

Make lowering BLD004 diagnostics target-aware

OpenTumCucTomwants to merge intofrom

Summary

Direct backend lowering diagnostics reported a generic direct backend local type is unsupported message regardless of the actual target, even though the expected and help fields already named the target correctly. The fix substitutes the generic direct backend prefix with a target-specific label (COFF x64, ELF64, AArch64 Mach-O, x86_64 Mach-O, COFF AArch64, AArch64 ELF) when the IR lowering message is wrapped into a buildability diagnostic.

The bug was originally surfaced as part of the agent-surface repros in #68, where the message stayed target-blind in spite of the target-correct expected and help strings. The agent-surface classification for the owned-drop-direct-backend-unsupported fixture already called out "keep backend diagnostics target-correct" as a follow-up.

Changes

  • Add z_direct_backend_target_label helper in target_backend.c.
  • Use it in init_lowering_backend_diag (the message-rewrite site hit by the targetReadiness JSON for lowering blockers) and in z_build_diag (the z_direct_buildability_check funnel).
  • Leave messages that do not start with the direct backend prefix untouched so callers that already pass a target-aware message are unaffected.
  • Bump the file-line budgets in scripts/compiler-metrics.mts to cover the new helper and the rewritten branch.
  • Add regression assertions in conformance/run.mjs covering linux-musl-x64, win32-x64.exe, and darwin-x64 against the existing owned-drop-direct-backend-unsupported.0 fixture, so a future regression to the generic prefix fails conformance.

Verification

  • ./.zero/bin/zero check --json --emit obj --target <tgt> conformance/agent-surface/fixtures/owned-drop-direct-backend-unsupported.0 for linux-musl-x64, linux-x64, linux-musl-arm64, win32-x64.exe, darwin-x64, darwin-arm64 now reports direct ELF64 local type is unsupported, direct ELF64 local type is unsupported, direct AArch64 ELF local type is unsupported, direct COFF x64 local type is unsupported, direct x86_64 Mach-O local type is unsupported, and direct AArch64 Mach-O local type is unsupported respectively.
  • node --experimental-strip-types --disable-warning=ExperimentalWarning scripts/compiler-metrics.mts reports zero budget violations.
  • ZERO_NATIVE_TEST_ALLOW_LOCAL=1 node conformance/run.mjs reports conformance ok, including the new target-aware message assertions.

Out of scope

The same generic prefix is also used in emit_*.c files (emit_elf64.c, emit_coff.c, emit_macho64.c, ...) that report CGEN004 from the emit layer. Those code paths are only hit if buildability passes and emission later fails, which is a different surface than the agent-surface fixture. They are not covered here to keep the change scoped to the buildability path that the user-visible diagnostic flows through today.

Activity

4
vercel[bot]5mo ago

@TumCucTom is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.