Skip to content

thirdparty: fix the tccbin preservation test for the macOS arm64 patch step - #32021

Merged
medvednikov merged 1 commit into
vlang:masterfrom
quaesitor-scientiam:fix/tccbin-preservation-macos-patch
Nov 12, 2026
Merged

medvednikov merged 1 commit into
vlang:masterfrom
quaesitor-scientiam:fix/tccbin-preservation-macos-patch

Conversation

@quaesitor-scientiam

Copy link
Copy Markdown
Contributor

Summary

tccbin_workflow_preservation_test.sh has failed on Linux since #31146, and with it the
linux-amd64 job of update_tccbin.yml (step "Test tccbin workflow preservation", exit 2), as
in the 2026-11-05 re-run of run 41268892804.

#31146 made the macOS arm64 recipe apply
patches/tccmacho-page-count-filesize.diff to the TinyCC checkout. The test runs every recipe
against a fixture V root and a fake TinyCC repo. The fixture had no patch file and the fake
TinyCC has no tccmacho.c, so git apply failed and the recipe exited 2. Recipes and the
workflow are unchanged; this only fixes the test.

  • The fake TinyCC gets a tracked tccmacho.c, and each fixture V root gets a stand-in patch at
    the path the recipe reads, editing that file.
  • The fake make records tccmacho.c at the build call and publishes it on install. The
    deferred and legacy loops check that the macOS arm64 output was built patched and every other
    recipe's unpatched. A patch applied too late, undone, skipped or only applied in one mode now
    fails.
  • A new macOS arm64 case swaps in a patch that does not apply. The recipe must fail with
    tccmacho page_count patch failed to apply and leave no stage or private sibling behind.
  • Because the fixtures use a stand-in, the test also checks the real patch: git apply --numstat must parse it and report exactly tccmacho.c. It runs outside any work tree, since
    inside one git apply drops paths outside the current directory.

Not in this PR

  • The Linux job will still stop at its build step, like every other target, on
    managed tccbin bundles require TCCBIN_DEFER_COMMIT=1. That is the separate deferred-build
    work.
  • The test still doesn't apply the real patch to real TinyCC. A local replay of tccbin's
    macos-arm64 CI applied it at 85ba3ae8 without problems.

Test plan

  • Ubuntu 24.04 in Docker, as a non-root user: exit 2 before, preservation contract: PASS
    after. Also passes when run from thirdparty/build_scripts/ and with TMPDIR inside a git
    repo.
  • Mutants of the recipe all fail the test: removing the git apply, --check only,
    applying after install, applying only in deferred mode, git reset --hard or
    git checkout -- . after applying, --exclude=tccmacho.c, ignoring the apply failure,
    changing the diagnostic, and another recipe touching tccmacho.c.
  • Mutants of the real patch all fail the test: deleted, empty, corrupt, aimed at another
    file, at src/tccmacho.c or at tccmacho.c.orig.
  • /vreview, plus four adversarial rounds. Rounds 1 to 3 confirmed 9 low-severity test gaps,
    all fixed here, and the last round found nothing.
  • CI. Note that this script only runs inside update_tccbin.yml, not in PR checks.

Known limits: the test can't run on macOS (GNU stat -c, as before). With one fake TinyCC
commit, applying the patch before a plain git checkout can't be detected. A patch failure in
legacy mode has no case of its own (same recipe lines as deferred mode).

🤖 Generated with Claude Code

…h step

vlang#31146 made the macOS arm64 recipe apply
patches/tccmacho-page-count-filesize.diff to the TinyCC checkout. The
preservation test's fixture V root had no such file and its fake TinyCC
has no tccmacho.c, so the recipe exited 2 and the test failed on Linux,
which fails the linux-amd64 job of update_tccbin.yml before its build.

- give the fake TinyCC a tracked tccmacho.c and each fixture V root a
  stand-in patch that edits it
- have the fake make record tccmacho.c at the build call and publish it
  on install, and check in the deferred and legacy loops that only the
  macOS arm64 recipe builds it patched
- add a macOS arm64 case where the patch does not apply: it must fail
  with the recipe's diagnostic and leave no stage behind
- check that the real patch parses and targets exactly tccmacho.c,
  running git apply outside any work tree so the working directory and
  TMPDIR do not matter

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

@medvednikov medvednikov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Reviewed commit 9c78e20cb14afc5b689af5e347766c0cdf13ac45, ignoring CI as requested.

No blocking findings; this looks OK to merge.

The fixture patch matches the fake TinyCC source, and recording tccmacho.c at the build call (then publishing that snapshot during install) correctly checks what the build saw. Both deferred and legacy paths assert the expected patch state, while the other recipes must remain unpatched. The new invalid-patch case checks the diagnostic and cleanup of both the final stage and private sibling directories.

Validation: Bash syntax checks passed for the test and all five recipes. Focused local checks passed for the real patch's --numstat parse, build-time snapshots and both positive/negative patch-state assertions, and the actual macOS arm64 deferred patch-failure path (including cleanup, candidate preservation, and fixture-patch restoration). I could not run the full preservation matrix because rsync is not installed in this environment.

One non-blocking wording nit: the PR description says the real patch must report exactly tccmacho.c, but the awk guard at line 59 only requires that file to be among the reported targets. The current patch has the intended sole target; either softening that description or rejecting additional targets would make the claim precise.

@medvednikov
medvednikov merged commit b21fd3d into vlang:master Nov 12, 2026
@quaesitor-scientiam
quaesitor-scientiam deleted the fix/tccbin-preservation-macos-patch branch November 20, 2026 18:42
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.

2 participants