Skip to content

test(c-backend): every C syntax check asks cc which flags it takes (Closes #5907) - #5930

Merged
dmitrii-f-t27 merged 1 commit into
masterfrom
fix/c-tests-use-get-cc-args
Oct 4, 2026
Merged

dmitrii-f-t27 merged 1 commit into
masterfrom
fix/c-tests-use-get-cc-args

Conversation

@gHashTag

@gHashTag gHashTag commented Oct 4, 2026

Copy link
Copy Markdown
Owner

Closes #5907
Part of #5906

Defect

Bootstrap Test Ratchet is red on master (5432ded): 24 tests are newly failing against scripts/ci/test-baseline.txt. 23 of them are C-backend tests. Fifteen bootstrap/tests/c_*.rs files hand-copied clang's -ferror-limit=0. CI's cc is gcc, which refuses the whole command line:

cc: error: unrecognized command-line option '-ferror-limit=0'

That refusal broke the two assertion shapes in opposite directions:

  • !stderr.contains("error") went red, because the refusal contains the word "error". That gives the 23 failures.
  • Counting file:line:col: error: lines went green having compiled nothing, because the refusal has no line:col (9 files).

common::get_cc_args() (1acab84) was written for this, but no test used it. It also did not compile, and its probe wrote -.o into the cwd.

Change

  • bootstrap/tests/common/mod.rs (rewritten):
    • get_cc_args() probes -ferror-limit=0, then -fmax-errors=0. It accepts a flag only on exit 0 with empty stderr: Apple clang takes -fmax-errors=0 with "argument unused" and exit 0.
    • cc_check(path, extra) panics if cc exits non-zero without naming a file:line:col error. That case is cc refusing its command line, not a reading of the header.
    • error_count() also counts fatal error: lines (e.g. a missing #include).
  • 17 c_*.rs files use mod common; + common::cc_check. git grep ferror-limit -- bootstrap/tests now names only common/mod.rs.
  • c_static_array_params.rs:
    • It compiles with -c, not -fsyntax-only. gcc reports a short [static N] argument in a later pass: measured on gcc 15, -fsyntax-only prints nothing and -c prints [-Wstringop-overflow=].
    • The test no longer demands clang's -Warray-bounds. It asks cc which tag a short argument gets in hand-written C: the tags a 2-element caller provokes minus the tags a 4-element control provokes.

Unchanged on purpose: the build-and-run cc calls in backend_behaviour.rs and c_struct_array_fields.rs. They compile to a binary with -std=gnu11/-std=c11 -o, not syntax-check.

Evidence

The 21 affected targets (18 c_* + corpus_unresolved, icarus_lowerable, backend_behaviour; 489 tests) were run locally on macOS. cc was a shim to Homebrew gcc 15.2, then Apple clang, then Homebrew LLVM clang 21.1.8.

cc before (master) after (this PR)
gcc 15.2 464 passed / 25 failed 488 passed / 1 failed
Apple clang 487 passed / 2 failed 488 passed / 1 failed
LLVM clang 21 -- 18/18 C targets pass
  • The 25 gcc failures before:
    • 23 C tests: c_auto_type_array_literal 3, c_enum_member_access 3, c_enum_path_members 1, c_literal_list_type 8, c_module_array_consts 4, c_static_array_params 1, c_tuple_positions 3;
    • corpus_unresolved 1, since fixed on master by test(corpus): reach PID-qualified artifact write failures #5909;
    • icarus_lowerable::corpus_classifier_matches_lean_completeness.
  • The one failure left after, on every compiler, is that icarus_lowerable test. It is tracked in Restore Lean completeness agreement for phi_rope and sacred_attention #5910 and is not C.
  • With LLVM clang as cc, backend_behaviour was not run: rustc's link step through Homebrew clang hung in Xcode ld. That file is unchanged here.

Negative control (not committed)

A temporary test in c_abs_generic.rs generated a header and appended int t27_negative_control = ;, then asserted errors() counts >= 1. It was removed before commit.

Before, with gcc as cc, the count-shaped checker was blind:

test negative_control_a_broken_header_is_counted ... FAILED
a header with a real syntax error must count >= 1 error; counted 0

(Apple clang: ok.)

After, with gcc, Apple clang and LLVM clang 21, every compiler catches it:

test negative_control_a_broken_header_is_counted ... ok

Ratchet

Run locally against the master CI log (run 37181879942, prefixes stripped):

the failing set grew by 24
117 targets ran; 24 failing test(s) (baseline 177)

The full cargo test -p t27c --no-fail-fast under gcc was not run locally: the shared disk was under the 3 GiB stop line. This PR's own Bootstrap Test Ratchet run is that comparison. If that run shows only #5910 failing, I will regenerate test-baseline.txt from its log with --emit-baseline and push that as a follow-up commit here, with the reason stated. All 177 current baseline rows pass on master.

CI's gcc is older than 15. Whether it warns on a short [static 4] argument at -O0 -c is read from this PR's run, not assumed. If it does not, the test fails with "this cc warns about no too-short [static 4] argument even in hand-written C" rather than passing vacuously.

🤖 Generated with Claude Code

…loses #5907)

The bootstrap C tests passed clang's -ferror-limit=0 to whatever `cc` was.
On CI that is gcc, which refuses the whole command line. Tests that grep
stderr for "error" went red (23 on master); tests that count
file:line:col errors went green having compiled nothing.

- tests/common/mod.rs: get_cc_args() probes -ferror-limit=0, then
  -fmax-errors=0, and accepts a flag only on exit 0 with empty stderr.
  cc_check() panics when cc exits non-zero without naming a line of the
  file. error_count() also counts `fatal error:` lines.
- 17 c_*.rs files go through `mod common;` and common::cc_check.
- c_static_array_params: compile with -c, where gcc reports a short
  [static N] argument, and ask cc which warning tag that gets rather
  than demanding clang's -Warray-bounds.

gcc 15 as cc, 21 affected targets: 25 failed before, 1 after
(icarus_lowerable, #5910, not C). Apple clang: 2 -> 1.

Part of #5906

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

📓 NotebookLM Notebook linked to this PR

This notebook contains session context, decisions, and artifacts for this work.

@github-actions

github-actions Bot commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

PR Dashboard

Generated at: 2026-10-04 07:02:51 UTC

Summary

Status Count
Total Open PRs 50
PRs with Failing Checks 47
PRs with All Checks Green 3
READY 1
FAILING 47
PENDING 0
NO CHECKS YET 0

These columns do not partition: 1 + 47 + 0 + 0 = 48, and there are 50 open PRs. A PR is being counted twice or not at all.

Seal Status

  • ⚠️ STALE -- sha256(compiler.rs)=b45a356c2eb6 != manifest seal=87e5cbd3ad94.
    The committed NMSE numbers were certified against an older compiler.rs.
    Run scripts/reseal-check.sh locally for the two-step reseal command (advisory; not a merge gate).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

C-backend tests still hand cc the clang-only flag: #4832 added get_cc_args() and no test calls it (test-ratchet red on master, 25 tests)

2 participants