Skip to content

build: freestanding profile enforces -Werror=switch; gate audits compile-bearing scripts (#835) - #863

Merged
InauguralPhysicist merged 1 commit into
mainfrom
freestanding-werror-switch-835
Aug 5, 2026
Merged

build: freestanding profile enforces -Werror=switch; gate audits compile-bearing scripts (#835)#863
InauguralPhysicist merged 1 commit into
mainfrom
freestanding-werror-switch-835

Conversation

@InauguralPhysicist

Copy link
Copy Markdown
Collaborator

Closes #835.

tools/freestanding_check.sh was a third compile mechanism alongside the Makefile and build.sh, and neither of its hand-written gcc invocations carried -Werror=switch — so the freestanding profile never enforced switch exhaustiveness, while the same omission is a hard error on every Makefile leg and under build.sh (#786/#817).

What changed

  • Both gcc invocations armed (stage-1 runtime set, stage-2 mini-libc/libm). Planted-fault verified: adding a temporary AST_PLANTED_FAULT_835 enum value makes make freestanding-check fail with cc1: some warnings being treated as errors; reverting restores green.
  • The [99i] gate closes its own documented blind spot: tools/werror_switch_check.sh now 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 naming script:tools/freestanding_check.sh.
  • New selftest shapes: script compile line caught when bare / clean when armed; commented compile lines are never examined.
  • build.sh stays 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_SOURCES variables 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.
  • Full suite: 3758/3758.

Closes #835.

🤖 Generated with Claude Code

…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>
Copilot AI lite review requested due to automatic review settings August 5, 2026 11:12

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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=switch to both gcc invocations in tools/freestanding_check.sh so freestanding compilation treats non-exhaustive switches as errors.
  • Extend tools/werror_switch_check.sh to 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"

@InauguralPhysicist
InauguralPhysicist merged commit c2e6a04 into main Aug 5, 2026
19 checks passed
@InauguralPhysicist
InauguralPhysicist deleted the freestanding-werror-switch-835 branch August 5, 2026 11:29
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.

tools/freestanding_check.sh compiles 21 sources without -Werror=switch, so the freestanding profile never enforces switch exhaustiveness

2 participants