chore(native): use system cc for native builds to avoid tcc crashes#134
Merged
Conversation
`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
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
moon test --target nativeruns its per-test C drivers through the bundledtcc -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(thebit.exebinary) already links via/usr/bin/cc— no tcc, unaffected.moon test --target native(debug) uses 119tcc -rundrivers → the crashing path.MOONBIT_NEW_NATIVE=1alone 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=ccswitches the test drivers fromtcc -runto compile-and-run viacc: 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
.claude/settings.jsonsettingMOON_CC=ccandMOONBIT_NEW_NATIVE=1so Claude Code sessions pick them up automatically.MOONBIT_NEW_NATIVE=1is harmless today and future-proofs for when the toolchain wires the new backend into the planner.AGENTS.md(aliased byCLAUDE.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 tccempty during the run.moon test --target native --dry-runvsMOON_CC=cc …→ tcc-driver count 119 → 0.🤖 Generated with Claude Code
https://claude.ai/code/session_01WHFC6qxKjqjrixgjFtGihM
Generated by Claude Code