Repository navigation
tcc: count only file-backed pages in chained-fixups page_count (#29744) - #31146
Merged
JalonSolov merged 1 commit intoOct 26, 2026
Merged
Conversation
…#29744) On macOS 27, TinyCC's chained-fixups writer sizes the __DATA segment's page_count from vmsize, so the zero-fill __bss pages are listed as file-backed. dyld then maps them from the file instead of zero-filling, which gives garbage globals. Add a patch that counts ceil(filesize / SEG_PAGE_SIZE) pages and skips segments with no file-backed pages. Apply it after checkout of TCC_COMMIT in the arm64 TCC build script. The script configures TinyCC with --config-new_macho=no, so the patch is compiled but inactive for this bundle. It is kept as defense in depth for builds that keep chained fixups. The recorded TCC commit hash does not reflect the applied patch. Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
1 open issue
What changed in this PR
Adds a defensive TinyCC patch to fix chained-fixups segment page counting on macOS 27, and applies it in the macOS arm64 TinyCC build script to prevent __bss zero-fill pages from being treated as file-backed.
Changes:
- Apply a TinyCC source patch during the macOS arm64 TinyCC build to correct chained-fixups
page_countbehavior. - Introduce a TinyCC patch that computes fixup pages from
filesize(file-backed pages) and skips segments with zero file-backed pages.
| File | Description |
|---|---|
| thirdparty/build_scripts/thirdparty-macos-arm64_tcc.sh | Applies the new TinyCC patch after checkout to harden against chained-fixups mis-sizing issues. |
| thirdparty/build_scripts/patches/tccmacho-page-count-filesize.diff | Patch adjusting tccmacho.c chained-fixups logic to count only file-backed pages and skip non-file-backed segments. |
Review effort: Lite
Copilot stopped reviewing on behalf of
JalonSolov due to an error
October 26, 2026 20:08
JalonSolov
pushed a commit
to vlang/tccbin
that referenced
this pull request
Oct 27, 2026
) PR #109 added patches/tccmacho-page-count-filesize.diff but nothing applied it, so the bundle built from TCC 85ba3ae8 was unchanged. Apply the patch from the V repo's copy after the TCC_COMMIT checkout, before configure. The configure step keeps --config-new_macho=yes, so the patch is active for this bundle. The V repo copy of this script (thirdparty/build_scripts/ thirdparty-macos-arm64_tcc.sh) applies the same patch, but with --config-new_macho=no, where it does nothing. Keep the two in sync. This script now needs the V checkout to contain the patch file (vlang/v#31146 or a branch that has it). Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
4 of 5 tasks
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.

Summary
__DATAsegment'spage_countfromvmsize, so the zero-fill__bsspages are listed as file-backed. dyld then maps them from the file instead of zero-filling, which gives garbage globals (macOS 27 arm64: bundled TCC links binaries with garbage in __bss (v up hangs, make panics) #29744).thirdparty/build_scripts/patches/tccmacho-page-count-filesize.diff, which countsceil(filesize / SEG_PAGE_SIZE)pages and skips segments with no file-backed pages.TCC_COMMIT.Important: the patch is inert for this script's output
The arm64 script configures TinyCC with
--config-new_macho=no, which does not use chained fixups. The patch is compiled in but has no effect on this bundle. It is kept as defense in depth for builds that keep chained fixups.The fix that actually matters for the prebuilt bundle is the TinyCC-side patch proposed in vlang/tccbin#109. This PR does not replace it.
Provenance
The recorded TinyCC commit hash does not reflect the applied patch. A build from that hash plus this patch is not byte-identical to a build from the hash alone.
Test plan
mob43c7708b and 85ba3ae8 in scratch (earlier session)mob43c7708b in a clean clone (not re-run)vglobals repro correctlytccbin_workflow_preservation_test.sh(fails on macOS for an unrelatedstat -creason; pre-existing)Caveat:
git apply --checkonly works inside a TinyCC clone, not from the V repo root.🤖 Generated with Claude Code