build: freestanding profile enforces -Werror=switch; gate audits compile-bearing scripts (#835) - #863
Merged
Conversation
…ile-bearing scripts (#835) Closes #835. - tools/freestanding_check.sh: both hand-written gcc invocations now carry -Werror=switch (stage-1 runtime set + stage-2 mini-libc/libm) — the freestanding profile was the one compile path where an unhandled ASTType/opcode case only warned. Planted-fault verified: a temporary extra enum value fails make freestanding-check, reverting restores green. - tools/werror_switch_check.sh: the [99i] gate now audits compile-bearing shell scripts directly (comment lines stripped, then the same join/split/classify pipeline and per-unit zero-line hard failure as the Makefile dry runs). SCRIPT_AUDITS = tools/freestanding_check.sh; the gate names the script on a violation (planted-fault verified). New selftest shapes: script compile line caught/clean, commented compile lines not examined. build.sh stays out of scope, documented honestly in the header ($SOURCES-variable compile lines are indistinguishable from link lines to the recognizer). - tests/run_all_tests.sh [99i] text updated; CHANGELOG entry. Validated: gate 320 invocations across 22 targets + 1 script, selftest green; make freestanding-check green; full suite 3758/3758. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR closes #835 by ensuring the freestanding build/profile enforces switch exhaustiveness consistently across build entrypoints, and by extending the existing -Werror=switch compile-line gate to cover certain compile-bearing shell scripts that make -n cannot see.
Changes:
- Add
-Werror=switchto bothgccinvocations intools/freestanding_check.shso freestanding compilation treats non-exhaustive switches as errors. - Extend
tools/werror_switch_check.shto audit specified shell scripts directly (after stripping comment lines) using the same classifier and “zero-line is failure” invariant as Makefile dry-runs. - Update test runner messaging and document the fix in
CHANGELOG.md.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tools/werror_switch_check.sh | Extends the -Werror=switch gate to also audit specific compile-bearing shell scripts (comment-stripped) in addition to Makefile dry-runs. |
| tools/freestanding_check.sh | Arms -Werror=switch on both freestanding compile stages so switch exhaustiveness is enforced. |
| tests/run_all_tests.sh | Updates the [99i] gate description/output to reflect scripted-audit coverage. |
| CHANGELOG.md | Documents the freestanding-profile enforcement + gate extension as a fixed item. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+81
to
+83
| # Compile-bearing shell scripts audited directly (#835) — see header. | ||
| SCRIPT_AUDITS="tools/freestanding_check.sh" | ||
|
|
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 #835.
tools/freestanding_check.shwas a third compile mechanism alongside the Makefile andbuild.sh, and neither of its hand-writtengccinvocations carried-Werror=switch— so the freestanding profile never enforced switch exhaustiveness, while the same omission is a hard error on every Makefile leg and underbuild.sh(#786/#817).What changed
AST_PLANTED_FAULT_835enum value makesmake freestanding-checkfail withcc1: some warnings being treated as errors; reverting restores green.tools/werror_switch_check.shnow audits compile-bearing shell scripts directly — comment lines stripped, then the script text goes through the exact same join/split/classify pipeline as the Makefile dry runs, with the same per-unit zero-line hard failure. Planted-fault verified: dropping the flag from one script line fails the gate namingscript:tools/freestanding_check.sh.build.shstays out of the gate's scope, stated honestly in the header: its three compile lines are armed (build: carry -Werror=switch in build.sh and the sanitizer/valgrind legs #786) but name sources via$SOURCES/$LSP_SOURCESvariables the recognizer cannot tell from a pure link line — auditing it would assert nothing and trip the zero-line assertion spuriously.Validation
bash tools/werror_switch_check.sh— OK: 320 compile invocations across 22 dry-run targets + 1 script.--selftest— all planted fault shapes caught, clean shapes pass.make freestanding-check— both stages green with the flag armed.Closes #835.
🤖 Generated with Claude Code