Skip to content

builder, cgen: fix macOS tcc header lookup#27134

Open
guweigang wants to merge 1 commit into
vlang:masterfrom
guweigang:codex/fix-macos-tcc-cstrict
Open

builder, cgen: fix macOS tcc header lookup#27134
guweigang wants to merge 1 commit into
vlang:masterfrom
guweigang:codex/fix-macos-tcc-cstrict

Conversation

@guweigang
Copy link
Copy Markdown
Contributor

Summary

  • declare posix_memalign in generated C headers so macOS aligned_alloc fallback compiles cleanly under tcc -cstrict
  • make parallel-cc locate bundled tcc headers/runtime from both lib/tcc and lib layouts
  • add an absolute bundled tcc include path for parallel C compile shards that run from tmp dirs

Root Cause

macOS fallback code for aligned_alloc calls posix_memalign, but the manual libc declarations did not include a posix_memalign prototype. In cstrict mode, tcc treats that implicit declaration as an error and V falls back to the system compiler.

parallel-cc also assumed the older bundled tcc lib/tcc layout. The current macOS arm64 tcc bundle has headers under thirdparty/tcc/lib/include, and tcc's -B path alone is cwd-sensitive there, so compile shards created in /tmp could fail to include stdbool.h through Apple SDK headers.

Validation

  • ./v -g -keepc -o ./vnew cmd/v
  • VMODULES=/tmp/vmodules_codex ./vnew -cc tcc -cstrict -show-c-output run examples/hello_world.v
  • VMODULES=/tmp/vmodules_codex ./vnew -silent vlib/v/builder/parallel_cc_failure_test.v
  • VMODULES=/tmp/vmodules_codex ./vnew -silent vlib/v/compiler_errors_test.v
  • VMODULES=/tmp/vmodules_codex ./vnew -silent vlib/v/gen/c/coutput_test.v

@guweigang guweigang marked this pull request as ready for review May 11, 2026 06:59
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2f0401eb4e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread vlib/v/builder/cbuilder/parallel_cc.v Outdated
@guweigang guweigang force-pushed the codex/fix-macos-tcc-cstrict branch from 2f0401e to 2ce94b6 Compare May 11, 2026 07:28
@StunxFS StunxFS changed the title fix macOS tcc header lookup builder, cgen: fix macOS tcc header lookup May 14, 2026
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.

1 participant