Skip to content

vself: do not default to tcc on macOS arm64 when it would just fail - #28024

Open
quaesitor-scientiam wants to merge 1 commit into
vlang:masterfrom
quaesitor-scientiam:v-self-tcc-prealloc-fix
Open

vself: do not default to tcc on macOS arm64 when it would just fail#28024
quaesitor-scientiam wants to merge 1 commit into
vlang:masterfrom
quaesitor-scientiam:v-self-tcc-prealloc-fix

Conversation

@quaesitor-scientiam

Copy link
Copy Markdown
Contributor

Summary

  • A plain v self on Apple Silicon macOS always fails to compile with the bundled tcc and silently falls back to cc, as reported in mac: v self not working with tcc #28023.
  • Root cause: Preferences.fill_with_defaults() forces -prealloc on for macOS builds of V itself when no real GC is selected (exactly what v self's implicit -gc none does). -prealloc declares its allocator global g_memory_block as _Thread_local, a C11 keyword the bundled tcc does not implement.
  • The builder's own try_to_use_tcc_by_default() already avoids defaulting to tcc when -prealloc is set, but cmd/tools/vself.v bypasses that guard by unconditionally injecting an explicit -cc tcc for Apple Silicon before the guard ever runs.
  • Fix: only add -cc tcc in vself.v when the caller explicitly requested a real GC via -gc (the one case where -prealloc isn't forced and tcc remains compatible). Plain v self (and v self -gc none) now goes straight to cc with no failing attempt; v self -gc boehm still gets the fast tcc path.

Test plan

  • Reproduced the failure on macOS/arm64 (v selfwarning: tcc compilation failed, falling back to cc), traced it to the _Thread_local g_memory_block declaration via -keepc.
  • Verified v self, v self -gc none, and v self -gc boehm all build cleanly after the fix, with correct compiler selection in each case.
  • v test vlib/v/builder/cc_tcc_retry_test.v passes.
  • v fmt -verify cmd/tools/vself.v passes.

Fixes #28023

🤖 Generated with Claude Code

Preferences.fill_with_defaults() forces `-prealloc` on for any macOS
build of V itself when no real GC is selected, which is exactly what
a plain `v self` does via its implicit `-gc none`. `-prealloc` emits
its allocator global as `_Thread_local`, a C11 keyword the bundled
tcc does not implement, so the compile always fails and silently
falls back to `cc`.

The builder already guards against defaulting to tcc when prealloc is
set, but `v self` bypasses that guard by passing an explicit `-cc tcc`
for Apple Silicon before the guard ever runs. Only add `-cc tcc` there
when the caller explicitly picked a real GC via `-gc`, which is the
one case prealloc isn't forced and tcc stays compatible.

Fixes vlang#28023

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@medvednikov

Copy link
Copy Markdown
Member

Not the right fix. Need to use tcc by default.

@quaesitor-scientiam

Copy link
Copy Markdown
Contributor Author

Not the right fix. Need to use tcc by default.

fixes the warning which is false because it currently bypasses the guard the tcc issue i found is at vlang/tccbin#86

@JalonSolov

Copy link
Copy Markdown
Collaborator

It may fix the warning, but the right fix will be to make tcc work as expected, rather than just blocking it.

@quaesitor-scientiam

Copy link
Copy Markdown
Contributor Author

It may fix the warning, but the right fix will be to make tcc work as expected, rather than just blocking it.

Requires vlang/tccbin#86 to be completed

@quaesitor-scientiam

Copy link
Copy Markdown
Contributor Author

See comments #28023 (comment)

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.

mac: v self not working with tcc

3 participants