Repository navigation
thirdparty: add tccmacho page_count patch for macOS 27 bss (vlang/v#29744) - #109
Merged
JalonSolov merged 1 commit intoOct 25, 2026
Conversation
…9744) Carry the tccmacho.c patch from vlang/v#29744 so it can be reviewed against this branch's TinyCC commit (85ba3ae8). With CONFIG_NEW_MACHO, page_count for __DATA is computed from vmsize, so chained-starts list the zero-fill __bss pages. macOS 27 dyld maps listed pages from the file, so __bss can hold the bytes that follow the segment (the start of __LINKEDIT) instead of zeros. The patch computes page_count from filesize and skips segments with no file-backed pages. This commit only adds the patch file. It does not change build.sh, which is a historical copy and not meant to be edited. The V repo's build script must apply it before the next bundle rebuild. Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
1 of 4 tasks
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
No open issues 🎉
What changed in this PR
Adds a TinyCC tccmacho.c patch file to fix chained-fixups page counting on macOS 27 by basing fixup page counts on file-backed pages (filesize) rather than virtual size (vmsize), avoiding __bss being incorrectly page-initialized from the file.
Changes:
- Add
patches/tccmacho-page-count-filesize.diffcontaining thetccmacho.cmodifications from vlang/v#29744. - Compute chained-starts
page_countfromfilesizeand skip segments with zero file-backed pages.
| File | Description |
|---|---|
| patches/tccmacho-page-count-filesize.diff | Introduces the patch that changes fixup page counting to be based on file-backed pages and skips non-file-backed segments. |
Review effort: Lite
Copilot stopped reviewing on behalf of
JalonSolov due to an error
October 26, 2026 14:06
JalonSolov
pushed a commit
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
medvednikov
added a commit
that referenced
this pull request
Nov 19, 2026
…OLDER=thirdparty/tcc bash thirdparty/build_scripts/thirdparty-macos-arm64_tcc.sh` (#120) Rebuild the macOS arm64 bundle at TinyCC mob 0f004a08. The previous tcc.exe was the 2026-07-28 build of 85ba3ae8; the recipe changes since then (#109/#110 tccmacho patch, #118 --config-new_macho=no) were never applied to a published binary. 0f004a08 contains 70adbb12 (arm64: fix sp offsets of 4096 and more in arm64_spoff). With the old tcc.exe, tests2/153_large_struct_args.c segfaults; with this one it matches its .expect. update_tccbin.yml cannot publish this managed bundle (the recipe refuses non-deferred builds, and monthly candidate composition needs a producer toolchain observation the base manifest does not have). So this was built by hand with vlang/v master f56fcbbaaa's recipe in deferred mode (TCCBIN_DEFER_COMMIT=1), MACOSX_DEPLOYMENT_TARGET=11.0 (minos 11.0, as before), Apple clang 21 on macOS 27.2 arm64. The libgc files, README.md, build.sh and patches are unchanged. automation/bundle-manifest.json: inventory/outputs sha256 updated for the rebuilt files, and lib/bcheck_run.o (new in this TinyCC) added. Policy fields (recipe, sources, probes, contract) are unchanged. Checked locally: tccbin_tests (hello, gc_alloc, crash) pass with libgc.dylib; V master builds itself with -cc tcc for two generations; `v -cc tcc test` over builtin, strings, os, math, time, sync, x/json2, regex, encoding: 451 passed, 0 failed.
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
Adds the
tccmacho.cpatch from vlang/v#29744 aspatches/tccmacho-page-count-filesize.diff, so it can be reviewed against this branch's TinyCC commit (85ba3ae8).On macOS 27 (arm64), TCC-linked binaries can start with garbage in
__bss. WithCONFIG_NEW_MACHO,page_countfor__DATAis computed fromvmsize, so chained starts list the zero-fill__bsspages. dyld maps listed pages from the file, so those pages hold the bytes that follow__DATA, not zeros. The patch computespage_countfromfilesizeand skips segments with no file-backed pages.What this PR does not do
build.sh. The README and the script header saybuild.shis a historical copy and is not meant to be edited, so the apply step belongs in the V repo'sthirdparty/build_scripts/thirdparty-macos-arm64_tcc.sh.tcc.exe. The bundle needs a rebuild from patched source through CI, not from a local build.Evidence (local, macOS 27.0.1 arm64)
85ba3ae8(git apply --check).85ba3ae8with chained fixups prints garbage in bss (nonzero=95071);--config-new_macho=noand the patched build print zeros.__DATAfile size 0 (thepage_count == 0skip path): patched build prints zeros.cmd/vbuilt with the patched TCC:versionand hello world work.Known limits
page_countis stored in auint16_twith no bound check, so a__DATAsegment above about 1 GiB wraps. The patch does not make this worse.seg_info_offset == 0as "no fixup starts" for skipped segments.Test plan
thirdparty-macos-arm64with the patch applied, then run the repro above against the new bundlemakeandv upon macOS 27 with the new bundle🤖 Generated with Claude Code