Skip to content

chore(native): use system cc for native builds to avoid tcc crashes#134

Merged
mizchi merged 1 commit into
mainfrom
claude/bold-mendel-2d7ygx
Jul 5, 2026
Merged

chore(native): use system cc for native builds to avoid tcc crashes#134
mizchi merged 1 commit into
mainfrom
claude/bold-mendel-2d7ygx

Conversation

@mizchi

@mizchi mizchi commented Jul 5, 2026

Copy link
Copy Markdown
Member

Summary

moon test --target native runs its per-test C drivers through the bundled tcc -run, which crashes in the web/remote build environment. This wires native builds to use the system C compiler instead.

What I found

  • moon build --target native --release (the bit.exe binary) already links via /usr/bin/cc — no tcc, unaffected.
  • moon test --target native (debug) uses 119 tcc -run drivers → the crashing path.
  • MOONBIT_NEW_NATIVE=1 alone is inert in the pinned toolchain (moon 0.1.20260608 / moonc 0.10.0): the build plan is byte-identical with and without it. Its own error string points at the real lever: "new native backend requires a C compiler/linker driver; ... set MOON_CC".
  • MOON_CC=cc switches the test drivers from tcc -run to compile-and-run via cc: the native test plan drops to 0 tcc invocations, and a sample native suite (mizchi/bit_hash) passes 15/15 end-to-end through gcc with no tcc process spawned.

Change

  • Add .claude/settings.json setting MOON_CC=cc and MOONBIT_NEW_NATIVE=1 so Claude Code sessions pick them up automatically. MOONBIT_NEW_NATIVE=1 is harmless today and future-proofs for when the toolchain wires the new backend into the planner.
  • Document the rationale under a new "Native builds" section in AGENTS.md (aliased by CLAUDE.md).

Committed to the repo (not settings.local.json) because the remote environment re-clones fresh each session, so only tracked files persist.

Test plan

  • MOON_CC=cc moon test --target native -p mizchi/bit_hash → 15/15 pass, pgrep tcc empty during the run.
  • moon test --target native --dry-run vs MOON_CC=cc … → tcc-driver count 119 → 0.

🤖 Generated with Claude Code

https://claude.ai/code/session_01WHFC6qxKjqjrixgjFtGihM


Generated by Claude Code

`moon test --target native` runs its test drivers through the bundled
`tcc -run`, which crashes in this environment. Setting `MOON_CC=cc` makes
moon compile and run native tests with the system C compiler instead
(verified: the native test plan drops to 0 tcc invocations and a sample
native suite passes end-to-end through gcc). `MOONBIT_NEW_NATIVE=1`
opts into moonc's newer native backend, which likewise routes through a
real cc/clang driver.

Set both in `.claude/settings.json` so Claude Code sessions pick them up
automatically, and document the rationale in AGENTS.md. `moon build
--target native --release` (the bit.exe binary) already used cc, so it is
unaffected.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WHFC6qxKjqjrixgjFtGihM
@mizchi mizchi merged commit 995e7b4 into main Jul 5, 2026
20 of 21 checks passed
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.

2 participants