chore(native): adopt MOONBIT_NEW_NATIVE backend with SessionStart toolchain upgrade#135
Merged
Conversation
…ain upgrade Replace the `MOON_CC=cc` override with moonc's newer native backend. `moon test --target native` compiles its test drivers through the bundled `tcc -run`, which crashes in the web environment. `MOONBIT_NEW_NATIVE=1` routes native builds through the system `cc`/`clang` driver instead. That flag is only wired into moonc from toolchain 0.1.20260629 onward and is inert on the environment's default 0.1.20260608. So add a SessionStart hook that upgrades the toolchain to the latest release when it is older than 0.1.20260629 (idempotent, remote-only, non-interactive), and keep `MOONBIT_NEW_NATIVE=1` in .claude/settings.json. Verified: the hook upgrades 0.1.20260608 -> 0.1.20260629, a second run is a no-op, and `MOONBIT_NEW_NATIVE=1 moon test --target native -p mizchi/bit_hash` then passes 15/15 with no tcc process spawned. 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
Follow-up to #134. Switches native builds from the
MOON_CC=ccoverride to moonc's newer native backend (MOONBIT_NEW_NATIVE=1), with a SessionStart hook that guarantees a toolchain new enough to honor it.Why
moon test --target nativecompiles its test drivers through the bundledtcc -run, which crashes in the web environment.MOONBIT_NEW_NATIVE=1routes native builds through the systemcc/clangdriver instead.The catch: that flag is only wired into
mooncfrom toolchain0.1.20260629onward. On the environment's default0.1.20260608it is completely inert (verified: the native build plan is byte-identical with and without it, still 2 tcc invocations forbit_hash). Fresh containers here come up on0.1.20260608.Change
.claude/hooks/session-start.sh(new): remote-only, idempotent, non-interactive. Readsmoon version; if older than0.1.20260629, upgrades to the latest toolchain via the official install script, then refreshes the module registry..claude/settings.json: dropMOON_CC, keepMOONBIT_NEW_NATIVE=1, register the hook.AGENTS.md: update the "Native builds" section to match.Validation
0.1.20260608 → 0.1.20260629; second run is a no-op (moonbit 20260629 already supports MOONBIT_NEW_NATIVE).moon check --target jsonbit_hash→ 0 errors on the upgraded toolchain.MOONBIT_NEW_NATIVE=1 moon test --target native -p mizchi/bit_hash→ 15/15 pass, zero tcc processes spawned during the build.Hook runs synchronously (guarantees the toolchain is ready before the agent runs native builds; adds ~1–2 min to session start only when an upgrade is actually needed). Can switch to async if faster startup is preferred. Once merged to the default branch, all future web sessions use it.
🤖 Generated with Claude Code
https://claude.ai/code/session_01WHFC6qxKjqjrixgjFtGihM
Generated by Claude Code