test(c-backend): every C syntax check asks cc which flags it takes (Closes #5907) - #5930
Merged
Merged
Conversation
…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>
Contributor
|
📓 NotebookLM Notebook linked to this PR
This notebook contains session context, decisions, and artifacts for this work. |
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #5907
Part of #5906
Defect
Bootstrap Test Ratchetis red on master (5432ded): 24 tests are newly failing againstscripts/ci/test-baseline.txt. 23 of them are C-backend tests. Fifteenbootstrap/tests/c_*.rsfiles hand-copied clang's-ferror-limit=0. CI'sccis gcc, which refuses the whole command line: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.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-.ointo 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=0with "argument unused" and exit 0.cc_check(path, extra)panics ifccexits non-zero without naming afile:line:colerror. That case isccrefusing its command line, not a reading of the header.error_count()also countsfatal error:lines (e.g. a missing#include).c_*.rsfiles usemod common;+common::cc_check.git grep ferror-limit -- bootstrap/testsnow names onlycommon/mod.rs.c_static_array_params.rs:-c, not-fsyntax-only. gcc reports a short[static N]argument in a later pass: measured on gcc 15,-fsyntax-onlyprints nothing and-cprints[-Wstringop-overflow=].-Warray-bounds. It asksccwhich 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
cccalls inbackend_behaviour.rsandc_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.ccwas a shim to Homebrew gcc 15.2, then Apple clang, then Homebrew LLVM clang 21.1.8.c_auto_type_array_literal3,c_enum_member_access3,c_enum_path_members1,c_literal_list_type8,c_module_array_consts4,c_static_array_params1,c_tuple_positions3;corpus_unresolved1, since fixed on master by test(corpus): reach PID-qualified artifact write failures #5909;icarus_lowerable::corpus_classifier_matches_lean_completeness.icarus_lowerabletest. It is tracked in Restore Lean completeness agreement for phi_rope and sacred_attention #5910 and is not C.cc,backend_behaviourwas not run: rustc's link step through Homebrew clang hung in Xcodeld. That file is unchanged here.Negative control (not committed)
A temporary test in
c_abs_generic.rsgenerated a header and appendedint t27_negative_control = ;, then assertederrors()counts >= 1. It was removed before commit.Before, with gcc as
cc, the count-shaped checker was blind:(Apple clang:
ok.)After, with gcc, Apple clang and LLVM clang 21, every compiler catches it:
Ratchet
Run locally against the master CI log (run 37181879942, prefixes stripped):
The full
cargo test -p t27c --no-fail-fastunder gcc was not run locally: the shared disk was under the 3 GiB stop line. This PR's ownBootstrap Test Ratchetrun is that comparison. If that run shows only #5910 failing, I will regeneratetest-baseline.txtfrom its log with--emit-baselineand 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 -cis 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