From f55b930e5a20e7d7696a6daa3dff10ada3c7cf5f Mon Sep 17 00:00:00 2001 From: Richard Wheeler Date: Sun, 25 Oct 2026 19:05:29 -0400 Subject: [PATCH 1/2] build: apply the tccmacho page_count patch after checkout (vlang/v#29744) 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 --- build.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/build.sh b/build.sh index e428d27..f02850c 100755 --- a/build.sh +++ b/build.sh @@ -30,6 +30,9 @@ if ! test -f vlib/v/compiler_errors_test.v; then exit 1 fi +## the patches live in the V repo, and this script changes into tinycc/ before applying them: +export V_ROOT="$(pwd)" + export CFLAGS='-O3' export CURRENT_SCRIPT_PATH=$(realpath "$0") @@ -58,6 +61,14 @@ cd tinycc git checkout $TCC_COMMIT export TCC_COMMIT_FULL_HASH=$(git rev-parse HEAD) +## vlang/v#29744: with chained fixups, TCC lists the zero-fill __bss pages in __DATA's +## page_count, and macOS 27 dyld maps them from the file, which gives garbage globals. +## The patch counts only file-backed pages. It is only needed for builds that keep chained fixups. +git apply "$V_ROOT/thirdparty/build_scripts/patches/tccmacho-page-count-filesize.diff" || { + echo "tccmacho page_count patch failed to apply" >&2 + exit 2 +} + ### NB: the symlinks below are needed, to ensure proper support for bootstrapping tcc, otherwise backtraces will be disabled . for i in include/*.h; do echo $i; ln -s $i $(basename $i); done From 68fbd62be2c144096db4b2f2a7f356003a4f6995 Mon Sep 17 00:00:00 2001 From: Richard Wheeler Date: Sun, 25 Oct 2026 21:13:46 -0400 Subject: [PATCH 2/2] build: check for the tccmacho patch file before the TinyCC checkout A V checkout without vlang/v#31146 has no patch file, and the failure used to show only as a git apply error. Check the path up front and name the file and the required V change. Co-Authored-By: Claude Haiku 5.5 --- build.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/build.sh b/build.sh index f02850c..ffb31ba 100755 --- a/build.sh +++ b/build.sh @@ -32,6 +32,12 @@ fi ## the patches live in the V repo, and this script changes into tinycc/ before applying them: export V_ROOT="$(pwd)" +export TCCMACHO_PATCH="$V_ROOT/thirdparty/build_scripts/patches/tccmacho-page-count-filesize.diff" +if ! test -f "$TCCMACHO_PATCH"; then + echo "missing patch: $TCCMACHO_PATCH" >&2 + echo "this script needs a V checkout that contains vlang/v#31146" >&2 + exit 2 +fi export CFLAGS='-O3' export CURRENT_SCRIPT_PATH=$(realpath "$0") @@ -64,7 +70,7 @@ export TCC_COMMIT_FULL_HASH=$(git rev-parse HEAD) ## vlang/v#29744: with chained fixups, TCC lists the zero-fill __bss pages in __DATA's ## page_count, and macOS 27 dyld maps them from the file, which gives garbage globals. ## The patch counts only file-backed pages. It is only needed for builds that keep chained fixups. -git apply "$V_ROOT/thirdparty/build_scripts/patches/tccmacho-page-count-filesize.diff" || { +git apply "$TCCMACHO_PATCH" || { echo "tccmacho page_count patch failed to apply" >&2 exit 2 }