Skip to content

chore(native): adopt MOONBIT_NEW_NATIVE backend with SessionStart toolchain upgrade#135

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

chore(native): adopt MOONBIT_NEW_NATIVE backend with SessionStart toolchain upgrade#135
mizchi merged 1 commit into
mainfrom
claude/bold-mendel-2d7ygx

Conversation

@mizchi

@mizchi mizchi commented Jul 5, 2026

Copy link
Copy Markdown
Member

Summary

Follow-up to #134. Switches native builds from the MOON_CC=cc override 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 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.

The catch: that flag is only wired into moonc from toolchain 0.1.20260629 onward. On the environment's default 0.1.20260608 it is completely inert (verified: the native build plan is byte-identical with and without it, still 2 tcc invocations for bit_hash). Fresh containers here come up on 0.1.20260608.

Change

  • .claude/hooks/session-start.sh (new): remote-only, idempotent, non-interactive. Reads moon version; if older than 0.1.20260629, upgrades to the latest toolchain via the official install script, then refreshes the module registry.
  • .claude/settings.json: drop MOON_CC, keep MOONBIT_NEW_NATIVE=1, register the hook.
  • AGENTS.md: update the "Native builds" section to match.

Validation

  • Hook execution: upgraded 0.1.20260608 → 0.1.20260629; second run is a no-op (moonbit 20260629 already supports MOONBIT_NEW_NATIVE).
  • Linter: moon check --target js on bit_hash → 0 errors on the upgraded toolchain.
  • Test: 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

…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
@mizchi mizchi merged commit 21f3627 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